Skip to content

Commit

Permalink
Improve test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Jan 4, 2019
1 parent f3ddcc3 commit 8e2fc00
Show file tree
Hide file tree
Showing 19 changed files with 170 additions and 93 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FEATURES:

IMPROVEMENTS:

- Improve test cases ([#152](https://github.com/alibaba/ansible-provider/pull/152))
- Improve inventory alicloud.py meta and use public_ip_address instead eip_address ([#152](https://github.com/alibaba/ansible-provider/pull/152))
- Improve module ali_vpc and ali_security_group multi_ok ([#149](https://github.com/alibaba/ansible-provider/pull/149))
- Improve module ali_slb_vsg and ali_slb_vsg_facts ([#148](https://github.com/alibaba/ansible-provider/pull/148))
Expand Down
3 changes: 3 additions & 0 deletions tests/ali_eip_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
hosts: localhost
remote_user: root

vars:
name: ansible-testacc-ali_eip_facts-module

roles:
- eip

Expand Down
1 change: 1 addition & 0 deletions tests/ali_eip_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

vars:
allocate_public_ip: False
name: ansible-testacc-ali_eip-module

roles:
- vpc
Expand Down
2 changes: 1 addition & 1 deletion tests/ali_eni_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root

vars:
name: ansible-testacc-ali_eni_facts
name: ansible-testacc-ali_eni_facts-module

roles:
- vpc
Expand Down
2 changes: 1 addition & 1 deletion tests/ali_eni_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root

vars:
name: ansible-testacc-ali_eni
name: ansible-testacc-ali_eni-module

roles:
- vpc
Expand Down
12 changes: 9 additions & 3 deletions tests/ali_instance_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
hosts: localhost
remote_user: root

vars:
name: ansible-testacc-ali_instance_facts-module

roles:
- vpc
- vswitch
Expand Down Expand Up @@ -61,19 +64,22 @@

- name: Changed. Deleting security groups
ali_security_group:
group_id: '{{item.id}}'
name: '{{ item.group_name }}'
vpc_id: '{{item.vpc_id}}'
state: absent
with_items: '{{sgs.groups}}'

- name: Changed. Deleting vswitches
ali_vswitch:
id: '{{item.id}}'
vpc_id: '{{ item.vpc_id}}'
cidr_block: '{{ item.cidr_block}}'
state: absent
with_items: '{{vswitches.vswitches}}'

- name: Changed. Deleting vpcs
ali_vpc:
vpc_id: '{{item.id}}'
name: '{{item.vpc_name}}'
cidr_block: '{{item.cidr_block}}'
state: absent
with_items: '{{vpcs.vpcs}}'

15 changes: 9 additions & 6 deletions tests/ali_instance_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- name: Changed. Modifying name, host name and description when C(present)
ali_instance:
instance_ids: '{{ instances.ids}}'
name: '{{ name }}-instance-modified'
name: '{{ name }}-modified'
description: 'Test modify name, host name and description'
host_name: 'modify-host-name'

Expand All @@ -40,14 +40,14 @@
ali_instance:
state: running
instance_ids: '{{ instances.ids}}'
name: '{{ name }}-instance'
name: '{{ name }}'
description: '{{instance_description}}'
host_name: 'modify-host-name'

- name: No Changed. There is no any attribute changed
ali_instance:
instance_ids: '{{ instances.ids}}'
name: '{{ name }}-instance'
name: '{{ name }}'
description: '{{instance_description}}'
host_name: 'modify-host-name'
password: 'Test12345'
Expand Down Expand Up @@ -100,19 +100,22 @@

- name: Changed. Deleting security groups
ali_security_group:
group_id: '{{item.id}}'
name: '{{ item.group_name }}'
vpc_id: '{{item.vpc_id}}'
state: absent
with_items: '{{sgs.groups}}'

- name: Changed. Deleting vswitches
ali_vswitch:
id: '{{item.id}}'
vpc_id: '{{ item.vpc_id}}'
cidr_block: '{{ item.cidr_block}}'
state: absent
with_items: '{{vswitches.vswitches}}'

- name: Changed. Deleting vpcs
ali_vpc:
vpc_id: '{{item.id}}'
name: '{{item.vpc_name}}'
cidr_block: '{{item.cidr_block}}'
state: absent
with_items: '{{vpcs.vpcs}}'

2 changes: 1 addition & 1 deletion tests/ali_security_group_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: localhost
remote_user: root
vars:
name: ansible-testacc-ali_security_group_facts
name: ansible-testacc-ali_security_group_facts-module
roles:
- vpc
- security_group
Expand Down
2 changes: 1 addition & 1 deletion tests/ali_security_group_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root

vars:
name: ansible-testacc-ali_security_group
name: ansible-testacc-ali_security_group-module

roles:
- vpc
Expand Down
23 changes: 21 additions & 2 deletions tests/ali_slb_lb_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
hosts: localhost
remote_user: root

vars:
name: ansible-testacc-ali_slb_lb_facts

roles:
- vpc
- vswitch
- slb

tasks:
- name: Retrieving slbs using ids
ali_slb_lb_facts:
ids: '{{slb.load_balancer.id}}'
ids: '{{slbpub.load_balancer.id}}'

- name: Create a slb and used to test name_regex
ali_slb_lb:
name: '{{name}}regex-slb'
name: '{{name}}regex'

- name: Filter slb using name_regex
ali_slb_lb_facts:
Expand All @@ -33,3 +38,17 @@
state: absent
with_items: '{{slbs.load_balancers}}'

- name: Changed. Deleting vswitches
ali_vswitch:
vpc_id: '{{ item.vpc_id}}'
cidr_block: '{{ item.cidr_block}}'
state: absent
with_items: '{{vswitches.vswitches}}'

- name: Changed. Deleting vpcs
ali_vpc:
name: '{{item.vpc_name}}'
cidr_block: '{{item.cidr_block}}'
state: absent
with_items: '{{vpcs.vpcs}}'

40 changes: 34 additions & 6 deletions tests/ali_slb_lb_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,60 @@
hosts: localhost
remote_user: root

vars:
name: ansible-testacc-ali_slb_lb

roles:
- vpc
- vswitch
- slb

tasks:
- name: Changed. Modifying internet charge type when C(present)
ali_slb_lb:
name: '{{ slb.load_balancer.name }}'
name: '{{ slbpub.load_balancer.name }}'
internet_charge_type: 'PayByBandwidth'
bandwidth: 5

- name: Filter slb using name_regex
ali_slb_lb_facts:
name_prefix: '{{name}}'
register: slbs

- name: Changed. Stop slb instance when C(stopped)
ali_slb_lb:
name: '{{ slb.load_balancer.name }}'
name: '{{ item.name }}'
state: stopped
with_items: '{{slbs.load_balancers}}'

- name: Changed. Running slb instance when C(running)
ali_slb_lb:
name: '{{ slb.load_balancer.name }}'
name: '{{ item.name }}'
state: running
with_items: '{{slbs.load_balancers}}'

- name: No Changed. There is no changed when C(running)
ali_slb_lb:
name: '{{ slb.load_balancer.name }}'
name: '{{ item.name }}'
state: running
with_items: '{{slbs.load_balancers}}'

- name: Changed. Delete slb instance when C(absent)
ali_slb_lb:
name: '{{ slb.load_balancer.name }}'
state: absent
name: '{{ item.name }}'
state: absent
with_items: '{{slbs.load_balancers}}'

- name: Changed. Deleting vswitches
ali_vswitch:
vpc_id: '{{ item.vpc_id}}'
cidr_block: '{{ item.cidr_block}}'
state: absent
with_items: '{{vswitches.vswitches}}'

- name: Changed. Deleting vpcs
ali_vpc:
name: '{{item.vpc_name}}'
cidr_block: '{{item.cidr_block}}'
state: absent
with_items: '{{vpcs.vpcs}}'
12 changes: 10 additions & 2 deletions tests/ali_slb_vsg_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
remote_user: root
vars:
number_of_instances: 2
name: ansible-testacc-ali_slb_vsg_facts
name: ansible-testacc-ali_slb_vsg_facts-module
roles:
- vpc
- vswitch
- security_group
- slb
- instance
- slb

tasks:
- name: Changed. Create a VServer Group in public SLB
Expand Down Expand Up @@ -76,6 +76,14 @@
force: True
state: absent

- name: Changed. Deleting security groups
ali_security_group:
name: '{{ item.group_name }}'
vpc_id: '{{item.vpc_id}}'
state: absent
with_items: '{{sgs.groups}}'
when: sgs.groups

- name: Changed. Deleting vswitches
ali_vswitch:
vpc_id: '{{ item.vpc_id}}'
Expand Down
10 changes: 9 additions & 1 deletion tests/ali_slb_vsg_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root
vars:
number_of_instances: 4
name: ansible-testacc-ali_slb_vsg
name: ansible-testacc-ali_slb_vsg-module
roles:
- vpc
- vswitch
Expand Down Expand Up @@ -198,6 +198,14 @@
force: True
state: absent

- name: Changed. Deleting security groups
ali_security_group:
name: '{{ item.group_name }}'
vpc_id: '{{item.vpc_id}}'
state: absent
with_items: '{{sgs.groups}}'
when: sgs.groups

- name: Changed. Deleting vswitches
ali_vswitch:
vpc_id: '{{ item.vpc_id}}'
Expand Down
2 changes: 1 addition & 1 deletion tests/ali_vpc_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root

vars:
name: ansible-testacc-ali_vpc_facts
name: ansible-testacc-ali_vpc_facts-module

roles:
- vpc
Expand Down
2 changes: 1 addition & 1 deletion tests/ali_vpc_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root

vars:
name: ansible-testacc-ali_vpc
name: ansible-testacc-ali_vpc-module

roles:
- vpc
Expand Down
2 changes: 1 addition & 1 deletion tests/ali_vswitch_facts_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root

vars:
name: ansible-testacc-ali_vswitch_facts
name: ansible-testacc-ali_vswitch_facts-module

roles:
- vpc
Expand Down
2 changes: 1 addition & 1 deletion tests/ali_vswitch_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
remote_user: root

vars:
name: ansible-testacc-ali_vswitch
name: ansible-testacc-ali_vswitch-module

roles:
- vpc
Expand Down
Loading

0 comments on commit 8e2fc00

Please sign in to comment.