Skip to content

Commit

Permalink
benchmark tests
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Madala <divyaasm@amazon.com>
  • Loading branch information
Divyaasm committed Mar 12, 2024
1 parent 0c266ec commit 017e9ef
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
7 changes: 3 additions & 4 deletions src/test_workflow/benchmark_test/benchmark_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
61 changes: 32 additions & 29 deletions src/test_workflow/benchmark_test/benchmark_test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion src/test_workflow/benchmark_test/benchmark_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
class BenchmarkTestSuite:
endpoint: str
security: bool
current_workspace: str
args: BenchmarkArgs
command: str
distribution_version: str
Expand Down

0 comments on commit 017e9ef

Please sign in to comment.