diff --git a/test/integration/cloudstack.yml b/test/integration/cloudstack.yml index 546c6fa806..0102689ed0 100644 --- a/test/integration/cloudstack.yml +++ b/test/integration/cloudstack.yml @@ -11,5 +11,6 @@ - { 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 } - { role: test_cs_firewall, tags: test_cs_firewall } 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