1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #11030 from resmo/feature/cloudstack_tests_cs_portforward

cloudstack: add tests for cs_portforward
This commit is contained in:
Brian Coca 2015-05-19 08:58:27 -04:00
commit 78985e5c33
4 changed files with 118 additions and 0 deletions

View file

@ -11,5 +11,6 @@
- { role: test_cs_securitygroup_rule, tags: test_cs_securitygroup_rule } - { role: test_cs_securitygroup_rule, tags: test_cs_securitygroup_rule }
- { role: test_cs_instance, tags: test_cs_instance } - { role: test_cs_instance, tags: test_cs_instance }
- { role: test_cs_instancegroup, tags: test_cs_instancegroup } - { 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_account, tags: test_cs_account }
- { role: test_cs_firewall, tags: test_cs_firewall } - { role: test_cs_firewall, tags: test_cs_firewall }

View file

@ -0,0 +1,3 @@
---
cs_portforward_public_ip: "10.100.212.5"
cs_portforward_vm: "{{ cs_resource_prefix }}-vm"

View file

@ -0,0 +1,3 @@
---
dependencies:
- test_cs_common

View file

@ -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