Best Python code snippet using localstack_python
TC_VVOL_DR_Block_SingleFamily_Primary_Snap.py
Source:TC_VVOL_DR_Block_SingleFamily_Primary_Snap.py
1from Framework.io_tool import *2from Framework.test_actions import *3from Framework.threads import *4from Framework.space_accounting_checker import *5from Framework.recovery_and_fsck import *67##############################################################################8# Module Variable9##############################################################################1011testcase_name = 'TC_VVOL_DR_Block_SingleFamily_Primary_Snap'12LOG = ExecuteLog(testcase_name, LOG_LEVEL, testlog)1314##############################################################################15# Test Case Definition16##############################################################################1718@tc_symbol_printer(testcase_name)19def TC_VVOL_DR_Block_SingleFamily_Primary_Snap(storage, io_host, uemcli_host, windows_host, d_testparam, d_storage_object={}):2021 # d_storage_object = {}22 # if setup_env:23 # LOG.print_step('Setup test environment.')24 # d_storage_object = setup_test_environment(storage, io_host, uemcli_host, windows_host, d_testparam)2526 #####27 LOG.print_step('Get the system, storage pool, and datastore.')28 vm_name = d_testparam['VM']['name']2930 if d_storage_object.get('VCENTER_1') is not None:31 vcenter = d_storage_object['VCENTER_1']32 else:33 vcenter_ip = d_testparam['VCENTER_1']['ip']34 vcenter_username = d_testparam['VCENTER_1']['username']35 vcenter_password = d_testparam['VCENTER_1']['password']36 vcenter = VCenter(storage, vcenter_ip, vcenter_username, vcenter_password)3738 system = System(storage)3940 if d_storage_object.get('POOL_1') is not None:41 pool = d_storage_object['POOL_1']42 else:43 pool_name = d_testparam['POOL_1']['name']44 pool = Pool(storage, pool_name)4546 datastores = []47 if d_storage_object.get('VVOL_DATASTORE_2') is not None:48 datastore = d_storage_object['VVOL_DATASTORE_2']49 datastore.get_ds_profile()50 else:51 ds_name = d_testparam['VVOL_DATASTORE_2']['name'] + storage.name52 datastore = Datastore(storage, ds_name)53 datastore.get_ds_profile()54 datastores.append(datastore)5556 ######57 sleep_time = 3005859 block_disk_size = [10, 20, 30, 40]60 block_selected_size = [20]6162 ######63 LOG.print_step('Power off the virtual machine.')64 poweroff_vm(vm_name, windows_host)6566 for ds in datastores:67 ds_name = ds.name68 disk_size = block_disk_size6970 LOG.print_step('Remove hard disks in datastore {}.'.format(ds_name))71 vm_name = d_testparam['VM']['name']72 remove_all_harddisk_in_datastore(vm_name, ds_name, windows_host)7374 LOG.print_step('Remove vvols in datastore {} from storage side.'.format(ds_name))75 ds_id = datastores[0].profile['ID']76 vvols_uuid = VVol.find_vvol_uuid_in_datastore(storage_obj=storage, datastore_id=ds_id)77 for uuid in vvols_uuid:78 remove_vvol(storage, uemcli_host, uuid)7980 LOG.print_step('Create harddisks for virtual machine.')81 storage_policy_1 = 'CompressionAndDedup_New'82 create_harddisk(vm_name, ds_name, storage_policy_1, disk_size, vcenter, windows_host)8384 LOG.print_step('Power on the virtual machine.')85 vm_name = d_testparam['VM']['name']86 poweron_vm(vm_name, windows_host)87 time.sleep(120)8889 #####90 LOG.print_step('Select the primary data vvol, CBFS, pool allocation, datastore, pool and system for test.')9192 d_cbfs_vvol, d_datastore_vvol, \93 test_primary_vvol, test_cbfs, test_poolalloc = \94 collect_vvol_cbfs_poolallocation_from_datastore(storage, datastores, [block_disk_size], [block_selected_size])9596 test_datastore = datastores97 test_pool = [pool]98 test_system = [system]99100 ######101 LOG.print_step('Check test objects for each level.')102103 LOG.print_log('INFO', 'Selected {} VVol in test_primary_vvol:'.format(len(test_primary_vvol)))104 LOG.print_plain_log('INFO', [(vvol.uuid, vvol.profile['Size']) for vvol in test_primary_vvol])105106 LOG.print_log('INFO', 'Selected {} CBFS in test_cbfs:'.format(len(test_cbfs)))107 LOG.print_plain_log('INFO', [obj.identifier for obj in test_cbfs])108109 LOG.print_log('INFO', 'Selected {} Poolallocation in test_poolalloc:'.format(len(test_poolalloc)))110 LOG.print_plain_log('INFO', [obj.identifier for obj in test_poolalloc])111112 LOG.print_log('INFO', 'Selected {} Datastore test_datastore:'.format(len(test_datastore)))113 LOG.print_plain_log('INFO', [obj.identifier for obj in test_datastore])114115 LOG.print_log('INFO', 'Selected {} Pool test_pool:'.format(len(test_pool)))116 LOG.print_plain_log('INFO', [obj.identifier for obj in test_pool])117118 LOG.print_log('INFO', 'Selected {} System test_system:'.format(len(test_system)))119 LOG.print_plain_log('INFO', [obj.identifier for obj in test_system])120121 #####122 LOG.print_step('Check space accounting for related level.')123124 do_assert = True125 # --- VVOL126 d_compare_profile = dict(D1)127 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)128 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)129130 # --- CBFS131 d_compare_profile = dict(D1)132 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.15)133 d_compare_profile['saving'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)134 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \135 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)136137 # --- POOL ALLOCATION138 d_compare_profile = dict(D1)139 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)140 d_compare_profile['saving'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)141 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)142143 # --- DATASTORE144 d_compare_profile = dict(D2)145 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)146 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)147148 # --- POOL149 d_compare_profile = dict(D2)150 d_compare_profile['used'] = compare_profile(values_to_compare=[12], symbols=['>'], deviation=0.1)151 d_compare_profile['saving'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)152 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)153 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['='], deviation=0.1)154 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)155156 pool_last_spaceaccounting = {}157 pool_last_spaceaccounting['used'] = used158 pool_last_spaceaccounting['saving'] = saving159 pool_last_spaceaccounting['saving_percent'] = saving_percent160 pool_last_spaceaccounting['saving_ratio'] = saving_ratio161162 # --- SYSTEM163 d_compare_profile = dict(D2)164 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)165 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)166 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)167 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)168 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)169170 #####171 LOG.print_step('Start IO to the primary data vvol.')172173 origin_file_path = './io_config_file/device_write_50comp_0dedup_read_no_offset_10-20g.vdb'174 updated_file_path = './io_config_file/new_vvol_write_50comp_0dedup_read_no_offset_10-20g.vdb'175 vdbench = VDBench(io_host)176 updated_workload_parameter_file = \177 vdbench.vdbench_prepare_vdb_file_for_device(block_selected_size[0], origin_file_path, updated_file_path)178 vdbench.vdbench_init_and_start_io(updated_workload_parameter_file)179 time.sleep(sleep_time)180181 ######182 LOG.print_step('Check space accounting for related level.')183184 do_assert = True185 # --- VVOL186 d_compare_profile = dict(D1)187 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)188 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)189190 # --- CBFS191 d_compare_profile = dict(D1)192 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)193 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)194 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \195 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)196197 # --- POOL ALLOCATION198 d_compare_profile = dict(D1)199 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)200 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)201 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)202203 # --- DATASTORE204 d_compare_profile = dict(D2)205 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['>'], deviation=0.1)206 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)207208 # --- POOL209 d_compare_profile = dict(D2)210 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5], symbols=['>'], deviation=0.1)211 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)212 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)213 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)214 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)215216 pool_last_spaceaccounting = {}217 pool_last_spaceaccounting['used'] = used218 pool_last_spaceaccounting['saving'] = saving219 pool_last_spaceaccounting['saving_percent'] = saving_percent220 pool_last_spaceaccounting['saving_ratio'] = saving_ratio221222 # --- SYSTEM223 d_compare_profile = dict(D2)224 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)225 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)226 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)227 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)228 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)229230 ######231 LOG.print_step('Take a snapshot for the vm.')232 snapshot_name = 'snap_1'233 snap_vvols = []234 test_snap_vvol = []235236 create_snapshot(vm_name, snapshot_name, windows_host)237 time.sleep(120)238239 fetched = False240 datastore_id = test_datastore[0].profile['ID']241 for vvol_size in block_disk_size:242 vvol_size_b = GB_to_B(vvol_size)243 if not fetched:244 snap_vvol = VVol.find_vvol(storage, datastore_id, vvol_size_b, vvol_type='Data', replica_type='Ready Snap', fetch=True)245 fetched = True246 else:247 snap_vvol = VVol.find_vvol(storage, datastore_id, vvol_size_b, vvol_type='Data', replica_type='Ready Snap', fetch=False)248 snap_vvols.append(snap_vvol)249 if vvol_size == 20:250 test_snap_vvol.append(snap_vvol)251252 ######253 LOG.print_step('Check test objects for each level.')254255 LOG.print_log('INFO', 'Selected {} VVol in test_snap_vvol:'.format(len(test_snap_vvol)))256 LOG.print_plain_log('INFO', [(vvol.uuid, vvol.profile['Size']) for vvol in test_snap_vvol])257258 ######259 LOG.print_step('Check space accounting for related level.')260261 do_assert = True262 # --- VVOL263 d_compare_profile = dict(D1)264 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)265 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)266 used, saving = check_vvol_space(test_snap_vvol, d_compare_profile, do_assert=do_assert)267268 # --- CBFS269 d_compare_profile = dict(D1)270 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)271 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)272 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \273 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)274275 # --- POOL ALLOCATION276 d_compare_profile = dict(D1)277 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)278 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)279 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)280281 # --- DATASTORE282 d_compare_profile = dict(D2)283 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['>'], deviation=0.1)284 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)285286 # --- POOL287 d_compare_profile = dict(D2)288 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5], symbols=['>'], deviation=0.1)289 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)290 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)291 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)292 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)293294 pool_last_spaceaccounting = {}295 pool_last_spaceaccounting['used'] = used296 pool_last_spaceaccounting['saving'] = saving297 pool_last_spaceaccounting['saving_percent'] = saving_percent298 pool_last_spaceaccounting['saving_ratio'] = saving_ratio299300 # --- SYSTEM301 d_compare_profile = dict(D2)302 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)303 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)304 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)305 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)306 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)307308 #####309 LOG.print_step('Start IO to the primary data vvol.')310311 origin_file_path = './io_config_file/device_write_75comp_0dedup_read_no_offset_0-10g.vdb'312 updated_file_path = './io_config_file/updated_vvol_write_75comp_0dedup_read_no_offset_0-10g.vdb'313 vdbench = VDBench(io_host)314 updated_workload_parameter_file = \315 vdbench.vdbench_prepare_vdb_file_for_device(block_selected_size[0], origin_file_path, updated_file_path)316 vdbench.vdbench_init_and_start_io(updated_workload_parameter_file)317 time.sleep(sleep_time)318319 #####320 LOG.print_step('Check space accounting for related level.')321322 do_assert = True323 # --- VVOL324 d_compare_profile = dict(D1)325 d_compare_profile['used'] = compare_profile(values_to_compare=[20], symbols=['='], deviation=0.1)326 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)327328 d_compare_profile = dict(D1)329 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)330 used, saving = check_vvol_space(test_snap_vvol, d_compare_profile, do_assert=do_assert)331332 # --- CBFS333 d_compare_profile = dict(D1)334 d_compare_profile['used'] = compare_profile(values_to_compare=[7.5], symbols=['='], deviation=0.2)335 d_compare_profile['saving'] = compare_profile(values_to_compare=[12.5], symbols=['='], deviation=0.2)336 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \337 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)338339 # --- POOL ALLOCATION340 d_compare_profile = dict(D1)341 d_compare_profile['used'] = compare_profile(values_to_compare=[5 + 2.5], symbols=['='], deviation=0.2)342 d_compare_profile['saving'] = compare_profile(values_to_compare=[5 + 7.5], symbols=['='], deviation=0.2)343 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)344345 # --- DATASTORE346 d_compare_profile = dict(D2)347 d_compare_profile['used'] = compare_profile(values_to_compare=[5 + 2.5], symbols=['>'], deviation=0.1)348 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)349350 # --- POOL351 d_compare_profile = dict(D2)352 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5 + 2.5], symbols=['>'], deviation=0.1)353 d_compare_profile['saving'] = compare_profile(values_to_compare=[5 + 7.5], symbols=['='], deviation=0.2)354 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)355 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)356 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)357358 pool_last_spaceaccounting = {}359 pool_last_spaceaccounting['used'] = used360 pool_last_spaceaccounting['saving'] = saving361 pool_last_spaceaccounting['saving_percent'] = saving_percent362 pool_last_spaceaccounting['saving_ratio'] = saving_ratio363364 # --- SYSTEM365 d_compare_profile = dict(D2)366 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)367 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)368 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)369 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)370 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)371372 ######373 LOG.print_step('Power off the virtual machine.')374 poweroff_vm(vm_name, windows_host)375376 #####377 LOG.print_step('Restore the primary data vvol with the snap vvol.')378 snap_vvol = test_snap_vvol[0]379 snap_vvol.restore_snap_vvol()380 time.sleep(sleep_time)381382 ######383 LOG.print_step('Check space accounting for related level.')384385 do_assert = True386 # --- VVOL387 d_compare_profile = dict(D1)388 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)389 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)390391 d_compare_profile = dict(D1)392 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)393 used, saving = check_vvol_space(test_snap_vvol, d_compare_profile, do_assert=do_assert)394395 # --- CBFS396 d_compare_profile = dict(D1)397 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)398 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)399 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \400 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)401402 # --- POOL ALLOCATION403 d_compare_profile = dict(D1)404 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)405 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)406 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)407408 # --- DATASTORE409 d_compare_profile = dict(D2)410 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['>'], deviation=0.1)411 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)412413 # --- POOL414 d_compare_profile = dict(D2)415 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5], symbols=['>'], deviation=0.1)416 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)417 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)418 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)419 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)420421 pool_last_spaceaccounting = {}422 pool_last_spaceaccounting['used'] = used423 pool_last_spaceaccounting['saving'] = saving424 pool_last_spaceaccounting['saving_percent'] = saving_percent425 pool_last_spaceaccounting['saving_ratio'] = saving_ratio426427 # --- SYSTEM428 d_compare_profile = dict(D2)429 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)430 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)431 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)432 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)433 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)434435 #####436 LOG.print_step('Run FSCK for VVol.')437 vvol_do_recovery(storage, test_primary_vvol, mode='sequential', check_modify='no')438439 #####440 LOG.print_step('Delete the snap for the vm.')441 remove_snapshot(vm_name, snapshot_name, windows_host)442443 ######444 LOG.print_step('Check space accounting for related level.')445446 do_assert = True447 # --- VVOL448 d_compare_profile = dict(D1)449 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)450 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)451452 # --- CBFS453 d_compare_profile = dict(D1)454 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)455 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)456 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \457 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)458459 # --- POOL ALLOCATION460 d_compare_profile = dict(D1)461 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.1)462 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)463 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)464465 # --- DATASTORE466 d_compare_profile = dict(D2)467 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['>'], deviation=0.1)468 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)469470 # --- POOL471 d_compare_profile = dict(D2)472 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5], symbols=['>'], deviation=0.1)473 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)474 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)475 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)476 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)477478 pool_last_spaceaccounting = {}479 pool_last_spaceaccounting['used'] = used480 pool_last_spaceaccounting['saving'] = saving481 pool_last_spaceaccounting['saving_percent'] = saving_percent482 pool_last_spaceaccounting['saving_ratio'] = saving_ratio483484 # --- SYSTEM485 d_compare_profile = dict(D2)486 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)487 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)488 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)489 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)490 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)491492 ######493 LOG.print_step('Remove snapshot for the virtual machine.')494 # snapshot_name = 'snap_1'495 remove_snapshot(vm_name, snapshot_name, windows_host)496497 ######498 LOG.print_step('Power off the virtual machine.')499 poweroff_vm(vm_name, windows_host)500501 for ds in datastores:502 ds_name = ds.name503 LOG.print_step('Remove hard disks in datastore {}...'.format(ds_name))504 remove_all_harddisk_in_datastore(vm_name, ds_name, windows_host)505506 LOG.print_step('Remove vvols in datastore {} from storage side.'.format(ds_name))507 ds_id = datastores[0].profile['ID']508 vvols_uuid = VVol.find_vvol_uuid_in_datastore(storage_obj=storage, datastore_id=ds_id)509 for uuid in vvols_uuid:510 remove_vvol(storage, uemcli_host, uuid)511512if __name__ == '__main__':513 pass
...
TC_VVOL_DR_File_SingleFamily_Primary_Snap.py
Source:TC_VVOL_DR_File_SingleFamily_Primary_Snap.py
1from Framework.io_tool import *2from Framework.test_actions import *3from Framework.threads import *4from Framework.space_accounting_checker import *5from Framework.recovery_and_fsck import *67##############################################################################8# Module Variable9##############################################################################1011testcase_name = 'TC_VVOL_DR_File_SingleFamily_Primary_Snap'12LOG = ExecuteLog(testcase_name, LOG_LEVEL, testlog)1314##############################################################################15# Test Case Definition16##############################################################################1718@tc_symbol_printer(testcase_name)19def TC_VVOL_DR_File_SingleFamily_Primary_Snap(storage, io_host, uemcli_host, windows_host, d_testparam, d_storage_object={}):2021 # d_storage_object = {}22 # if setup_env:23 # LOG.print_step('Setup test environment.')24 # d_storage_object = setup_test_environment(storage, io_host, uemcli_host, windows_host, d_testparam)2526 #####27 LOG.print_step('Get the system, storage pool, and datastore.')28 vm_name = d_testparam['VM']['name']2930 if d_storage_object.get('VCENTER_1') is not None:31 vcenter = d_storage_object['VCENTER_1']32 else:33 vcenter_ip = d_testparam['VCENTER_1']['ip']34 vcenter_username = d_testparam['VCENTER_1']['username']35 vcenter_password = d_testparam['VCENTER_1']['password']36 vcenter = VCenter(storage, vcenter_ip, vcenter_username, vcenter_password)3738 system = System(storage)3940 if d_storage_object.get('POOL_1') is not None:41 pool = d_storage_object['POOL_1']42 else:43 pool_name = d_testparam['POOL_1']['name']44 pool = Pool(storage, pool_name)4546 datastores = []47 if d_storage_object.get('VVOL_DATASTORE_4') is not None:48 datastore = d_storage_object['VVOL_DATASTORE_4']49 datastore.get_ds_profile()50 else:51 ds_name = d_testparam['VVOL_DATASTORE_4']['name'] + storage.name52 datastore = Datastore(storage, ds_name)53 datastore.get_ds_profile()54 datastores.append(datastore)5556 block_disk_size = [10, 20, 30, 40]57 block_selected_size = [20]58 file_disk_size = [10, 20, 30, 40]59 file_selected_size = [20]6061 ######62 LOG.print_step('Power off the virtual machine.')63 poweroff_vm(vm_name, windows_host)6465 for ds in datastores:66 ds_name = ds.name67 if ds_name.startswith('Block'):68 disk_size = block_disk_size69 elif ds_name.startswith('File'):70 disk_size = file_disk_size7172 LOG.print_step('Remove hard disks on datastore.')73 vm_name = d_testparam['VM']['name']74 remove_all_harddisk_in_datastore(vm_name, ds_name, windows_host)7576 LOG.print_step('Create harddisks for virtual machine.')77 storage_policy_1 = 'CompressionAndDedup_New'78 create_harddisk(vm_name, ds_name, storage_policy_1, disk_size, vcenter, windows_host)7980 LOG.print_step('Power on the virtual machine.')81 vm_name = d_testparam['VM']['name']82 poweron_vm(vm_name, windows_host)83 time.sleep(30)8485 #####86 LOG.print_step('Select the primary data vvol, CBFS, pool allocation, datastore, pool and system for test.')8788 d_cbfs_vvol, d_datastore_vvol, \89 test_primary_vvol, test_cbfs, test_poolalloc = \90 collect_vvol_cbfs_poolallocation_from_datastore(storage, datastores, [file_disk_size], [file_selected_size])9192 test_datastore = datastores93 test_pool = [pool]94 test_system = [system]9596 ######97 LOG.print_step('Check test objects for each level.')9899 LOG.print_log('INFO', 'Selected {} VVol in test_primary_vvol:'.format(len(test_primary_vvol)))100 LOG.print_plain_log('INFO', [(vvol.uuid, vvol.profile['Size']) for vvol in test_primary_vvol])101102 LOG.print_log('INFO', 'Selected {} CBFS in test_cbfs:'.format(len(test_cbfs)))103 LOG.print_plain_log('INFO', [obj.identifier for obj in test_cbfs])104105 LOG.print_log('INFO', 'Selected {} Poolallocation in test_poolalloc:'.format(len(test_poolalloc)))106 LOG.print_plain_log('INFO', [obj.identifier for obj in test_poolalloc])107108 LOG.print_log('INFO', 'Selected {} Datastore test_datastore:'.format(len(test_datastore)))109 LOG.print_plain_log('INFO', [obj.identifier for obj in test_datastore])110111 LOG.print_log('INFO', 'Selected {} Pool test_pool:'.format(len(test_pool)))112 LOG.print_plain_log('INFO', [obj.identifier for obj in test_pool])113114 LOG.print_log('INFO', 'Selected {} System test_system:'.format(len(test_system)))115 LOG.print_plain_log('INFO', [obj.identifier for obj in test_system])116117 #####118 LOG.print_step('Check space accounting for related level.')119120 do_assert = True121 # --- VVOL122 d_compare_profile = dict(D1)123 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)124 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)125126 # --- CBFS127 d_compare_profile = dict(D1)128 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.15)129 d_compare_profile['saving'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)130 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \131 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)132133 # --- POOL ALLOCATION134 d_compare_profile = dict(D1)135 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)136 d_compare_profile['saving'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)137 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)138139 # --- DATASTORE140 d_compare_profile = dict(D2)141 d_compare_profile['used'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)142 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)143144 # --- POOL145 d_compare_profile = dict(D2)146 d_compare_profile['used'] = compare_profile(values_to_compare=[12], symbols=['>'], deviation=0.1)147 d_compare_profile['saving'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)148 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['='], deviation=0.1)149 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['='], deviation=0.1)150 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)151152 pool_last_spaceaccounting = {}153 pool_last_spaceaccounting['used'] = used154 pool_last_spaceaccounting['saving'] = saving155 pool_last_spaceaccounting['saving_percent'] = saving_percent156 pool_last_spaceaccounting['saving_ratio'] = saving_ratio157158 # --- SYSTEM159 d_compare_profile = dict(D2)160 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)161 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)162 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)163 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)164 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)165166 #####167 LOG.print_step('Start IO to the primary data vvol.')168169 origin_file_path = './io_config_file/device_write_50comp_0dedup_read_no_offset_10-20g.vdb'170 updated_file_path = './io_config_file/new_vvol_write_50comp_0dedup_read_no_offset_10-20g.vdb'171 vdbench = VDBench(io_host)172 updated_workload_parameter_file = \173 vdbench.vdbench_prepare_vdb_file_for_device(file_selected_size[0], origin_file_path, updated_file_path)174 vdbench.vdbench_init_and_start_io(updated_workload_parameter_file)175 time.sleep(120)176177 ######178 LOG.print_step('Check space accounting for related level.')179180 do_assert = True181 # --- VVOL182 d_compare_profile = dict(D1)183 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)184 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)185186 # --- CBFS187 d_compare_profile = dict(D1)188 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)189 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)190 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \191 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)192193 # --- POOL ALLOCATION194 d_compare_profile = dict(D1)195 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)196 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)197 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)198199 # --- DATASTORE200 d_compare_profile = dict(D2)201 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['>'], deviation=0.1)202 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)203204 # --- POOL205 d_compare_profile = dict(D2)206 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5], symbols=['>'], deviation=0.1)207 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)208 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)209 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)210 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)211212 pool_last_spaceaccounting = {}213 pool_last_spaceaccounting['used'] = used214 pool_last_spaceaccounting['saving'] = saving215 pool_last_spaceaccounting['saving_percent'] = saving_percent216 pool_last_spaceaccounting['saving_ratio'] = saving_ratio217218 # --- SYSTEM219 d_compare_profile = dict(D2)220 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)221 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)222 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)223 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)224 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)225226 ######227 LOG.print_step('Take a snapshot for the vm.')228 snapshot_name = 'snap_1'229 snap_vvols = []230 test_snap_vvol = []231232 create_snapshot(vm_name, snapshot_name, windows_host)233 time.sleep(5)234235 fetched = False236 datastore_id = test_datastore[0].profile['ID']237 for vvol_size in block_disk_size:238 vvol_size_b = GB_to_B(vvol_size)239 if not fetched:240 snap_vvol = VVol.find_vvol(storage, datastore_id, vvol_size_b, vvol_type='Data', replica_type='Ready Snap', fetch=True)241 fetched = True242 else:243 snap_vvol = VVol.find_vvol(storage, datastore_id, vvol_size_b, vvol_type='Data', replica_type='Ready Snap', fetch=False)244 snap_vvols.append(snap_vvol)245 if vvol_size == 20:246 test_snap_vvol.append(snap_vvol)247 # snap_vvol.get_vvol_profile()248 # snap_vvol.get_vvol_mlucli_profile()249250 ######251 LOG.print_step('Check test objects for each level.')252253 LOG.print_log('INFO', 'Selected {} VVol in test_snap_vvol:'.format(len(test_snap_vvol)))254 LOG.print_plain_log('INFO', [(vvol.uuid, vvol.profile['Size']) for vvol in test_snap_vvol])255256 ######257 LOG.print_step('Check space accounting for related level.')258259 do_assert = True260 # --- VVOL261 d_compare_profile = dict(D1)262 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)263 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)264 used, saving = check_vvol_space(test_snap_vvol, d_compare_profile, do_assert=do_assert)265266 # --- CBFS267 d_compare_profile = dict(D1)268 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)269 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)270 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \271 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)272273 # --- POOL ALLOCATION274 d_compare_profile = dict(D1)275 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)276 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)277 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)278279 # --- DATASTORE280 d_compare_profile = dict(D2)281 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['>'], deviation=0.1)282 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)283284 # --- POOL285 d_compare_profile = dict(D2)286 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5], symbols=['>'], deviation=0.1)287 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)288 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)289 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)290 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)291292 pool_last_spaceaccounting = {}293 pool_last_spaceaccounting['used'] = used294 pool_last_spaceaccounting['saving'] = saving295 pool_last_spaceaccounting['saving_percent'] = saving_percent296 pool_last_spaceaccounting['saving_ratio'] = saving_ratio297298 # --- SYSTEM299 d_compare_profile = dict(D2)300 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)301 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)302 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)303 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)304 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)305306 #####307 LOG.print_step('Start IO to the primary data vvol.')308309 origin_file_path = './io_config_file/device_write_75comp_0dedup_read_no_offset_0-10g.vdb'310 updated_file_path = './io_config_file/updated_vvol_write_75comp_0dedup_read_no_offset_0-10g.vdb'311 vdbench = VDBench(io_host)312 updated_workload_parameter_file = \313 vdbench.vdbench_prepare_vdb_file_for_device(file_selected_size[0], origin_file_path, updated_file_path)314 vdbench.vdbench_init_and_start_io(updated_workload_parameter_file)315 time.sleep(120)316317 #####318 LOG.print_step('Check space accounting for related level.')319320 do_assert = True321 # --- VVOL322 d_compare_profile = dict(D1)323 d_compare_profile['used'] = compare_profile(values_to_compare=[20], symbols=['='], deviation=0.1)324 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)325326 d_compare_profile = dict(D1)327 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)328 used, saving = check_vvol_space(test_snap_vvol, d_compare_profile, do_assert=do_assert)329330 # --- CBFS331 d_compare_profile = dict(D1)332 d_compare_profile['used'] = compare_profile(values_to_compare=[7.5], symbols=['='], deviation=0.2)333 d_compare_profile['saving'] = compare_profile(values_to_compare=[12.5], symbols=['='], deviation=0.2)334 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \335 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)336337 # --- POOL ALLOCATION338 d_compare_profile = dict(D1)339 d_compare_profile['used'] = compare_profile(values_to_compare=[5 + 2.5], symbols=['='], deviation=0.2)340 d_compare_profile['saving'] = compare_profile(values_to_compare=[5 + 7.5], symbols=['='], deviation=0.2)341 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)342343 # --- DATASTORE344 d_compare_profile = dict(D2)345 d_compare_profile['used'] = compare_profile(values_to_compare=[5 + 2.5], symbols=['>'], deviation=0.1)346 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)347348 # --- POOL349 d_compare_profile = dict(D2)350 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5 + 2.5], symbols=['>'], deviation=0.1)351 d_compare_profile['saving'] = compare_profile(values_to_compare=[5 + 7.5], symbols=['='], deviation=0.2)352 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)353 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)354 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)355356 pool_last_spaceaccounting = {}357 pool_last_spaceaccounting['used'] = used358 pool_last_spaceaccounting['saving'] = saving359 pool_last_spaceaccounting['saving_percent'] = saving_percent360 pool_last_spaceaccounting['saving_ratio'] = saving_ratio361362 # --- SYSTEM363 d_compare_profile = dict(D2)364 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)365 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)366 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)367 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)368 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)369370 ######371 LOG.print_step('Power off the virtual machine.')372 poweroff_vm(vm_name, windows_host)373374 #####375 LOG.print_step('Restore the primary data vvol with the snap vvol.')376 snap_vvol = test_snap_vvol[0]377 snap_vvol.restore_snap_vvol()378379 ######380 LOG.print_step('Check space accounting for related level.')381382 do_assert = True383 # --- VVOL384 d_compare_profile = dict(D1)385 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)386 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)387388 d_compare_profile = dict(D1)389 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)390 used, saving = check_vvol_space(test_snap_vvol, d_compare_profile, do_assert=do_assert)391392 # --- CBFS393 d_compare_profile = dict(D1)394 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)395 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)396 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \397 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)398399 # --- POOL ALLOCATION400 d_compare_profile = dict(D1)401 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)402 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)403 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)404405 # --- DATASTORE406 d_compare_profile = dict(D2)407 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['>'], deviation=0.1)408 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)409410 # --- POOL411 d_compare_profile = dict(D2)412 d_compare_profile['used'] = compare_profile(values_to_compare=[12 + 5], symbols=['>'], deviation=0.1)413 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)414 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)415 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)416 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)417418 pool_last_spaceaccounting = {}419 pool_last_spaceaccounting['used'] = used420 pool_last_spaceaccounting['saving'] = saving421 pool_last_spaceaccounting['saving_percent'] = saving_percent422 pool_last_spaceaccounting['saving_ratio'] = saving_ratio423424 # --- SYSTEM425 d_compare_profile = dict(D2)426 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)427 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)428 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)429 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)430 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)431432 #####433 LOG.print_step('Run FSCK for VVol.')434 vvol_do_recovery(storage, test_primary_vvol, mode='sequential', check_modify='no')435436 #####437 LOG.print_step('Delete the snap for the vm.')438 remove_snapshot(vm_name, snapshot_name, windows_host)439440 ######441 LOG.print_step('Check space accounting for related level.')442443 do_assert = True444 # --- VVOL445 d_compare_profile = dict(D1)446 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)447 used, saving = check_vvol_space(test_primary_vvol, d_compare_profile, do_assert=do_assert)448449 # --- CBFS450 d_compare_profile = dict(D1)451 d_compare_profile['used'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)452 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)453 used, saving, nAUsNeededIfNoCompression, nPatternZeroMatched, nPatternNonZeroMatched, nDedupMappingPointers = \454 check_cbfs_space(test_cbfs, d_compare_profile, do_assert=do_assert)455456 # --- POOL ALLOCATION457 d_compare_profile = dict(D1)458 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['='], deviation=0.1)459 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)460 used, saving = check_poolalloc_space(test_poolalloc, d_compare_profile, do_assert=do_assert)461462 # --- DATASTORE463 d_compare_profile = dict(D2)464 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['>'], deviation=0.1)465 used, saving, saving_percent, saving_ratio = check_datastore_space(test_datastore, d_compare_profile, do_assert=do_assert)466467 # --- POOL468 d_compare_profile = dict(D2)469 d_compare_profile['used'] = compare_profile(values_to_compare=[10], symbols=['>'], deviation=0.1)470 d_compare_profile['saving'] = compare_profile(values_to_compare=[5], symbols=['='], deviation=0.2)471 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=[0], symbols=['>'], deviation=0.1)472 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=[1], symbols=['>'], deviation=0.1)473 used, saving, saving_percent, saving_ratio = check_pool_space(test_pool, d_compare_profile, do_assert=do_assert)474475 pool_last_spaceaccounting = {}476 pool_last_spaceaccounting['used'] = used477 pool_last_spaceaccounting['saving'] = saving478 pool_last_spaceaccounting['saving_percent'] = saving_percent479 pool_last_spaceaccounting['saving_ratio'] = saving_ratio480481 # --- SYSTEM482 d_compare_profile = dict(D2)483 d_compare_profile['used'] = compare_profile(values_to_compare=used, symbols=['='], deviation=0.1)484 d_compare_profile['saving'] = compare_profile(values_to_compare=saving, symbols=['='], deviation=0.1)485 d_compare_profile['saving_percent'] = compare_profile(values_to_compare=saving_percent, symbols=['='], deviation=0.1)486 d_compare_profile['saving_ratio'] = compare_profile(values_to_compare=saving_ratio, symbols=['='], deviation=0.1)487 used, saving, saving_percent, saving_ratio = check_system_space(test_system, d_compare_profile, do_assert=do_assert)488489 # ######490 # LOG.print_step('Power off the virtual machine.')491 # snapshot_name = 'snap_1'492 # remove_snapshot(vm_name, snapshot_name, windows_host)493 #494 # ######495 # LOG.print_step('Power off the virtual machine.')496 # poweroff_vm(vm_name, windows_host)497 #498 # for ds in datastores:499 # ds_name = ds.name500 # LOG.print_step('Remove hard disks in datastore {}...'.format(ds_name))501 # remove_all_harddisk_in_datastore(vm_name, ds_name, windows_host)502503504if __name__ == '__main__':505 pass
...
test_euler_estimator.py
Source:test_euler_estimator.py
...19 },20 point=(0, {'1': 0, '2': 0, '3': 0})21)2223do_assert("point", euler.point,24 (0, {'1': 0, '2': 0, '3': 0}))25do_assert("calc derivative", euler.calc_derivative_at_point(),26 {'1': 1, '2': 0, '3': 0})2728euler.step_forward(0.1)29do_assert("step forward", euler.point,30 (0.1, {'1': 0.1, '2': 0, '3': 0}))3132do_assert("new derivative", euler.calc_derivative_at_point(),33 {'1': 1.1, '2': 0.1, '3': 0})34euler.step_forward(-0.5)35do_assert("step forward 2", euler.point,36 (-0.4, {'1': -0.45, '2': -0.05, '3': 0}))3738euler.go_to_input(5, step_size=2)3940# notes to help you debug:4142# point: (-0.4, (-0.45, -0.05, 0))43# derivative: (0.55, -0.5, -0.1)44# deltas: (2, (1.1, -1, -0.2))4546# point: (1.6, (0.65, -1.05, -0.2))47# derivative: (1.65, -0.4, -2.1)48# deltas: (2, (3.3, -0.8, 4.2))4950# point: (3.6, (3.95, -1.85, 4))51# derivative: (4.95, 2.1, -3.7)52# deltas: (1.4, (9.8, 4.2, -7.4))5354do_assert("go to input", euler.point[1],55 {'1': 10.88, '2': 1.09, '3': -9.58})5657euler.plot([-5, 5], step_size=0.1, filename='plot.png')58
...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!