From 3916dc8f9e2d01f75c5d81af9efecb7348291616 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Tue, 19 May 2015 10:11:55 +0200 Subject: [PATCH] cloudstack: add tests for cs_portforward --- test/integration/cloudstack.yml | 1 + .../test_cs_portforward/defaults/main.yml | 3 + .../roles/test_cs_portforward/meta/main.yml | 3 + .../roles/test_cs_portforward/tasks/main.yml | 111 ++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 test/integration/roles/test_cs_portforward/defaults/main.yml create mode 100644 test/integration/roles/test_cs_portforward/meta/main.yml create mode 100644 test/integration/roles/test_cs_portforward/tasks/main.yml diff --git a/test/integration/cloudstack.yml b/test/integration/cloudstack.yml index 7cdf593a8c..7eff30d22f 100644 --- a/test/integration/cloudstack.yml +++ b/test/integration/cloudstack.yml @@ -11,4 +11,5 @@ - { role: test_cs_securitygroup_rule, tags: test_cs_securitygroup_rule } - { role: test_cs_instance, tags: test_cs_instance } - { role: test_cs_instancegroup, tags: test_cs_instancegroup } + - { role: test_cs_portforward, tags: test_cs_portforward } - { role: test_cs_account, tags: test_cs_account } diff --git a/test/integration/roles/test_cs_portforward/defaults/main.yml b/test/integration/roles/test_cs_portforward/defaults/main.yml new file mode 100644 index 0000000000..f4083ed220 --- /dev/null +++ b/test/integration/roles/test_cs_portforward/defaults/main.yml @@ -0,0 +1,3 @@ +--- +cs_portforward_public_ip: "10.100.212.5" +cs_portforward_vm: "{{ cs_resource_prefix }}-vm" diff --git a/test/integration/roles/test_cs_portforward/meta/main.yml b/test/integration/roles/test_cs_portforward/meta/main.yml new file mode 100644 index 0000000000..03e38bd4f7 --- /dev/null +++ b/test/integration/roles/test_cs_portforward/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - test_cs_common diff --git a/test/integration/roles/test_cs_portforward/tasks/main.yml b/test/integration/roles/test_cs_portforward/tasks/main.yml new file mode 100644 index 0000000000..02326ec13b --- /dev/null +++ b/test/integration/roles/test_cs_portforward/tasks/main.yml @@ -0,0 +1,111 @@ +--- +- name: setup + cs_portforward: + ip_address: "{{ cs_portforward_public_ip }}" + public_port: 80 + private_port: 8080 + state: absent + register: pf +- name: verify setup + assert: + that: + - pf|success + +- name: test fail if missing params + action: cs_portforward + register: pf + ignore_errors: true +- name: verify results of fail if missing params + assert: + that: + - pf|failed + - 'pf.msg == "missing required arguments: private_port,ip_address,public_port"' + +- name: test present port forwarding + cs_portforward: + ip_address: "{{ cs_portforward_public_ip }}" + public_port: 80 + vm: "{{ cs_portforward_vm }}" + private_port: 8080 + register: pf +- name: verify results of present port forwarding + assert: + that: + - pf|success + - pf|changed + - pf.vm_name == "{{ cs_portforward_vm }}" + - pf.ip_address == "{{ cs_portforward_public_ip }}" + - pf.public_port == 80 + - pf.public_end_port == 80 + - pf.private_port == 8080 + - pf.private_end_port == 8080 + +- name: test present port forwarding idempotence + cs_portforward: + ip_address: "{{ cs_portforward_public_ip }}" + public_port: 80 + vm: "{{ cs_portforward_vm }}" + private_port: 8080 + register: pf +- name: verify results of present port forwarding idempotence + assert: + that: + - pf|success + - not pf|changed + - pf.vm_name == "{{ cs_portforward_vm }}" + - pf.ip_address == "{{ cs_portforward_public_ip }}" + - pf.public_port == 80 + - pf.public_end_port == 80 + - pf.private_port == 8080 + - pf.private_end_port == 8080 + +- name: test change port forwarding + cs_portforward: + ip_address: "{{ cs_portforward_public_ip }}" + public_port: 80 + vm: "{{ cs_portforward_vm }}" + private_port: 8888 + register: pf +- name: verify results of change port forwarding + assert: + that: + - pf|success + - pf|changed + - pf.vm_name == "{{ cs_portforward_vm }}" + - pf.ip_address == "{{ cs_portforward_public_ip }}" + - pf.public_port == 80 + - pf.public_end_port == 80 + - pf.private_port == 8888 + - pf.private_end_port == 8888 + +- name: test absent port forwarding + cs_portforward: + ip_address: "{{ cs_portforward_public_ip }}" + public_port: 80 + private_port: 8888 + state: absent + register: pf +- name: verify results of absent port forwarding + assert: + that: + - pf|success + - pf|changed + - pf.vm_name == "{{ cs_portforward_vm }}" + - pf.ip_address == "{{ cs_portforward_public_ip }}" + - pf.public_port == 80 + - pf.public_end_port == 80 + - pf.private_port == 8888 + - pf.private_end_port == 8888 + +- name: test absent port forwarding idempotence + cs_portforward: + ip_address: "{{ cs_portforward_public_ip }}" + public_port: 80 + private_port: 8888 + state: absent + register: pf +- name: verify results of absent port forwarding idempotence + assert: + that: + - pf|success + - not pf|changed