kubevirt_vm: Run integration test in random namespace

Run the integration tests for kubevirt_vm in a random namespace
and cleanup after the tests finish.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
Felix Matouschek
2024-08-15 13:31:48 +02:00
parent 00690ebc4c
commit 71ea312cfc
7 changed files with 46 additions and 10 deletions

View File

@@ -0,0 +1,50 @@
---
- name: Verify creation with existing VM
connection: local
gather_facts: false
hosts: localhost
tasks:
- name: Create a VM
kubevirt.core.kubevirt_vm:
name: testvm
namespace: {{ NAMESPACE }}
labels:
app: test
register: recreate
- name: Assert module reported no or expected changes
ansible.builtin.assert:
that:
- >-
not recreate.changed or
recreate.changed and
recreate.method == "update" and
recreate.diff.before.metadata.annotations.get('kubemacpool.io/transaction-timestamp') and
not recreate.diff.after.metadata.annotations
- name: Delete VM
connection: local
gather_facts: false
hosts: localhost
tasks:
- name: Delete a VM
kubevirt.core.kubevirt_vm:
name: testvm
namespace: {{ NAMESPACE }}
state: absent
wait: true
- name: Verify VM deletion
connection: local
gather_facts: false
hosts: localhost
tasks:
- name: Delete a VM
kubevirt.core.kubevirt_vm:
name: testvm
namespace: {{ NAMESPACE }}
state: absent
register: delete
- name: Assert module reported no changes
ansible.builtin.assert:
that:
- not delete.changed