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 machine
This commit is contained in:
Gonéri Le Bouder 2019-07-11 08:12:49 +02:00
parent 08b9e18d4f
commit 964783fbd2
30 changed files with 266 additions and 362 deletions

View file

@ -136,6 +136,10 @@ Once your configuration is ready, you can trigger a run with the following comma
``vmware_host_firewall_manager`` is the name of the module to test.
``vmware_guest`` is much larger than any other test role and is rather slow. You can enable or disable some of its test playbooks in
:file:`test/integration/targets/vmware_guest/defaults/main.yml`.
Unit-test
=========
@ -174,6 +178,22 @@ Depending upon the functionality provided by ESXi or vCenter, some modules can s
if self.host is None:
self.module.fail_json(msg="Failed to find host system.")
Functional tests
----------------
No need to create too much resources
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Most of the time, it's not necessary to use ``with_items`` to create multiple resources. By avoiding it,
you speed up the test execution and you simplify the clean up afterwards.
VM names should be predictable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you need to create a new VM during your test, you can use ``test_vm1``, ``test_vm2`` or ``test_vm3``. This
way it will be automatically clean up for you.
Typographic convention
======================

View file

@ -34,3 +34,15 @@
vcenter_hostname: "{{ vcsim }}"
vcenter_username: "user"
vcenter_password: "pass"
- name: set state to poweroff on all VMs
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ item.name }}"
state: poweredoff
with_items: "{{ virtual_machines + virtual_machines_in_cluster }}"
register: poweroff_d1_c1_f0

View file

@ -8,7 +8,7 @@
validate_certs: no
folder: '{{ item.folder }}'
name: '{{ item.name }}'
state: poweredon
state: poweredoff
guest_id: debian8_64Guest
disk:
- size_gb: 1
@ -36,7 +36,7 @@
folder: '{{ item.folder }}'
cluster: '{{ item.cluster }}'
name: '{{ item.name }}'
state: poweredon
state: poweredoff
guest_id: debian8_64Guest
disk:
- size_gb: 1

View file

@ -1,16 +1,28 @@
---
- name: Remove VM
- name: Remove the VM prepared by prepare_vmware_tests
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
cluster: "{{ ccr1 }}"
name: "{{ item.name }}"
force: yes
state: absent
with_items: '{{ virtual_machines + virtual_machines_in_cluster }}'
ignore_errors: yes
- name: Remove the test_vm* VMs
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
name: "{{ item }}"
force: yes
state: absent
with_items:
- test_vm1
- test_vm2
- test_vm3
- name: Remove the DVSwitch
vmware_dvswitch:

View file

@ -4,6 +4,8 @@
- import_role:
name: prepare_vmware_tests
vars:
setup_datacenter: true
# Testcase 0001: Add Cluster
- &add_cluster

View file

@ -7,7 +7,31 @@
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- name: Create VMs
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
validate_certs: no
folder: '{{ f0 }}'
name: test_vm1
state: poweredoff
guest_id: debian8_64Guest
disk:
- size_gb: 1
type: thin
datastore: '{{ ds2 }}'
hardware:
memory_mb: 128
num_cpus: 1
scsi: paravirtual
cdrom:
type: iso
iso_path: "[{{ ds1 }}] fedora.iso"
networks:
- name: VM Network
- name: Create DRS VM group
vmware_drs_group:

View file

@ -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

View file

