From 4d6a15ebc36e5b3cc088fffed2353f6457552735 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Tue, 2 Feb 2016 20:21:13 +0100 Subject: [PATCH] cloudstack: new integration tests test_cluster --- test/integration/cloudstack.yml | 1 + .../roles/test_cs_cluster/meta/main.yml | 3 + .../roles/test_cs_cluster/tasks/main.yml | 211 ++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 test/integration/roles/test_cs_cluster/meta/main.yml create mode 100644 test/integration/roles/test_cs_cluster/tasks/main.yml diff --git a/test/integration/cloudstack.yml b/test/integration/cloudstack.yml index 3f732d9fe43..99d08bb0cfc 100644 --- a/test/integration/cloudstack.yml +++ b/test/integration/cloudstack.yml @@ -26,3 +26,4 @@ - { role: test_cs_instance_facts, tags: test_cs_instance_facts } - { role: test_cs_configuration, tags: test_cs_configuration } - { role: test_cs_pod, tags: test_cs_pod } + - { role: test_cs_cluster, tags: test_cs_cluster } diff --git a/test/integration/roles/test_cs_cluster/meta/main.yml b/test/integration/roles/test_cs_cluster/meta/main.yml new file mode 100644 index 00000000000..03e38bd4f7a --- /dev/null +++ b/test/integration/roles/test_cs_cluster/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - test_cs_common diff --git a/test/integration/roles/test_cs_cluster/tasks/main.yml b/test/integration/roles/test_cs_cluster/tasks/main.yml new file mode 100644 index 00000000000..bfaa09805d5 --- /dev/null +++ b/test/integration/roles/test_cs_cluster/tasks/main.yml @@ -0,0 +1,211 @@ +--- +- name: setup cluster is absent + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + state: absent + register: cluster +- name: verify setup cluster is absent + assert: + that: + - cluster|success + +- name: setup zone is present + cs_zone: + name: "{{ cs_resource_prefix }}-zone" + dns1: 8.8.8.8 + dns2: 8.8.4.4 + network_type: basic + register: zone +- name: verify setup zone is present + assert: + that: + - zone|success + +- name: setup pod is preset + cs_pod: + name: "{{ cs_resource_prefix }}-pod" + zone: "{{ cs_resource_prefix }}-zone" + start_ip: 10.100.10.101 + gateway: 10.100.10.1 + netmask: 255.255.255.0 + register: pod +- name: verify setup pod is preset + assert: + that: + - pod|success + +- name: test fail if missing name + cs_cluster: + register: cluster + ignore_errors: true +- name: verify results of fail if missing name + assert: + that: + - cluster|failed + - "cluster.msg == 'missing required arguments: name'" + +- name: test create cluster + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + zone: "{{ cs_resource_prefix }}-zone" + hypervisor: simulator + cluster_type: CloudManaged + register: cluster_origin + tags: disable +- name: verify test create cluster + assert: + that: + - cluster_origin|changed + - cluster_origin.name == "{{ cs_resource_prefix }}-cluster" + - cluster_origin.zone == "{{ cs_resource_prefix }}-zone" + - cluster_origin.allocation_state == "Enabled" + - cluster_origin.hypervisor == "Simulator" + - cluster_origin.cluster_type == "CloudManaged" + +- name: test create cluster idempotence + cs_cluster: + name: "{{ cs_resource_prefix }}-Cluster" + zone: "{{ cs_resource_prefix }}-Zone" + hypervisor: Simulator + cluster_type: CloudManaged + register: cluster +- name: verify test create cluster idempotence + assert: + that: + - cluster.id == cluster_origin.id + - not cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Enabled" + - cluster_origin.hypervisor == "Simulator" + - cluster.cluster_type == "CloudManaged" + +- name: test update cluster + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + zone: "{{ cs_resource_prefix }}-zone" + hypervisor: simulator + cluster_type: ExternalManaged + register: cluster +- name: verify test update cluster + assert: + that: + - cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Enabled" + - cluster.hypervisor == "Simulator" + - cluster.cluster_type == "ExternalManaged" + - cluster.id == cluster_origin.id + +- name: test update cluster idempotence + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + zone: "{{ cs_resource_prefix }}-zone" + hypervisor: simulator + cluster_type: ExternalManaged + register: cluster +- name: verify test update cluster idempotence + assert: + that: + - not cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Enabled" + - cluster.hypervisor == "Simulator" + - cluster.cluster_type == "ExternalManaged" + - cluster.id == cluster_origin.id + +- name: test disable cluster + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + state: disabled + register: cluster + tags: disable +- name: verify test disable cluster + assert: + that: + - cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Disabled" + - cluster.hypervisor == "Simulator" + - cluster.cluster_type == "ExternalManaged" + - cluster.id == cluster_origin.id + tags: disable + +- name: test disable cluster idempotence + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + state: disabled + register: cluster + tags: disable +- name: verify test disable cluster idempotence + assert: + that: + - not cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Disabled" + - cluster.hypervisor == "Simulator" + - cluster.cluster_type == "ExternalManaged" + tags: disable + +- name: test enable cluster + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + state: enabled + register: cluster +- name: verify test enable cluster + assert: + that: + - cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Enabled" + - cluster.hypervisor == "Simulator" + - cluster.cluster_type == "ExternalManaged" + - cluster.id == cluster_origin.id + +- name: test enable cluster idempotence + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + state: enabled + register: cluster +- name: verify test enable cluster idempotence + assert: + that: + - not cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Enabled" + - cluster.hypervisor == "Simulator" + - cluster.cluster_type == "ExternalManaged" + - cluster.id == cluster_origin.id + +- name: test remove cluster + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + zone: "{{ cs_resource_prefix }}-zone" + state: absent + register: cluster +- name: verify test remove cluster + assert: + that: + - cluster.id == cluster_origin.id + - cluster|changed + - cluster.name == "{{ cs_resource_prefix }}-cluster" + - cluster.zone == "{{ cs_resource_prefix }}-zone" + - cluster.allocation_state == "Enabled" + - cluster_origin.hypervisor == "Simulator" + +- name: test remove cluster idempotence + cs_cluster: + name: "{{ cs_resource_prefix }}-cluster" + zone: "{{ cs_resource_prefix }}-zone" + state: absent + register: cluster +- name: verify test remove cluster idempotence + assert: + that: + - not cluster|changed