forked from ansible-collections/vmware.vmware_rest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lookup plugin integration test (ansible-collections#549)
Added lookup plugin integration test Reviewed-by: Polina Rabinovich Reviewed-by: mikemorency
- Loading branch information
1 parent
1efb395
commit 7cc48d2
Showing
14 changed files
with
224 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
collections: | ||
- name: vmware.vmware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
# vcenter specific vars | ||
# please edit according to your vcenter configs | ||
vcenter_cluster_name: "Eco-Cluster" | ||
vcenter_datacenter: "Eco-Datacenter" | ||
vcenter_port: 443 | ||
rhel_9_3_iso_path: "[eco-nfs-datastore-iso] rhel-9.3-x86_64-dvd.iso" | ||
vm_network_name: "VM Network" | ||
test_network_name: "TestNetwork" | ||
shared_storage_01: "eco-iscsi-ds1" | ||
eco_nfs_datastore_iso: "eco-nfs-datastore-iso" | ||
vcenter_vm_folder: "e2e-qe" | ||
vcenter_resource_pool: "Resources" |
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/vmware_rest_lookup_plugin/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
vcenter_datastore: "{{ shared_storage_01 }}" | ||
test_cluster: "test-cluster" |
14 changes: 14 additions & 0 deletions
14
tests/integration/targets/vmware_rest_lookup_plugin/playbook.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- hosts: localhost | ||
gather_facts: no | ||
|
||
tasks: | ||
- name: Import eco-vcenter credentials | ||
ansible.builtin.include_vars: | ||
file: ../../integration_config.yml | ||
tags: eco-vcenter-ci | ||
|
||
- name: Import vmware_rest_lookup_plugin test | ||
ansible.builtin.import_role: | ||
name: vmware_rest_lookup_plugin | ||
tags: | ||
- eco-vcenter-ci |
46 changes: 46 additions & 0 deletions
46
tests/integration/targets/vmware_rest_lookup_plugin/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
- name: Test lookup plugin | ||
block: | ||
- name: Import common vars | ||
ansible.builtin.include_vars: | ||
file: ../group_vars.yml | ||
|
||
- name: Create test cluster | ||
vmware.vmware.cluster: | ||
hostname: "{{ VMWARE_HOST }}" | ||
username: "{{ VMWARE_USER }}" | ||
password: "{{ VMWARE_PASSWORD }}" | ||
validate_certs: "{{ VMWARE_VALIDATE_CERTS }}" | ||
datacenter: "{{ vcenter_datacenter }}" | ||
port: "{{ vcenter_port }}" | ||
cluster_name: "{{ test_cluster }}" | ||
|
||
- name: Get random host info | ||
vmware.vmware_rest.vcenter_host_info: | ||
hosts: "{{ lookup('vmware.vmware_rest.host_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/')[0] }}" | ||
register: vcenter_host_info | ||
|
||
- name: Set host name for tests | ||
ansible.builtin.set_fact: | ||
vcenter_host_name: "{{ vcenter_host_info.value[0].name }}" | ||
|
||
- import_tasks: test_datacenter_moid.yml | ||
- import_tasks: test_cluster_moid.yml | ||
- import_tasks: test_host_moid.yml | ||
- import_tasks: test_datastore_moid.yml | ||
- import_tasks: test_folder_moid.yml | ||
- import_tasks: test_network_moid.yml | ||
- import_tasks: test_vm_moid.yml | ||
- import_tasks: test_resource_pool_moid.yml | ||
|
||
always: | ||
- name: Destroy test cluster | ||
vmware.vmware.cluster: | ||
hostname: "{{ VMWARE_HOST }}" | ||
username: "{{ VMWARE_USER }}" | ||
password: "{{ VMWARE_PASSWORD }}" | ||
validate_certs: "{{ VMWARE_VALIDATE_CERTS }}" | ||
datacenter: "{{ vcenter_datacenter }}" | ||
port: "{{ vcenter_port }}" | ||
cluster_name: "{{ test_cluster }}" | ||
state: absent |
24 changes: 24 additions & 0 deletions
24
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_cluster_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
- name: Verify number of clusters in datacenter | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/') | length > 1 | ||
|
||
- name: Lookup clusters in datacenter | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/' + item) | ||
loop: | ||
- "" | ||
- "{{ vcenter_cluster_name }}" | ||
- "{{ test_cluster }}" | ||
|
||
- name: verify no inner clusters | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/') | length == 0 | ||
|
||
- name: Get specific cluster info | ||
vmware.vmware_rest.vcenter_cluster_info: | ||
cluster: "{{ lookup('vmware.vmware_rest.cluster_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name) }}" | ||
register: cluster_info | ||
|
||
- name: Verify cluster info | ||
ansible.builtin.assert: | ||
that: cluster_info.value.name == vcenter_cluster_name |
8 changes: 8 additions & 0 deletions
8
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_datacenter_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- name: Get datacenter info | ||
vmware.vmware_rest.vcenter_datacenter_info: | ||
datacenter: "{{ lookup('vmware.vmware_rest.datacenter_moid', '/' + vcenter_datacenter) }}" | ||
register: datacenter_info | ||
|
||
- name: Verify datacenter info | ||
ansible.builtin.assert: | ||
that: datacenter_info.value.name == vcenter_datacenter |
22 changes: 22 additions & 0 deletions
22
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_datastore_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- name: Verify number of datastores in datacenter | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.datastore_moid', '/' + vcenter_datacenter + '/') | length > 1 | ||
|
||
- name: Lookup datastores in datacenter | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.datastore_moid', '/' + vcenter_datacenter + '/' + item) | ||
loop: | ||
- "" | ||
- "{{ vcenter_host_name }}/" | ||
- "{{ vcenter_host_name }}/{{ shared_storage_01 }}" | ||
- "{{ shared_storage_01 }}" | ||
- "{{ eco_nfs_datastore_iso }}" | ||
|
||
- name: Get specific datastore info | ||
vmware.vmware_rest.vcenter_datastore_info: | ||
datastore: "{{ lookup('vmware.vmware_rest.datastore_moid', '/' + vcenter_datacenter + '/' + shared_storage_01) }}" | ||
register: datastore_info | ||
|
||
- name: Verify datastore info | ||
ansible.builtin.assert: | ||
that: datastore_info.value.name == shared_storage_01 |
10 changes: 10 additions & 0 deletions
10
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_folder_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: Lookup folders | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.folder_moid', '/' + vcenter_datacenter + '/' + item) | ||
loop: | ||
- vm/{{ vcenter_vm_folder }} | ||
- "{{ vcenter_vm_folder }}" | ||
|
||
- name: Verify number of folders | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.folder_moid', '/' + vcenter_datacenter + '/') | length > 1 |
16 changes: 16 additions & 0 deletions
16
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_host_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- name: Lookup hosts | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.host_moid', '/' + vcenter_datacenter + '/' + item) | ||
loop: | ||
- "" | ||
- "{{ vcenter_host_name }}" | ||
- "{{ vcenter_cluster_name }}/" | ||
- "{{ vcenter_cluster_name }}/{{ vcenter_host_name }}" | ||
|
||
- name: Verify number of hosts in cluster | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.host_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/') | length > 1 | ||
|
||
- name: Verify no hosts in cluster | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.host_moid', '/' + vcenter_datacenter + '/' + test_cluster + '/') | length == 0 |
19 changes: 19 additions & 0 deletions
19
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_network_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- name: Lookup networks | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.network_moid', '/' + vcenter_datacenter + '/' + item) | ||
loop: | ||
- "" | ||
- "{{ vm_network_name }}" | ||
|
||
- name: Verify number of networks in datacenter | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.network_moid', '/' + vcenter_datacenter + '/') | length > 1 | ||
|
||
- name: Get specific network info | ||
vmware.vmware_rest.vcenter_network_info: | ||
networks: "{{ lookup('vmware.vmware_rest.network_moid', '/' + vcenter_datacenter + '/' + vm_network_name) }}" | ||
register: network_info | ||
|
||
- name: Verify network info | ||
ansible.builtin.assert: | ||
that: network_info.value[0].name == vm_network_name |
22 changes: 22 additions & 0 deletions
22
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_resource_pool_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- name: Verify number of resource pools in a cluster | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.resource_pool_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/') | length > 1 | ||
|
||
- name: Verify that just 1 resource pool in a cluster | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.resource_pool_moid', '/' + vcenter_datacenter + '/' + test_cluster + '/') | length == 1 | ||
|
||
- name: Verify no resource pool found | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.resource_pool_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/' + vcenter_resource_pool + '/') | length == 0 | ||
|
||
- name: Verify resource pool doesn't exist | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.resource_pool_moid', '/' + vcenter_datacenter + '/' + "no_resource_pool") is none | ||
|
||
- name: Lookup resource pools | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.resource_pool_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/' + item) | ||
loop: | ||
- "" | ||
- "{{ vcenter_resource_pool }}" |
20 changes: 20 additions & 0 deletions
20
tests/integration/targets/vmware_rest_lookup_plugin/tasks/test_vm_moid.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- name: Get random VM's info | ||
vmware.vmware_rest.vcenter_vm_info: | ||
vm: "{{ lookup('vmware.vmware_rest.vm_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/')[0] }}" | ||
register: vm_info | ||
|
||
- name: Lookup VMs | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.vm_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/' + item) | ||
loop: | ||
- "{{ vcenter_host_name }}/" | ||
- "{{ vm_info.value.identity.name }}" | ||
- "{{ vcenter_resource_pool }}/" | ||
|
||
- name: Verify number of VMs in a cluster | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.vm_moid', '/' + vcenter_datacenter + '/' + vcenter_cluster_name + '/') | length > 1 | ||
|
||
- name: Verify no VMs in a cluster | ||
ansible.builtin.assert: | ||
that: lookup('vmware.vmware_rest.vm_moid', '/' + vcenter_datacenter + '/' + test_cluster + '/') | length == 0 |