@ -8,7 +8,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item.name }}"
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -20,8 +20,7 @@
type: thin
autoselect_datastore: True
state: poweredoff
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ f0 }}"
register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0
@ -29,7 +28,7 @@
- name: assert that changes were made
assert:
that:
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]"
- clone_d1_c1_f0 is changed
# VCSIM does not recognizes existing VMs boot firmware
- when: vcsim is not defined
@ -40,7 +39,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_' + item.name }}"
name: test_vm2
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -52,14 +51,13 @@
type: thin
autoselect_datastore: True
state: poweredoff
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ f0 }}"
register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0
- name: assert that changes were not made
assert:
that:
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
- clone_d1_c1_f0 is changed
- name: create new VMs with boot_firmware as 'efi'
vmware_guest:
@ -67,7 +65,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_efi_' + item.name }}"
name: test_vm3
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -79,8 +77,7 @@
type: thin
autoselect_datastore: True
state: poweredoff
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ f0 }}"
register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0
@ -88,7 +85,7 @@
- name: assert that changes were made
assert:
that:
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [true]"
- clone_d1_c1_f0 is changed
# VCSIM does not recognizes existing VMs boot firmware
- when: vcsim is not defined
@ -99,7 +96,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_efi_' + item.name }}"
name: test_vm3
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -111,11 +108,10 @@
type: thin
autoselect_datastore: True
state: poweredoff
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ f0 }}"
register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0
- name: assert that changes were not made
assert:
that:
- "clone_d1_c1_f0.results|map(attribute='changed')|unique|list == [false]"
- not (clone_d1_c1_f0 is changed)

View file

@ -5,7 +5,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "vm"
name: CDROM-Test
name: test_vm1
datacenter: "{{ dc1 }}"
cluster: "{{ ccr1 }}"
resource_pool: Resources
@ -38,7 +38,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "vm"
name: CDROM-Test
name: test_vm1
datastore: "{{ ds2 }}"
cdrom:
type: iso
@ -61,7 +61,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: vm
name: CDROM-Test
name: test_vm1
datacenter: "{{ dc1 }}"
cdrom:
type: client
@ -83,7 +83,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: vm
name: CDROM-Test
name: test_vm1
datacenter: "{{ dc1 }}"
cdrom:
type: none
@ -105,7 +105,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: vm
name: CDROM-Test-38679
name: test_vm2
datacenter: "{{ dc1 }}"
cluster: "{{ ccr1 }}"
resource_pool: Resources
@ -148,7 +148,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "{{ f0 }}"
name: CDROM-Test-38679
name: test_vm2
datacenter: "{{ dc1 }}"
cluster: "{{ ccr1 }}"
resource_pool: Resources

View file

@ -8,13 +8,12 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'net_customize_' + item.name }}"
template: "{{ item.name }}"
name: test_vm1
template: "{{ virtual_machines[0].name }}"
datacenter: "{{ dc1 }}"
state: poweredoff
folder: "{{ item.folder }}"
folder: "{{ virtual_machines[0].folder }}"
convert: thin
with_items: "{{ virtual_machines }}"
register: clone_customize
- debug:
@ -23,7 +22,7 @@
- name: assert that changes were made
assert:
that:
- "clone_customize.results|map(attribute='changed')|unique|list == [true]"
- clone_customize is changed
- name: clone vm from template and customize GOS again
vmware_guest:
@ -31,13 +30,12 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'net_customize_' + item.name }}"
template: "{{ item.name }}"
name: test_vm1
template: "{{ virtual_machines[0].name }}"
datacenter: "{{ dc1 }}"
state: poweredoff
folder: "{{ item.folder }}"
folder: "{{ virtual_machines[0].folder }}"
convert: thin
with_items: "{{ virtual_machines }}"
register: clone_customize_again
- debug:
@ -46,4 +44,4 @@
- name: assert that changes were not made
assert:
that:
- "clone_customize_again.results|map(attribute='changed')|unique|list == [false]"
- not (clone_customize_again is changed)

View file

@ -12,7 +12,7 @@
template: "{{ virtual_machines[0].name }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
folder: D1/C1/F0
folder: "{{ f0 }}"
linked_clone: True
register: linked_clone_d1_c1_f0
ignore_errors: True
@ -35,7 +35,7 @@
template: "{{ virtual_machines[0].name }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
folder: D1/C1/F0
folder: "{{ f0 }}"
snapshot_src: "snap_shot1"
register: linked_clone_d1_c1_f0
ignore_errors: True

View file

