VMware: Additional testcase for mem_reservation (#59365)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2019-07-22 10:44:19 +05:30 committed by GitHub
parent 8d0f2e5725
commit 791e565802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 1 deletions

View file

@ -896,7 +896,9 @@ class PyVmomiHelper(PyVmomi):
rai_change_detected = True
if 'mem_reservation' in self.params['hardware'] or 'memory_reservation' in self.params['hardware']:
mem_reservation = self.params['hardware'].get('mem_reservation') or self.params['hardware'].get('memory_reservation')
mem_reservation = self.params['hardware'].get('mem_reservation')
if mem_reservation is None:
mem_reservation = self.params['hardware'].get('memory_reservation')
try:
mem_reservation = int(mem_reservation)
except ValueError:

View file

@ -116,6 +116,10 @@
- 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

View file

@ -44,3 +44,85 @@
assert:
that:
- "mem_reserve_result_0002.results|map(attribute='changed')|unique|list == [false]"
- &add_memory_reserve
name: Create new VMs with memory_reservation as 0
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'memory_res_' + item.name }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
num_cpus: 4
memory_mb: 512
memory_reservation: 0
disk:
- size: 1gb
type: thin
autoselect_datastore: True
state: present
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
register: memory_reserve_result_0003
- debug: var=memory_reserve_result_0003
- name: Assert that changes were made
assert:
that:
- "memory_reserve_result_0003.results|map(attribute='changed')|unique|list == [true]"
- <<: *add_memory_reserve
name: Again create new VMs with memory_reservation as 0
register: memory_reserve_result_0004
- debug: var=memory_reserve_result_0004
- name: Assert that changes were not made
assert:
that:
- "memory_reserve_result_0004.results|map(attribute='changed')|unique|list == [false]"
- &no_memory_reserve
name: Create new VMs without memory_reservation or mem_reservation
vmware_guest:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ 'newvm_no_mem_' + item.name }}"
guest_id: centos64Guest
datacenter: "{{ dc1 }}"
hardware:
num_cpus: 4
memory_mb: 512
memory_reservation: 0
disk:
- size: 1gb
type: thin
autoselect_datastore: True
state: present
folder: "{{ item.folder }}"
with_items: "{{ virtual_machines }}"
register: no_memory_reserve_result_0005
- debug: var=no_memory_reserve_result_0005
- name: Assert that changes were made
assert:
that:
- "no_memory_reserve_result_0005.results|map(attribute='changed')|unique|list == [true]"
- <<: *no_memory_reserve
name: Again create new VMs without memory_reservation or mem_reservation
register: no_memory_reserve_result_0006
- debug: var=no_memory_reserve_result_0006
- name: Assert that changes were not made
assert:
that:
- "no_memory_reserve_result_0006.results|map(attribute='changed')|unique|list == [false]"