From 3fe5de907fbb684deb49670923ff9e3193f815b2 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Mon, 19 Jun 2017 09:47:50 +0200 Subject: [PATCH] cloudstack: cs_host: add integration tests --- test/integration/targets/cs_host/aliases | 2 + .../integration/targets/cs_host/meta/main.yml | 3 + .../targets/cs_host/tasks/main.yml | 296 ++++++++++++++++++ 3 files changed, 301 insertions(+) create mode 100644 test/integration/targets/cs_host/aliases create mode 100644 test/integration/targets/cs_host/meta/main.yml create mode 100644 test/integration/targets/cs_host/tasks/main.yml diff --git a/test/integration/targets/cs_host/aliases b/test/integration/targets/cs_host/aliases new file mode 100644 index 00000000000..ba249b99d73 --- /dev/null +++ b/test/integration/targets/cs_host/aliases @@ -0,0 +1,2 @@ +cloud/cs +posix/ci/cloud/cs diff --git a/test/integration/targets/cs_host/meta/main.yml b/test/integration/targets/cs_host/meta/main.yml new file mode 100644 index 00000000000..e9a5b9eeaef --- /dev/null +++ b/test/integration/targets/cs_host/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - cs_common diff --git a/test/integration/targets/cs_host/tasks/main.yml b/test/integration/targets/cs_host/tasks/main.yml new file mode 100644 index 00000000000..32567664413 --- /dev/null +++ b/test/integration/targets/cs_host/tasks/main.yml @@ -0,0 +1,296 @@ +--- +- name: test fail missing params + cs_host: + register: host + ignore_errors: true +- name: verify test fail missing url if host is not existent + assert: + that: + - host|failed + - 'host.msg == "missing required arguments: name"' + +- name: test fail missing params if host is not existent + cs_host: + name: sim + register: host + ignore_errors: true +- name: verify test fail missing params if host is not existent + assert: + that: + - host|failed + - 'host.msg == "missing required arguments: password,username,hypervisor,pod"' + +- name: test create a host in check mode + cs_host: + name: sim + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: root + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: + - perf + - gpu + register: host + check_mode: true +- name: verify test create a host in check mode + assert: + that: + - host|changed + +- name: test create a host + cs_host: + name: sim + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: root + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: + - perf + - gpu + register: host +- name: verify test create a host + assert: + that: + - host|changed + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - "host.name.startswith('SimulatedAgent.')" + - host.host_tags == ['perf', 'gpu'] + +# This is special in simulator mode, we can not predict the full hostname. +# That is why we gather the infos from the returns and use a fact. +- name: assume the sim would resolve to the IP address + set_fact: + host_hostname: "{{ host.name }}" + host_ip_address: "{{ host.ip_address }}" + +- name: test create a host idempotence + cs_host: + name: "{{ host_hostname }}" + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: admin + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: + - perf + - gpu + register: host +- name: verify test create a host idempotence + assert: + that: + - not host|changed + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + - host.host_tags == ['perf', 'gpu'] + +- name: test update host in check mode + cs_host: + name: "{{ host_hostname }}" + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: admin + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: + - perf + - gpu + - x2 + register: host + check_mode: true +- name: verify test update a host in check mode + assert: + that: + - host|changed + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + - host.host_tags == ['perf', 'gpu'] + +- name: test update host + cs_host: + name: "{{ host_hostname }}" + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: admin + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: + - perf + - gpu + - x2 + register: host +- name: verify test update a host in check mode + assert: + that: + - host|changed + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + - host.host_tags == ['perf', 'gpu', 'x2'] + +- name: test update host idempotence + cs_host: + name: "{{ host_hostname }}" + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: admin + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: + - perf + - gpu + - x2 + register: host +- name: verify test update a host idempotence + assert: + that: + - not host|changed + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + - host.host_tags == ['perf', 'gpu', 'x2'] + +# FIXME: Removing by empty list seems to be an issue in the used lib cs underneath, disabled +- name: test update host remove host_tags + cs_host: + name: "{{ host_hostname }}" + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: admin + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: [] + register: host + when: false +- name: verify test update host remove host_tags + assert: + that: + - host|changed + - host.host_tags|length == 0 + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + when: false + +# FIXME: Removing by empty list seems to be an issue in the used lib cs underneath, disabled +- name: test update host remove host_tags idempotence + cs_host: + name: "{{ host_hostname }}" + url: "http://sim/c0-basic/h2" + cluster: C0-basic + pod: POD0-basic + username: admin + password: password + hypervisor: Simulator + allocation_state: enabled + host_tags: [] + register: host + when: false +- name: verify test update host remove host_tags idempotence + assert: + that: + - not host|changed + - len(host.host_tags) == 0 + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + when: false + +- name: test remove host in check mode + cs_host: + name: "{{ host_hostname }}" + cluster: C0-basic + pod: POD0-basic + state: absent + check_mode: true + register: host +- name: verify test remove a host in check mode + assert: + that: + - host|changed + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + - host.host_tags == ['perf', 'gpu', 'x2'] + +- name: test remove host + cs_host: + name: "{{ host_hostname }}" + cluster: C0-basic + pod: POD0-basic + state: absent + register: host +- name: verify test remove a host + assert: + that: + - host|changed + - host.cluster == 'C0-basic' + - host.pod == 'POD0-basic' + - host.hypervisor == 'Simulator' + - host.allocation_state == 'enabled' + - host.zone == 'Sandbox-simulator-basic' + - host.state == 'Up' + - host.name == '{{ host_hostname }}' + - host.host_tags == ['perf', 'gpu', 'x2'] + +- name: test remove host idempotence + cs_host: + name: "{{ host_hostname }}" + cluster: C0-basic + pod: POD0-basic + state: absent + register: host +- name: verify test remove a host idempotenc + assert: + that: + - not host|changed