@ -8,13 +8,12 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'thin_' + item.name }}"
template: "{{ item.name }}"
name: test_vm1
template: "{{ virtual_machines[0].name }}"
datacenter: "{{ dc1 }}"
state: poweredoff
folder: "{{ item.folder }}"
folder: "{{ virtual_machines[0].folder }}"
convert: thin
with_items: "{{ virtual_machines }}"
register: clone_thin
- debug: var=clone_thin
@ -22,7 +21,7 @@
- name: assert that changes were made
assert:
that:
- "clone_thin.results|map(attribute='changed')|unique|list == [true]"
- clone_thin is changed
- name: clone vm from template and convert to thick
vmware_guest:
@ -30,13 +29,12 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'thick_' + item.name }}"
template: "{{ item.name }}"
name: test_vm2
template: "{{ virtual_machines[0].name }}"
datacenter: "{{ dc1 }}"
state: poweredoff
folder: "{{ item.folder }}"
folder: "{{ virtual_machines[0].folder }}"
convert: thick
with_items: "{{ virtual_machines }}"
register: clone_thick
- debug: var=clone_thick
@ -44,7 +42,7 @@
- name: assert that changes were made
assert:
that:
- "clone_thick.results|map(attribute='changed')|unique|list == [true]"
- clone_thick is changed
- name: clone vm from template and convert to eagerzeroedthick
vmware_guest:
@ -52,13 +50,12 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'eagerzeroedthick_' + item.name }}"
template: "{{ item.name }}"
name: test_vm3
template: "{{ virtual_machines[0].name }}"
datacenter: "{{ dc1 }}"
state: poweredoff
folder: "{{ item.folder }}"
folder: "{{ virtual_machines[0].folder }}"
convert: eagerzeroedthick
with_items: "{{ virtual_machines }}"
register: clone_eagerzeroedthick
- debug: var=clone_eagerzeroedthick
@ -66,4 +63,4 @@
- name: assert that changes were made
assert:
that:
- "clone_eagerzeroedthick.results|map(attribute='changed')|unique|list == [true]"
- clone_eagerzeroedthick is changed

View file

@ -8,7 +8,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_1
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -34,7 +34,7 @@
type: thin
autoselect_datastore: True
state: poweredoff
folder: F0
folder: '{{ f0 }}'
register: clone_d1_c1_f0
- debug: var=clone_d1_c1_f0
@ -50,7 +50,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_1
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -63,7 +63,7 @@
type: thin
autoselect_datastore: True
state: poweredoff
folder: F0
folder: '{{ f0 }}'
register: clone_d1_c1_f0_recreate
- debug: var=clone_d1_c1_f0_recreate
@ -79,7 +79,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_1
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -87,7 +87,7 @@
num_cpus: 2
memory_mb: 1024
state: present
folder: F0
folder: '{{ f0 }}'
register: clone_d1_c1_f0_modify
- debug: var=clone_d1_c1_f0_modify
@ -103,7 +103,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_1
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -111,7 +111,7 @@
num_cpus: 2
memory_mb: 1024
state: present
folder: F0
folder: '{{ f0 }}'
register: clone_d1_c1_f0_remodify
- debug: var=clone_d1_c1_f0_remodify
@ -127,12 +127,12 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_1
name: test_vm1
#template: "{{ item|basename }}"
#guest_id: centos64Guest
datacenter: "{{ dc1 }}"
state: absent
folder: F0
folder: '{{ f0 }}'
register: clone_d1_c1_f0_delete
- debug: var=clone_d1_c1_f0_delete
@ -148,12 +148,12 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_1
name: test_vm1
#template: "{{ item|basename }}"
#guest_id: centos64Guest
datacenter: "{{ dc1 }}"
state: absent
folder: F0
folder: '{{ f0 }}'
register: clone_d1_c1_f0_redelete
- debug: var=clone_d1_c1_f0_redelete

View file

@ -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]"

View file

@ -8,7 +8,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvmnw_4
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:

View file

@ -5,7 +5,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -33,7 +33,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
#guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -55,7 +55,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -84,7 +84,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
#guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -107,7 +107,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -137,7 +137,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
#guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -160,7 +160,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
@ -189,7 +189,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_2
name: test_vm1
#template: "{{ item|basename }}"
#guest_id: centos64Guest
datacenter: "{{ dc1 }}"

