@@ -289,128 +289,62 @@ def test_positive_resource_vm_power_management(session, vmware):
289
289
raise AssertionError ('Timed out waiting for VM to toggle power state' ) from err
290
290
291
291
292
+ @pytest .mark .e2e
292
293
@pytest .mark .tier2
293
294
@pytest .mark .parametrize ('vmware' , ['vmware7' , 'vmware8' ], indirect = True )
294
- def test_positive_select_vmware_custom_profile_guest_os_rhel7 (session , vmware ):
295
- """Select custom default (3-Large) compute profile guest OS RHEL7 .
295
+ def test_positive_vmware_custom_profile_end_to_end (session , vmware ):
296
+ """Perform end to end testing for VMware compute profile .
296
297
297
298
:id: 24f7bb5f-2aaf-48cb-9a56-d2d0713dfe3d
298
299
299
300
:customerscenario: true
300
301
301
- :setup: vmware hostname and credentials.
302
-
303
302
:steps:
304
303
305
304
1. Create a compute resource of type vmware.
306
- 2. Provide valid hostname, username and password.
307
- 3. Select the created vmware CR.
308
- 4. Click Compute Profile tab.
309
- 5. Select 3-Large profile
310
- 6. Set Guest OS field to RHEL7 OS.
305
+ 2. Update a compute profile with all values
311
306
312
- :expectedresults: Guest OS RHEL7 is selected successfully.
307
+ :expectedresults: Compute profiles are updated successfully with all the values .
313
308
314
309
:BZ: 1315277
315
310
"""
316
311
cr_name = gen_string ('alpha' )
317
- guest_os_name = 'Red Hat Enterprise Linux 7 (64-bit)'
318
- with session :
319
- session .computeresource .create (
320
- {
321
- 'name' : cr_name ,
322
- 'provider' : FOREMAN_PROVIDERS ['vmware' ],
323
- 'provider_content.vcenter' : vmware .hostname ,
324
- 'provider_content.user' : settings .vmware .username ,
325
- 'provider_content.password' : settings .vmware .password ,
326
- 'provider_content.datacenter.value' : settings .vmware .datacenter ,
327
- }
328
- )
329
- assert session .computeresource .search (cr_name )[0 ]['Name' ] == cr_name
330
- session .computeresource .update_computeprofile (
331
- cr_name , COMPUTE_PROFILE_LARGE , {'provider_content.guest_os' : guest_os_name }
332
- )
333
- values = session .computeresource .read_computeprofile (cr_name , COMPUTE_PROFILE_LARGE )
334
- assert values ['provider_content' ]['guest_os' ] == guest_os_name
335
-
336
-
337
- @pytest .mark .tier2
338
- @pytest .mark .parametrize ('vmware' , ['vmware7' , 'vmware8' ], indirect = True )
339
- def test_positive_access_vmware_with_custom_profile (session , vmware ):
340
- """Associate custom default (3-Large) compute profile
341
-
342
- :id: 751ef765-5091-4322-a0d9-0c9c73009cc4
343
-
344
- :setup: vmware hostname and credentials.
345
-
346
- :steps:
347
-
348
- 1. Create a compute resource of type vmware.
349
- 2. Provide valid hostname, username and password.
350
- 3. Select the created vmware CR.
351
- 4. Click Compute Profile tab.
352
- 5. Edit (3-Large) with valid configurations and submit.
353
-
354
- :expectedresults: The Compute Resource created and associated to compute profile (3-Large)
355
- with provided values.
356
- """
357
- cr_name = gen_string ('alpha' )
312
+ guest_os_names = [
313
+ 'Red Hat Enterprise Linux 7 (64-bit)' ,
314
+ 'Red Hat Enterprise Linux 8 (64 bit)' ,
315
+ 'Red Hat Enterprise Linux 9 (64 bit)' ,
316
+ ]
317
+ compute_profile = ['1-Small' , '2-Medium' , '3-Large' ]
318
+ cpus = ['2' , '4' , '6' ]
319
+ vm_memory = ['4000' , '6000' , '8000' ]
320
+ annotation_notes = gen_string ('alpha' )
321
+ firmware_type = ['Automatic' , 'BIOS' , 'EFI' ]
322
+ resource_pool = VMWARE_CONSTANTS .get ('pool' )
323
+ folder = VMWARE_CONSTANTS .get ('folder' )
324
+ virtual_hw_version = (VMWARE_CONSTANTS .get ('virtualhw_version' ),)
325
+ memory_hot_add = (True ,)
326
+ cpu_hot_add = (True ,)
327
+ cdrom_drive = (True ,)
358
328
data_store_summary_string = _get_vmware_datastore_summary_string (vmware = vmware )
359
- cr_profile_data = dict (
360
- cpus = '2' ,
361
- cores_per_socket = '2' ,
362
- memory = '1024' ,
363
- firmware = 'EFI' ,
364
- cluster = settings .vmware .cluster ,
365
- resource_pool = VMWARE_CONSTANTS .get ('pool' ),
366
- folder = VMWARE_CONSTANTS .get ('folder' ),
367
- guest_os = VMWARE_CONSTANTS .get ('guest_os' ),
368
- virtual_hw_version = VMWARE_CONSTANTS .get ('virtualhw_version' ),
369
- memory_hot_add = True ,
370
- cpu_hot_add = True ,
371
- cdrom_drive = True ,
372
- annotation_notes = gen_string ('alpha' ),
329
+ storage_data = dict (
330
+ storage = dict (
331
+ controller = VMWARE_CONSTANTS .get ('scsicontroller' ),
332
+ disks = [
333
+ dict (
334
+ data_store = data_store_summary_string ,
335
+ size = '10 GB' ,
336
+ thin_provision = True ,
337
+ )
338
+ ],
339
+ )
340
+ )
341
+ network_data = dict (
373
342
network_interfaces = []
374
343
if not settings .provisioning .vlan_id
375
- else [
376
- dict (
377
- nic_type = VMWARE_CONSTANTS .get ('network_interface_name' ),
378
- network = 'VLAN 1001' , # hardcoding network here as these test won't be doing actual provisioning
379
- ),
380
- dict (
381
- nic_type = VMWARE_CONSTANTS .get ('network_interface_name' ),
382
- network = 'VLAN 1001' ,
383
- ),
384
- ],
385
- storage = [
386
- dict (
387
- controller = VMWARE_CONSTANTS .get ('scsicontroller' ),
388
- disks = [
389
- dict (
390
- data_store = data_store_summary_string ,
391
- size = '10 GB' ,
392
- thin_provision = True ,
393
- ),
394
- dict (
395
- data_store = data_store_summary_string ,
396
- size = '20 GB' ,
397
- thin_provision = False ,
398
- eager_zero = False ,
399
- ),
400
- ],
401
- ),
402
- dict (
403
- controller = VMWARE_CONSTANTS .get ('scsicontroller' ),
404
- disks = [
405
- dict (
406
- data_store = data_store_summary_string ,
407
- size = '30 GB' ,
408
- thin_provision = False ,
409
- eager_zero = True ,
410
- )
411
- ],
412
- ),
413
- ],
344
+ else dict (
345
+ nic_type = VMWARE_CONSTANTS .get ('network_interface_name' ),
346
+ network = 'VLAN 1001' , # hardcoding network here as these test won't be doing actual provisioning
347
+ ),
414
348
)
415
349
with session :
416
350
session .computeresource .create (
@@ -424,45 +358,54 @@ def test_positive_access_vmware_with_custom_profile(session, vmware):
424
358
}
425
359
)
426
360
assert session .computeresource .search (cr_name )[0 ]['Name' ] == cr_name
427
- session .computeresource .update_computeprofile (
428
- cr_name ,
429
- COMPUTE_PROFILE_LARGE ,
430
- {f'provider_content.{ key } ' : value for key , value in cr_profile_data .items ()},
431
- )
432
- values = session .computeresource .read_computeprofile (cr_name , COMPUTE_PROFILE_LARGE )
433
- provider_content = values ['provider_content' ]
434
- # assert main compute resource profile data updated successfully.
435
- excluded_keys = ['network_interfaces' , 'storage' ]
436
- expected_value = {
437
- key : value for key , value in cr_profile_data .items () if key not in excluded_keys
438
- }
439
- provided_value = {
440
- key : value for key , value in provider_content .items () if key in expected_value
441
- }
442
- assert provided_value == expected_value
443
- # assert compute resource profile network data updated successfully.
444
- for network_index , expected_network_value in enumerate (
445
- cr_profile_data ['network_interfaces' ]
361
+ for guest_os_name , cprofile , cpu , memory , firmware in zip (
362
+ guest_os_names , compute_profile , cpus , vm_memory , firmware_type , strict = True
446
363
):
447
- provided_network_value = {
448
- key : value
449
- for key , value in provider_content ['network_interfaces' ][network_index ].items ()
450
- if key in expected_network_value
451
- }
452
- assert provided_network_value == expected_network_value
453
- # assert compute resource profile storage data updated successfully.
454
- for controller_index , expected_controller_value in enumerate (cr_profile_data ['storage' ]):
455
- provided_controller_value = provider_content ['storage' ][controller_index ]
456
- assert (
457
- provided_controller_value ['controller' ] == expected_controller_value ['controller' ]
364
+ session .computeresource .update_computeprofile (
365
+ cr_name ,
366
+ cprofile ,
367
+ {
368
+ 'provider_content.guest_os' : guest_os_name ,
369
+ 'provider_content.cpus' : cpu ,
370
+ 'provider_content.memory' : memory ,
371
+ 'provider_content.cluster' : settings .vmware .cluster ,
372
+ 'provider_content.annotation_notes' : annotation_notes ,
373
+ 'provider_content.virtual_hw_version' : virtual_hw_version ,
374
+ 'provider_content.firmware' : firmware ,
375
+ 'provider_content.resource_pool' : resource_pool ,
376
+ 'provider_content.folder' : folder ,
377
+ 'provider_content.memory_hot_add' : memory_hot_add ,
378
+ 'provider_content.cpu_hot_add' : cpu_hot_add ,
379
+ 'provider_content.cdrom_drive' : cdrom_drive ,
380
+ 'provider_content.storage' : [value for value in storage_data .values ()],
381
+ 'provider_content.network_interfaces' : [
382
+ value for value in network_data .values ()
383
+ ],
384
+ },
385
+ )
386
+ values = session .computeresource .read_computeprofile (cr_name , COMPUTE_PROFILE_LARGE )
387
+ assert values ['provider_content' ]['guest_os' ] == guest_os_name
388
+ assert values ['provider_content' ]['cpus' ] == cpus
389
+ assert values ['provider_content' ]['memory' ] == memory
390
+ assert values ['provider_content' ]['cluster' ] == settings .vmware .cluster
391
+ assert values ['provider_content' ]['annotation_notes' ] == annotation_notes
392
+ assert values ['provider_content' ]['virtual_hw_version' ] == virtual_hw_version
393
+ assert values ['provider_content' ]['firmware' ] == firmware
394
+ assert values ['provider_content' ]['resource_pool' ] == resource_pool
395
+ assert values ['provider_content' ]['folder' ] == folder
396
+ assert values ['provider_content' ]['memory_hot_add' ] == memory_hot_add
397
+ assert values ['provider_content' ]['cpu_hot_add' ] == cpu_hot_add
398
+ assert values ['provider_content' ]['cdrom_drive' ] == cdrom_drive
399
+ assert values ['provider_content' ]['storage' ][0 ]['controller' ] == VMWARE_CONSTANTS .get (
400
+ 'scsicontroller'
458
401
)
459
- for disk_index , expected_disk_value in enumerate ( expected_controller_value [ ' disks' ]):
460
- provided_disk_value = {
461
- key : value
462
- for key , value in provided_controller_value [ 'disks' ][ disk_index ]. items ( )
463
- if key in expected_disk_value
464
- }
465
- assert provided_disk_value == expected_disk_value
402
+ assert values [ 'provider_content' ][ 'storage' ][ 0 ][ ' disks' ][ 0 ][ 'size' ] == '10 GB'
403
+ assert values [ 'provider_content' ][ 'network_interfaces' ][ 0 ][
404
+ 'nic_type'
405
+ ] == VMWARE_CONSTANTS . get ( 'network_interface_name' )
406
+ assert values [ 'provider_content' ][ 'network_interfaces' ][ 0 ][ 'network' ] == 'VLAN 1001'
407
+ session . computeresource . delete ( cr_name )
408
+ assert not session . computeresource . search ( cr_name )
466
409
467
410
468
411
@pytest .mark .tier2
0 commit comments