def test_05_license_check_compute(self): reporting.add_test_script(str(__name__) + "_check_compute") try: #Create license using CLI command self.cmd = command_argument_string.license_create + tvaultconf.compute_license_filename rc = cli_parser.cli_returncode(self.cmd) if rc != 0: reporting.add_test_step("Apply 10 compute node license", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Apply 10 compute node license", tvaultconf.PASS) #Verify license-check CLI command self.cmd = command_argument_string.license_check rc = cli_parser.cli_returncode(self.cmd) if rc != 0: reporting.add_test_step("Execute license-check command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Execute license-check command", tvaultconf.PASS) #Verification out = cli_parser.cli_output(self.cmd) LOG.debug("CLI Response: " + str(out)) if(str(out).find('Number of compute nodes deployed \'' + str(tvaultconf.no_of_compute_nodes) + '\'') != -1): reporting.add_test_step("License-check verification", tvaultconf.PASS) else: reporting.add_test_step("License-check verification", tvaultconf.FAIL) raise Exception("License-check verification failed") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_4_config_workload_configure_invalid_user(self): reporting.add_test_script(str(__name__) + "_invalid_user") try: # remove sudo access from config_user self.sudo_access_config_user(access=False) # for config backup configuration, yaml_file creation self.create_config_backup_yaml() # config backup configuration with CLI command config_workload_command = command_argument_string.config_workload_configure + " --config-file yaml_file.yaml --authorized-key config_backup_pvk " LOG.debug("config workload configure cli command: " + str(config_workload_command)) rc = cli_parser.cli_returncode(config_workload_command) if rc != 0: reporting.add_test_step( "Triggering config_workload_configure command via CLI", tvaultconf.PASS) LOG.debug("Command executed correctly") else: reporting.add_test_step( "Triggering config_workload_configure command via CLI", tvaultconf.FAIL) LOG.debug("Command executed incorrectly") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_3_config_backup_show(self): global config_backup_id reporting.add_test_script(str(__name__) + "_config_backup_show: cli") try: # test config_backup_show config_backup_show_command = command_argument_string.config_backup_show + " " + str( config_backup_id) LOG.debug("config backup show cli command: " + str(config_backup_show_command)) rc = cli_parser.cli_returncode(config_backup_show_command) if rc != 0: reporting.add_test_step( "Triggering config_backup_show command via CLI", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step( "Triggering config_backup_show command via CLI", tvaultconf.PASS) LOG.debug("Command executed correctly") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_01_expired_license(self): reporting.add_test_script(str(__name__) + "_expired_license") try: #Create license using CLI command self.cmd = command_argument_string.license_create + tvaultconf.expired_license_filename LOG.debug("License create command: " + str(self.cmd)) rc = cli_parser.cli_returncode(self.cmd) LOG.debug("rc value: " + str(rc)) if rc != 0: reporting.add_test_step( "Execute license_create command with expired license", tvaultconf.FAIL) raise Exception("Command not executed correctly") else: reporting.add_test_step( "Execute license_create command with expired license", tvaultconf.PASS) LOG.debug("Command executed correctly") out = self.get_license_check() LOG.debug("license-check API output: " + str(out)) if (str(out).find('License expired') != -1): reporting.add_test_step("Verify license expiration message", tvaultconf.PASS) else: reporting.add_test_step("Verify license expiration message", tvaultconf.FAIL) raise Exception( "Incorrect license expiration message displayed") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_02_invalid_license(self): reporting.add_test_script(str(__name__)+"_invalid_license") try: #Create license using CLI command self.cmd = command_argument_string.license_create + tvaultconf.invalid_license_filename LOG.debug("License create command: " + str(self.cmd)) rc = cli_parser.cli_returncode(self.cmd) if rc != 0: reporting.add_test_step("Execute license_create command with invalid license", tvaultconf.PASS) LOG.debug("Command executed correctly") else: reporting.add_test_step("Execute license_create command with invalid license", tvaultconf.FAIL) raise Exception("Command not executed correctly") self.license_txt = "" #Get license key content with open(tvaultconf.invalid_license_filename) as f: for line in f: self.license_txt += line LOG.debug("License text: " + str(self.license_txt)) out = self.create_license(tvaultconf.invalid_license_filename, self.license_txt) LOG.debug("license-create API output: " + str(out)) if(str(out).find('Cannot verify the license signature') != -1): reporting.add_test_step("Verify error message", tvaultconf.PASS) else: reporting.add_test_step("Verify error message", tvaultconf.FAIL) raise Exception("Incorrect error message displayed") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_2_umount_snapshot(self): reporting.add_test_script(str(__name__) + "_umount_snapshot") try: global instances_ids global snapshot_ids global wid global security_group_id global volumes_ids global fvm_id global floating_ips_list instances_ids = instances_ids snapshot_ids = snapshot_ids wid = wid volumes_ids = volumes_ids security_group_id = security_group_id fvm_id = fvm_id unmount_snapshot_id = snapshot_ids[0] floating_ips_list = floating_ips_list LOG.debug("unmount snapshot") is_unmounted = self.unmount_snapshot(wid, unmount_snapshot_id) LOG.debug("VALUE OF is_unmounted: " + str(is_unmounted)) if is_unmounted == True: LOG.debug("unmount snapshot with full snapshot is successful") reporting.add_test_step( "Verification of unmount snapshot with full snapshot", tvaultconf.PASS) else: LOG.debug( "unmount snapshot with full snapshot is unsuccessful") reporting.add_test_step( "Verification of unmount snapshot with full snapshot", tvaultconf.FAIL) raise Exception( "Snapshot unmount with full_snapshot does not execute correctly" ) LOG.debug("validate that snapshot is unmounted from FVM") ssh = self.SshRemoteMachineConnectionWithRSAKey( str(floating_ips_list[1]), CONF.compute.fvm_ssh_user) output_list = self.validate_snapshot_mount(ssh) ssh.close() if output_list == '': LOG.debug("Unmounting successful") reporting.add_test_step("Unmounting of a full snapshot", tvaultconf.PASS) else: LOG.debug("Unmounting unsuccessful") reporting.add_test_step("Unmounting of a full snapshot", tvaultconf.FAIL) raise Exception("Unmouting of a snapshot failed") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_3_snapshot_mount_incremental(self): reporting.add_test_script(str(__name__) + "_incremental_snasphot") try: global instances_ids global snapshot_ids global wid global security_group_id global volumes_ids global fvm_id global floating_ips_list instances_ids = self.instances_ids snapshot_ids = self.snapshot_ids wid = self.wid volumes_ids = self.volumes_ids security_group_id = self.security_group_id fvm_id = self.fvm_id incremental_snapshot_id = snapshot_ids[1] floating_ips_list = self.floating_ips_list LOG.debug("mount incremental snapshot") is_mounted = self.mount_snapshot(wid, incremental_snapshot_id, fvm_id) LOG.debug("VALUE OF is_mounted: " + str(is_mounted)) if is_mounted == True: LOG.debug(" mount snapshot with incremental snapshot is successful") reporting.add_test_step("Verification of mount snapshot with incremental snapshot", tvaultconf.PASS) reporting.test_case_to_write() else: LOG.debug("mount snapshot with incremental snapshot is unsuccessful") reporting.add_test_step("Verification of mount snapshot with incremental snapshot", tvaultconf.FAIL) raise Exception ("Snapshot mount with incremental_snapshot does not execute correctly") LOG.debug("validate that snapshot is mounted on FVM") ssh = self.SshRemoteMachineConnectionWithRSAKey(str(floating_ips_list[1])) output_list = self.validate_snapshot_mount(ssh) ssh.close() for i in output_list: if '/home/ubuntu/mount_data_b' in i: LOG.debug("connect to fvm and check mountpoint is mounted on FVM instance for incremntal snapshot") reporting.add_test_step("Verify that mountpoint mounted is shown on FVM instance", tvaultconf.PASS) reporting.test_case_to_write() else: LOG.debug("mount snapshot with incremental snapshot is unsuccessful on FVM") reporting.add_test_step("Verify that mountpoint mounted is shown on FVM instance", tvaultconf.FAIL) raise Exception ("mountpoint is not showing on FVM instance") if 'File_1.txt' in i: LOG.debug("check that file is exist on mounted snapshot") reporting.add_test_step("Verification of file exist on moutned snapshot", tvaultconf.PASS) reporting.test_case_to_write() else: LOG.debug("file does not found on FVM instacne") reporting.add_test_step("Verification of file exist on moutned snapshot") raise Exception ("file does not found on FVM instacne") except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_2_filesearch_snapshotids(self): reporting.add_test_script(str(__name__) + "_snapshotids") try: global instances_ids global snapshot_ids global date_from global date_to global wid global security_group_id global volumes_ids LOG.debug("gloabal parameters: {0} {1} {2} {3} {4} {5} {6}".format( str(instances_ids), str(snapshot_ids), str(date_from), str(date_to), str(wid), str(volumes_ids), str(security_group_id))) # Run Filesearch on vm-1 with snapshot IDs vmid_to_search = instances_ids[0] filepath_to_search = "/File_1.txt" snapshot_ids_tosearch = snapshot_ids[2] filecount_in_snapshots = { snapshot_ids[0]: 0, snapshot_ids[1]: 0, snapshot_ids[2]: 0, snapshot_ids[3]: 1 } filesearch_id = self.filepath_search(vmid_to_search, filepath_to_search, snapshot_ids_tosearch) snapshot_wise_filecount = self.verifyFilepath_Search( filesearch_id, filepath_to_search) for snapshot_id in snapshot_wise_filecount.keys(): if filecount_in_snapshots[ snapshot_id] == snapshot_wise_filecount[ snapshot_id] and snapshot_id in snapshot_ids[2]: filesearch_status = True else: filesearch_status = False LOG.debug("Filepath Search with snapshotids unsuccessful") reporting.add_test_step( "Verification of Filepath serach with snapshotids", tvaultconf.FAIL) raise Exception( "Filesearch with snapshotids does not execute correctly" ) if filesearch_status == True: LOG.debug("Filepath_Search with snapshotids successful") reporting.add_test_step( "Verification of Filepath serach with snapshotids", tvaultconf.PASS) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_1_create_full_snapshot(self): try: reporting.add_test_script(str(__name__) + "_create_full_snapshot") global vm_id global volume_id global workload_id global snapshot_id workload_id = self.wid vm_id = self.vm_id volume_id = self.volume_id LOG.debug("workload is:" + str(workload_id)) LOG.debug("vm id: " + str(vm_id)) LOG.debug("volume id: " + str(volume_id)) self.created = False # Create snapshot with CLI command create_snapshot = command_argument_string.snapshot_create + workload_id LOG.debug("Create snapshot command: " + str(create_snapshot)) rc = cli_parser.cli_returncode(create_snapshot) if rc != 0: reporting.add_test_step( "Execute workload-snapshot command with --full", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step( "Execute workload-snapshot command with --full", tvaultconf.PASS) LOG.debug("Command executed correctly") snapshot_id = query_data.get_inprogress_snapshot_id(workload_id) LOG.debug("Snapshot ID: " + str(snapshot_id)) wc = self.wait_for_snapshot_tobe_available(workload_id, snapshot_id) if (str(wc) == "available"): reporting.add_test_step("Full snapshot", tvaultconf.PASS) LOG.debug("Workload snapshot successfully completed") self.created = True else: if (str(wc) == "error"): pass if (self.created == False): reporting.add_test_step("Full snapshot", tvaultconf.FAIL) raise Exception("Workload snapshot did not get created") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_workload_reassign(self): try: ### Create vm and workload ### reporting.add_test_script(str(__name__)) self.created = False vm_id = self.create_vm(vm_cleanup=True) LOG.debug("\nVm id : {}\n".format(str(vm_id))) vmdetails = self.get_vm_details(vm_id) workload_id = self.workload_create([vm_id], tvaultconf.parallel, workload_cleanup=True) LOG.debug("Workload ID: " + str(workload_id)) if (workload_id != None): self.wait_for_workload_tobe_available(workload_id) if (self.getWorkloadStatus(workload_id) == "available"): reporting.add_test_step("Create workload", tvaultconf.PASS) else: reporting.add_test_step("Create workload", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) else: reporting.add_test_step("Create workload", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) tenant_id = CONF.identity.tenant_id tenant_id_1 = CONF.identity.tenant_id_1 user_id = CONF.identity.user_id user_id_1 = CONF.identity.user_id_1 rc = self.workload_reassign(tenant_id_1, workload_id, user_id_1) if rc == 0: LOG.debug("Workload reassign from tenant 1 to tenant 2 passed") reporting.add_test_step("Workload reassign from tenant 1 to 2", tvaultconf.PASS) else: LOG.error("Workload reassign from tenant 1 to 2 failed") reporting.add_test_step("Workload reassign from tenant 1 to 2", tvaultconf.FAIL) rc = self.workload_reassign(tenant_id, workload_id, user_id) if rc == 0: LOG.debug("Workload reassign from tenant 2 to tenant 1 passed") reporting.add_test_step("Workload reassign from tenant 2 to 1", tvaultconf.PASS) else: LOG.error("Workload reassign from tenant 2 to 1 failed") reporting.add_test_step("Workload reassign from tenant 2 to 1", tvaultconf.FAIL) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_retention(self): try: vm_id = self.create_vm( vm_cleanup=True) LOG.debug("VM ID : "+str(vm_id)) reporting.add_test_script(str(__name__)+ "_create_workload" + time.strftime("%H%M%S")) i = 1 jobschedule = {'retention_policy_type': 'Number of Snapshots to Keep', 'retention_policy_value': '3', 'full_backup_interval': '2'} rpv = int(jobschedule['retention_policy_value']) workload_id=self.workload_create([vm_id],tvaultconf.parallel,jobschedule=jobschedule,workload_cleanup=True) LOG.debug("Workload ID: " + str(workload_id)) if(workload_id != None): self.wait_for_workload_tobe_available(workload_id) if(self.getWorkloadStatus(workload_id) == "available"): reporting.add_test_step("Create workload", tvaultconf.PASS) else: reporting.add_test_step("Create workload", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) else: reporting.add_test_step("Create workload", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("Workload creation failed") for i in range(0, (rpv+1)): snapshot_id=self.workload_snapshot(workload_id, True, snapshot_cleanup=False) self.wait_for_workload_tobe_available(workload_id) if(self.getSnapshotStatus(workload_id, snapshot_id) == "available"): reporting.add_test_step("Create full snapshot-{}".format(i+1), tvaultconf.PASS) LOG.debug("Full snapshot available!!") else: reporting.add_test_step("Create full snapshot-{}".format(i+1), tvaultconf.FAIL) raise Exception("Snapshot creation failed") snapshotlist = self.getSnapshotList(workload_id=workload_id) if len(snapshotlist) == rpv: reporting.add_test_step("Retention", tvaultconf.PASS) LOG.debug("Retention worked!!") else: reporting.add_test_step("Retention", tvaultconf.FAIL) LOG.debug("Retention didn't work!!") raise Exception("Retention failed") if (tvaultconf.cleanup == True): for snapshot in snapshotlist: self.addCleanup(self.snapshot_delete,workload_id, snapshot) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_2_regression(self): reporting.add_test_script(str(__name__) + "_nested_security") try: if self.exception != "": LOG.debug("pre req failed") reporting.add_test_step(str(self.exception), tvaultconf.FAIL) raise Exception(str(self.exception)) LOG.debug("pre req completed") except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_2_create_incremental_snapshot(self): try: reporting.add_test_script( str(__name__) + "_create_incremental_snapshot") global workload_id self.created = False LOG.debug("workload is:" + str(workload_id)) # Create incremental snapshot using CLI command create_snapshot = command_argument_string.incr_snapshot_create + workload_id LOG.debug("Create snapshot command: " + str(create_snapshot)) rc = cli_parser.cli_returncode(create_snapshot) if rc != 0: reporting.add_test_step("Execute workload-snapshot command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Execute workload-snapshot command", tvaultconf.PASS) LOG.debug("Command executed correctly") self.incr_snapshot_id = query_data.get_inprogress_snapshot_id( workload_id) LOG.debug("Incremental Snapshot ID: " + str(self.incr_snapshot_id)) # Wait for incremental snapshot to complete wc = self.wait_for_snapshot_tobe_available(workload_id, self.incr_snapshot_id) if (str(wc) == "available"): reporting.add_test_step("Incremental snapshot", tvaultconf.PASS) LOG.debug( "Workload incremental snapshot successfully completed") self.created = True if (self.created == False): reporting.add_test_step("Incremental snapshot", tvaultconf.FAIL) raise Exception( "Workload incremental snapshot did not get created") # Cleanup # Delete snapshot self.snapshot_delete(workload_id, self.incr_snapshot_id) LOG.debug("Incremental Snapshot deleted successfully") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_4_delete_snapshot(self): try: global workload_id global snapshot_id global volume_id global vm_id reporting.add_test_script(str(__name__) + "_delete_snapshot") # Delete snapshot using CLI command rc = cli_parser.cli_returncode( command_argument_string.snapshot_delete + snapshot_id) if rc != 0: reporting.add_test_step("Execute snapshot-delete command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Execute snapshot-delete command", tvaultconf.PASS) LOG.debug("Command executed correctly") time.sleep(5) wc = query_data.get_workload_snapshot_delete_status( tvaultconf.snapshot_name, tvaultconf.snapshot_type_full, snapshot_id) LOG.debug("Snapshot Delete status: " + str(wc)) if (str(wc) == "1"): reporting.add_test_step("Verification", tvaultconf.PASS) LOG.debug("Workload snapshot successfully deleted") else: reporting.add_test_step("Verification", tvaultconf.FAIL) raise Exception("Snapshot did not get deleted") # Cleanup # Delete volume self.volume_snapshots = self.get_available_volume_snapshots() self.delete_volume_snapshots(self.volume_snapshots) # Delete workload self.workload_delete(workload_id) # Delete vm self.delete_vm(vm_id) # Delete volume self.delete_volume(volume_id) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_5_filesearch_daterange(self): reporting.add_test_script(str(__name__) + "_daterange") try: global instances_ids global snapshot_ids global date_from global date_to # Run Filesearch on vm-1 with latest snapshots vmid_to_search = instances_ids[0] filepath_to_search = "/File_1.txt" snapshot_ids_tosearch = [] start_snapshot = 0 end_snapshot = 0 filecount_in_snapshots = { snapshot_ids[0]: 0, snapshot_ids[1]: 0, snapshot_ids[2]: 0, snapshot_ids[3]: 1 } filesearch_id = self.filepath_search(vmid_to_search, filepath_to_search, snapshot_ids_tosearch, start_snapshot, end_snapshot, date_from, date_to) snapshot_wise_filecount = self.verifyFilepath_Search( filesearch_id, filepath_to_search) for snapshot_id in snapshot_wise_filecount.keys(): if filecount_in_snapshots[ snapshot_id] == snapshot_wise_filecount[ snapshot_id] and snapshot_id in snapshot_ids[1:]: filesearch_status = True else: filesearch_status = False LOG.debug("Filepath Search with daterange unsuccessful") reporting.add_test_step( "Verification of Filepath serach with daterange", tvaultconf.FAIL) raise Exception( "Filesearch with daterange does not execute correctly") if filesearch_status == True: LOG.debug("Filepath_Search successful with daterange") reporting.add_test_step( "Verification of Filepath serach with daterange", tvaultconf.PASS) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def license_check_capacity(self): reporting.add_test_script(str(__name__) + "_check_capacity") try: # Create license using CLI command self.cmd = command_argument_string.license_create + \ tvaultconf.capacity_license_filename rc = cli_parser.cli_returncode(self.cmd) if rc != 0: reporting.add_test_step("Apply 100GB license", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Apply 100GB license", tvaultconf.PASS) # Verify license-check CLI command self.cmd = command_argument_string.license_check rc = cli_parser.cli_returncode(self.cmd) if rc != 0: reporting.add_test_step("Execute license-check command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Execute license-check command", tvaultconf.PASS) # Verification out = cli_parser.cli_output(self.cmd) LOG.debug("CLI Response: " + str(out)) get_usage_tvault = "df -h | grep triliovault-mounts" ssh = self.SshRemoteMachineConnection(tvaultconf.tvault_ip[0], tvaultconf.tvault_dbusername, tvaultconf.tvault_password) stdin, stdout, stderr = ssh.exec_command(get_usage_tvault) tmp = ' '.join(stdout.read().split()) usage = tmp.split(' ') LOG.debug("Data from Tvault: " + str(usage) + " Usage: " + str(usage[2])) ssh.close() if (str(out).find(usage[2]) != -1): reporting.add_test_step("License-check verification", tvaultconf.PASS) else: reporting.add_test_step("License-check verification", tvaultconf.FAIL) raise Exception("License-check verification failed") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_03_license_check_vms(self): reporting.add_test_script(str(__name__) + "_check_vms") try: #Create license using CLI command self.cmd = command_argument_string.license_create + tvaultconf.vm_license_filename rc = cli_parser.cli_returncode(self.cmd) if rc != 0: reporting.add_test_step("Apply 10VM license", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Apply 10VM license", tvaultconf.PASS) #Create simple workload self.workload_instances = [] for i in range(0, 2): self.vm_id = self.create_vm() self.volume_id = self.create_volume() self.attach_volume(self.volume_id, self.vm_id) self.workload_instances.append(self.vm_id) self.wid = self.workload_create(self.workload_instances, tvaultconf.parallel) LOG.debug("Workload ID: " + str(self.wid)) #Verify license-check CLI command self.cmd = command_argument_string.license_check rc = cli_parser.cli_returncode(self.cmd) if rc != 0: reporting.add_test_step("Execute license-check command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Execute license-check command", tvaultconf.PASS) #Verification out = cli_parser.cli_output(self.cmd) LOG.debug("CLI Response: " + str(out)) if (str(out).find('2') != -1): reporting.add_test_step("License-check verification", tvaultconf.PASS) else: reporting.add_test_step("License-check verification", tvaultconf.FAIL) raise Exception("License-check verification failed") reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_1_get_audit_log(self): try: reporting.add_test_script(str(__name__) + "_get_audit_log") global vm_id global volume_id global workload_id global snapshot_id workload_id = self.wid vm_id = self.vm_id volume_id = self.volume_id LOG.debug("workload is:" + str(workload_id)) LOG.debug("vm id: " + str(vm_id)) LOG.debug("volume id: " + str(volume_id)) snapshot_id = self.workload_snapshot(workload_id, True) wc = self.wait_for_snapshot_tobe_available(workload_id, snapshot_id) if (str(wc) == "available"): reporting.add_test_step("Full snapshot", tvaultconf.PASS) LOG.debug("Workload snapshot successfully completed") self.created = True else: if (str(wc) == "error"): pass if (self.created == False): reporting.add_test_step("Full snapshot", tvaultconf.FAIL) raise Exception("Workload snapshot did not get created") audit_log = self.getAuditLog() LOG.debug("Audit logs are : " + str(audit_log)) wkld_name = tvaultconf.workload_name if len(audit_log) >= 0 and str(audit_log).find(wkld_name): LOG.debug("audit log API returns log successfully") reporting.add_test_step("Audit Log", tvaultconf.PASS) else: LOG.debug("audit log API does not return anything") reporting.add_test_step("Audit Log", tvaultconf.FAIL) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_4_config_backup_delete(self): global config_backup_id reporting.add_test_script(str(__name__) + "_config_backup_delete: cli") try: # test_config_backup_delete # config backup configuration with CLI command config_backup_delete_command = command_argument_string.config_backup_delete + " " + str( config_backup_id) LOG.debug("config backup delete cli command: " + str(config_backup_delete_command)) rc = cli_parser.cli_returncode(config_backup_delete_command) if rc != 0: reporting.add_test_step( "Triggering config_backup_delete command via CLI", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step( "Triggering config_backup_delete command via CLI", tvaultconf.PASS) LOG.debug("Command executed correctly") config_backup_id_after_deletion = query_data.get_config_backup_id() LOG.debug("Config backup id after: " + str(config_backup_id_after_deletion)) if config_backup_id_after_deletion == config_backup_id: reporting.add_test_step("Config Backup Deletion", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) else: reporting.add_test_step("Config Backup Deletion", tvaultconf.PASS) # delete config_user self.delete_config_user() reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_6_filesearch_wildcard_star(self): reporting.add_test_script(str(__name__) + "_wildcard_star") try: global instances_ids global snapshot_ids # Run Filesearch on vm-2 vmid_to_search = instances_ids[1] filepath_to_search = "/File*" filecount_in_snapshots = { snapshot_ids[0]: 0, snapshot_ids[1]: 0, snapshot_ids[2]: 2, snapshot_ids[3]: 2 } filesearch_id = self.filepath_search(vmid_to_search, filepath_to_search) snapshot_wise_filecount = self.verifyFilepath_Search( filesearch_id, filepath_to_search) for snapshot_id in filecount_in_snapshots.keys(): if snapshot_wise_filecount[ snapshot_id] == filecount_in_snapshots[snapshot_id]: filesearch_status = True else: filesearch_status = False LOG.debug( "Filepath Search with wildcard_star unsuccessful") reporting.add_test_step( "Verification of Filepath serach with wildcard_star", tvaultconf.FAIL) raise Exception( "Filesearch wildcard_star does not execute correctly") if filesearch_status == True: LOG.debug("Filepath_Search with wildcard_star successful") reporting.add_test_step( "Verification of Filepath serach with wildcard_star", tvaultconf.PASS) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_3_get_tenant_details(self): try: reporting.add_test_script(str(__name__) + "_get_tenant_details") tenant_usage = self.getTenantUsage() LOG.debug("Tenant details are : " + str(tenant_usage)) wkld_name = tvaultconf.workload_name if len(tenant_usage) > 0: LOG.debug("Tenant details returns successfully") reporting.add_test_step("Tenant Details ", tvaultconf.PASS) else: LOG.debug("Tenant details API does not return anything") reporting.add_test_step("Tenant Details", tvaultconf.FAIL) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_2_get_storage_details(self): try: reporting.add_test_script(str(__name__) + "_get_storage_details") storage_usage = self.getStorageUsage() LOG.debug("Storage details are : " + str(storage_usage)) wkld_name = tvaultconf.workload_name if len(storage_usage) > 0 and storage_usage[0][ 'total_capacity_humanized'] is not None: LOG.debug("storage details returns successfully") reporting.add_test_step("Storage Details ", tvaultconf.PASS) else: LOG.debug("storage detailsAPI does not return anything") reporting.add_test_step("Storage Details", tvaultconf.FAIL) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_2_config_backup_list(self): global config_backup_id reporting.add_test_script(str(__name__) + "_config_backup_list: api") try: # test config_backup_list config_backup_list_output = self.get_config_backup_list() LOG.debug("config_backup list output: " + str(config_backup_list_output)) if config_backup_list_output != "": reporting.add_test_step("Config_backup_list", tvaultconf.PASS) else: reporting.add_test_step("Config_backup_list", tvaultconf.FAIL) config_backups_list = config_backup_list_output['backups'] config_backup_found = False LOG.debug("Finding config backup id: " + str(config_backup_id)) for backup in config_backups_list: if backup['id'] == str(config_backup_id): config_backup_found = True LOG.debug("config_backup_id found in config_backups_list") break if config_backup_found: reporting.add_test_step( "config_backup_id in config_backups_list", tvaultconf.PASS) else: LOG.debug("config_backup_id not found in config_backups_list") reporting.add_test_step( "config_backup_id in config_backups_list", tvaultconf.FAIL) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_3_list_snapshot(self): try: reporting.add_test_script(str(__name__) + "_list_snapshot") # List snapshots using CLI command rc = cli_parser.cli_returncode( command_argument_string.snapshot_list) if rc != 0: reporting.add_test_step("Execute snapshot-list command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Execute snapshot-list command", tvaultconf.PASS) LOG.debug("Command executed correctly") wc = query_data.get_available_snapshots() out = cli_parser.cli_output(command_argument_string.snapshot_list) if (int(wc) == int(out)): reporting.add_test_step("Verification with DB", tvaultconf.PASS) LOG.debug( "Snapshot list command listed available snapshots correctly" ) else: reporting.add_test_step("Verification with DB", tvaultconf.FAIL) raise Exception( "Snapshot list command did not list available snapshots correctly" ) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_network_restore(self): try: reporting.add_test_script(str(__name__)) self.delete_network_topology() vms = [] ntwrks = self.create_network() for network in ntwrks: if network['name'] in ['Private-1', 'Private-2', 'Private-5']: vm_name = "instance-{}".format(network['name']) vmid = self.create_vm(vm_name=vm_name, networkid=[ {'uuid': network['id']}], vm_cleanup=True) vms.append((vm_name, vmid)) LOG.debug("Launched vms : {}".format(vms)) nws = [x['id'] for x in ntwrks] nt_bf, sbnt_bf, rt_bf, intf_bf = self.get_topology_details() vms_ids = [x[1] for x in vms] workload_id = self.workload_create( vms_ids, tvaultconf.parallel, workload_cleanup=True) LOG.debug("Workload ID: " + str(workload_id)) if(workload_id is not None): self.wait_for_workload_tobe_available(workload_id) if(self.getWorkloadStatus(workload_id) == "available"): reporting.add_test_step("Create workload", tvaultconf.PASS) else: reporting.add_test_step("Create workload", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) else: reporting.add_test_step("Create workload", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("Workload creation failed") snapshot_id = self.workload_snapshot( workload_id, True, snapshot_cleanup=True) time.sleep(5) self.wait_for_workload_tobe_available(workload_id) if(self.getSnapshotStatus(workload_id, snapshot_id) == "available"): reporting.add_test_step( "Create full snapshot", tvaultconf.PASS) LOG.debug("Full snapshot available!!") else: reporting.add_test_step( "Create full snapshot", tvaultconf.FAIL) raise Exception("Snapshot creation failed") instance_details = [] for vm in vms: temp_instance_data = {'id': vm[1], 'include': True, 'restore_boot_disk': True, 'name': vm[0] + "restored_instance", 'vdisks': [] } instance_details.append(temp_instance_data) LOG.debug("Instance details for restore: " + str(instance_details)) vm_details_bf = {} for vm in vms: vm_details_bf[vm[0]] = self.get_vm_details(vm[1])['server'] self.delete_vm(vm[1]) self.delete_network_topology() restore_id = self.snapshot_selective_restore( workload_id, snapshot_id, restore_name=tvaultconf.restore_name, instance_details=instance_details, network_restore_flag=True, restore_cleanup=True) self.wait_for_snapshot_tobe_available(workload_id, snapshot_id) if(self.getRestoreStatus(workload_id, snapshot_id, restore_id) == "available"): reporting.add_test_step( "Selective restore with network restore", tvaultconf.PASS) else: reporting.add_test_step( "Selective restore with network restore", tvaultconf.FAIL) raise Exception( "Selective restore with network restore failed") nt_af, sbnt_af, rt_af, intf_af = self.get_topology_details() if nt_bf == nt_af: reporting.add_test_step( "Verify network details after network restore", tvaultconf.PASS) else: reporting.add_test_step( "Verify network details after network restore", tvaultconf.FAIL) LOG.error( "Network details before and after restore: {0}, {1}".format( nt_bf, nt_af)) if sbnt_bf == sbnt_af: reporting.add_test_step( "Verify subnet details after network restore", tvaultconf.PASS) else: reporting.add_test_step( "Verify subnet details after network restore", tvaultconf.FAIL) LOG.error( "Subnet details before and after restore: {0}, {1}".format( sbnt_bf, sbnt_af)) if rt_bf == rt_af: reporting.add_test_step( "Verify router details after network restore", tvaultconf.PASS) else: reporting.add_test_step( "Verify router details after network restore", tvaultconf.FAIL) LOG.error( "Router details before and after restore: {0}, {1}".format( rt_bf, rt_af)) if intf_bf == intf_af: reporting.add_test_step( "Verify interface details after network restore", tvaultconf.PASS) else: reporting.add_test_step( "Verify interface details after network restore", tvaultconf.FAIL) LOG.error( "Interface details before and after restore: {0}, {1}".format( intf_bf, intf_af)) vm_details_af = {} restored_vms = self.get_restored_vm_list(restore_id) for vm in restored_vms: vm_details = self.get_vm_details(vm)['server'] vm_details_af[vm_details['name'].replace( 'restored_instance', '')] = vm_details klist = sorted([*vm_details_bf]) for vm in klist: netname = [*vm_details_bf[vm]['addresses']][0] vm_details_bf[vm]['addresses'][netname][0]['OS-EXT-IPS-MAC:mac_addr'] = '' vm_details_af[vm]['addresses'][netname][0]['OS-EXT-IPS-MAC:mac_addr'] = '' vm_details_bf[vm]['links'][1]['href'] = '' vm_details_af[vm]['links'][1]['href'] = '' vm_details_af[vm]['metadata']['config_drive'] = '' vm_details_af[vm]['metadata']['ordered_interfaces'] = '' vm_details_bf[vm]['links'] = '' vm_details_af[vm]['links'] = '' vm_details_bf[vm]['OS-EXT-SRV-ATTR:instance_name'] = '' vm_details_af[vm]['OS-EXT-SRV-ATTR:instance_name'] = '' vm_details_bf[vm]['updated'] = '' vm_details_af[vm]['updated'] = '' vm_details_bf[vm]['created'] = '' vm_details_af[vm]['created'] = '' vm_details_bf[vm]['id'] = '' vm_details_af[vm]['id'] = '' vm_details_bf[vm]['OS-SRV-USG:launched_at'] = '' vm_details_af[vm]['OS-SRV-USG:launched_at'] = '' vm_details_af[vm]['name'] = vm_details_af[vm]['name'].replace( 'restored_instance', '') if vm_details_bf == vm_details_af: reporting.add_test_step( "Verify instance details after restore", tvaultconf.PASS) else: reporting.add_test_step( "Verify instance details after restore", tvaultconf.FAIL) LOG.error( "Instance details before and after restore: {0}, {1}".format( vm_details_bf, vm_details_af)) for rvm in restored_vms: self.delete_vm(rvm) self.delete_network_topology() reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write
def setup_clients(cls): super(WorkloadTest, cls).setup_clients() reporting.add_test_script(str(__name__))
def setup_clients(cls): super(WorkloadsTest, cls).setup_clients() cls.client = cls.os.wlm_client reporting.add_test_script(str(__name__))
def test_1_snapshot_mount_full(self): reporting.add_test_script(str(__name__) + "_full_snasphot") try: if self.exception != "": LOG.debug("pre req failed") reporting.add_test_step(str(self.exception), tvaultconf.FAIL) raise Exception(str(self.exception)) LOG.debug("pre req completed") global instances_ids global snapshot_ids global wid global security_group_id global volumes_ids global fvm_id global floating_ips_list instances_ids = self.instances_ids snapshot_ids = self.snapshot_ids wid = self.wid volumes_ids = self.volumes_ids security_group_id = self.security_group_id fvm_id = self.fvm_id full_snapshot_id = snapshot_ids[0] floating_ips_list = self.floating_ips_list LOG.debug("mount snasphot of a full snapshot") is_mounted = self.mount_snapshot( wid, full_snapshot_id, fvm_id, mount_cleanup=False) LOG.debug("VALUE OF is_mounted: " + str(is_mounted)) if is_mounted: LOG.debug(" mount snapshot with full snapshot is successful") reporting.add_test_step( "Verification of mount snapshot with full snapshot", tvaultconf.PASS) else: LOG.debug("mount snapshot with full snapshot is unsuccessful") reporting.add_test_step( "Verification of mount snapshot with full snapshot", tvaultconf.FAIL) raise Exception( "Snapshot mount with full_snapshot does not execute correctly") LOG.debug("validate that snapshot is mounted on FVM") ssh = self.SshRemoteMachineConnectionWithRSAKey( str(floating_ips_list[1]), CONF.validation.fvm_ssh_user) output_list = self.validate_snapshot_mount(ssh).decode('UTF-8').split('\n') ssh.close() flag = 0 for i in output_list: if 'vdbb' in i: LOG.debug( "connect to fvm and check mountpoint is mounted on FVM instance") reporting.add_test_step( "Verify that mountpoint mounted is shown on FVM instance", tvaultconf.PASS) flag = 1 if 'File_1' in i: LOG.debug("check that file exists on mounted snapshot") reporting.add_test_step( "Verification of file's existance on moutned snapshot", tvaultconf.PASS) else: LOG.debug("file does not found on FVM instacne") reporting.add_test_step( "Verification of file's existance on moutned snapshot", tvaultconf.FAIL) raise Exception("file does not found on FVM instacne") else: pass if flag == 0: LOG.debug( "mount snapshot with full snapshot is unsuccessful on FVM") reporting.add_test_step( "Verify that mountpoint mounted is shown on FVM instance", tvaultconf.FAIL) LOG.debug("file does not found on FVM instacne") reporting.add_test_step( "Verification of file's existance on moutned snapshot", tvaultconf.FAIL) raise Exception("mountpoint is not showing on FVM instance") else: pass reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_3_snapshot_mount_incremental(self): reporting.add_test_script(str(__name__) + "_incremental_snasphot") try: global instances_ids global snapshot_ids global wid global security_group_id global volumes_ids global fvm_id global floating_ips_list instances_ids = instances_ids snapshot_ids = snapshot_ids wid = wid volumes_ids = volumes_ids security_group_id = security_group_id fvm_id = fvm_id incremental_snapshot_id = snapshot_ids[1] floating_ips_list = floating_ips_list LOG.debug("mount incremental snapshot") is_mounted = self.mount_snapshot( wid, incremental_snapshot_id, fvm_id) LOG.debug("VALUE OF is_mounted: " + str(is_mounted)) if is_mounted: LOG.debug( " mount snapshot with incremental snapshot is successful") reporting.add_test_step( "Verification of mount snapshot with incremental snapshot", tvaultconf.PASS) else: LOG.debug( "mount snapshot with incremental snapshot is unsuccessful") reporting.add_test_step( "Verification of mount snapshot with incremental snapshot", tvaultconf.FAIL) raise Exception( "Snapshot mount with incremental_snapshot does not execute correctly") LOG.debug("validate that snapshot is mounted on FVM") ssh = self.SshRemoteMachineConnectionWithRSAKey( str(floating_ips_list[1]), CONF.validation.fvm_ssh_user) output_list = self.validate_snapshot_mount(ssh).decode('UTF-8').split('\n') ssh.close() flag = 0 for i in output_list: if 'vdbb' in i: LOG.debug( "connect to fvm and check mountpoint is mounted on FVM instance") reporting.add_test_step( "Verify that mountpoint mounted is shown on FVM instance", tvaultconf.PASS) flag = 1 if 'File_1' in i: LOG.debug( "check that file is exist on mounted snapshot") reporting.add_test_step( "Verification of file's existance on mounted snapshot", tvaultconf.PASS) else: LOG.debug("file does not found on FVM instacne") reporting.add_test_step( "Verification of file's existance on mounted snapshot", tvaultconf.FAIL) raise Exception("file does not found on FVM instacne") else: pass if flag == 0: LOG.debug( "mount snapshot with full snapshot is unsuccessful on FVM") reporting.add_test_step( "Verify that mountpoint mounted is shown on FVM instance", tvaultconf.FAIL) LOG.debug("file does not found on FVM instacne") reporting.add_test_step( "Verification of file's existance on mounted snapshot", tvaultconf.FAIL) raise Exception("mountpoint is not showing on FVM instance") else: pass # Cleanup # Unmount incremental snapshot self.unmount_snapshot(wid, incremental_snapshot_id) # Delete all snapshots for snapshot_id in snapshot_ids: self.snapshot_delete(wid, snapshot_id) # Delete workload self.workload_delete(wid) # Delete VMs for instance_id in instances_ids: self.delete_vm(instance_id) self.delete_vm(fvm_id) # Delete volumes for volume_id in volumes_ids: self.delete_volume(volume_id) # Delete security group self.delete_security_group(security_group_id) # Delete key pair self.delete_key_pair(tvaultconf.key_pair_name) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()
def test_1_config_backup(self): global config_backup_id reporting.add_test_script(str(__name__) + "_default + added_dir: cli") try: # prerequisite handles config_user creation and config_backup_pvk(private key) creation and config_workload configuration config_workload_md5sum_before_backup = self.calculate_md5_config_backup( added_dir=tvaultconf.additional_dir) LOG.debug("config_workload_md5sum_before_backup: " + str(config_workload_md5sum_before_backup)) #config backup configuration with CLI command config_backup_command = command_argument_string.config_backup LOG.debug("config backup cli command: " + str(config_backup_command)) rc = cli_parser.cli_returncode(config_backup_command) if rc != 0: reporting.add_test_step( "Triggering config_backup command via CLI", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step( "Triggering config_backup command via CLI", tvaultconf.PASS) LOG.debug("Command executed correctly") time.sleep(10) config_backup_id = query_data.get_config_backup_id() LOG.debug("Config backup id: " + str(config_backup_id)) if (config_backup_id != None): status = self.wait_for_config_backup_tobe_available( config_backup_id) if status == "available": LOG.debug("config backup detials: " + str(self.show_config_backup(config_backup_id))) reporting.add_test_step("Config Backup", tvaultconf.PASS) else: reporting.add_test_step("Config Backup", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) else: reporting.add_test_step("Config Backup", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("Config Backup Failed.") config_workload_md5sum_after_backup = self.calculate_md5_config_backup( added_dir=tvaultconf.additional_dir) LOG.debug("config_workload_md5sum_after_backup: " + str(config_workload_md5sum_after_backup)) if config_workload_md5sum_before_backup == config_workload_md5sum_after_backup: reporting.add_test_step("Config backup md5 verification", tvaultconf.PASS) else: reporting.add_test_step("Config backup md5 verification", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) vault_storage_path = self.show_config_backup(config_backup_id)[ 'config_backup']['vault_storage_path'].rstrip() compute_hostname = self.get_compute_hostname().rstrip() config_workload_md5sum_after_backup_vault_storage = self.calculate_md5_config_backup( vault_storage_path=vault_storage_path, compute_hostname=compute_hostname, added_dir=tvaultconf.additional_dir) LOG.debug("config_workload_vault_md5_sum_vault_storage: " + str(config_workload_md5sum_after_backup_vault_storage)) if config_workload_md5sum_before_backup == config_workload_md5sum_after_backup_vault_storage: reporting.add_test_step( "Config backup md5 verification : vault_storage", tvaultconf.PASS) else: reporting.add_test_step( "Config backup md5 verification: vault_storage", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write() except Exception as e: LOG.error("Exception: " + str(e)) reporting.set_test_script_status(tvaultconf.FAIL) reporting.test_case_to_write()