View file

@ -8,7 +8,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: disk_mode_d1_c1_f0
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -21,15 +21,15 @@
disk_mode: 'invalid_disk_mode'
state: poweredoff
folder: "{{ f0 }}"
register: disk_mode_d1_c1_f0
register: test_vm1
ignore_errors: True
- debug: var=disk_mode_d1_c1_f0
- debug: var=test_vm1
- name: assert that changes were not made
assert:
that:
- not(disk_mode_d1_c1_f0 is changed)
- not(test_vm1 is changed)
- name: create new VMs with valid disk mode
vmware_guest:
@ -37,7 +37,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: disk_mode_d1_c1_f0
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -50,14 +50,14 @@
disk_mode: 'independent_persistent'
state: poweredoff
folder: "{{ f0 }}"
register: disk_mode_d1_c1_f0_2
register: test_vm1_2
- debug: var=disk_mode_d1_c1_f0_2
- debug: var=test_vm1_2
- name: assert that changes were made
assert:
that:
- disk_mode_d1_c1_f0_2 is changed
- test_vm1_2 is changed
#TODO: vcsim does not support reconfiguration of disk mode, fails with types.InvalidDeviceSpec
- when: vcsim is not defined
@ -68,7 +68,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: disk_mode_d1_c1_f0
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -81,9 +81,9 @@
disk_mode: 'independent_persistent'
state: poweredoff
folder: "{{ f0 }}"
register: disk_mode_d1_c1_f0_2
- debug: var=disk_mode_d1_c1_f0_2
register: test_vm1_2
- debug: var=test_vm1_2
- name: assert that changes were not made
assert:
that:
- not (disk_mode_d1_c1_f0_2 is changed)
- not (test_vm1_2 is changed)

View file

@ -8,7 +8,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_6
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:

View file

@ -8,7 +8,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: newvm_3
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:

View file

@ -8,7 +8,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: DC0_H0_VM12
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:

View file

@ -5,125 +5,13 @@
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datacenter: true
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
setup_resource_pool: true
- block:
- include: poweroff_d1_c1_f0.yml
- include: poweroff_d1_c1_f1.yml
- include: check_mode.yml
- include: clone_resize_disks.yml
- include: clone_d1_c1_f0.yml
- include: create_d1_c1_f0.yml
- include: cdrom_d1_c1_f0.yml
- include: create_rp_d1_c1_f0.yml
- include: create_guest_invalid_d1_c1_f0.yml
- include: mac_address_d1_c1_f0.yml
- include: disk_type_d1_c1_f0.yml
- include: create_nw_d1_c1_f0.yml
- include: delete_vm.yml
- include: non_existent_vm_ops.yml
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:
- CDROM-Test
- CDROM-Test-38679
- clone_resize_disks_clone
- clone_resize_disks_original
- newvm_2
- newvm_3
- newvmnw_4
- DC0_H0_VM12
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- block:
- include: network_negative_test.yml
# VCSIM does not return list of portgroups for dvswitch so commenting following TC
#- include: network_with_portgroup.yml
# Currently, VCSIM doesn't support DVPG (as portkeys are not available) so commenting this test
# - include: network_with_dvpg.yml
#- include: template_d1_c1_f0.yml
- include: vapp_d1_c1_f0.yml
- include: disk_size_d1_c1_f0.yml
- include: network_with_device.yml
- include: disk_mode_d1_c1_f0.yml
- include: linked_clone_d1_c1_f0.yml
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:
- disk_mode_d1_c1_f0
- network_with_device
- new_vm_no_nw_type
- vApp-Test
- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- block:
- include: boot_firmware_d1_c1_f0.yml
- include: clone_with_convert.yml
- include: clone_customize_guest_test.yml
- include: max_connections.yml
- include: mem_reservation.yml
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:
- newvm_DC0_H0_VM0
- newvm_DC0_H0_VM1
- newvm_efi_DC0_H0_VM0
- newvm_efi_DC0_H0_VM1
- newvm_mk_conn_DC0_H0_VM0
- newvm_mk_conn_DC0_H0_VM1
- newvm_mem_res_DC0_H0_VM0
- newvm_mem_res_DC0_H0_VM1
- newvm_no_mem_DC0_H0_VM0
- newvm_no_mem_DC0_H0_VM1
- memory_res_DC0_H0_VM0
- memory_res_DC0_H0_VM1
- thin_DC0_H0_VM0
- thin_DC0_H0_VM1
- thick_DC0_H0_VM0
- thick_DC0_H0_VM1
- eagerzeroedthick_DC0_H0_VM0
- eagerzeroedthick_DC0_H0_VM1
- net_customize_DC0_H0_VM0
- net_customize_DC0_H0_VM1
- include_tasks: run_test_playbook.yml
with_items: '{{ vmware_guest_test_playbooks }}'
loop_control:
loop_var: test_playbook

