Skip to content

Commit

Permalink
add more changes
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Madala <[email protected]>
  • Loading branch information
Divyaasm committed Apr 5, 2024
1 parent 190aa1a commit d070349
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/test_workflow/benchmark_test/benchmark_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self) -> None:
help="Load balancer url for benchmark testing")
parser.add_argument("--distribution-version", dest="distribution_version",
help="provide OpenSearch version if using distribution-url param.")
parser.add_argument("--username", dest="username", help="Username for the cluster")
parser.add_argument("--username", dest="username", default="admin", help="Username for the cluster")
parser.add_argument("--password", dest="password", help="Password for the cluster")
parser.add_argument("--suffix", dest="suffix", help="Suffix to be added to stack name for performance test")
parser.add_argument("--component", dest="component", default="OpenSearch",
Expand Down
16 changes: 7 additions & 9 deletions src/test_workflow/benchmark_test/benchmark_test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ def __init__(
self.args = args
self.cluster_endpoint = self.args.cluster_endpoint
self.cluster_endpoint_with_port = None
self.password = self.args.password
self.password = self.args.password if self.args.password else get_password('2.12.0')

def start(self) -> None:

command = f"curl http://{self.cluster_endpoint}" if self.args.insecure else f"curl https://{self.cluster_endpoint} -ku '{self.args.username}:{self.args.password}'"
logging.info(command)
command = f"curl http://{self.cluster_endpoint}" if self.args.insecure else f"curl https://{self.cluster_endpoint} -ku '{self.args.username}:{self.password}'"
try:
result = subprocess.run(command, shell=True, capture_output=True, timeout=5)
except subprocess.TimeoutExpired:
Expand All @@ -46,10 +45,10 @@ def start(self) -> None:
if result.stdout:
res_dict = json.loads(result.stdout)
self.args.distribution_version = res_dict['version']['number']
logging.info(self.args.distribution_version)
self.wait_for_processing()

self.cluster_endpoint_with_port = "".join([self.cluster_endpoint, ":", str(self.port)])
self.wait_for_processing()
self.cluster_endpoint_with_port = "".join([self.cluster_endpoint, ":", str(self.port)])
else:
raise Exception("Empty response retrieved from the curl command")

@property
def endpoint(self) -> str:
Expand All @@ -70,7 +69,6 @@ def wait_for_processing(self, tries: int = 3, delay: int = 15, backoff: int = 2)
logging.info("Waiting for domain ******* to be up")
protocol = "http://" if self.args.insecure else "https://"
url = "".join([protocol, self.endpoint, "/_cluster/health"])
# self.password = None if self.args.insecure else get_password(self.args.distribution_version)
request_args = {"url": url} if self.args.insecure else {"url": url, "auth": HTTPBasicAuth(self.args.username, self.args.password), # type: ignore
request_args = {"url": url} if self.args.insecure else {"url": url, "auth": HTTPBasicAuth(self.args.username, self.password), # type: ignore
"verify": False} # type: ignore
retry_call(requests.get, fkwargs=request_args, tries=tries, delay=delay, backoff=backoff)
4 changes: 2 additions & 2 deletions src/test_workflow/benchmark_test/benchmark_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def __init__(

def execute(self) -> None:
if self.security:
self.command += f' --client-options="timeout:300,use_ssl:true,verify_certs:false,basic_auth_user:\'{self.args.username}\',basic_auth_password:\'{self.args.password}\'"'
self.command += f' --client-options="timeout:300,use_ssl:true,verify_certs:false,basic_auth_user:\'{self.args.username}\',basic_auth_password:\'{self.password}\'"'
else:
self.command += ' --client-options="timeout:300"'
logging.info(f"Executing {self.command.replace(self.endpoint, len(self.endpoint)*'*').replace(self.args.username, len(self.args.username)*'*').replace(self.args.password, len(self.args.password)*'*')}")
logging.info(f"Executing {self.command.replace(self.endpoint, len(self.endpoint)*'*').replace(self.args.username, len(self.args.username)*'*').replace(self.password, len(self.password)*'*')}")
subprocess.check_call(f"{self.command}", cwd=os.getcwd(), shell=True)

0 comments on commit d070349

Please sign in to comment.