mirror of https://github.com/ansible/ansible.git
vmware_guest: speed up vmware_guest tests
- Use predictable VM name during the tests (test_vm1, test_vm2 and test_vm2). This to simplify the teardown of the newly created resource before the next test. - Update the documentation to explain the new requirement - Avoid VM creation with `with_items` when it's not mandatory. This to: - speed up the test execution, our hypervisors have limited resources - simplify the teardown - Remove `create_d1_c1_f0_env.yml`, the test was just testing how Ansible pass environment variables. - Correct the name for the `f0` variable (`f1`) - Fix the DVS tests, the hosts can now reach the dvswitch1 vswitch - Provision the VM with a poweroff status, this to improve the idempotency and sleep up the tests - Avoid the use of `prepare_vmware_tests` to prepare virtual machines when we just need one machinepull/59591/head
parent
08b9e18d4f
commit
964783fbd2
@ -0,0 +1,31 @@
|
||||
vmware_guest_test_playbooks:
|
||||
- boot_firmware_d1_c1_f0.yml
|
||||
- boot_firmware_d1_c1_f0.yml
|
||||
- cdrom_d1_c1_f0.yml
|
||||
- check_mode.yml
|
||||
- clone_customize_guest_test.yml
|
||||
- clone_d1_c1_f0.yml
|
||||
- clone_resize_disks.yml
|
||||
- clone_with_convert.yml
|
||||
- create_d1_c1_f0.yml
|
||||
- create_guest_invalid_d1_c1_f0.yml
|
||||
- create_nw_d1_c1_f0.yml
|
||||
- create_rp_d1_c1_f0.yml
|
||||
- delete_vm.yml
|
||||
- disk_mode_d1_c1_f0.yml
|
||||
- disk_size_d1_c1_f0.yml
|
||||
- disk_type_d1_c1_f0.yml
|
||||
- linked_clone_d1_c1_f0.yml
|
||||
- mac_address_d1_c1_f0.yml
|
||||
- max_connections.yml
|
||||
- mem_reservation.yml
|
||||
- network_negative_test.yml
|
||||
- network_with_device.yml
|
||||
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
|
||||
# - network_with_dvpg.yml
|
||||
# - network_with_portgroup.yml
|
||||
- non_existent_vm_ops.yml
|
||||
- poweroff_d1_c1_f0.yml
|
||||
- poweroff_d1_c1_f1.yml
|
||||
# - template_d1_c1_f0.yml
|
||||
- vapp_d1_c1_f0.yml
|
@ -1,108 +0,0 @@
|
||||
# Test code for the vmware_guest module.
|
||||
# Copyright: (c) 2018 Abhijeet Kasurde <akasurde@redhat.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: create new VMs without connection parameters
|
||||
vmware_guest:
|
||||
name: "{{ 'newvm_' + item|basename }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
memory_mb: 512
|
||||
disk:
|
||||
- size: 1gb
|
||||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
register: clone_d1_c1_f0_env
|
||||
ignore_errors: True
|
||||
- debug: var=clone_d1_c1_f0_env
|
||||
|
||||
- name: assert that changes were not made
|
||||
assert:
|
||||
that:
|
||||
- "clone_d1_c1_f0_env.results|map(attribute='changed')|unique|list == [False]"
|
||||
|
||||
- name: create new VMs using only hostname environment variable
|
||||
vmware_guest:
|
||||
name: "{{ 'newvm_' + item|basename }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
memory_mb: 512
|
||||
disk:
|
||||
- size: 1gb
|
||||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
register: clone_d1_c1_f0_env
|
||||
ignore_errors: True
|
||||
environment:
|
||||
VMWARE_HOST: "{{ vcenter_hostname }}"
|
||||
- debug: var=clone_d1_c1_f0_env
|
||||
|
||||
- name: assert that changes were made
|
||||
assert:
|
||||
that:
|
||||
- "clone_d1_c1_f0_env.results|map(attribute='changed')|unique|list == [False]"
|
||||
|
||||
- name: create new VMs using hostname and username environment variable
|
||||
vmware_guest:
|
||||
name: "{{ 'newvm_' + item|basename }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
memory_mb: 512
|
||||
disk:
|
||||
- size: 1gb
|
||||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
register: clone_d1_c1_f0_env
|
||||
ignore_errors: True
|
||||
environment:
|
||||
VMWARE_HOST: "{{ vcenter_hostname }}"
|
||||
VMWARE_USER: "{{ vcenter_username }}"
|
||||
- debug: var=clone_d1_c1_f0_env
|
||||
|
||||
- name: assert that changes were not made
|
||||
assert:
|
||||
that:
|
||||
- "clone_d1_c1_f0_env.results|map(attribute='changed')|unique|list == [False]"
|
||||
|
||||
- name: create new VMs using all environment variables
|
||||
vmware_guest:
|
||||
name: "{{ 'newvm_' + item|basename }}"
|
||||
guest_id: centos64Guest
|
||||
datacenter: "{{ (item|basename).split('_')[0] }}"
|
||||
hardware:
|
||||
num_cpus: 4
|
||||
memory_mb: 512
|
||||
disk:
|
||||
- size: 1gb
|
||||
type: thin
|
||||
autoselect_datastore: True
|
||||
state: poweredoff
|
||||
folder: "{{ item|dirname }}"
|
||||
with_items: "{{ vmlist['json'] }}"
|
||||
register: clone_d1_c1_f0_env
|
||||
environment:
|
||||
VMWARE_HOST: "{{ vcenter_hostname }}"
|
||||
VMWARE_USER: "{{ vcenter_username }}"
|
||||
VMWARE_PASSWORD: "{{ vcenter_password }}"
|
||||
VMWARE_VALIDATE_CERTS: False
|
||||
- debug: var=clone_d1_c1_f0_env
|
||||
|
||||
- name: assert that changes were made
|
||||
assert:
|
||||
that:
|
||||
- "clone_d1_c1_f0_env.results|map(attribute='changed')|unique|list == [True]"
|
@ -0,0 +1,17 @@
|
||||
- block:
|
||||
- include_tasks: '{{ test_playbook }}'
|
||||
always:
|
||||
- name: Remove VM
|
||||
vmware_guest:
|
||||
hostname: "{{ vcenter_hostname }}"
|
||||
username: "{{ vcenter_username }}"
|
||||
password: "{{ vcenter_password }}"
|
||||
validate_certs: no
|
||||
# cluster: "{{ ccr1 }}"
|
||||
name: '{{ item }}'
|
||||
force: yes
|
||||
state: absent
|
||||
with_items:
|
||||
- test_vm1
|
||||
- test_vm2
|
||||
- test_vm3
|
Loading…
Reference in New Issue