View file

@ -5,13 +5,13 @@
- when: vcsim is not defined
block:
- &add_mk_conn
name: Create new VMs again with max_connections as 4
name: Create new VM with max_connections as 4
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_mk_conn_' + item.name }}"
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -23,8 +23,7 @@
type: thin
autoselect_datastore: True
state: present
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ f0 }}"
register: mk_conn_result_0001
- debug: var=mk_conn_result_0001
@ -32,7 +31,7 @@
- name: Assert that changes were made
assert:
that:
- "mk_conn_result_0001.results|map(attribute='changed')|unique|list == [true]"
- mk_conn_result_0001 is changed
- <<: *add_mk_conn
name: Again create new VMs again with max_connections as 4
@ -43,4 +42,4 @@
- name: Assert that changes were not made
assert:
that:
- "mk_conn_result_0002.results|map(attribute='changed')|unique|list == [false]"
- not (mk_conn_result_0002 is changed)

View file

@ -11,7 +11,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_mem_res_' + item.name }}"
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -23,8 +23,7 @@
type: thin
autoselect_datastore: True
state: present
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ virtual_machines[0].folder }}"
register: mem_reserve_result_0001
- debug: var=mem_reserve_result_0001
@ -32,7 +31,7 @@
- name: Assert that changes were made
assert:
that:
- "mem_reserve_result_0001.results|map(attribute='changed')|unique|list == [true]"
- mem_reserve_result_0001 is changed
- <<: *add_mem_reserve
name: Again create new VMs with mem_reservation as 0
@ -43,16 +42,16 @@
- name: Assert that changes were not made
assert:
that:
- "mem_reserve_result_0002.results|map(attribute='changed')|unique|list == [false]"
- not (mem_reserve_result_0002 is changed)
- &add_memory_reserve
name: Create new VMs with memory_reservation as 0
name: Create new VM with memory_reservation as 0
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'memory_res_' + item.name }}"
name: test_vm2
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -64,8 +63,7 @@
type: thin
autoselect_datastore: True
state: present
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ virtual_machines[0].folder }}"
register: memory_reserve_result_0003
- debug: var=memory_reserve_result_0003
@ -73,7 +71,7 @@
- name: Assert that changes were made
assert:
that:
- "memory_reserve_result_0003.results|map(attribute='changed')|unique|list == [true]"
- memory_reserve_result_0003 is changed
- <<: *add_memory_reserve
name: Again create new VMs with memory_reservation as 0
@ -84,7 +82,7 @@
- name: Assert that changes were not made
assert:
that:
- "memory_reserve_result_0004.results|map(attribute='changed')|unique|list == [false]"
- not (memory_reserve_result_0004 is changed)
- &no_memory_reserve
name: Create new VMs without memory_reservation or mem_reservation
@ -93,7 +91,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_no_mem_' + item.name }}"
name: test_vm3
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
@ -105,8 +103,7 @@
type: thin
autoselect_datastore: True
state: present
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
folder: "{{ virtual_machines[0].folder }}"
register: no_memory_reserve_result_0005
- debug: var=no_memory_reserve_result_0005
@ -114,7 +111,7 @@
- name: Assert that changes were made
assert:
that:
- "no_memory_reserve_result_0005.results|map(attribute='changed')|unique|list == [true]"
- no_memory_reserve_result_0005 is changed
- <<: *no_memory_reserve
name: Again create new VMs without memory_reservation or mem_reservation
@ -125,4 +122,4 @@
- name: Assert that changes were not made
assert:
that:
- "no_memory_reserve_result_0006.results|map(attribute='changed')|unique|list == [false]"
- not (no_memory_reserve_result_0006 is changed)

