Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemorency committed Jul 11, 2024
1 parent 3dd688a commit 9fec3ee
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
vcenter_port: 443
run_on_simulator: false
---
vcenter_hostname: "127.0.0.1"
vcenter_username: "user"
vcenter_password: "pass"
vcenter_port: 8989
vcenter_datacenter_name: DC0
vcenter_cluster_name: DC0_C0

run_on_simulator: true

template_folder: e2e-qe
vm_name: DC0_H0_VM0
vm_name_match: first
template_name: "{{ vm_name }}_template"

vm: test-folder_template
vm_cluster: "Eco-Cluster"
vm_datacenter: "Eco-Datacenter"
vm_guest_id: "rhel8_64Guest"
vm_disk:
- size_gb: 10
Expand Down
16 changes: 14 additions & 2 deletions tests/integration/targets/vmware_folder_template_from_vm/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@
gather_facts: no
collections:
- community.general
vars_files:
- vars.yml

tasks:
- name: Import eco-vcenter test vars
ansible.builtin.include_vars:
file: "{{ item }}"
loop:
- ../../integration_config.yml
- ../../group_vars.yml
- vars.yml
tags: eco-vcenter-ci

- name: Vcsim
ansible.builtin.import_role:
name: prepare_vcsim
tags: integration-ci

- name: Import vmware_folder_template role
ansible.builtin.import_role:
name: vmware_folder_template_from_vm
tags:
- integration-ci
- eco-vcenter-ci

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,87 +1,101 @@
---
- block:
- name: Test On Simulator
when: run_on_simulator
block:
- name: "Test setup: Create Folder"
community.vmware.vcenter_folder:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
port: "{{ vcenter_port }}"
datacenter: "{{ vm_datacenter }}"
datacenter: "{{ vcenter_datacenter_name }}"
folder_name: "{{ template_folder }}"
folder_type: vm
state: present
when: run_on_simulator

- name: "Test setup: Create VM guest {{ vm }}"
- name: "Test setup: Power Off VM guest {{ vm_name }}"
community.vmware.vmware_guest:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster: "{{ vm_cluster }}"
cluster: "{{ vcenter_cluster_name }}"
datacenter: "{{ vcenter_datacenter_name }}"
port: "{{ vcenter_port }}"
datacenter: "{{ vm_datacenter }}"
folder: "{{ template_folder }}"
state: present
name: "{{ vm }}"
disk: "{{ vm_disk }}"
guest_id: "{{ vm_guest_id }}"
hardware: "{{ vm_hardware }}"
when: not run_on_simulator
state: poweredoff
name: "{{ vm_name }}"

- name: "Test setup: Power Off VM guest {{ vm }}"
- name: Create template from vm in vcenter folder
vmware.vmware.folder_template_from_vm:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ vcenter_datacenter_name }}"
port: "{{ vcenter_port }}"
template_folder: "{{ template_folder }}"
vm_name: "{{ vm_name }}"
template_name: "{{ template_name }}"
register: __res

- name: Run On VCenter
when: not run_on_simulator
block:
- name: "Test setup: Create VM guest {{ vm }}"
community.vmware.vmware_guest:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster: "{{ vm_cluster }}"
datacenter: "{{ vm_datacenter }}"
cluster: "{{ vcenter_cluster_name }}"
port: "{{ vcenter_port }}"
state: poweredoff
name: "{{ vm }}"
when: run_on_simulator
datacenter: "{{ vcenter_datacenter_name }}"
folder: "{{ template_folder }}"
state: present
name: "{{ vm_name }}"
disk: "{{ vm_disk }}"
guest_id: "{{ vm_guest_id }}"
hardware: "{{ vm_hardware }}"

- name: Create template from vm in vcenter folder
vmware.vmware.folder_template_from_vm:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ vm_datacenter }}"
datacenter: "{{ vcenter_datacenter_name }}"
port: "{{ vcenter_port }}"
template_folder: "{{ template_folder }}"
vm_name: "{{ vm }}"
template_name: "test_template"
vm_name: "{{ vm_name }}"
template_name: "{{ template_name }}"
register: __res

always:
- name: "Test teardown: Destroy VM guest {{ vm }}"
- 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 }}"
cluster: "{{ vcenter_cluster_name }}"
port: "{{ vcenter_port }}"
datacenter: "{{ vm_datacenter }}"
datacenter: "{{ vcenter_datacenter_name }}"
folder: "{{ vm_folder }}"
state: absent
force: true
name: "{{ vm }}"
when: not run_on_simulator
- name: "Test teardown: Destroy VM template {{ vm }}"
name: "{{ vm_name }}"

- name: "Test teardown: Destroy VM template {{ template_name }}"
community.vmware.vmware_guest:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster: "{{ vm_cluster }}"
cluster: "{{ vcenter_cluster_name }}"
port: "{{ vcenter_port }}"
datacenter: "{{ vm_datacenter }}"
datacenter: "{{ vcenter_datacenter_name }}"
folder: "{{ vm_folder }}"
state: absent
force: true
name: "{{ vm }}_template"
when: not run_on_simulator
name: "{{ template_name }}"
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
vcenter_hostname: "127.0.0.1"
vcenter_username: "user"
vcenter_password: "pass"
vcenter_port: 8989
vm_cluster: DC0_C0
vm_datacenter: DC0
vm_folder: test
run_on_simulator: true
vm: DC0_H0_VM0
---
run_on_simulator: false
template_folder: e2e-qe
vm_name: folder_template_from_vm_test
vm_name_match: first

0 comments on commit 9fec3ee

Please sign in to comment.