def TestParallelInstanceReinstall(instance): """PERFORMANCE: Instance reinstall with parallel instance creation. """ # instance reinstall requires the instance to be down qa_utils.AssertCommand(["gnt-instance", "stop", instance.name]) _TestInstanceOperationInParallelToInstanceCreation( ["gnt-instance", "reinstall", "--submit", "-f", instance.name]) qa_utils.AssertCommand(["gnt-instance", "start", instance.name])
def TestParallelInstanceRename(instance): """PERFORMANCE: Instance rename with parallel instance creation. """ # instance rename requires the instance to be down qa_utils.AssertCommand(["gnt-instance", "stop", instance.name]) new_instance = qa_config.AcquireInstance() try: _TestInstanceOperationInParallelToInstanceCreation( ["gnt-instance", "rename", "--submit", instance.name, new_instance.name], ["gnt-instance", "rename", "--submit", new_instance.name, instance.name]) finally: new_instance.Release() qa_utils.AssertCommand(["gnt-instance", "start", instance.name])
def RunPerformanceTests(): if not qa_config.TestEnabled("performance"): ReportTestSkip("performance related tests", "performance") return # For reproducable performance, run performance tests with the watcher # paused. qa_utils.AssertCommand(["gnt-cluster", "watcher", "pause", "4h"]) if qa_config.TestEnabled("jobqueue-performance"): RunTest(qa_performance.TestParallelMaxInstanceCreationPerformance) RunTest( qa_performance.TestParallelNodeCountInstanceCreationPerformance) instances = qa_performance.CreateAllInstances() RunTest(qa_performance.TestParallelModify, instances) RunTest(qa_performance.TestParallelInstanceOSOperations, instances) RunTest(qa_performance.TestParallelInstanceQueries, instances) qa_performance.RemoveAllInstances(instances) RunTest(qa_performance.TestJobQueueSubmissionPerformance) if qa_config.TestEnabled("parallel-performance"): if qa_config.IsTemplateSupported(constants.DT_DRBD8): RunTest(qa_performance.TestParallelDRBDInstanceCreationPerformance) if qa_config.IsTemplateSupported(constants.DT_PLAIN): RunTest( qa_performance.TestParallelPlainInstanceCreationPerformance) # Preparations need to be made only if some of these tests are enabled if qa_config.IsTemplateSupported(constants.DT_DRBD8) and \ qa_config.TestEnabled(qa_config.Either(list(PARALLEL_TEST_DICT))): inodes = qa_config.AcquireManyNodes(2) try: instance = qa_instance.TestInstanceAddWithDrbdDisk(inodes) try: for (test_name, test_fn) in PARALLEL_TEST_DICT.items(): RunTestIf(test_name, test_fn, instance) finally: instance.Release() qa_instance.TestInstanceRemove(instance) finally: qa_config.ReleaseManyNodes(inodes) qa_utils.AssertCommand(["gnt-cluster", "watcher", "continue"])
def TestJobQueueSubmissionPerformance(): """PERFORMANCE: Job queue submission performance. This test exercises the job queue and verifies that the job submission time does not increase as more jobs are added. """ MAX_CLUSTER_INFO_SECONDS = 15.0 job_driver = _JobQueueDriver() submission_durations = [] def _VerifySubmissionDuration(duration_seconds): # only start to verify the submission duration once we got data from the # first 10 job submissions if len(submission_durations) >= 10: avg_duration = sum(submission_durations) / len(submission_durations) max_duration = avg_duration * 1.5 if duration_seconds > max_duration: print(qa_logging.FormatWarning( "Submitting a delay job took %f seconds, max %f expected" % (duration_seconds, max_duration))) else: submission_durations.append(duration_seconds) def _SubmitDelayJob(count): for _ in range(count): cmd = ["gnt-debug", "delay", "--submit", "0.1"] start = datetime.datetime.now() job_id = _ExecuteJobSubmittingCmd(cmd) duration_seconds = \ qa_utils.TimedeltaToTotalSeconds(datetime.datetime.now() - start) _VerifySubmissionDuration(duration_seconds) job_driver.AddJob(job_id) threads = qa_job_utils.QAThreadGroup() for _ in range(10): thread = qa_job_utils.QAThread(_SubmitDelayJob, [20], {}) threads.Start(thread) threads.JoinAndReraise() qa_utils.AssertCommand(["gnt-cluster", "info"], max_seconds=MAX_CLUSTER_INFO_SECONDS) job_driver.WaitForCompletion()