From 35097e8c361fea417a7aa7e7ba5a40778c72c832 Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Mon, 3 Apr 2023 11:28:18 +0200 Subject: [PATCH 01/10] CI move base_smtp out of base_cfg to avoid warning Warning was like tests/integration/integration_config.yml, line 79, column 5, found a duplicate dict key (smtp). Using last defined value only. Signed-off-by: Justin Cinkelj --- tests/integration/integration_config.yml.j2 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/integration/integration_config.yml.j2 b/tests/integration/integration_config.yml.j2 index 7c2073056..28bbfa287 100644 --- a/tests/integration/integration_config.yml.j2 +++ b/tests/integration/integration_config.yml.j2 @@ -15,6 +15,16 @@ smb_share: "{{ smb_share }}" smb_username: "{{ smb_username }}" smb_password: "{{ smb_password }}" +__base_smtp: &base_smtp + host: smtp-relay.gmail.com + port: 25 + use_ssl: false + # from_address: PUB5@scalecomputing.com + use_auth: false + auth_user: "" + auth_password: "" + + # sc_config is specific for each test cluster # The values should be set after tests, to ensure cluster is left in functional state. sc_config: @@ -35,14 +45,7 @@ sc_config: contact: Alex Nicholson email: email_hidden@scalecomputing.com phone: "123 456 7890" - smtp: &base_smtp - host: smtp-relay.gmail.com - port: 25 - use_ssl: false - # from_address: PUB5@scalecomputing.com - use_auth: false - auth_user: "" - auth_password: "" + # smtp: ... email_alert: - email_hidden@scalecomputing.com oidc: From 71e0151b3166709ec719e3a78d17eb14eb7156e8 Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Mon, 3 Apr 2023 11:32:06 +0200 Subject: [PATCH 02/10] CI add variables to signal what can be tested on a cluster This depends on HyperCore version. We need to know if cluster name can be changed, version can be upgraded, and if virtual disk feature is supported. Signed-off-by: Justin Cinkelj --- tests/integration/integration_config.yml.j2 | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/integration/integration_config.yml.j2 b/tests/integration/integration_config.yml.j2 index 28bbfa287..e2074c6b1 100644 --- a/tests/integration/integration_config.yml.j2 +++ b/tests/integration/integration_config.yml.j2 @@ -81,6 +81,24 @@ sc_config: smtp: <<: *base_smtp from_address: PUB5@scalecomputing.com + # Under features are described properties that affect expected integration test output. + features: + version_update: + # Current SW (ICOS) version running on the host. + current_version: "9.2.13.211102" + # The next version available update for the host. + next_version: "" + # The latest version available update for the host. + latest_version: "" + # Can we update the host? VSNS hosts report update as available, + # but if we try to update, the update fails (unsupported HW is reported back). + can_be_applied: True + virtual_disk: + # Virtual disk feature is supported iff version ">=9.2.10" + is_supported: True + cluster_name: + # cluster name can be changed iff version ">=9.1.21 <9.2.0 || >=9.2.11" + is_writable: True https://10.5.11.200: <<: *base_cfg @@ -96,6 +114,16 @@ sc_config: from_address: VSNS200@scalecomputing.com syslog_server: host: 10.5.11.222 + features: + version_update: + current_version: "9.1.14.208456" + next_version: "9.1.23.210897" + latest_version: "9.1.23.210897" + can_be_applied: False + virtual_disk: + is_supported: False + cluster_name: + is_writable: False https://10.5.11.201: <<: *base_cfg @@ -111,3 +139,13 @@ sc_config: from_address: VSNS201@scalecomputing.com syslog_server: host: 10.5.11.222 + features: + version_update: + current_version: "9.2.13.211102" + next_version: "" + latest_version: "" + can_be_applied: False + virtual_disk: + is_supported: True + cluster_name: + is_writable: True From 9795e155aa22075ea82fdbceccc13e52dd3907d5 Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Mon, 3 Apr 2023 12:01:03 +0200 Subject: [PATCH 03/10] Test cluster_name does fail on version 9.1 Signed-off-by: Justin Cinkelj --- tests/integration/integration_config.yml.j2 | 2 +- .../cluster_name/tasks/01_supported.yml | 87 ++++++++++++++++++ .../cluster_name/tasks/02_not_supported.yml | 21 +++++ .../targets/cluster_name/tasks/main.yml | 90 ++----------------- 4 files changed, 115 insertions(+), 85 deletions(-) create mode 100644 tests/integration/targets/cluster_name/tasks/01_supported.yml create mode 100644 tests/integration/targets/cluster_name/tasks/02_not_supported.yml diff --git a/tests/integration/integration_config.yml.j2 b/tests/integration/integration_config.yml.j2 index e2074c6b1..761eec005 100644 --- a/tests/integration/integration_config.yml.j2 +++ b/tests/integration/integration_config.yml.j2 @@ -105,7 +105,7 @@ sc_config: sc_username: admin sc_password: admin cluster: - name: VSNS200 + name: "HC3 System" # VSNS200 support_tunnel: open: true code: "4423" diff --git a/tests/integration/targets/cluster_name/tasks/01_supported.yml b/tests/integration/targets/cluster_name/tasks/01_supported.yml new file mode 100644 index 000000000..c43616bf6 --- /dev/null +++ b/tests/integration/targets/cluster_name/tasks/01_supported.yml @@ -0,0 +1,87 @@ +--- +- name: Change cluster name + block: + - name: Retrieve cluster name + scale_computing.hypercore.cluster_info: + register: cluster_initial + + - name: Update cluster name + scale_computing.hypercore.cluster_name: + name_new: name_updated + register: cluster + - ansible.builtin.assert: + that: + - cluster is changed + - cluster.record.keys() | sort == ['icos_version', 'name', 'uuid'] + - cluster.record.name == "name_updated" + - cluster.diff.before.name == cluster_initial.record.name + - cluster.diff.after.name == "name_updated" + register: cluster # to catch assertion msg for always + + - name: Check if cluster name is updated + scale_computing.hypercore.cluster_info: + register: cluster + - ansible.builtin.assert: + that: + - cluster.record.name == "name_updated" + register: cluster # to catch assertion msg for always + + - name: Update cluster name - idempotence + scale_computing.hypercore.cluster_name: + name_new: name_updated + register: cluster + - ansible.builtin.assert: + that: + - cluster is not changed + - cluster.record.keys() | sort == ['icos_version', 'name', 'uuid'] + - cluster.record.name == "name_updated" + - cluster.diff.before.name == "name_updated" + - cluster.diff.after.name == "name_updated" + register: cluster # to catch assertion msg for always + + - name: Retrieve cluster name + scale_computing.hypercore.cluster_info: + register: cluster + - ansible.builtin.assert: + that: + - cluster.record.name == "name_updated" + register: cluster # to catch assertion msg for always + + - name: Set back the initial cluster name + scale_computing.hypercore.cluster_name: + name_new: "{{ cluster_initial.record.name }}" + register: cluster + - ansible.builtin.assert: + that: + - cluster is changed + - cluster.record.keys() | sort == ['icos_version', 'name', 'uuid'] + - cluster.record.name == cluster_initial.record.name + - cluster.diff.before.name == "name_updated" + - cluster.diff.after.name == cluster_initial.record.name + register: cluster # to catch assertion msg for always + + - name: Check if cluster name is updated + scale_computing.hypercore.cluster_info: + register: cluster + - ansible.builtin.assert: + that: + - cluster.record.name == cluster_initial.record.name + register: cluster # to catch assertion msg for always + + always: + - name: Set back the initial cluster_name + scale_computing.hypercore.api: + action: patch + endpoint: /rest/v1/Cluster/{{ cluster_initial.record.uuid }} + data: + clusterName: "{{ cluster_config.name }}" + when: "'does not match required version' not in cluster.msg" + + - name: Get current cluster name + scale_computing.hypercore.api: + action: get + endpoint: /rest/v1/Cluster + register: cluster + - name: Show cluster + ansible.builtin.debug: + var: cluster diff --git a/tests/integration/targets/cluster_name/tasks/02_not_supported.yml b/tests/integration/targets/cluster_name/tasks/02_not_supported.yml new file mode 100644 index 000000000..7206fdecd --- /dev/null +++ b/tests/integration/targets/cluster_name/tasks/02_not_supported.yml @@ -0,0 +1,21 @@ +--- +- name: Retrieve cluster name + scale_computing.hypercore.cluster_info: + register: cluster_initial + +- ansible.builtin.assert: + that: + - cluster_initial.record.name == cluster_config.name + +- name: Update cluster name + scale_computing.hypercore.cluster_name: + name_new: cluster_config.cluster_name + register: cluster + ignore_errors: True + +- ansible.builtin.assert: + that: + - cluster is not changed + - cluster is failed + - "{{ 'does not match required version' in cluster.msg }}" + - "{{ 'record' not in cluster }}" diff --git a/tests/integration/targets/cluster_name/tasks/main.yml b/tests/integration/targets/cluster_name/tasks/main.yml index 7c2398b7c..d6a79070a 100644 --- a/tests/integration/targets/cluster_name/tasks/main.yml +++ b/tests/integration/targets/cluster_name/tasks/main.yml @@ -8,87 +8,9 @@ cluster_config: "{{ sc_config[sc_host].cluster }}" block: - - name: Retrieve cluster name - scale_computing.hypercore.cluster_info: - register: cluster_initial - - - name: Update cluster name - scale_computing.hypercore.cluster_name: - name_new: name_updated - register: cluster - - ansible.builtin.assert: - that: - - cluster is changed - - cluster.record.keys() | sort == ['icos_version', 'name', 'uuid'] - - cluster.record.name == "name_updated" - - cluster.diff.before.name == cluster_initial.record.name - - cluster.diff.after.name == "name_updated" - register: cluster # to catch assertion msg for always - - - name: Check if cluster name is updated - scale_computing.hypercore.cluster_info: - register: cluster - - ansible.builtin.assert: - that: - - cluster.record.name == "name_updated" - register: cluster # to catch assertion msg for always - - - name: Update cluster name - idempotence - scale_computing.hypercore.cluster_name: - name_new: name_updated - register: cluster - - ansible.builtin.assert: - that: - - cluster is not changed - - cluster.record.keys() | sort == ['icos_version', 'name', 'uuid'] - - cluster.record.name == "name_updated" - - cluster.diff.before.name == "name_updated" - - cluster.diff.after.name == "name_updated" - register: cluster # to catch assertion msg for always - - - name: Retrieve cluster name - scale_computing.hypercore.cluster_info: - register: cluster - - ansible.builtin.assert: - that: - - cluster.record.name == "name_updated" - register: cluster # to catch assertion msg for always - - - name: Set back the initial cluster name - scale_computing.hypercore.cluster_name: - name_new: "{{ cluster_initial.record.name }}" - register: cluster - - ansible.builtin.assert: - that: - - cluster is changed - - cluster.record.keys() | sort == ['icos_version', 'name', 'uuid'] - - cluster.record.name == cluster_initial.record.name - - cluster.diff.before.name == "name_updated" - - cluster.diff.after.name == cluster_initial.record.name - register: cluster # to catch assertion msg for always - - - name: Check if cluster name is updated - scale_computing.hypercore.cluster_info: - register: cluster - - ansible.builtin.assert: - that: - - cluster.record.name == cluster_initial.record.name - register: cluster # to catch assertion msg for always - - always: - - name: Set back the initial cluster_name - scale_computing.hypercore.api: - action: patch - endpoint: /rest/v1/Cluster/{{ cluster_initial.record.uuid }} - data: - clusterName: "{{ cluster_config.name }}" - when: "'does not match required version' not in cluster.msg" - - - name: Get current cluster name - scale_computing.hypercore.api: - action: get - endpoint: /rest/v1/Cluster - register: cluster - - name: Show cluster - ansible.builtin.debug: - var: cluster + # if HC3 version is recent enough, we can change cluster name + - include_tasks: 01_supported.yml + when: sc_config[sc_host].features.cluster_name.is_writable + # if HC3 version is not recent, we cannot change cluster name + - include_tasks: 02_not_supported.yml + when: not sc_config[sc_host].features.cluster_name.is_writable From 3b3b4dc0d1f334eed22b2f7a83bf85a439493cf4 Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Mon, 3 Apr 2023 13:17:42 +0200 Subject: [PATCH 04/10] Test virtual_disk module on 9.1 Also test replication factor is exactly as expected. Signed-off-by: Justin Cinkelj --- tests/integration/integration_config.yml.j2 | 4 + .../virtual_disk/tasks/01_supported.yml | 262 +++++++++++++++++ .../virtual_disk/tasks/02_not_supported.yml | 20 ++ .../targets/virtual_disk/tasks/main.yml | 270 +----------------- .../virtual_disk_info/tasks/01_supported.yml | 79 +++++ .../tasks/02_not_supported.yml | 12 + .../targets/virtual_disk_info/tasks/main.yml | 86 +----- 7 files changed, 388 insertions(+), 345 deletions(-) create mode 100644 tests/integration/targets/virtual_disk/tasks/01_supported.yml create mode 100644 tests/integration/targets/virtual_disk/tasks/02_not_supported.yml create mode 100644 tests/integration/targets/virtual_disk_info/tasks/01_supported.yml create mode 100644 tests/integration/targets/virtual_disk_info/tasks/02_not_supported.yml diff --git a/tests/integration/integration_config.yml.j2 b/tests/integration/integration_config.yml.j2 index 761eec005..867efb356 100644 --- a/tests/integration/integration_config.yml.j2 +++ b/tests/integration/integration_config.yml.j2 @@ -96,6 +96,8 @@ sc_config: virtual_disk: # Virtual disk feature is supported iff version ">=9.2.10" is_supported: True + # expected virtual disk replucation factor + replication_factor: 2 cluster_name: # cluster name can be changed iff version ">=9.1.21 <9.2.0 || >=9.2.11" is_writable: True @@ -122,6 +124,7 @@ sc_config: can_be_applied: False virtual_disk: is_supported: False + # replication_factor: cluster_name: is_writable: False @@ -147,5 +150,6 @@ sc_config: can_be_applied: False virtual_disk: is_supported: True + replication_factor: 1 cluster_name: is_writable: True diff --git a/tests/integration/targets/virtual_disk/tasks/01_supported.yml b/tests/integration/targets/virtual_disk/tasks/01_supported.yml new file mode 100644 index 000000000..9b6d390cc --- /dev/null +++ b/tests/integration/targets/virtual_disk/tasks/01_supported.yml @@ -0,0 +1,262 @@ +--- +# ----------------------------------Setup------------------------------------------------------------------------ +- name: Delete virtual disk files if exist + scale_computing.hypercore.virtual_disk: + state: absent + name: "{{ item }}" + loop: + - xlab-ci-test-VD.qcow2 + - xlab-ci-test-VD.vmdk + # half-uploaded VD has "uploading-" magic prefix. + - uploading-xlab-ci-test-VD.qcow2 + - uploading-xlab-ci-test-VD.vmdk + +- name: Assert cleanup was successful + scale_computing.hypercore.virtual_disk_info: + name: "{{ virtual_disk_name }}" + register: virtual_disk_file + loop: + - xlab-ci-test-VD.qcow2 + - xlab-ci-test-VD.vmdk + loop_control: + loop_var: virtual_disk_name +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.results.0.records|length==0 + - virtual_disk_file.results.1.records|length==0 + +- name: Generate virtual disk file qcow2 + ansible.builtin.shell: + cmd: qemu-img create -f qcow2 xlab-ci-test-VD.qcow2 10M + register: generated_img + +- name: Generate virtual disk file vmdk + ansible.builtin.shell: + cmd: qemu-img create -f vmdk xlab-ci-test-VD.vmdk 10M + register: generated_img + +# ----------------------------------Job------------------------------------------------------------------------ +- name: Upload virtual disk file .qcow2 + scale_computing.hypercore.virtual_disk: + state: present + source: xlab-ci-test-VD.qcow2 + name: xlab-ci-test-VD.qcow2 + register: uploaded_virtual_disk +- ansible.builtin.assert: + that: + - uploaded_virtual_disk is succeeded + - uploaded_virtual_disk is changed + - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.qcow2" + - uploaded_virtual_disk.record.block_size == 1048576 + - uploaded_virtual_disk.record.replication_factor == expected_virtual_disk_replication_factor | int + - uploaded_virtual_disk.record.size == 10485760 + +- name: Assert that virtual disk .qcow2 exist on cluster + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.qcow2 + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 1 + - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - virtual_disk_file.records.0.name == "xlab-ci-test-VD.qcow2" + - virtual_disk_file.records.0.block_size == 1048576 + - virtual_disk_file.records.0.replication_factor == expected_virtual_disk_replication_factor | int + - virtual_disk_file.records.0.size == 10485760 + - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" + +# ----------------------------------Idempotence check---------------------------------------------------------- +- name: Upload virtual disk file .qcow2 - IDEMPOTENCE + scale_computing.hypercore.virtual_disk: + state: present + source: xlab-ci-test-VD.qcow2 + name: xlab-ci-test-VD.qcow2 + register: uploaded_virtual_disk +- ansible.builtin.assert: + that: + - uploaded_virtual_disk is succeeded + - uploaded_virtual_disk is not changed + - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.qcow2" + - uploaded_virtual_disk.record.block_size == 1048576 + - uploaded_virtual_disk.record.replication_factor == expected_virtual_disk_replication_factor | int + - uploaded_virtual_disk.record.size == 10485760 + - uploaded_virtual_disk.diff.before == uploaded_virtual_disk.diff.after + +- name: Assert that virtual disk .qcow2 exist on cluster - IDEMPOTENCE + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.qcow2 + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 1 + - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - virtual_disk_file.records.0.name == "xlab-ci-test-VD.qcow2" + - virtual_disk_file.records.0.block_size == 1048576 + - virtual_disk_file.records.0.replication_factor == expected_virtual_disk_replication_factor | int + - virtual_disk_file.records.0.size == 10485760 + - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" + +# ----------------------------------Job------------------------------------------------------------------------ +- name: Upload virtual disk file .vmdk + scale_computing.hypercore.virtual_disk: + state: present + source: xlab-ci-test-VD.vmdk + name: xlab-ci-test-VD.vmdk + register: uploaded_virtual_disk +- ansible.builtin.assert: + that: + - uploaded_virtual_disk is succeeded + - uploaded_virtual_disk is changed + - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.vmdk" + - uploaded_virtual_disk.record.block_size == 1048576 + - uploaded_virtual_disk.record.replication_factor == expected_virtual_disk_replication_factor | int + - uploaded_virtual_disk.record.size == 10485760 + +- name: Assert that virtual disk .vmdk exist on cluster + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.vmdk + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 1 + - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - virtual_disk_file.records.0.name == "xlab-ci-test-VD.vmdk" + - virtual_disk_file.records.0.block_size == 1048576 + - virtual_disk_file.records.0.replication_factor == expected_virtual_disk_replication_factor | int + - virtual_disk_file.records.0.size == 10485760 + - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" + +# ----------------------------------Idempotence check---------------------------------------------------------- +- name: Upload virtual disk file .vmdk - IDEMPOTENCE + scale_computing.hypercore.virtual_disk: + state: present + source: xlab-ci-test-VD.vmdk + name: xlab-ci-test-VD.vmdk + register: uploaded_virtual_disk +- ansible.builtin.assert: + that: + - uploaded_virtual_disk is succeeded + - uploaded_virtual_disk is not changed + - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.vmdk" + - uploaded_virtual_disk.record.block_size == 1048576 + - uploaded_virtual_disk.record.replication_factor == expected_virtual_disk_replication_factor | int + - uploaded_virtual_disk.record.size == 10485760 + - uploaded_virtual_disk.diff.before == uploaded_virtual_disk.diff.after + +- name: Assert that virtual disk .vmdk exist on cluster - IDEMPOTENCE + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.vmdk + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 1 + - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + - virtual_disk_file.records.0.name == "xlab-ci-test-VD.vmdk" + - virtual_disk_file.records.0.block_size == 1048576 + - virtual_disk_file.records.0.replication_factor == expected_virtual_disk_replication_factor | int + - virtual_disk_file.records.0.size == 10485760 + - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" + +# ----------------------------------Job------------------------------------------------------------------------ +- name: Delete virtual disk file .qcow2 + scale_computing.hypercore.virtual_disk: + state: absent + name: xlab-ci-test-VD.qcow2 + register: deleted_virtual_disk +- ansible.builtin.assert: + that: + - deleted_virtual_disk is succeeded + - deleted_virtual_disk is changed + - deleted_virtual_disk.diff.before.name == "xlab-ci-test-VD.qcow2" + +- name: Assert that virtual disk .qcow2 is deleted + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.qcow2 + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 0 + +# ----------------------------------Idempotence check---------------------------------------------------------- +- name: Delete virtual disk file .qcow2 - IDEMPOTENCE + scale_computing.hypercore.virtual_disk: + state: absent + name: xlab-ci-test-VD.qcow2 + register: deleted_virtual_disk +- ansible.builtin.assert: + that: + - deleted_virtual_disk is succeeded + - deleted_virtual_disk is not changed + - deleted_virtual_disk.diff.before == None + - deleted_virtual_disk.diff.before == deleted_virtual_disk.diff.after + +- name: Assert that virtual disk .qcow2 is deleted - IDEMPOTENCE + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.qcow2 + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 0 + +# ----------------------------------Job------------------------------------------------------------------------ +- name: Delete virtual disk file .vmdk + scale_computing.hypercore.virtual_disk: + state: absent + name: xlab-ci-test-VD.vmdk + register: deleted_virtual_disk +- ansible.builtin.assert: + that: + - deleted_virtual_disk is succeeded + - deleted_virtual_disk is changed + - deleted_virtual_disk.diff.before.name == "xlab-ci-test-VD.vmdk" + +- name: Assert that virtual disk .vmdk is deleted + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.vmdk + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 0 + +# ----------------------------------Idempotence check---------------------------------------------------------- +- name: Delete virtual disk file .vmdk - IDEMPOTENCE + scale_computing.hypercore.virtual_disk: + state: absent + name: xlab-ci-test-VD.vmdk + register: deleted_virtual_disk +- ansible.builtin.assert: + that: + - deleted_virtual_disk is succeeded + - deleted_virtual_disk is not changed + - deleted_virtual_disk.diff.before == None + - deleted_virtual_disk.diff.before == deleted_virtual_disk.diff.after + +- name: Assert that virtual disk .vmdk is deleted - IDEMPOTENCE + scale_computing.hypercore.virtual_disk_info: + name: xlab-ci-test-VD.vmdk + register: virtual_disk_file +- ansible.builtin.assert: + that: + - virtual_disk_file is succeeded + - virtual_disk_file is not changed + - virtual_disk_file.records | length == 0 diff --git a/tests/integration/targets/virtual_disk/tasks/02_not_supported.yml b/tests/integration/targets/virtual_disk/tasks/02_not_supported.yml new file mode 100644 index 000000000..3cb7e5d47 --- /dev/null +++ b/tests/integration/targets/virtual_disk/tasks/02_not_supported.yml @@ -0,0 +1,20 @@ +--- +- name: Generate virtual disk file qcow2 + ansible.builtin.shell: + cmd: qemu-img create -f qcow2 xlab-ci-test-VD.qcow2 10M + register: generated_img + +- name: Create virtual disk, must fail + scale_computing.hypercore.virtual_disk: + state: present + source: xlab-ci-test-VD.qcow2 + name: xlab-ci-test-VD.qcow2 + register: result + ignore_errors: True + +- ansible.builtin.assert: + that: + - result is failed + - result is not changed + - "{{ 'record' not in result }}" + - "{{ 'does not match required version >=9.2.10' in result.msg }}" diff --git a/tests/integration/targets/virtual_disk/tasks/main.yml b/tests/integration/targets/virtual_disk/tasks/main.yml index d879130ce..9cfe61510 100644 --- a/tests/integration/targets/virtual_disk/tasks/main.yml +++ b/tests/integration/targets/virtual_disk/tasks/main.yml @@ -5,269 +5,11 @@ SC_PASSWORD: "{{ sc_config[sc_host].sc_password }}" SC_TIMEOUT: "{{ sc_timeout }}" vars: - expected_virtual_disk_replication_factors: - - 1 # (virtual) single node systems have no replication - - 2 # real 3 node systems + image_filename: "ci-test-virtual-disk-1.qcow2" + expected_virtual_disk_replication_factor: "{{ sc_config[sc_host].features.virtual_disk.replication_factor }}" -# ----------------------------------Setup------------------------------------------------------------------------ block: - - name: Delete virtual disk files if exist - scale_computing.hypercore.virtual_disk: - state: absent - name: "{{ item }}" - loop: - - xlab-ci-test-VD.qcow2 - - xlab-ci-test-VD.vmdk - # half-uploaded VD has "uploading-" magic prefix. - - uploading-xlab-ci-test-VD.qcow2 - - uploading-xlab-ci-test-VD.vmdk - - - name: Assert cleanup was successful - scale_computing.hypercore.virtual_disk_info: - name: "{{ virtual_disk_name }}" - register: virtual_disk_file - loop: - - xlab-ci-test-VD.qcow2 - - xlab-ci-test-VD.vmdk - loop_control: - loop_var: virtual_disk_name - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.results.0.records|length==0 - - virtual_disk_file.results.1.records|length==0 - - - name: Generate virtual disk file qcow2 - ansible.builtin.shell: - cmd: qemu-img create -f qcow2 xlab-ci-test-VD.qcow2 10M - register: generated_img - - - name: Generate virtual disk file vmdk - ansible.builtin.shell: - cmd: qemu-img create -f vmdk xlab-ci-test-VD.vmdk 10M - register: generated_img - -# ----------------------------------Job------------------------------------------------------------------------ - - name: Upload virtual disk file .qcow2 - scale_computing.hypercore.virtual_disk: - state: present - source: xlab-ci-test-VD.qcow2 - name: xlab-ci-test-VD.qcow2 - register: uploaded_virtual_disk - - ansible.builtin.assert: - that: - - uploaded_virtual_disk is succeeded - - uploaded_virtual_disk is changed - - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.qcow2" - - uploaded_virtual_disk.record.block_size == 1048576 - - uploaded_virtual_disk.record.replication_factor in expected_virtual_disk_replication_factors - - uploaded_virtual_disk.record.size == 10485760 - - - name: Assert that virtual disk .qcow2 exist on cluster - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.qcow2 - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 1 - - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - virtual_disk_file.records.0.name == "xlab-ci-test-VD.qcow2" - - virtual_disk_file.records.0.block_size == 1048576 - - virtual_disk_file.records.0.replication_factor in expected_virtual_disk_replication_factors - - virtual_disk_file.records.0.size == 10485760 - - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" - -# ----------------------------------Idempotence check---------------------------------------------------------- - - name: Upload virtual disk file .qcow2 - IDEMPOTENCE - scale_computing.hypercore.virtual_disk: - state: present - source: xlab-ci-test-VD.qcow2 - name: xlab-ci-test-VD.qcow2 - register: uploaded_virtual_disk - - ansible.builtin.assert: - that: - - uploaded_virtual_disk is succeeded - - uploaded_virtual_disk is not changed - - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.qcow2" - - uploaded_virtual_disk.record.block_size == 1048576 - - uploaded_virtual_disk.record.replication_factor in expected_virtual_disk_replication_factors - - uploaded_virtual_disk.record.size == 10485760 - - uploaded_virtual_disk.diff.before == uploaded_virtual_disk.diff.after - - - name: Assert that virtual disk .qcow2 exist on cluster - IDEMPOTENCE - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.qcow2 - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 1 - - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - virtual_disk_file.records.0.name == "xlab-ci-test-VD.qcow2" - - virtual_disk_file.records.0.block_size == 1048576 - - virtual_disk_file.records.0.replication_factor in expected_virtual_disk_replication_factors - - virtual_disk_file.records.0.size == 10485760 - - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" - -# ----------------------------------Job------------------------------------------------------------------------ - - name: Upload virtual disk file .vmdk - scale_computing.hypercore.virtual_disk: - state: present - source: xlab-ci-test-VD.vmdk - name: xlab-ci-test-VD.vmdk - register: uploaded_virtual_disk - - ansible.builtin.assert: - that: - - uploaded_virtual_disk is succeeded - - uploaded_virtual_disk is changed - - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.vmdk" - - uploaded_virtual_disk.record.block_size == 1048576 - - uploaded_virtual_disk.record.replication_factor in expected_virtual_disk_replication_factors - - uploaded_virtual_disk.record.size == 10485760 - - - name: Assert that virtual disk .vmdk exist on cluster - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.vmdk - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 1 - - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - virtual_disk_file.records.0.name == "xlab-ci-test-VD.vmdk" - - virtual_disk_file.records.0.block_size == 1048576 - - virtual_disk_file.records.0.replication_factor in expected_virtual_disk_replication_factors - - virtual_disk_file.records.0.size == 10485760 - - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" - -# ----------------------------------Idempotence check---------------------------------------------------------- - - name: Upload virtual disk file .vmdk - IDEMPOTENCE - scale_computing.hypercore.virtual_disk: - state: present - source: xlab-ci-test-VD.vmdk - name: xlab-ci-test-VD.vmdk - register: uploaded_virtual_disk - - ansible.builtin.assert: - that: - - uploaded_virtual_disk is succeeded - - uploaded_virtual_disk is not changed - - uploaded_virtual_disk.record.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - uploaded_virtual_disk.record.name == "xlab-ci-test-VD.vmdk" - - uploaded_virtual_disk.record.block_size == 1048576 - - uploaded_virtual_disk.record.replication_factor in expected_virtual_disk_replication_factors - - uploaded_virtual_disk.record.size == 10485760 - - uploaded_virtual_disk.diff.before == uploaded_virtual_disk.diff.after - - - name: Assert that virtual disk .vmdk exist on cluster - IDEMPOTENCE - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.vmdk - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 1 - - virtual_disk_file.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - virtual_disk_file.records.0.name == "xlab-ci-test-VD.vmdk" - - virtual_disk_file.records.0.block_size == 1048576 - - virtual_disk_file.records.0.replication_factor in expected_virtual_disk_replication_factors - - virtual_disk_file.records.0.size == 10485760 - - "{{ virtual_disk_file.records.0.uuid == uploaded_virtual_disk.record.uuid }}" - -# ----------------------------------Job------------------------------------------------------------------------ - - name: Delete virtual disk file .qcow2 - scale_computing.hypercore.virtual_disk: - state: absent - name: xlab-ci-test-VD.qcow2 - register: deleted_virtual_disk - - ansible.builtin.assert: - that: - - deleted_virtual_disk is succeeded - - deleted_virtual_disk is changed - - deleted_virtual_disk.diff.before.name == "xlab-ci-test-VD.qcow2" - - - name: Assert that virtual disk .qcow2 is deleted - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.qcow2 - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 0 - -# ----------------------------------Idempotence check---------------------------------------------------------- - - name: Delete virtual disk file .qcow2 - IDEMPOTENCE - scale_computing.hypercore.virtual_disk: - state: absent - name: xlab-ci-test-VD.qcow2 - register: deleted_virtual_disk - - ansible.builtin.assert: - that: - - deleted_virtual_disk is succeeded - - deleted_virtual_disk is not changed - - deleted_virtual_disk.diff.before == None - - deleted_virtual_disk.diff.before == deleted_virtual_disk.diff.after - - - name: Assert that virtual disk .qcow2 is deleted - IDEMPOTENCE - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.qcow2 - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 0 - -# ----------------------------------Job------------------------------------------------------------------------ - - name: Delete virtual disk file .vmdk - scale_computing.hypercore.virtual_disk: - state: absent - name: xlab-ci-test-VD.vmdk - register: deleted_virtual_disk - - ansible.builtin.assert: - that: - - deleted_virtual_disk is succeeded - - deleted_virtual_disk is changed - - deleted_virtual_disk.diff.before.name == "xlab-ci-test-VD.vmdk" - - - name: Assert that virtual disk .vmdk is deleted - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.vmdk - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 0 - -# ----------------------------------Idempotence check---------------------------------------------------------- - - name: Delete virtual disk file .vmdk - IDEMPOTENCE - scale_computing.hypercore.virtual_disk: - state: absent - name: xlab-ci-test-VD.vmdk - register: deleted_virtual_disk - - ansible.builtin.assert: - that: - - deleted_virtual_disk is succeeded - - deleted_virtual_disk is not changed - - deleted_virtual_disk.diff.before == None - - deleted_virtual_disk.diff.before == deleted_virtual_disk.diff.after - - - name: Assert that virtual disk .vmdk is deleted - IDEMPOTENCE - scale_computing.hypercore.virtual_disk_info: - name: xlab-ci-test-VD.vmdk - register: virtual_disk_file - - ansible.builtin.assert: - that: - - virtual_disk_file is succeeded - - virtual_disk_file is not changed - - virtual_disk_file.records | length == 0 + - include_tasks: 01_supported.yml + when: sc_config[sc_host].features.virtual_disk.is_supported + - include_tasks: 02_not_supported.yml + when: not sc_config[sc_host].features.virtual_disk.is_supported diff --git a/tests/integration/targets/virtual_disk_info/tasks/01_supported.yml b/tests/integration/targets/virtual_disk_info/tasks/01_supported.yml new file mode 100644 index 000000000..c4d6b1835 --- /dev/null +++ b/tests/integration/targets/virtual_disk_info/tasks/01_supported.yml @@ -0,0 +1,79 @@ +--- +# -------------------------------------------------------------------- +# Prepare one disk with known content +- name: List all virtual disks using API module + scale_computing.hypercore.api: + action: get + endpoint: /rest/v1/VirtualDisk + register: api_virtual_disk_result + +- name: Remove partially uploaded virtual disk with name uploading-{{ image_filename }} + when: ('uploading-' + image_filename) in api_virtual_disk_result.record | map(attribute='name') + block: + - name: Remove {{ 'uploading-' + image_filename }} + scale_computing.hypercore.api: + action: delete + endpoint: /rest/v1/VirtualDisk/{{ (api_virtual_disk_result.record | selectattr("name", "==", 'uploading-' + image_filename))[0]["uuid"] }} + +- name: Upload new virtual disk with name {{ image_filename }} if it is missing + when: image_filename not in api_virtual_disk_result.record | map(attribute='name') + block: + - name: Create image + ansible.builtin.command: qemu-img create /tmp/{{ image_filename }}.uncompressed 1G + - name: Compress image + ansible.builtin.command: qemu-img convert -c -O qcow2 /tmp/{{ image_filename }}.uncompressed /tmp/{{ image_filename }} + + - name: Get the Virtual Disk size + ansible.builtin.stat: + path: /tmp/{{ image_filename }} + register: disk_file_info + + - name: Upload Virtual Disk {{ image_filename }} to HyperCore + scale_computing.hypercore.api: + action: put + endpoint: /rest/v1/VirtualDisk/upload + data: + filename: "{{ image_filename }}" + filesize: "{{ disk_file_info.stat.size }}" + source: /tmp/{{ image_filename }} + register: upload_result + +# -------------------------------------------------------------------- +# Test +- name: List all virtual disks + scale_computing.hypercore.virtual_disk_info: + register: result +- ansible.builtin.assert: + that: + - result is succeeded + - result is not changed + - result.records | length >= 1 + - result.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] + +- name: List a single virtual disk + scale_computing.hypercore.virtual_disk_info: + name: "{{ image_filename }}" + register: result +- ansible.builtin.assert: + that: + - result is succeeded + - result is not changed + - result.records | length == 1 + - result.records.0.block_size == 1048576 + - result.records.0.size == 1073741824 + - result.records.0.name == "{{ image_filename }}" + - result.records.0.replication_factor == expected_virtual_disk_replication_factor | int + - result.records.0.uuid | length == 36 + +- name: List a non-existent virtual disk + scale_computing.hypercore.virtual_disk_info: + name: "{{ image_filename }}-no-such-disk-2897gfabv9o7i6w4e" + register: result +- ansible.builtin.assert: + that: + - result is succeeded + - result is not changed + - result.records | length == 0 + +# -------------------------------------------------------------------- +# Cleanup - not needed diff --git a/tests/integration/targets/virtual_disk_info/tasks/02_not_supported.yml b/tests/integration/targets/virtual_disk_info/tasks/02_not_supported.yml new file mode 100644 index 000000000..409c61eda --- /dev/null +++ b/tests/integration/targets/virtual_disk_info/tasks/02_not_supported.yml @@ -0,0 +1,12 @@ +--- +- name: List all virtual disks, must fail + scale_computing.hypercore.virtual_disk_info: + register: result + ignore_errors: True + +- ansible.builtin.assert: + that: + - result is failed + - result is not changed + - "{{ 'records' not in result }}" + - "{{ 'does not match required version >=9.2.10' in result.msg }}" diff --git a/tests/integration/targets/virtual_disk_info/tasks/main.yml b/tests/integration/targets/virtual_disk_info/tasks/main.yml index fbe1d85e6..9cfe61510 100644 --- a/tests/integration/targets/virtual_disk_info/tasks/main.yml +++ b/tests/integration/targets/virtual_disk_info/tasks/main.yml @@ -6,86 +6,10 @@ SC_TIMEOUT: "{{ sc_timeout }}" vars: image_filename: "ci-test-virtual-disk-1.qcow2" - expected_virtual_disk_replication_factors: - - 1 # (virtual) single node systems have no replication - - 2 # real 3 node systems + expected_virtual_disk_replication_factor: "{{ sc_config[sc_host].features.virtual_disk.replication_factor }}" block: - # -------------------------------------------------------------------- - # Prepare one disk with known content - - name: List all virtual disks using API module - scale_computing.hypercore.api: - action: get - endpoint: /rest/v1/VirtualDisk - register: api_virtual_disk_result - - - name: Remove partially uploaded virtual disk with name uploading-{{ image_filename }} - when: ('uploading-' + image_filename) in api_virtual_disk_result.record | map(attribute='name') - block: - - name: Remove {{ 'uploading-' + image_filename }} - scale_computing.hypercore.api: - action: delete - endpoint: /rest/v1/VirtualDisk/{{ (api_virtual_disk_result.record | selectattr("name", "==", 'uploading-' + image_filename))[0]["uuid"] }} - - - name: Upload new virtual disk with name {{ image_filename }} if it is missing - when: image_filename not in api_virtual_disk_result.record | map(attribute='name') - block: - - name: Create image - ansible.builtin.command: qemu-img create /tmp/{{ image_filename }}.uncompressed 1G - - name: Compress image - ansible.builtin.command: qemu-img convert -c -O qcow2 /tmp/{{ image_filename }}.uncompressed /tmp/{{ image_filename }} - - - name: Get the Virtual Disk size - ansible.builtin.stat: - path: /tmp/{{ image_filename }} - register: disk_file_info - - - name: Upload Virtual Disk {{ image_filename }} to HyperCore - scale_computing.hypercore.api: - action: put - endpoint: /rest/v1/VirtualDisk/upload - data: - filename: "{{ image_filename }}" - filesize: "{{ disk_file_info.stat.size }}" - source: /tmp/{{ image_filename }} - register: upload_result - - # -------------------------------------------------------------------- - # Test - - name: List all virtual disks - scale_computing.hypercore.virtual_disk_info: - register: result - - ansible.builtin.assert: - that: - - result is succeeded - - result is not changed - - result.records | length >= 1 - - result.records.0.keys() | sort == ['block_size', 'name', 'replication_factor', 'size', 'uuid'] - - - name: List a single virtual disk - scale_computing.hypercore.virtual_disk_info: - name: "{{ image_filename }}" - register: result - - ansible.builtin.assert: - that: - - result is succeeded - - result is not changed - - result.records | length == 1 - - result.records.0.block_size == 1048576 - - result.records.0.size == 1073741824 - - result.records.0.name == "{{ image_filename }}" - - result.records.0.replication_factor in expected_virtual_disk_replication_factors - - result.records.0.uuid | length == 36 - - - name: List a non-existent virtual disk - scale_computing.hypercore.virtual_disk_info: - name: "{{ image_filename }}-no-such-disk-2897gfabv9o7i6w4e" - register: result - - ansible.builtin.assert: - that: - - result is succeeded - - result is not changed - - result.records | length == 0 - - # -------------------------------------------------------------------- - # Cleanup - not needed + - include_tasks: 01_supported.yml + when: sc_config[sc_host].features.virtual_disk.is_supported + - include_tasks: 02_not_supported.yml + when: not sc_config[sc_host].features.virtual_disk.is_supported From bec405511b442f760a4790d2b390b76ce52b236e Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Tue, 4 Apr 2023 07:42:41 +0200 Subject: [PATCH 05/10] Test version_update_info on 2 clusters Signed-off-by: Justin Cinkelj --- .../targets/version_update_info/tasks/main.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/version_update_info/tasks/main.yml b/tests/integration/targets/version_update_info/tasks/main.yml index 35005149a..bf5dd5812 100644 --- a/tests/integration/targets/version_update_info/tasks/main.yml +++ b/tests/integration/targets/version_update_info/tasks/main.yml @@ -6,12 +6,24 @@ SC_TIMEOUT: "{{ sc_timeout }}" block: - - name: Get list of hc version updates + - name: Get list of HyperCore version updates scale_computing.hypercore.version_update_info: register: updates - - ansible.builtin.assert: + + - name: Check returned update list - updates available + ansible.builtin.assert: that: - updates.records[0].keys() | sort == ['build_id', 'change_log', 'description', 'major_version', 'minor_version', 'revision', 'timestamp', 'uuid'] - updates.next.keys() | sort == ['build_id', 'change_log', 'description', 'major_version', 'minor_version', 'revision', 'timestamp', 'uuid'] - updates.latest.keys() | sort == ['build_id', 'change_log', 'description', 'major_version', 'minor_version', 'revision', 'timestamp', 'uuid'] - when: updates.records != [] + - updates.records[0].uuid == sc_config[sc_host].features.version_update.next_version + - updates.records[-1].uuid == sc_config[sc_host].features.version_update.latest_version + - updates.next.uuid == sc_config[sc_host].features.version_update.next_version + - updates.latest.uuid == sc_config[sc_host].features.version_update.latest_version + when: sc_config[sc_host].features.version_update.next_version + + - name: Check returned update list - no updates available + ansible.builtin.assert: + that: + - updates.records == [] + when: not sc_config[sc_host].features.version_update.next_version From a2e069f045228c530c938972708e6bec72f9b799 Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Tue, 4 Apr 2023 08:27:37 +0200 Subject: [PATCH 06/10] Refactor vm_replication_info to pass also on cluster without replication Signed-off-by: Justin Cinkelj --- tests/integration/integration_config.yml.j2 | 7 +++ .../01_vm_replication_info_missing_vm.yml | 12 +++++ .../tasks/02_cleanup_destination_vms.yml | 21 ++++++++ ...ate_vms.yml => 03_recreate_source_vms.yml} | 48 +------------------ .../tasks/10_vm_replication_info.yml | 11 +++++ .../vm_replication_info/tasks/main.yml | 21 ++++++-- 6 files changed, 69 insertions(+), 51 deletions(-) create mode 100644 tests/integration/targets/vm_replication_info/tasks/01_vm_replication_info_missing_vm.yml create mode 100644 tests/integration/targets/vm_replication_info/tasks/02_cleanup_destination_vms.yml rename tests/integration/targets/vm_replication_info/tasks/{01_prepare_create_vms.yml => 03_recreate_source_vms.yml} (58%) diff --git a/tests/integration/integration_config.yml.j2 b/tests/integration/integration_config.yml.j2 index 867efb356..5f39be9a9 100644 --- a/tests/integration/integration_config.yml.j2 +++ b/tests/integration/integration_config.yml.j2 @@ -68,6 +68,7 @@ sc_config: sc_username: "{{ sc_username_50 }}" sc_password: "{{ sc_password_50 }}" # Only .50 is configured with remote replication. + # Set sc_replication_dest_host/username/password to "" to signal no replication is configured. sc_replication_dest_host: https://10.5.11.60 # We have same username on .50 and .60 node. sc_replication_dest_username: "{{ sc_username_50 }}" @@ -106,6 +107,9 @@ sc_config: <<: *base_cfg sc_username: admin sc_password: admin + sc_replication_dest_host: "" + sc_replication_dest_username: "" + sc_replication_dest_password: "" cluster: name: "HC3 System" # VSNS200 support_tunnel: @@ -132,6 +136,9 @@ sc_config: <<: *base_cfg sc_username: admin sc_password: admin + sc_replication_dest_host: "" + sc_replication_dest_username: "" + sc_replication_dest_password: "" cluster: name: VSNS201 support_tunnel: diff --git a/tests/integration/targets/vm_replication_info/tasks/01_vm_replication_info_missing_vm.yml b/tests/integration/targets/vm_replication_info/tasks/01_vm_replication_info_missing_vm.yml new file mode 100644 index 000000000..0e20ea669 --- /dev/null +++ b/tests/integration/targets/vm_replication_info/tasks/01_vm_replication_info_missing_vm.yml @@ -0,0 +1,12 @@ +# ------------------------------------------------------------------------- +# Test vm_replication_info for not present VM +- name: Get replication info for one VM + scale_computing.hypercore.vm_replication_info: + vm_name: XLAB-vm_replication_info_CI_test-bf238ai6d2 + register: replication_info + ignore_errors: true + +- ansible.builtin.assert: + that: + - replication_info is failed + - replication_info is not changed diff --git a/tests/integration/targets/vm_replication_info/tasks/02_cleanup_destination_vms.yml b/tests/integration/targets/vm_replication_info/tasks/02_cleanup_destination_vms.yml new file mode 100644 index 000000000..3d50e704c --- /dev/null +++ b/tests/integration/targets/vm_replication_info/tasks/02_cleanup_destination_vms.yml @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------------- +# Cleanup replicated VMs on dest cluster. +# The vm module cannot be used - we can have old replicas still present, +# so the VM name might not be unique on dest cluster. +- name: List old replicated VMs on dest cluster + scale_computing.hypercore.vm_info: + cluster_instance: "{{ dest_cluster_instance }}" + vm_name: "{{ vm_name }}" + register: dest_old_replicated_vms + loop: "{{ vm_names }}" + loop_control: + loop_var: vm_name + +- name: Remove old replicated VMs on dest cluster + scale_computing.hypercore.api: + cluster_instance: "{{ dest_cluster_instance }}" + action: delete + endpoint: /rest/v1/VirDomain/{{ vm.uuid }} + loop: "{{ dest_old_replicated_vms.results.0.records + dest_old_replicated_vms.results.1.records }}" + loop_control: + loop_var: vm diff --git a/tests/integration/targets/vm_replication_info/tasks/01_prepare_create_vms.yml b/tests/integration/targets/vm_replication_info/tasks/03_recreate_source_vms.yml similarity index 58% rename from tests/integration/targets/vm_replication_info/tasks/01_prepare_create_vms.yml rename to tests/integration/targets/vm_replication_info/tasks/03_recreate_source_vms.yml index 15c5e4b3f..e1391a8d8 100644 --- a/tests/integration/targets/vm_replication_info/tasks/01_prepare_create_vms.yml +++ b/tests/integration/targets/vm_replication_info/tasks/03_recreate_source_vms.yml @@ -1,39 +1,4 @@ -# Create test VMs, no replication configured. -# Test output for VM with no replication. - -# ------------------------------------------------------------------------- -# Test vm_replication_info for not present VM -- name: Get replication info for one VM - scale_computing.hypercore.vm_replication_info: - vm_name: XLAB-vm_replication_info_CI_test-bf238ai6d2 - register: replication_info - ignore_errors: true -- ansible.builtin.assert: - that: - - replication_info is failed - - replication_info is not changed - -# ------------------------------------------------------------------------- -# Cleanup replicated VMs on dest cluster. -# The vm module cannot be used - we can have old replicas still present, -# so the VM name might not be unique on dest cluster. -- name: List old replicated VMs on dest cluster - scale_computing.hypercore.vm_info: - cluster_instance: "{{ dest_cluster_instance }}" - vm_name: "{{ vm_name }}" - register: dest_old_replicated_vms - loop: "{{ vm_names }}" - loop_control: - loop_var: vm_name - -- name: Remove old replicated VMs on dest cluster - scale_computing.hypercore.api: - cluster_instance: "{{ dest_cluster_instance }}" - action: delete - endpoint: /rest/v1/VirDomain/{{ vm.uuid }} - loop: "{{ dest_old_replicated_vms.results.0.records + dest_old_replicated_vms.results.1.records }}" - loop_control: - loop_var: vm +# Remove and recreate test VMs on source cluster. # ------------------------------------------------------------------------- # Create 1st VM @@ -107,17 +72,6 @@ scale_computing.hypercore.task_wait: task_tag: "{{ vm2_created.record }}" -# ------------------------------------------------------------------------- -- name: Get available cluster connection - scale_computing.hypercore.api: - action: get - endpoint: /rest/v1/RemoteClusterConnection - register: cluster_connection_info -- ansible.builtin.assert: - that: - - cluster_connection_info is succeeded - - cluster_connection_info.record | length > 0 - # ------------------------------------------------------------------------- # Test vm_replication_info for VM without replication # Module fails if VM with given name is not present, diff --git a/tests/integration/targets/vm_replication_info/tasks/10_vm_replication_info.yml b/tests/integration/targets/vm_replication_info/tasks/10_vm_replication_info.yml index e8817645d..3e86976a0 100644 --- a/tests/integration/targets/vm_replication_info/tasks/10_vm_replication_info.yml +++ b/tests/integration/targets/vm_replication_info/tasks/10_vm_replication_info.yml @@ -1,6 +1,17 @@ # Setup replication for 1st VM, test output. # Next setup replication for 2nd VM, test output. +# ------------------------------------------------------------------------- +- name: Get available cluster connection + scale_computing.hypercore.api: + action: get + endpoint: /rest/v1/RemoteClusterConnection + register: cluster_connection_info +- ansible.builtin.assert: + that: + - cluster_connection_info is succeeded + - cluster_connection_info.record | length > 0 + # ------------------------------------------------------------------------- - name: Create replication scale_computing.hypercore.api: diff --git a/tests/integration/targets/vm_replication_info/tasks/main.yml b/tests/integration/targets/vm_replication_info/tasks/main.yml index 54cb5f719..a1d7a3cf1 100644 --- a/tests/integration/targets/vm_replication_info/tasks/main.yml +++ b/tests/integration/targets/vm_replication_info/tasks/main.yml @@ -11,11 +11,24 @@ - "{{ vm_name_0 }}" - "{{ vm_name_1 }}" dest_cluster_instance: - host: "{{ sc_replication_dest_host }}" - username: "{{ sc_replication_dest_username }}" - password: "{{ sc_replication_dest_password }}" + host: "{{ sc_config[sc_host].sc_replication_dest_host }}" + username: "{{ sc_config[sc_host].sc_replication_dest_username }}" + password: "{{ sc_config[sc_host].sc_replication_dest_password }}" + block: - - include_tasks: 01_prepare_create_vms.yml + - include_tasks: 01_vm_replication_info_missing_vm.yml + + - include_tasks: 02_cleanup_destination_vms.yml + when: sc_config[sc_host].sc_replication_dest_host + + # We can create VM and check vm_replication_info output also on + # cluster without replication + - include_tasks: 03_recreate_source_vms.yml + - include_tasks: 10_vm_replication_info.yml + when: sc_config[sc_host].sc_replication_dest_host + - include_tasks: 20_vm_info.yml + when: sc_config[sc_host].sc_replication_dest_host + - include_tasks: 99_cleanup.yml From 54e396a647f3e3b17ee24032b4e64956e9c09828 Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Tue, 4 Apr 2023 08:50:22 +0200 Subject: [PATCH 07/10] Test vm_replication on real cluster Signed-off-by: Justin Cinkelj --- .github/workflows/integ-test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index a0f227769..3c723ff55 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -197,6 +197,13 @@ jobs: sc_host: - https://10.5.11.200 - https://10.5.11.201 + include: + - ansible: 2.13.0 + sc_host: https://10.5.11.50 + test_name: vm_replication + - ansible: 2.13.0 + sc_host: https://10.5.11.50 + test_name: vm_replication_info steps: - name: Checkout uses: actions/checkout@v3 From 9d94a964ded6df2317331861bb59bd18d6711fad Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Tue, 4 Apr 2023 10:18:04 +0200 Subject: [PATCH 08/10] Cleanup CI_CONFIG_HC_IP50_SC_USERNAME was not set in github. ci_config_all was not used anymore. Signed-off-by: Justin Cinkelj --- .github/actions/make-integ-config/action.yml | 8 +------- .github/workflows/integ-test.yml | 10 ---------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/actions/make-integ-config/action.yml b/.github/actions/make-integ-config/action.yml index b88fc5eda..59d126def 100644 --- a/.github/actions/make-integ-config/action.yml +++ b/.github/actions/make-integ-config/action.yml @@ -2,17 +2,11 @@ name: 'Create ansible-test integration_config.yml' description: 'Create ansible-test integration_config.yml' inputs: - ci_config_all: - description: 'CI config for all HyperCore hosts' - required: true sc_host: # id of input description: 'SC_HOST environ variable' required: true # default: 'World' # Node with IP .50 is our physical node. - sc_username_50: - description: 'sc_username variable to access physical nodes' - required: true sc_password_50: description: 'sc_password variable to access physical nodes' required: true @@ -33,7 +27,7 @@ runs: - run: | cd ${{ inputs.working_directory }} cat <integ_config_vars.yml - sc_username_50: ${{ inputs.sc_username_50 }} + sc_username_50: xlab sc_password_50: ${{ inputs.sc_password_50 }} smb_username: ;administrator smb_password: ${{ inputs.smb_password }} diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index 3c723ff55..535ec88fa 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -62,9 +62,7 @@ jobs: - run: ansible-galaxy collection list - uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config with: - ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }} sc_host: ${{ matrix.sc_host }} - sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }} sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }} smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }} oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }} @@ -157,9 +155,7 @@ jobs: # ${{ env.WORKDIR }} cannot be used - uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config with: - ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }} sc_host: https://10.5.11.200 - sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }} sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }} smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }} oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }} @@ -218,9 +214,7 @@ jobs: # ${{ env.WORKDIR }} cannot be used - uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config with: - ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }} sc_host: ${{ matrix.sc_host }} - sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }} sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }} smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }} oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }} @@ -247,9 +241,7 @@ jobs: # ${{ env.WORKDIR }} cannot be used - uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config with: - ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }} sc_host: https://10.5.11.200 - sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }} sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }} smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }} oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }} @@ -273,9 +265,7 @@ jobs: # ${{ env.WORKDIR }} cannot be used - uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config with: - ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }} sc_host: https://10.5.11.200 - sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }} sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }} smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }} oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }} From 89746abfdcb7dda07a560efad1ef61d1d09ee9ee Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Tue, 4 Apr 2023 10:30:48 +0200 Subject: [PATCH 09/10] Test replication only on real HW cluster Signed-off-by: Justin Cinkelj --- .github/workflows/integ-test.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index 535ec88fa..a2f0eb3f6 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -186,7 +186,7 @@ jobs: strategy: fail-fast: false matrix: - ansible: [2.13.0] + # ansible: [2.13.0] # python: [3.11] # test_name: [user_info] test_name: ${{ fromJson(needs.integ-matrix.outputs.matrix) }} @@ -194,18 +194,21 @@ jobs: - https://10.5.11.200 - https://10.5.11.201 include: - - ansible: 2.13.0 - sc_host: https://10.5.11.50 + - sc_host: https://10.5.11.50 test_name: vm_replication - - ansible: 2.13.0 - sc_host: https://10.5.11.50 + - sc_host: https://10.5.11.50 test_name: vm_replication_info + exclude: + - sc_host: https://10.5.11.200 + test_name: vm_replication + - sc_host: https://10.5.11.201 + test_name: vm_replication steps: - name: Checkout uses: actions/checkout@v3 with: path: ${{ env.WORKDIR }} - - run: pip install ansible-core~=${{ matrix.ansible }} + - run: pip install ansible-core~=2.13.0 # We have ansible.cfg "for testing" in git repo # (it is excluded in galaxy.yml, so it is not part of collection artifact) # But it does affect ansible-galaxy and ansible-test commands. From 9b5fdec2462b0f2383f198e8c39af13b34e995cd Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Tue, 4 Apr 2023 11:50:32 +0200 Subject: [PATCH 10/10] Fix typo in exclude test Signed-off-by: Justin Cinkelj --- .github/workflows/integ-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integ-test.yml b/.github/workflows/integ-test.yml index a2f0eb3f6..9a74cc8c3 100644 --- a/.github/workflows/integ-test.yml +++ b/.github/workflows/integ-test.yml @@ -23,10 +23,10 @@ on: List integration tests to exclude. Use "*" to exclude all tests. Use regex like 'node|^git_issue|^dns_config$' to exclude only a subset. - default: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^version_update_single_node$" + default: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^role_version_update_single_node$" env: INTEG_TESTS_INCLUDE_SCHEDULE: "*" - INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^version_update_single_node$" + INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^role_version_update_single_node$" # ansible-test needs special directory structure. # WORKDIR is a subdir of GITHUB_WORKSPACE WORKDIR: work-dir/ansible_collections/scale_computing/hypercore