diff --git a/tests/integration/prepare/prepare_iso.yml b/tests/integration/prepare/prepare_iso.yml index 308d22446..75058c433 100644 --- a/tests/integration/prepare/prepare_iso.yml +++ b/tests/integration/prepare/prepare_iso.yml @@ -14,6 +14,7 @@ username: "{{ sc_config[sc_host].sc_username }}" password: "{{ sc_config[sc_host].sc_password }}" timeout: "{{ sc_timeout }}" + expected_iso_size: 356352 vars_files: - ../integration_config.yml @@ -22,30 +23,53 @@ ansible.builtin.debug: msg: SC_HOST={{ lookup('ansible.builtin.env', 'SC_HOST') }} sc_host={{ sc_host }} - - name: Delete the ISO image (if it may exist) - scale_computing.hypercore.iso: + - name: Get integration-test.iso and integration-test-disk.iso info + scale_computing.hypercore.iso_info: cluster_instance: "{{ cluster_instance }}" name: "{{ item }}" - state: absent + register: iso_info_all loop: - - integration-test.iso - - integration-test-disk.iso + - integration-test.iso + - integration-test-disk.iso - - name: Create a text file - command: touch integration.txt + - name: Show existing ISO size + debug: + msg: | + name={{ iso_info_all.results.0.item }} size={{ iso_info_all.results.0.records.0.size | default(omit) }} + name={{ iso_info_all.results.1.item }} size={{ iso_info_all.results.1.records.0.size | default(omit) }} - - name: Create an ISO file - command: genisoimage -output integration.iso integration.txt + - name: Recreate ISOs if needed + when: | + not ( + ((iso_info_all.results.1.records.0.size | default(0)) == expected_iso_size) + and + ((iso_info_all.results.0.records.0.size | default(0)) == expected_iso_size) + ) + block: + - name: Delete the ISO image (if it may exist) + scale_computing.hypercore.iso: + cluster_instance: "{{ cluster_instance }}" + name: "{{ item }}" + state: absent + loop: + - integration-test.iso + - integration-test-disk.iso - - name: Upload ISO image integration-test.iso to HyperCore API - scale_computing.hypercore.iso: - cluster_instance: "{{ cluster_instance }}" - name: "{{ item }}" - source: "integration.iso" - state: present - loop: - - integration-test.iso - - integration-test-disk.iso + - name: Create a text file + command: touch integration.txt + + - name: Create an ISO file + command: genisoimage -output integration.iso integration.txt + + - name: Upload ISO image integration-test.iso to HyperCore API + scale_computing.hypercore.iso: + cluster_instance: "{{ cluster_instance }}" + name: "{{ item }}" + source: "integration.iso" + state: present + loop: + - integration-test.iso + - integration-test-disk.iso - name: Get integration-test.iso info scale_computing.hypercore.iso_info: @@ -57,6 +81,7 @@ - uploaded_iso_info.records | length > 0 - uploaded_iso_info.records.0.name == "integration-test.iso" - uploaded_iso_info.records.0.ready_for_insert is true + - uploaded_iso_info.records.0.size == expected_iso_size - name: Get integration-test-disk.iso info scale_computing.hypercore.iso_info: @@ -68,6 +93,7 @@ - uploaded_iso_info.records | length > 0 - uploaded_iso_info.records.0.name == "integration-test-disk.iso" - uploaded_iso_info.records.0.ready_for_insert is true + - uploaded_iso_info.records.0.size == expected_iso_size # ========================================================================================= # prepare other ISO images we use. @@ -99,7 +125,7 @@ state: present when: uploaded_iso_info.records == [] - - name: Get integration-test-disk.iso info + - name: Get {{ iso_filename }} info scale_computing.hypercore.iso_info: cluster_instance: "{{ cluster_instance }}" name: "{{ iso_filename }}" diff --git a/tests/integration/targets/vm_boot_devices/tasks/main.yml b/tests/integration/targets/vm_boot_devices/tasks/main.yml index ad78e0810..8b5f17bf2 100644 --- a/tests/integration/targets/vm_boot_devices/tasks/main.yml +++ b/tests/integration/targets/vm_boot_devices/tasks/main.yml @@ -32,22 +32,9 @@ scale_computing.hypercore.iso_info: name: "integration-test.iso" register: uploaded_iso_info - - - name: Create a text file - command: touch integration.txt - when: uploaded_iso_info.records | length == 0 - - - name: Create an ISO file - command: genisoimage -output integration.iso integration.txt - when: uploaded_iso_info.records | length == 0 - - - name: Upload ISO image integration-test.iso to HyperCore API - scale_computing.hypercore.iso: - name: "integration-test.iso" - source: "integration.iso" - state: present - when: uploaded_iso_info.records | length == 0 - register: result + - ansible.builtin.assert: + that: + - uploaded_iso_info.records | length == 1 - name: Set a couple of disks scale_computing.hypercore.vm_disk: diff --git a/tests/integration/targets/vm_disk/tasks/main.yml b/tests/integration/targets/vm_disk/tasks/main.yml index e179d50c3..ebde5eff8 100644 --- a/tests/integration/targets/vm_disk/tasks/main.yml +++ b/tests/integration/targets/vm_disk/tasks/main.yml @@ -133,28 +133,26 @@ - result is changed - result.record | length == 0 + # The file should be already created by prepare_iso.yml - name: Get integration-test.iso info scale_computing.hypercore.iso_info: name: "integration-test.iso" register: uploaded_iso_info + - ansible.builtin.assert: + that: + - uploaded_iso_info.records | length == 1 + - uploaded_iso_info.records.0.size == 356352 - - name: Create a text file - command: touch integration.txt - when: uploaded_iso_info.records | length == 0 - - - name: Create an ISO file - command: genisoimage -output integration.iso integration.txt - when: uploaded_iso_info.records | length == 0 - - - name: Upload ISO image integration-test.iso to HyperCore API - scale_computing.hypercore.iso: + - name: Get integration-test-disk.iso info + scale_computing.hypercore.iso_info: name: "integration-test-disk.iso" - source: "integration.iso" - state: present - when: uploaded_iso_info.records | length == 0 - register: result + register: uploaded_iso_info + - ansible.builtin.assert: + that: + - uploaded_iso_info.records | length == 1 + - uploaded_iso_info.records.0.size == 356352 - - name: Attach integration.iso ISO onto the current CD-ROM device + - name: Attach integration-test-disk.iso ISO onto the current CD-ROM device scale_computing.hypercore.vm_disk: &create-cdrom-disk vm_name: vm-integration-test-disks items: @@ -259,12 +257,6 @@ - result is changed - result.record == [] - - name: Delete locally installed ISO image from current dir - ansible.builtin.file: - path: integration.iso - state: absent - register: file_deleted - - name: Delete the VM on which the tests were performed scale_computing.hypercore.vm: *vm-delete register: result