def _TestInstanceOperationInParallelToInstanceCreation(*cmds): """Run the given test command in parallel to an instance creation. @type cmds: list of list of strings @param cmds: commands to execute in parallel to an instance creation. Each command in the list is executed once the previous job starts to run. """ def _SubmitNextCommand(cmd_idx, job_driver, _): if cmd_idx >= len(cmds): return job_id = _ExecuteJobSubmittingCmd(cmds[cmd_idx]) job_driver.AddJob(job_id, running_fn=functools.partial(_SubmitNextCommand, cmd_idx + 1)) if not qa_config.IsTemplateSupported(constants.DT_DRBD8): print( qa_logging.FormatInfo( "DRBD disk template not supported, skipping")) assert len(cmds) > 0 job_driver = _JobQueueDriver() _SubmitNextCommand(0, job_driver, None) _TestParallelInstanceCreationAndRemoval(max_instances=1, disk_template=constants.DT_DRBD8, custom_job_driver=job_driver) job_driver.WaitForCompletion()
def TestRapiInstanceReplaceDisks(instance): """Test replacing instance disks via RAPI""" if not IsDiskReplacingSupported(instance): print qa_logging.FormatInfo("Instance doesn't support disk replacing," " skipping test") return fn = _rapi_client.ReplaceInstanceDisks _WaitForRapiJob( fn(instance.name, mode=constants.REPLACE_DISK_AUTO, disks=[])) _WaitForRapiJob( fn(instance.name, mode=constants.REPLACE_DISK_SEC, disks="0"))
def TestRapiInstanceFailover(instance): """Test failing over instance via RAPI""" if not IsFailoverSupported(instance): print qa_logging.FormatInfo("Instance doesn't support failover, skipping" " test") return # Move to secondary node _WaitForRapiJob(_rapi_client.FailoverInstance(instance.name)) qa_utils.RunInstanceCheck(instance, True) # And back to previous primary _WaitForRapiJob(_rapi_client.FailoverInstance(instance.name))
def TestRapiInstanceMigrate(instance): """Test migrating instance via RAPI""" if not IsMigrationSupported(instance): print qa_logging.FormatInfo("Instance doesn't support migration, skipping" " test") return # Move to secondary node _WaitForRapiJob(_rapi_client.MigrateInstance(instance.name)) qa_utils.RunInstanceCheck(instance, True) # And back to previous primary _WaitForRapiJob(_rapi_client.MigrateInstance(instance.name))
def TestParallelPlainInstanceCreationPerformance(): """PERFORMANCE: Parallel plain backed instance creation. """ if not qa_config.IsTemplateSupported(constants.DT_PLAIN): print( qa_logging.FormatInfo( "Plain disk template not supported, skipping")) nodes = list(_AcquireAllNodes()) _TestParallelInstanceCreationAndRemoval(max_instances=len(nodes) * 2, disk_template=constants.DT_PLAIN) qa_config.ReleaseManyNodes(nodes)
def TestRapiInstanceReinstall(instance): """Test reinstalling an instance via RAPI""" if instance.disk_template == constants.DT_DISKLESS: print qa_logging.FormatInfo("Test not supported for diskless instances") return _WaitForRapiJob(_rapi_client.ReinstallInstance(instance.name)) # By default, the instance is started again qa_utils.RunInstanceCheck(instance, True) # Reinstall again without starting _WaitForRapiJob(_rapi_client.ReinstallInstance(instance.name, no_startup=True))
def ApplyPatch(data, patch_module, patches, patch_path): """Applies a single patch. @type data: dict (deserialized json) @param data: The QA configuration to modify @type patch_module: module @param patch_module: The json patch module, loaded dynamically @type patches: dict of string to dict @param patches: The dictionary of patch path to content @type patch_path: string @param patch_path: The path to the patch, relative to the QA directory """ patch_content = patches[patch_path] print qa_logging.FormatInfo("Applying patch %s" % patch_path) if not patch_content and patch_path != _QA_DEFAULT_PATCH: print qa_logging.FormatWarning("The patch %s added by the user is empty" % patch_path) patch_module.apply_patch(data, patch_content, in_place=True)