View file

@ -314,7 +314,7 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: new_vm_no_nw_type
name: test_vm1
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
disk:

View file

@ -15,7 +15,7 @@
datacenter: "{{ dc1 }}"
state: poweredon
folder: "{{ f0 }}"
name: network_with_device
name: test_vm1
disk:
- size: 10mb
autoselect_datastore: yes
@ -43,7 +43,7 @@
datacenter: "{{ dc1 }}"
state: poweredon
folder: "{{ f0 }}"
name: network_with_device
name: test_vm1
disk:
- size: 10mb
autoselect_datastore: yes

View file

@ -2,7 +2,7 @@
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: set state to poweroff on all VMs
- name: create a VM with the poweroff status
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
@ -16,9 +16,12 @@
- debug:
var: poweroff_d1_c1_f0
# vcsim (v0.18.0) VMs are spawned PoweredOn
- name: make sure changes were made
assert:
that:
- "poweroff_d1_c1_f0.results[0].changed == true"
- "poweroff_d1_c1_f0.results[1].changed == true"
- poweroff_d1_c1_f0.results[0].instance.hw_power_status == "poweredOff"
- name: make sure no changes were made (the VMs are already off)
assert:
that:
- poweroff_d1_c1_f0.results[0].changed|bool == false

View file

@ -19,12 +19,4 @@
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
register: poweroff_d1_c1_f1
- debug: var=poweroff_d1_c1_f1
# vcsim (v0.18.0) VMs are spawned PoweredOn
- name: make sure changes were made
assert:
that:
- '"instance" in poweroff_d1_c1_f1.results[0]'
- '"instance" in poweroff_d1_c1_f1.results[1]'

View file

@ -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

View file

@ -11,7 +11,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "vm"
name: vApp-Test
name: test_vm1
datacenter: "{{ dc1 }}"
cluster: "{{ ccr1 }}"
resource_pool: Resources
@ -67,7 +67,7 @@
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "vm"
name: vApp-Test
name: test_vm1
datacenter: "{{ dc1 }}"
vapp_properties:
- id: prop_id1

View file

@ -7,7 +7,31 @@
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
- name: Create a VM with the state poweredoff
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ dc1 }}"
validate_certs: no
folder: '{{ f0 }}'
name: test_vm1
state: poweredoff
guest_id: debian8_64Guest
disk:
- size_gb: 1
type: thin
datastore: '{{ ds2 }}'
hardware:
memory_mb: 128
num_cpus: 1
scsi: paravirtual
cdrom:
type: iso
iso_path: "[{{ ds1 }}] fedora.iso"
networks:
- name: VM Network
- name: set state to poweroff the first VM
vmware_guest_powerstate:
@ -15,8 +39,8 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
name: test_vm1
folder: '{{ f0 }}'
state: powered-off
register: poweroff_d1_c1_f0
@ -26,7 +50,7 @@
- name: make sure change was made
assert:
that:
- poweroff_d1_c1_f0.changed
- not (poweroff_d1_c1_f0 is changed)
- when: vcsim is not defined
block:
@ -36,8 +60,8 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
name: test_vm1
folder: '{{ f0 }}'
scheduled_at: "10/10/2030 10:10"
state: powered-on
register: poweron_d1_c1_f0
@ -45,4 +69,4 @@
- name: Check that task is schedule
assert:
that:
- poweron_d1_c1_f0.changed
- poweron_d1_c1_f0 is changed