From 5141fbdbf9c9898c9c4340d481cdc60f1bc4f9d1 Mon Sep 17 00:00:00 2001 From: Kunal Kotwani Date: Fri, 1 Apr 2022 16:12:53 -0700 Subject: [PATCH] Update secure mode flag name, pythonify branch code Signed-off-by: Kunal Kotwani --- src/run_perf_test.py | 15 ++++++++------- src/test_workflow/perf_test/perf_test_suite.py | 10 +--------- .../TestRunNonSecurityPerfTestScript.groovy | 2 +- tests/jenkins/TestRunPerfTestScript.groovy | 2 +- .../perf-test-with-security.jenkinsfile.txt | 2 +- .../opensearch/perf-test.jenkinsfile.txt | 2 +- tests/test_run_perf_test.py | 2 +- vars/runPerfTestScript.groovy | 2 +- 8 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/run_perf_test.py b/src/run_perf_test.py index caca751578..9be49ccce1 100644 --- a/src/run_perf_test.py +++ b/src/run_perf_test.py @@ -36,7 +36,7 @@ def main(): parser.add_argument("--bundle-manifest", type=argparse.FileType("r"), help="Bundle Manifest file.", required=True) parser.add_argument("--stack", dest="stack", help="Stack name for performance test") parser.add_argument("--config", type=argparse.FileType("r"), help="Config file.", required=True) - parser.add_argument("--force-insecure-mode", dest="insecure", action="store_true", + parser.add_argument("--without-security", dest="insecure", action="store_true", help="Force the security of the cluster to be disabled.", default=False) parser.add_argument("--keep", dest="keep", action="store_true", help="Do not delete the working temporary directory.") @@ -50,18 +50,19 @@ def main(): config = yaml.safe_load(args.config) security = "security" in manifest.components and not args.insecure - if security: - tests_dir = os.path.join(os.getcwd(), "test-results", "perf-test", "with-security") - else: - tests_dir = os.path.join(os.getcwd(), "test-results", "perf-test", "without-security") + tests_dir = os.path.join(os.getcwd(), "test-results", "perf-test", f"{'with' if security else 'without'}-security") os.makedirs(tests_dir, exist_ok=True) with TemporaryDirectory(keep=args.keep, chdir=True) as work_dir: current_workspace = os.path.join(work_dir.name, "infra") with GitRepository(get_infra_repo_url(), "main", current_workspace): with WorkingDirectory(current_workspace): - with PerfTestCluster.create(manifest, config, args.stack, security, current_workspace) \ - as (test_cluster_endpoint, test_cluster_port): + with PerfTestCluster.create( + manifest, + config, + args.stack, + security, + current_workspace) as (test_cluster_endpoint, test_cluster_port): perf_test_suite = PerfTestSuite(manifest, test_cluster_endpoint, security, current_workspace, tests_dir, args) retry_call(perf_test_suite.execute, tries=3, delay=60, backoff=2) diff --git a/src/test_workflow/perf_test/perf_test_suite.py b/src/test_workflow/perf_test/perf_test_suite.py index 3f6fc55ce8..d885690edd 100644 --- a/src/test_workflow/perf_test/perf_test_suite.py +++ b/src/test_workflow/perf_test/perf_test_suite.py @@ -17,19 +17,11 @@ def __init__(self, bundle_manifest, endpoint, security, current_workspace, test_ self.args = args self.command = ( f"pipenv run python test_config.py -i {self.endpoint} -b {self.manifest.build.id}" - f" -a {self.manifest.build.architecture} -p {self.current_workspace}" + f" -a {self.manifest.build.architecture} -p {os.getcwd() if test_results_path is None else test_results_path}" f" --workload {self.args.workload} --workload-options '{self.args.workload_options}'" f" --warmup-iters {self.args.warmup_iters} --test-iters {self.args.test_iters}" ) - if test_results_path is not None: - self.command = ( - f"pipenv run python test_config.py -i {self.endpoint} -b {self.manifest.build.id}" - f" -a {self.manifest.build.architecture} -p {test_results_path}" - f" --workload {self.args.workload} --workload-options '{self.args.workload_options}'" - f" --warmup-iters {self.args.warmup_iters} --test-iters {self.args.test_iters}" - ) - def execute(self): try: current_workspace = os.path.join(self.current_workspace, self.work_dir) diff --git a/tests/jenkins/TestRunNonSecurityPerfTestScript.groovy b/tests/jenkins/TestRunNonSecurityPerfTestScript.groovy index 387ac12076..91f4cb1e9d 100644 --- a/tests/jenkins/TestRunNonSecurityPerfTestScript.groovy +++ b/tests/jenkins/TestRunNonSecurityPerfTestScript.groovy @@ -88,7 +88,7 @@ class TestRunSecurityPerfTestScript extends BuildPipelineTest { assertThat(testScriptCommands.size(), equalTo(1)) assertThat(testScriptCommands, hasItem( - "./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --force-insecure-mode --workload nyc_taxis --test-iters 1 --warmup-iters 1".toString() + "./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1".toString() )) def resultUploadScriptCommands = getCommandExecutions('s3Upload', 'test-results').findAll { diff --git a/tests/jenkins/TestRunPerfTestScript.groovy b/tests/jenkins/TestRunPerfTestScript.groovy index ab86b43630..5520ef1940 100644 --- a/tests/jenkins/TestRunPerfTestScript.groovy +++ b/tests/jenkins/TestRunPerfTestScript.groovy @@ -91,7 +91,7 @@ class TestRunPerfTestScript extends BuildPipelineTest { "./test.sh perf-test --stack test-single-security-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --workload nyc_taxis --test-iters 1 --warmup-iters 1".toString() )) assertThat(testScriptCommands, hasItem( - "./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --force-insecure-mode --workload nyc_taxis --test-iters 1 --warmup-iters 1".toString() + "./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1".toString() )) def resultUploadScriptCommands = getCommandExecutions('s3Upload', 'test-results').findAll { diff --git a/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test-with-security.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test-with-security.jenkinsfile.txt index 9aa9d84d95..f87e978372 100644 --- a/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test-with-security.jenkinsfile.txt +++ b/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test-with-security.jenkinsfile.txt @@ -107,7 +107,7 @@ ) runPerfTestScript.withAWS({role=opensearch-test, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) runPerfTestScript.s3Download({file=config.yml, bucket=test_bucket, path=test_config/config.yml, force=true}) - runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --force-insecure-mode --workload nyc_taxis --test-iters 1 --warmup-iters 1) + runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1) Messages.asBoolean() Messages.add(perf-test, Performance tests without security for 1236 completed) perf-test.writeFile({file=messages/perf-test.msg, text=Performance tests without security for 1236 completed}) diff --git a/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test.jenkinsfile.txt b/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test.jenkinsfile.txt index 938d295bea..5d06d7bf9c 100644 --- a/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test.jenkinsfile.txt +++ b/tests/jenkins/jenkinsjob-regression-files/opensearch/perf-test.jenkinsfile.txt @@ -51,7 +51,7 @@ ) runPerfTestScript.withAWS({role=opensearch-test, roleAccount=dummy_account, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure) runPerfTestScript.s3Download({file=config.yml, bucket=test_bucket, path=test_config/config.yml, force=true}) - runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --force-insecure-mode --workload nyc_taxis --test-iters 1 --warmup-iters 1) + runPerfTestScript.sh(./test.sh perf-test --stack test-single-1236-x64 --bundle-manifest tests/jenkins/data/opensearch-1.3.0-non-security-bundle.yml --config config.yml --without-security --workload nyc_taxis --test-iters 1 --warmup-iters 1) Messages.asBoolean() Messages.add(perf-test, Performance tests without security for 1236 completed) perf-test.writeFile({file=messages/perf-test.msg, text=Performance tests without security for 1236 completed}) diff --git a/tests/test_run_perf_test.py b/tests/test_run_perf_test.py index 6dcb216435..d96f0063d9 100644 --- a/tests/test_run_perf_test.py +++ b/tests/test_run_perf_test.py @@ -67,7 +67,7 @@ def test_default_execute_perf_test(self, mock_git, mock_temp, mock_working_dir, self.assertIn(True, mock_suite.call_args[0]) @patch("argparse._sys.argv", ["run_perf_test.py", "--bundle-manifest", OPENSEARCH_BUNDLE_MANIFEST, - "--stack", "test-stack", "--config", PERF_TEST_CONFIG, "--force-insecure-mode"]) + "--stack", "test-stack", "--config", PERF_TEST_CONFIG, "--without-security"]) @patch("run_perf_test.PerfTestCluster.create") @patch("run_perf_test.PerfTestSuite") @patch("run_perf_test.WorkingDirectory") diff --git a/vars/runPerfTestScript.groovy b/vars/runPerfTestScript.groovy index c90f03296e..bec1267c2c 100644 --- a/vars/runPerfTestScript.groovy +++ b/vars/runPerfTestScript.groovy @@ -15,7 +15,7 @@ void call(Map args = [:]) { "--stack test-single-security-${args.buildId}-${args.architecture}", "--bundle-manifest ${args.bundleManifest}", "--config config.yml", - args.insecure ? "--force-insecure-mode" : "", + args.insecure ? "--without-security" : "", isNullOrEmpty(args.workload) ? "" : "--workload ${args.workload}", isNullOrEmpty(args.testIterations) ? "" : "--test-iters ${args.testIterations}", isNullOrEmpty(args.warmupIterations) ? "" : "--warmup-iters ${args.warmupIterations}",