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()
Beispiel #2
0
    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()
Beispiel #3
0
    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_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_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()
Beispiel #7
0
    def test_tvault1031_show_workloadtype(self):
        try:
            #Get workload type details using CLI command
            rc = cli_parser.cli_returncode(
                command_argument_string.workload_type_show)
            if rc != 0:
                reporting.add_test_step("Execute workload-type-show command",
                                        tvaultconf.FAIL)
                raise Exception("Command did not execute correctly")
            else:
                reporting.add_test_step("Execute workload-type-show command",
                                        tvaultconf.PASS)
                LOG.debug("Command executed correctly")

            db_resp = query_data.get_workload_type_data(
                tvaultconf.workload_type_id)
            LOG.debug("Response from DB: " + str(db_resp))
            cmd_resp = cli_parser.cli_output(
                command_argument_string.workload_type_show)
            LOG.debug("Response from CLI: " + str(cmd_resp))

            if (db_resp[5] == tvaultconf.workload_type_id):
                reporting.add_test_step("Verification with DB",
                                        tvaultconf.PASS)
                LOG.debug("Workload type response from CLI and DB match")
            else:
                reporting.add_test_step("Verification with DB",
                                        tvaultconf.FAIL)
                raise Exception(
                    "Workload type response from CLI and DB do not match")
            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_workload_reconfigure(self):
        reporting.add_test_script(
            str(__name__) + "_reconfigure_additional_dir")
        try:
            # prerequisite handles config_user creation and config_backup_pvk(private key) creation

            # for config backup configuration, yaml_file creation
            added_dir = {
                'tvault-contego': {
                    'config_dir': ['/etc/tvault-contego/']
                }
            }
            self.create_config_backup_yaml(added_dir=added_dir)

            # 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.FAIL)
                raise Exception("Command did not execute correctly")
            else:
                reporting.add_test_step(
                    "Triggering config_workload_configure command via CLI",
                    tvaultconf.PASS)
                LOG.debug("Command executed correctly")

            config_workload_show_command = command_argument_string.config_workload_show

            config_workload_output = cli_parser.cli_output(
                config_workload_show_command)

            LOG.debug("config_workload_show_command output from cli: " +
                      str(config_workload_output))

            if added_dir.keys()[0] in str(config_workload_output):
                LOG.debug("config_workload output with added dir: " +
                          added_dir.keys()[0] + " : " +
                          str(config_workload_output))
                reporting.add_test_step(
                    "config_workload completed with added dir ",
                    tvaultconf.PASS)
            else:
                LOG.debug("config_workload output without added dir: " +
                          added_dir.keys()[0] + " : " +
                          str(config_workload_output))
                reporting.add_test_step(
                    "config_workload completed with added dir ",
                    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_tvault1043_show_workload(self):
        try:
            #Prerequisites
            self.created = False
            self.workload_instances = []
            #Launch instance
            self.vm_id = self.create_vm(vm_name="bootfromvol_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))

            #Show workload details using CLI command
            rc = cli_parser.cli_returncode(
                command_argument_string.workload_show + self.wid)
            if rc != 0:
                reporting.add_test_step("Execute workload-show command",
                                        tvaultconf.FAIL)
                raise Exception("Command did not execute correctly")
            else:
                reporting.add_test_step("Execute workload-show command",
                                        tvaultconf.PASS)
                LOG.debug("Command executed correctly")

            #Compare the workload details against database
            out = cli_parser.cli_output(command_argument_string.workload_show +
                                        self.wid)
            LOG.debug("Response from DB: " + str(out))

            if (query_data.get_workload_display_name(
                    self.wid) == cli_parser.cli_response_parser(out, 'name')):
                reporting.add_test_step("Verify workload name",
                                        tvaultconf.PASS)
            else:
                reporting.add_test_step("Verify workload name",
                                        tvaultconf.FAIL)
            if (query_data.get_workload_display_description(
                    self.wid) == cli_parser.cli_response_parser(
                        out, 'description')):
                reporting.add_test_step("Verify workload description",
                                        tvaultconf.PASS)
            else:
                reporting.add_test_step("Verify workload description",
                                        tvaultconf.FAIL)
            if (query_data.get_workload_status_by_id(
                    self.wid) == cli_parser.cli_response_parser(out,
                                                                'status')):
                reporting.add_test_step("Verify workload status",
                                        tvaultconf.PASS)
            else:
                reporting.add_test_step("Verify workload status",
                                        tvaultconf.FAIL)

            instances_cli = []
            temp = json.loads(cli_parser.cli_response_parser(out, 'instances'))
            for i in range(0, len(temp)):
                instances_cli.append(temp[i]['id'])
            instances_cli.sort()
            instances_db = query_data.get_workload_vmids(self.wid)
            instances_db.sort()
            if (instances_db == instances_cli):
                reporting.add_test_step("Verify workload instances",
                                        tvaultconf.PASS)
            else:
                reporting.add_test_step("Verify workload instances",
                                        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()
Beispiel #10
0
    def test_tvault1037_list_restore(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))
            time.sleep(5)

            # Create snapshot
            self.snapshot_id = self.workload_snapshot(self.wid, True,
                                                      tvaultconf.snapshot_name)
            LOG.debug("Snapshot ID: " + str(self.snapshot_id))
            self.wait_for_snapshot_tobe_available(self.wid, self.snapshot_id)

            # Delete instance
            self.delete_vm(self.vm_id)
            LOG.debug("Instance deleted successfully")

            # Delete corresponding volume
            self.delete_volume(self.volume_id)
            LOG.debug("Volume deleted successfully")

            # Create one-click restore
            self.restore_id = self.snapshot_restore(self.wid, self.snapshot_id,
                                                    tvaultconf.restore_name)
            LOG.debug("Restore ID: " + str(self.restore_id))

            # Wait till restore is complete
            wc = query_data.get_snapshot_restore_status(
                tvaultconf.restore_name, self.snapshot_id)
            LOG.debug("Snapshot restore status: " + str(wc))
            while (str(wc) != "available" or str(wc) != "error"):
                time.sleep(5)
                wc = query_data.get_snapshot_restore_status(
                    tvaultconf.restore_name, self.snapshot_id)
                LOG.debug("Snapshot restore status: " + str(wc))
                if (str(wc) == "available"):
                    LOG.debug("Snapshot Restore successfully completed")
                    self.created = True
                    break
                else:
                    if (str(wc) == "error"):
                        break

            if (self.created == False):
                reporting.add_test_step("One click Restore", tvaultconf.FAIL)
                raise Exception("Snapshot Restore did not get created")

            # List Restores using CLI command
            rc = cli_parser.cli_returncode(
                command_argument_string.restore_list)
            if rc != 0:
                reporting.add_test_step("Execute restore-list command",
                                        tvaultconf.FAIL)
                raise Exception("Command did not execute correctly")
            else:
                reporting.add_test_step("Execute restore-list command",
                                        tvaultconf.PASS)
                LOG.debug("Command executed correctly")

            wc = query_data.get_available_restores()
            out = cli_parser.cli_output(command_argument_string.restore_list)
            if (int(wc) == int(out)):
                reporting.add_test_step("Verification with DB",
                                        tvaultconf.PASS)
                LOG.debug(
                    "Restore list command listed available restores correctly")
            else:
                reporting.add_test_step("Verification with DB",
                                        tvaultconf.FAIL)
                raise Exception(
                    "Restore list command did not list available restores 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()