diff --git a/src/test_workflow/benchmark_test/benchmark_args.py b/src/test_workflow/benchmark_test/benchmark_args.py index fe9393fb58..69a629d321 100644 --- a/src/test_workflow/benchmark_test/benchmark_args.py +++ b/src/test_workflow/benchmark_test/benchmark_args.py @@ -156,9 +156,8 @@ def __init__(self) -> None: self.telemetry_params = args.telemetry_params if args.telemetry_params else None self.logging_level = args.logging_level - """ + if self.bundle_manifest is None and self.distribution_url is None: raise Exception('Please provide either --bundle-manifest or --distribution-url to run the performance test.') - elif self.distribution_url and self.distribution_version is None: - raise Exception("--distribution-version is required parameter while using --distribution-url param.") - """ + elif (self.distribution_url or self.cluster_endpoint) and self.distribution_version is None: + raise Exception("--distribution-version is required parameter while using --distribution-url or --cluster-endpoint param.") diff --git a/src/test_workflow/benchmark_test/benchmark_test_cluster.py b/src/test_workflow/benchmark_test/benchmark_test_cluster.py index a4a53cbf83..d610d863d1 100644 --- a/src/test_workflow/benchmark_test/benchmark_test_cluster.py +++ b/src/test_workflow/benchmark_test/benchmark_test_cluster.py @@ -25,12 +25,10 @@ class BenchmarkTestCluster: manifest: Union[BundleManifest, BuildManifest] - work_dir: str current_workspace: str args: BenchmarkArgs output_file: str params: str - is_endpoint_public: bool cluster_endpoint_with_port: str """ @@ -48,32 +46,35 @@ def __init__( self.manifest = bundle_manifest self.current_workspace = current_workspace self.args = args - self.output_file = "output.json" - """role = config["Constants"]["Role"] - params_dict = self.setup_cdk_params(config) - params_list = [] - for key, value in params_dict.items(): - if value: - ''' - TODO: To send json input to typescript code from command line it needs to be enclosed in - single-quotes, this is a temp fix to achieve that since the quoted string passed from command line in - tesh.sh wrapper script gets un-quoted and we need to handle it here. - ''' - if key == 'additionalConfig': - params_list.append(f" -c {key}=\'{value}\'") - else: - params_list.append(f" -c {key}={value}") - role_params = ( - f" --require-approval=never --plugin cdk-assume-role-credential-plugin" - f" -c assume-role-credentials:writeIamRoleName={role} -c assume-role-credentials:readIamRoleName={role} " - ) - self.params = "".join(params_list) + role_params - """ - self.is_endpoint_public = False - self.cluster_endpoint_with_port = None - self.stack_name = f"opensearch-infra-stack-{self.args.stack_suffix}" - if self.manifest: - self.stack_name += f"-{self.manifest.build.id}-{self.manifest.build.architecture}" + + + if self.args.cluster_endpoint is None: + + role = config["Constants"]["Role"] + params_dict = self.setup_cdk_params(config) + params_list = [] + for key, value in params_dict.items(): + if value: + ''' + TODO: To send json input to typescript code from command line it needs to be enclosed in + single-quotes, this is a temp fix to achieve that since the quoted string passed from command line in + tesh.sh wrapper script gets un-quoted and we need to handle it here. + ''' + if key == 'additionalConfig': + params_list.append(f" -c {key}=\'{value}\'") + else: + params_list.append(f" -c {key}={value}") + role_params = ( + f" --require-approval=never --plugin cdk-assume-role-credential-plugin" + f" -c assume-role-credentials:writeIamRoleName={role} -c assume-role-credentials:readIamRoleName={role} " + ) + self.params = "".join(params_list) + role_params + + self.cluster_endpoint_with_port = None + self.output_file = "output.json" + self.stack_name = f"opensearch-infra-stack-{self.args.stack_suffix}" + if self.manifest: + self.stack_name += f"-{self.manifest.build.id}-{self.manifest.build.architecture}" def start(self) -> None: if self.args.cluster_endpoint is None: @@ -164,6 +165,7 @@ def setup_cdk_params(self, config: dict) -> dict: "serverAccessType": config["Constants"]["serverAccessType"], "restrictServerAccessTo": config["Constants"]["restrictServerAccessTo"], "additionalConfig": self.args.additional_config, + "additionalConfig": self.args.additional_config, "dataInstanceType": self.args.data_instance_type, "managerNodeCount": self.args.manager_node_count, "dataNodeCount": self.args.data_node_count, @@ -192,4 +194,5 @@ def create(cls, *args: Any) -> Generator[Any, None, None]: cluster.start() yield cluster finally: - cluster.terminate() + if cls.args.cluster_endpoint is None: + cluster.terminate() diff --git a/src/test_workflow/benchmark_test/benchmark_test_runner_opensearch.py b/src/test_workflow/benchmark_test/benchmark_test_runner_opensearch.py index 84315d8219..0ab6926ab9 100644 --- a/src/test_workflow/benchmark_test/benchmark_test_runner_opensearch.py +++ b/src/test_workflow/benchmark_test/benchmark_test_runner_opensearch.py @@ -37,8 +37,7 @@ def get_cluster_repo_url(self) -> str: return "https://github.com/opensearch-project/opensearch-cluster-cdk.git" def run_tests(self) -> None: - # config = yaml.safe_load(self.args.config) if config else None - config = {} + config = yaml.safe_load(self.args.config) if config else None with TemporaryDirectory(keep=self.args.keep, chdir=True) as work_dir: current_workspace = os.path.join(work_dir.name, "opensearch-cluster-cdk") diff --git a/src/test_workflow/benchmark_test/benchmark_test_suite.py b/src/test_workflow/benchmark_test/benchmark_test_suite.py index 304439a414..b4a436db19 100644 --- a/src/test_workflow/benchmark_test/benchmark_test_suite.py +++ b/src/test_workflow/benchmark_test/benchmark_test_suite.py @@ -18,7 +18,6 @@ class BenchmarkTestSuite: endpoint: str security: bool - current_workspace: str args: BenchmarkArgs command: str distribution_version: str