From 0c416b589120accd183c9a73fb80169903f3af9c Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Wed, 11 Oct 2017 16:18:40 +0200 Subject: [PATCH] tests: cs_snapshot_policy: add integration tests --- .../targets/cs_snapshot_policy/aliases | 2 + .../targets/cs_snapshot_policy/meta/main.yml | 3 + .../targets/cs_snapshot_policy/tasks/main.yml | 177 ++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 test/integration/targets/cs_snapshot_policy/aliases create mode 100644 test/integration/targets/cs_snapshot_policy/meta/main.yml create mode 100644 test/integration/targets/cs_snapshot_policy/tasks/main.yml diff --git a/test/integration/targets/cs_snapshot_policy/aliases b/test/integration/targets/cs_snapshot_policy/aliases new file mode 100644 index 00000000000..ee8454c6d12 --- /dev/null +++ b/test/integration/targets/cs_snapshot_policy/aliases @@ -0,0 +1,2 @@ +cloud/cs +posix/ci/cloud/group1/cs diff --git a/test/integration/targets/cs_snapshot_policy/meta/main.yml b/test/integration/targets/cs_snapshot_policy/meta/main.yml new file mode 100644 index 00000000000..e9a5b9eeaef --- /dev/null +++ b/test/integration/targets/cs_snapshot_policy/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - cs_common diff --git a/test/integration/targets/cs_snapshot_policy/tasks/main.yml b/test/integration/targets/cs_snapshot_policy/tasks/main.yml new file mode 100644 index 00000000000..1ea40e8982e --- /dev/null +++ b/test/integration/targets/cs_snapshot_policy/tasks/main.yml @@ -0,0 +1,177 @@ +--- +- name: setup instance + cs_instance: + name: "{{ cs_resource_prefix }}-vm-snapshot-policy" + template: "{{ cs_common_template }}" + service_offering: "{{ cs_common_service_offering }}" + zone: "{{ cs_common_zone_adv }}" + register: instance +- name: verify setup instance + assert: + that: + - instance|success + +- name: setup snapshot policy absent + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + state: absent + register: snapshot +- name: verify setup snapshot policy absent + assert: + that: + - snapshot|success + +- name: create snapshot policy in check mode + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + schedule: 5 + check_mode: true + register: snapshot +- name: verify create snapshot policy in check mode + assert: + that: + - snapshot|changed + +- name: create snapshot policy + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + schedule: 5 + register: snapshot +- name: verify create snapshot policy + assert: + that: + - snapshot|changed + - snapshot.schedule == "5" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + +- name: create snapshot policy idempotence + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + schedule: 5 + register: snapshot +- name: verify create snapshot policy idempotence + assert: + that: + - not snapshot|changed + - snapshot.schedule == "5" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + +- name: update snapshot policy + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + schedule: 6 + check_mode: true + register: snapshot +- name: verify update snapshot policy + assert: + that: + - snapshot|changed + - snapshot.schedule == "5" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + +- name: update snapshot policy in check mode + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + schedule: 6 + max_snaps: 3 + time_zone: "Europe/Zurich" + check_mode: true + register: snapshot +- name: verify update snapshot policy in check mode + assert: + that: + - snapshot|changed + - snapshot.schedule == "5" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + - snapshot.max_snaps == 8 + - snapshot.time_zone == "UTC" + +- name: update snapshot policy + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + schedule: 6 + max_snaps: 3 + time_zone: "Europe/Zurich" + register: snapshot +- name: verify update snapshot policy + assert: + that: + - snapshot|changed + - snapshot.schedule == "6" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + - snapshot.max_snaps == 3 + - snapshot.time_zone == "Europe/Zurich" + +- name: update snapshot policy idempotence + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + schedule: 6 + max_snaps: 3 + time_zone: "Europe/Zurich" + register: snapshot +- name: verify update snapshot policy idempotence + assert: + that: + - not snapshot|changed + - snapshot.schedule == "6" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + - snapshot.max_snaps == 3 + - snapshot.time_zone == "Europe/Zurich" + +- name: remove snapshot policy in check mode + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + state: absent + check_mode: true + register: snapshot +- name: verify remove snapshot policy in check mode + assert: + that: + - snapshot|changed + - snapshot.schedule == "6" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + - snapshot.max_snaps == 3 + - snapshot.time_zone == "Europe/Zurich" + +- name: remove snapshot policy + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + state: absent + register: snapshot +- name: verify remove snapshot policy + assert: + that: + - snapshot|changed + - snapshot.schedule == "6" + - snapshot.interval_type == "hourly" + - snapshot.volume != "" + - snapshot.max_snaps == 3 + - snapshot.time_zone == "Europe/Zurich" + +- name: remove snapshot policy idempotence + cs_snapshot_policy: + vm: "{{ cs_resource_prefix }}-vm-snapshot-policy" + interval_type: hourly + state: absent + register: snapshot +- name: verify remove snapshot policy idempotence + assert: + that: + - not snapshot|changed