Skip to content

Commit

Permalink
CI create test ISO only once
Browse files Browse the repository at this point in the history
ISOs were removed/recreated while some other VMs were using them
https://github.com/ScaleComputing/HyperCoreAnsibleCollection/actions/runs/6347832281/job/17243445064#step:8:113

Signed-off-by: Justin Cinkelj <[email protected]>
  • Loading branch information
justinc1 committed Oct 2, 2023
1 parent 41c3524 commit 1fba269
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 56 deletions.
64 changes: 45 additions & 19 deletions tests/integration/prepare/prepare_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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 }}"
Expand Down
19 changes: 3 additions & 16 deletions tests/integration/targets/vm_boot_devices/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 13 additions & 21 deletions tests/integration/targets/vm_disk/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

0 comments on commit 1fba269

Please sign in to comment.