test(inventory): Add integration test for stopped VMs

Add an integration test that ensures that the inventory supports looking up
stopped VMs.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
Felix Matouschek
2024-06-27 13:34:50 +02:00
parent 3d501de002
commit f3b40ffdbd
3 changed files with 19 additions and 1 deletions

View File

@@ -17,3 +17,10 @@
name: testvm2
namespace: default
wait: true
- name: Delete the stopped VM
kubevirt.core.kubevirt_vm:
state: absent
name: testvm-stopped
namespace: default
wait: true

View File

@@ -52,3 +52,13 @@
name: containerdisk
wait: true
wait_timeout: 600
- name: Create a stopped VM
kubevirt.core.kubevirt_vm:
state: present
name: testvm-stopped
namespace: default
running: false
spec:
domain:
devices: {}

View File

@@ -16,11 +16,12 @@
ansible.builtin.include_vars:
file: all.yml
name: inv_all
- name: Assert two instances with different labels
- name: Assert all expected hosts were discovered
ansible.builtin.assert:
that:
- inv_all['all']['children']['label_app_test']['hosts'] | length == 1
- inv_all['all']['children']['label_foo_bar']['hosts'] | length == 1
- "'default-testvm-stopped' in inv_all['all']['children']['test']['children']['namespace_default']['hosts']"
- name: Read filtered inventory
ansible.builtin.include_vars:
file: label.yml