From 3c99315bdd5ccb8e3b2c0545cbb392a5306de92a Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Sat, 15 Jul 2017 10:09:25 +0200 Subject: [PATCH] cloudstack: cs_router: add integration tests --- test/integration/targets/cs_router/aliases | 2 + .../targets/cs_router/meta/main.yml | 3 + .../targets/cs_router/tasks/main.yml | 184 ++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 test/integration/targets/cs_router/aliases create mode 100644 test/integration/targets/cs_router/meta/main.yml create mode 100644 test/integration/targets/cs_router/tasks/main.yml diff --git a/test/integration/targets/cs_router/aliases b/test/integration/targets/cs_router/aliases new file mode 100644 index 0000000000..ba249b99d7 --- /dev/null +++ b/test/integration/targets/cs_router/aliases @@ -0,0 +1,2 @@ +cloud/cs +posix/ci/cloud/cs diff --git a/test/integration/targets/cs_router/meta/main.yml b/test/integration/targets/cs_router/meta/main.yml new file mode 100644 index 0000000000..e9a5b9eeae --- /dev/null +++ b/test/integration/targets/cs_router/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - cs_common diff --git a/test/integration/targets/cs_router/tasks/main.yml b/test/integration/targets/cs_router/tasks/main.yml new file mode 100644 index 0000000000..bc4215cd4d --- /dev/null +++ b/test/integration/targets/cs_router/tasks/main.yml @@ -0,0 +1,184 @@ +--- +- name: setup network + cs_network: + name: "net_router" + zone: "{{ cs_common_zone_adv }}" + network_offering: DefaultSharedNetworkOffering + network_domain: example.com + vlan: 1234 + start_ip: 10.100.12.11 + end_ip: 10.100.12.250 + gateway: 10.100.12.1 + netmask: 255.255.255.0 + register: net +- name: verify setup network + assert: + that: + - net|success + - net.name == "net_router" + +- name: setup instance + cs_instance: + name: "instance-vm" + template: "{{ cs_common_template }}" + service_offering: "{{ cs_common_service_offering }}" + zone: "{{ cs_common_zone_adv }}" + network: "net_router" + state: started + register: instance +- name: verify setup instance + assert: + that: + - instance|success + - instance.name == "instance-vm" + - instance.state == "Running" + +- name: setup instance starts a router + cs_instance: + name: "instance-vm" + template: "{{ cs_common_template }}" + service_offering: "{{ cs_common_service_offering }}" + zone: "{{ cs_common_zone_adv }}" + network: "net_router" + state: started + register: instance +- name: verify setup instance + assert: + that: + - instance|success + - instance.name == "instance-vm" + - instance.state == "Running" + +- name: install jq + package: + name: jq + +- name: setup find the routers name + shell: cs listRouters listall=true networkid="{{ net.id }}" zone="{{ cs_common_zone_adv }}" | jq ".router[].name" | tr -d '"' + args: + chdir: "{{ playbook_dir }}" + register: router + +- debug: + var: router.stdout + +- set_fact: + router_name: "{{ router.stdout }}" + +- name: test router started + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: started + register: router +- name: verify test router started + assert: + that: + - router|success + +- name: test stop router in check mode + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: stopped + check_mode: true + register: router +- name: verify test stop router in check mode + assert: + that: + - router|changed + - router.state == "Running" + - router.service_offering == "System Offering For Software Router" + +- name: test stop router + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: stopped + register: router +- name: verify test stop router + assert: + that: + - router|changed + - router.state == "Stopped" + - router.service_offering == "System Offering For Software Router" + +- name: test stop router idempotence + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: stopped + register: router +- name: verify test stop router idempotence + assert: + that: + - not router|changed + - router.state == "Stopped" + - router.service_offering == "System Offering For Software Router" + +- name: test start router in check mode + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: started + register: router + check_mode: true +- name: verify test start router in check mode + assert: + that: + - router|changed + - router.state == "Stopped" + - router.service_offering == "System Offering For Software Router" + +- name: test start router + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: started + register: router +- name: verify test start router + assert: + that: + - router|changed + - router.state == "Running" + - router.service_offering == "System Offering For Software Router" + +- name: test start router idempotence + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: started + register: router +- name: verify test start router idempotence + assert: + that: + - not router|changed + - router.state == "Running" + - router.service_offering == "System Offering For Software Router" + +- name: test restart router in check mode + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: restarted + register: router + check_mode: true +- name: verify test restart router in check mode + assert: + that: + - router|changed + - router.state == "Running" + - router.service_offering == "System Offering For Software Router" + +- name: test restart router + cs_router: + name: "{{ router_name }}" + zone: "{{ cs_common_zone_adv }}" + state: restarted + register: router +- name: verify test restart router + assert: + that: + - router|changed + - router.state == "Running" + - router.service_offering == "System Offering For Software Router"