Skip to content

Commit

Permalink
Update VMware tests
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Ganar <[email protected]>
  • Loading branch information
shubhamsg199 committed Oct 3, 2023
1 parent 8d98645 commit 6c2fc07
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 387 deletions.
36 changes: 17 additions & 19 deletions conf/vmware.yaml.template
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
VMWARE:
# Vmware to be added as a compute resource
# vmware vcenter URL, e.g. example.com
# VMware to be added as a compute resource
# VCENTER: vmware vcenter URL
VCENTER:
# Login for vmware
# USERNAME: Login for vmware
USERNAME:
# Password for vmware
# PASSWORD: Password for vmware
PASSWORD:
# vmware datacenter
# DATACENTER: vmware datacenter
DATACENTER:
# cluster: vmware cluster
# CLUSTER: vmware cluster
CLUSTER:
# Name of VM that should be used
# DATASTORE: vmware datastore
DATASTORE:
# VM_NAME: Name of VM to power On/Off & delete
VM_NAME:
# mac_address: Mac address of the vm
# MAC_ADDRESS: Mac address of the vm
MAC_ADDRESS:
# hypervisor: IP address of the hypervisor
# HYPERVISOR: IP address or hostname of the hypervisor
HYPERVISOR:


# Vmware Compute resource image data
# Operating system of the image
# VMware Compute resource image data
# IMAGE_OS: Operating system of the image
IMAGE_OS:
# Architecture of the image
# IMAGE_ARCH: Architecture of the image
IMAGE_ARCH:
# Login to the image
# IMAGE_USERNAME: Login to the image
IMAGE_USERNAME:
# Password of that user
# IMAGE_PASSWORD: Password to the image
IMAGE_PASSWORD:
# Image name on the external provider
# IMAGE_NAME: Image name on the external provider
IMAGE_NAME:
# Interface used for some tests; not required to work with provisioning, not required to be in VLAN
INTERFACE:
212 changes: 91 additions & 121 deletions tests/foreman/cli/test_computeresource_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,158 +11,128 @@
:CaseImportance: High
:CaseAutomation: Automated
:Upstream: No
"""
from fauxfactory import gen_string
import pytest
from wait_for import wait_for
from wrapanapi import VMWareSystem

from robottelo.cli.factory import make_compute_resource
from robottelo.cli.org import Org
from robottelo.config import settings
from robottelo.constants import FOREMAN_PROVIDERS


@pytest.fixture(scope='module')
def vmware(module_org, module_location):
vmware = type('vmware', (object,), {})()
vmware.org = module_org
vmware.loc = module_location
Org.add_location({'id': vmware.org.id, 'location-id': vmware.loc.id})
vmware.vmware_server = settings.vmware.vcenter
vmware.vmware_password = settings.vmware.password
vmware.vmware_username = settings.vmware.username
vmware.vmware_datacenter = settings.vmware.datacenter
vmware.vmware_img_name = settings.vmware.image_name
vmware.vmware_img_arch = settings.vmware.image_arch
vmware.vmware_img_os = settings.vmware.image_os
vmware.vmware_img_user = settings.vmware.image_username
vmware.vmware_img_pass = settings.vmware.image_password
vmware.vmware_vm_name = settings.vmware.vm_name
return vmware


@pytest.mark.tier1
def test_positive_create_with_server(vmware):
"""Create VMware compute resource with server field
:id: a06b02c4-fe6a-44ef-bf61-5a28c3905527
:customerscenario: true
:expectedresults: Compute resource is created, server field saved
correctly
:BZ: 1387917
:CaseAutomation: Automated
:CaseImportance: Critical
"""
cr_name = gen_string('alpha')
vmware_cr = make_compute_resource(
{
'name': cr_name,
'provider': FOREMAN_PROVIDERS['vmware'],
'server': vmware.vmware_server,
'user': vmware.vmware_username,
'password': vmware.vmware_password,
'datacenter': vmware.vmware_datacenter,
}
)
assert vmware_cr['name'] == cr_name
assert vmware_cr['server'] == vmware.vmware_server


@pytest.mark.tier1
def test_positive_create_with_org(vmware):
"""Create VMware Compute Resource with organizations
@pytest.mark.upgrade
def test_positive_create_with_org_and_loc(target_sat, module_org, module_location):
"""Create VMware Compute Resource with organizations and locations
:id: 807a1f70-4cc3-4925-b145-0c3b26c57559
:id: 96faae3f-bc64-4147-a9fc-09c858e0a68f
:customerscenario: true
:expectedresults: VMware Compute resource is created
:BZ: 1387917
:CaseAutomation: Automated
:CaseImportance: Critical
"""
cr_name = gen_string('alpha')
vmware_cr = make_compute_resource(
vmware_cr = target_sat.cli.ComputeResource.create(
{
'name': cr_name,
'organization-ids': vmware.org.id,
'organization-ids': module_org.id,
'location-ids': module_location.id,
'provider': FOREMAN_PROVIDERS['vmware'],
'server': vmware.vmware_server,
'user': vmware.vmware_username,
'password': vmware.vmware_password,
'datacenter': vmware.vmware_datacenter,
'server': settings.vmware.vcenter,
'user': settings.vmware.username,
'password': settings.vmware.password,
'datacenter': settings.vmware.datacenter,
}
)
assert vmware_cr['name'] == cr_name


@pytest.mark.tier1
def test_positive_create_with_loc(vmware):
"""Create VMware Compute Resource with locations
:id: 214a0f54-6fc2-4e7b-91ab-a45760ffb2f2
:customerscenario: true
:expectedresults: VMware Compute resource is created
:BZ: 1387917
assert vmware_cr['locations'][0] == module_location.name
assert vmware_cr['organizations'] == module_org.name
assert vmware_cr['server'] == settings.vmware.vcenter
assert vmware_cr['datacenter'] == settings.vmware.datacenter


@pytest.mark.e2e
@pytest.mark.on_premises_provisioning
@pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True)
@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True)
@pytest.mark.parametrize('provision_method', ['build', 'bootdisk'])
@pytest.mark.rhel_ver_match('[8]')
@pytest.mark.tier3
def test_positive_provision_end_to_end(
request,
setting_update,
module_provisioning_sat,
module_sca_manifest_org,
module_location,
pxe_loader,
module_vmware_cr,
module_vmware_hostgroup,
provision_method,
):
"""Provision a host on vmware compute resource with
the help of hostgroup.
:id: ff9963fc-a2a7-4392-aa9a-190d5d1c8357
:steps:
1. Configure provisioning setup.
2. Create VMware CR
3. Configure host group setup.
4. Provision a host on VMware
5. Verify created host on VMware with wrapanapi
:expectedresults: Host is provisioned succesfully with hostgroup
:CaseAutomation: Automated
:CaseImportance: Critical
"""
cr_name = gen_string('alpha')
vmware_cr = make_compute_resource(
sat = module_provisioning_sat.sat
hostname = gen_string('alpha').lower()
host = sat.cli.Host.create(
{
'name': cr_name,
'location-ids': vmware.loc.id,
'provider': FOREMAN_PROVIDERS['vmware'],
'server': vmware.vmware_server,
'user': vmware.vmware_username,
'password': vmware.vmware_password,
'datacenter': vmware.vmware_datacenter,
'name': hostname,
'organization': module_sca_manifest_org.name,
'location': module_location.name,
'hostgroup': module_vmware_hostgroup.name,
'compute-resource-id': module_vmware_cr['id'],
'ip': None,
'mac': None,
'compute-attributes': f'cluster={settings.vmware.cluster},'
f'path=/Datacenters/{settings.vmware.datacenter}/vm/,'
'scsi_controller_type=VirtualLsiLogicController,'
'guest_id=rhel8_64Guest,firmware=automatic,'
'cpus=1,memory_mb=6000, start=1',
'interface': f'compute_type=VirtualVmxnet3,'
f'compute_network=VLAN {settings.provisioning.vlan_id}',
'volume': f'name=Hard disk,size_gb=10,thin=true,eager_zero=false,datastore={settings.vmware.datastore}',
'provision-method': provision_method,
}
)
assert vmware_cr['name'] == cr_name


@pytest.mark.tier1
@pytest.mark.upgrade
def test_positive_create_with_org_and_loc(vmware):
"""Create VMware Compute Resource with organizations and locations
:id: 96faae3f-bc64-4147-a9fc-09c858e0a68f
:customerscenario: true
:expectedresults: VMware Compute resource is created
:BZ: 1387917
:CaseAutomation: Automated
:CaseImportance: Critical
"""
cr_name = gen_string('alpha')
vmware_cr = make_compute_resource(
{
'name': cr_name,
'organization-ids': vmware.org.id,
'location-ids': vmware.loc.id,
'provider': FOREMAN_PROVIDERS['vmware'],
'server': vmware.vmware_server,
'user': vmware.vmware_username,
'password': vmware.vmware_password,
'datacenter': vmware.vmware_datacenter,
}
# teardown
request.addfinalizer(lambda: sat.cli.Host.delete({'id': host['id']}))

hostname = f'{hostname}.{module_provisioning_sat.domain.name}'
assert hostname == host['name']
# check if vm is created on vmware
vmware = VMWareSystem(
hostname=settings.vmware.vcenter,
username=settings.vmware.username,
password=settings.vmware.password,
)
assert vmware_cr['name'] == cr_name
assert vmware.does_vm_exist(hostname) is True
wait_for(
lambda: sat.cli.Host.info({'name': hostname})['status']['build-status']
!= 'Pending installation',
timeout=1800,
delay=30,
)
host_info = sat.cli.Host.info({'id': host['id']})
assert host_info['status']['build-status'] == 'Installed'
Loading

0 comments on commit 6c2fc07

Please sign in to comment.