Skip to content

Commit

Permalink
Update secure mode flag name, pythonify branch code
Browse files Browse the repository at this point in the history
Signed-off-by: Kunal Kotwani <[email protected]>
  • Loading branch information
kotwanikunal committed Apr 1, 2022
1 parent 74bf99a commit 6467372
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 22 deletions.
15 changes: 8 additions & 7 deletions src/run_perf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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)
Expand Down
10 changes: 1 addition & 9 deletions src/test_workflow/perf_test/perf_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/TestRunNonSecurityPerfTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/TestRunPerfTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion tests/test_run_perf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion vars/runPerfTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down

0 comments on commit 6467372

Please sign in to comment.