Skip to content

Commit

Permalink
run guest_info tests on eco-vcenter
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapassaro committed May 28, 2024
1 parent 79911a1 commit fcda34b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 14 deletions.
17 changes: 17 additions & 0 deletions tests/integration/targets/guest_info/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
vcenter_port: 443
run_on_simulator: false

guests_length: 1
vm_name: eco-vm-test
vm_cluster: "Eco-Cluster"
vm_datacenter: "Eco-Datacenter"
vm_folder: "/Eco-Datacenter/vm/e2e-qe"
vm_guest_id: "rhel8_64Guest"
vm_disk:
- size_gb: 10
type: thin
autoselect_datastore: true
vm_hardware:
memory_mb: 2000
num_cpus: 2
boot_firmware: efi
59 changes: 46 additions & 13 deletions tests/integration/targets/guest_info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
---
- name: Gather guest info
vmware.vmware.guest_info:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
port: "{{ vcenter_port }}"
register: __res
- block:
- name: "Test setup: Create VM guest {{ vm_name }}"
community.vmware.vmware_guest:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster: "{{ vm_cluster }}"
datacenter: "{{ vm_datacenter }}"
folder: "{{ vm_folder }}"
state: present
name: "{{ vm_name }}"
disk: "{{ vm_disk }}"
guest_id: "{{ vm_guest_id }}"
hardware: "{{ vm_hardware }}"
when: not run_on_simulator

- name: Assert values
ansible.builtin.assert:
that:
- __res.changed == False
- __res.guests | length == 0
- name: Gather guest info
vmware.vmware.guest_info:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
port: "{{ vcenter_port }}"
guest_name: "{{ vm_name | d(omit) }}"
register: __res

- name: Assert values
ansible.builtin.assert:
that:
- __res.changed == False
- __res.guests | length == guests_length

always:
- name: "Test teardown: Destroy VM guest {{ vm_name }}"
community.vmware.vmware_guest:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster: "{{ vm_cluster }}"
datacenter: "{{ vm_datacenter }}"
folder: "{{ vm_folder }}"
state: absent
force: true
name: "{{ vm_name }}"
when: not run_on_simulator
4 changes: 3 additions & 1 deletion tests/integration/targets/guest_info/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ vcenter_username: "user"
vcenter_password: "pass"
vcenter_port: 1080

mock_file: "guest_info"
run_on_simulator: true
mock_file: "guest_info"
guests_length: 0

0 comments on commit fcda34b

Please sign in to comment.