1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/vmware_guest_snapshot/tasks/main.yml
Gonéri Le Bouder e4cca4e40a vmware: refactoring of vmware test roles -- part4
Refactoring of the following roles to make use of the new
`prepare_vmware_tests` role.

- `vmware_guest`
- `vmware_guest_boot_facts`
- `vmware_guest_custom_attribute_defs`
- `vmware_guest_customization_facts`
- `vmware_guest_disk_facts`
- `vmware_guest_facts`
- `vmware_guest_find`
- `vmware_guest_move`
- `vmware_guest_powerstate`
- `vmware_guest_snapshot`
- `vmware_guest_snapshot_facts`
- `vmware_guest_tools_wait`

This patch depends on: https://github.com/ansible/ansible/pull/55719

Original PR: https://github.com/ansible/ansible/pull/54882
2019-05-01 11:22:14 -04:00

178 lines
5.1 KiB
YAML

- import_role:
name: prepare_vmware_tests
vars:
setup_attach_host: true
setup_datastore: true
setup_virtualmachines: true
# Test0001: Try to delete the non-existent snapshot
- name: 0001 - Delete non-existent snapshot
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: absent
snapshot_name: snap_a
# Test0002: Create two snapshots
- name: 0002 - Create snapshot
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: present
snapshot_name: "snap_{{item}}"
description: "snap named {{item}}"
with_items:
- a
- b
- when: vcsim is not defined
block:
# Test0003: Reanme a to c
- name: 0003 - Rename snapshot
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: present
snapshot_name: snap_a
new_snapshot_name: snap_c
# Test0004: Create snap_a again
- name: 0004 - Re-create snapshot a
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: present
snapshot_name: snap_a
description: "snap named a"
# Test0005: Change description of snap_c
- name: 0005 - Change description of snap_c
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: present
snapshot_name: snap_c
new_description: "renamed to snap_c from snap_a"
- when: vcsim is not defined
block:
# Test0006: Delete snap_b with child remove
- name: 0006 - Delete snap_b with child remove
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: absent
snapshot_name: snap_b
remove_children: True
# Test0007: Delete all snapshots
- name: 0007 - Delete all snapshots
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: remove_all
# Test0008: Create snap_a again and revert to it
- name: 0008 - Re-create snapshot a
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: present
snapshot_name: snap_a
description: "snap named a"
- when: vcsim is not defined
block:
- name: 0008 - Revert to snap_a
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: revert
snapshot_name: snap_a
# Test0009: Create snap_a and check in result
- name: 0009 - create snapshot a
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
folder: "{{ f0 }}"
name: "{{ infra.vm_list[0] }}"
state: present
snapshot_name: snap_a
description: "snap named a"
register: snapshot_details
- debug: var=snapshot_details
- name: Check if snapshot details available or not
assert:
that:
- "snapshot_details['msg'] == 'Snapshot named [snap_a] already exists and is current.'"
# Test0011: Failure sceanrios - when name and UUID is not specified
- name: 0011 - name and UUID is missing
vmware_guest_snapshot:
validate_certs: False
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
state: present
snapshot_name: snap_a
description: "snap named a"
register: snapshot_failure_details
ignore_errors: yes
- name: Check if error is shown
assert:
that:
- "'one of the following is required: name, uuid' in snapshot_failure_details['msg']"
- "snapshot_failure_details.changed == false"