mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-05-13 21:12:01 +00:00
Always remove temporary files in volume's integration test
This will ensure proper cleanup when tests fail. Change-Id: Ia5758ffeab43d92f670d3e159fe4f3747491ec94
This commit is contained in:
@@ -97,60 +97,70 @@
|
||||
- ansible_volume1
|
||||
- ansible_volume2
|
||||
|
||||
- name: Create a test image file
|
||||
shell: mktemp
|
||||
register: tmp_file
|
||||
- name: Test images
|
||||
block:
|
||||
- name: Ensure clean environment
|
||||
ansible.builtin.set_fact:
|
||||
tmp_file: !!null
|
||||
|
||||
- name: Fill test image file to 1MB
|
||||
shell: truncate -s 1048576 {{ tmp_file.stdout }}
|
||||
- name: Create a test image file
|
||||
ansible.builtin.tempfile:
|
||||
register: tmp_file
|
||||
|
||||
- name: Create test image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ test_volume_image }}"
|
||||
filename: "{{ tmp_file.stdout }}"
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
register: returned_image
|
||||
- name: Fill test image file to 1MB
|
||||
community.general.filesize:
|
||||
path: '{{ tmp_file.path }}'
|
||||
size: 1M
|
||||
|
||||
- name: Create volume from image
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
image: "{{ test_volume_image }}"
|
||||
name: ansible_volume2
|
||||
description: Test volume
|
||||
register: vol
|
||||
- name: Create test image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ test_volume_image }}"
|
||||
filename: "{{ tmp_file.path }}"
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
|
||||
- name: Delete volume from image
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_volume2
|
||||
state: absent
|
||||
register: vol
|
||||
- name: Create volume from image
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
image: "{{ test_volume_image }}"
|
||||
name: ansible_volume2
|
||||
description: Test volume
|
||||
|
||||
- name: Create test shared image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ image_name }}"
|
||||
filename: "{{ tmp_file.stdout }}"
|
||||
is_public: true
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
register: returned_image
|
||||
- name: Delete volume from image
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_volume2
|
||||
state: absent
|
||||
|
||||
- name: Delete test shared image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ image_name }}"
|
||||
filename: "{{ tmp_file.stdout }}"
|
||||
is_public: true
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
register: returned_image
|
||||
- name: Create test shared image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ image_name }}"
|
||||
filename: "{{ tmp_file.path }}"
|
||||
is_public: true
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
|
||||
- name: Delete test shared image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ image_name }}"
|
||||
filename: "{{ tmp_file.path }}"
|
||||
is_public: true
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
|
||||
always:
|
||||
- name: Remove temporary image file
|
||||
ansible.builtin.file:
|
||||
path: "{{ tmp_file.path }}"
|
||||
state: absent
|
||||
when: tmp_file is defined and 'path' in tmp_file
|
||||
|
||||
- include_tasks: volume_info.yml
|
||||
|
||||
Reference in New Issue
Block a user