def test_tvault1030_list_workloadtype(self): try: # List available workload types using CLI command rc = cli_parser.cli_returncode( command_argument_string.workload_type_list) if rc != 0: reporting.add_test_step("Execute workload-type-list command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step("Execute workload-type-list command", tvaultconf.PASS) LOG.debug("Command executed correctly") wc = query_data.get_available_workload_types() out = cli_parser.cli_output( command_argument_string.workload_type_list) if (int(wc) == int(out)): reporting.add_test_step("Verification with DB", tvaultconf.PASS) LOG.debug( "Workload type list command listed available workload types correctly" ) else: reporting.add_test_step("Verification with DB", tvaultconf.FAIL) raise Exception( "Workload type list command did not list available workload types 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_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_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_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_create_license(self): # Create license using CLI command self.cmd = command_argument_string.license_create + tvaultconf.compute_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", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step( "Execute license_create command", tvaultconf.PASS) LOG.debug("Command executed correctly") # Verification self.license_data = self.get_license_list() LOG.debug("License data returned: " + str(self.license_data)) if(len(self.license_data.keys()) != 0): reporting.add_test_step("License verification", tvaultconf.PASS) else: reporting.add_test_step("License verification", tvaultconf.FAIL) reporting.set_test_script_status(tvaultconf.FAIL) raise Exception("License not added") 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_tvault1035_list_workload(self): try: # Prerequisites self.created = False self.workload_instances = [] # Launch instance self.vm_id = self.create_vm() LOG.debug("VM ID: " + str(self.vm_id)) # Create volume self.volume_id = self.create_volume() LOG.debug("Volume ID: " + str(self.volume_id)) # Attach volume to the instance self.attach_volume(self.volume_id, self.vm_id) LOG.debug("Volume attached") # Create workload self.workload_instances.append(self.vm_id) self.wid = self.workload_create( self.workload_instances, tvaultconf.parallel, workload_name=tvaultconf.workload_name) LOG.debug("Workload ID: " + str(self.wid)) # List available workloads using CLI command rc = cli_parser.cli_returncode( command_argument_string.workload_list) if rc != 0: reporting.add_test_step( "Execute workload-list command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step( "Execute workload-list command", tvaultconf.PASS) LOG.debug("Command executed correctly") wc = query_data.get_available_workloads() out = cli_parser.cli_output(command_argument_string.workload_list) if (int(wc) == int(out)): reporting.add_test_step( "Verification with DB", tvaultconf.PASS) LOG.debug( "Workload list command listed available workloads correctly") else: reporting.add_test_step( "Verification with DB", tvaultconf.FAIL) raise Exception( "Workload list command did not list available workloads correctly, from db: " + str(wc) + " , from cmd: " + str(out)) 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_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_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_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_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_tvault1033_create_workload(self): try: # Prerequisites self.created = False # Launch instance self.vm_id = self.create_vm() LOG.debug("VM ID: " + str(self.vm_id)) # Create volume self.volume_id = self.create_volume() LOG.debug("Volume ID: " + str(self.volume_id)) # Attach volume to the instance self.attach_volume(self.volume_id, self.vm_id) LOG.debug("Volume attached") # Create workload with CLI command workload_create = command_argument_string.workload_create + \ " --instance instance-id=" + str(self.vm_id) rc = cli_parser.cli_returncode(workload_create) if rc != 0: reporting.add_test_step( "Execute workload-create command", tvaultconf.FAIL) raise Exception("Command did not execute correctly") else: reporting.add_test_step( "Execute workload-create command", tvaultconf.PASS) LOG.debug("Command executed correctly") time.sleep(10) self.wid = query_data.get_workload_id(tvaultconf.workload_name) LOG.debug("Workload ID: " + str(self.wid)) if(self.wid is not None): self.wait_for_workload_tobe_available(self.wid) if(self.getWorkloadStatus(self.wid) == "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) # Cleanup # Delete workload self.workload_delete(self.wid) LOG.debug("Workload 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_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 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_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_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 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_chargeback_api(self): 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") # Run getVMProtected API : vm_protected = self.getVMProtected() if not vm_protected: reporting.add_test_step("Verified getVMProtected API", tvaultconf.FAIL) LOG.debug("getVMProtected API failed") raise Exception("getVMProtected API Failed") else: reporting.add_test_step("Verified getVMProtected API", tvaultconf.PASS) # Verify Instance ID : vm_id = self.vm_id counter = 0 vm_protected_list = vm_protected['protected_vms'] for vm in vm_protected_list: openstack_vm_id = vm_protected_list[counter]['id'] LOG.debug(" Openstack VM ID : " + openstack_vm_id) if (vm_id == openstack_vm_id): LOG.debug(" VM ID : " + vm_id) instance_found = True break else: instance_found = False counter = counter + 1 if (instance_found): reporting.add_test_step(" Verified Instance ID ", tvaultconf.PASS) else: reporting.add_test_step(" Verified Instance ID ", tvaultconf.FAIL) raise Exception(" Verification for instance id 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_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_bootfromvol_fullsnapshot(self): try: #Create full snapshot self.snapshot_id = self.workload_snapshot(self.workload_id, True, snapshot_cleanup=False) self.wait_for_workload_tobe_available(self.workload_id) if (self.getSnapshotStatus(self.workload_id, self.snapshot_id) == "available"): reporting.add_test_step( "Create full snapshot of boot from volume instance", tvaultconf.PASS) else: reporting.add_test_step( "Create full snapshot of boot from volume instance", tvaultconf.FAIL) raise Exception("Snapshot creation failed") #Cleanup #Delete Snapshot self.snapshot_delete(self.workload_id, self.snapshot_id) #Delete volume self.volume_snapshots = self.get_available_volume_snapshots() self.delete_volume_snapshots(self.volume_snapshots) #Delete workload self.workload_delete(self.workload_id) #Delete vm self.delete_vm(self.vm_id) #Delete volume self.delete_volume(self.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_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_tvault1063_bootfromvol_restore(self): try: #Create full snapshot self.snapshot_id = self.workload_snapshot(self.workload_id, True) self.wait_for_workload_tobe_available(self.workload_id) if (self.getSnapshotStatus(self.workload_id, self.snapshot_id) == "available"): reporting.add_test_step( "Create full snapshot of boot from volume instance", tvaultconf.PASS) else: reporting.add_test_step( "Create full snapshot of boot from volume instance", tvaultconf.FAIL) raise Exception("Snapshot creation failed") self.delete_vms(self.workload_instances) #Trigger oneclick restore self.restore_id = self.snapshot_restore(self.workload_id, self.snapshot_id) self.wait_for_workload_tobe_available(self.workload_id) if (self.getRestoreStatus(self.workload_id, self.snapshot_id, self.restore_id) == "available"): reporting.add_test_step( "Oneclick restore of boot from volume instance", tvaultconf.PASS) else: reporting.add_test_step( "Oneclick restore of boot from volume instance", tvaultconf.FAIL) raise Exception("Oneclick restore 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()