|
15 | 15 |
|
16 | 16 | import requests
|
17 | 17 |
|
| 18 | +from test_workflow.integ_test.utils import get_password |
18 | 19 | from validation_workflow.api_request import ApiTest
|
19 | 20 | from validation_workflow.api_test_cases import ApiTestCases
|
20 | 21 | from validation_workflow.docker.inspect_docker_image import InspectDockerImage
|
@@ -60,7 +61,7 @@ def start_cluster(self) -> bool:
|
60 | 61 | def validation(self) -> bool:
|
61 | 62 | # STEP 2 . inspect image digest between opensearchproject(downloaded/local) and opensearchstaging(dockerHub)
|
62 | 63 | if not self.args.using_staging_artifact_only:
|
63 |
| - self.image_names_list = [self.args.OS_image, self.args.OSD_image] |
| 64 | + self.image_names_list = ['opensearchproject/' + project for project in self.args.projects] |
64 | 65 | self.image_names_list = [x for x in self.image_names_list if (os.path.basename(x) in self.args.projects)]
|
65 | 66 | self.image_digests = list(map(lambda x: self.inspect_docker_image(x[0], x[1]), zip(self.image_ids.values(), self.image_names_list))) # type: ignore
|
66 | 67 | if all(self.image_digests):
|
@@ -93,8 +94,8 @@ def validation(self) -> bool:
|
93 | 94 | raise Exception(f'Not all tests Pass : {_counter}')
|
94 | 95 | else:
|
95 | 96 | raise Exception("Cluster is not ready for API test.")
|
96 |
| - else: |
97 |
| - raise Exception('The container failed to start. Exiting the validation.') |
| 97 | + else: |
| 98 | + raise Exception('The container failed to start. Exiting the validation.') |
98 | 99 |
|
99 | 100 | return True
|
100 | 101 |
|
@@ -130,10 +131,10 @@ def cleanup_process(self) -> bool:
|
130 | 131 |
|
131 | 132 | def check_http_request(self) -> bool:
|
132 | 133 | self.test_readiness_urls = {
|
133 |
| - 'https://localhost:9200/': 'opensearch cluster API', |
134 |
| - 'http://localhost:5601/api/status': 'opensearch-dashboards API', |
| 134 | + 'https://localhost:9200': 'opensearch cluster API' |
135 | 135 | }
|
136 |
| - |
| 136 | + if 'opensearch-dashboards' in self.args.projects: |
| 137 | + self.test_readiness_urls['http://localhost:5601/api/status'] = 'opensearch-dashboards API' |
137 | 138 | for url, name in self.test_readiness_urls.items():
|
138 | 139 | try:
|
139 | 140 | status_code, response_text = ApiTest(url, self.args.version).api_get()
|
@@ -200,8 +201,7 @@ def inplace_change(self, filename: str, old_string: str, new_string: str) -> Non
|
200 | 201 | with open(filename) as f:
|
201 | 202 | s = f.read()
|
202 | 203 | if old_string not in s:
|
203 |
| - logging.info |
204 |
| - ('"{old_string}" not found in {filename}.'.format(**locals())) |
| 204 | + logging.info('"{old_string}" not found in {filename}.'.format(**locals())) |
205 | 205 | return
|
206 | 206 | with open(filename, 'w') as f:
|
207 | 207 | logging.info('Changing "{old_string}" to "{new_string}" in {filename}'.format(**locals()))
|
@@ -250,8 +250,9 @@ def run_container(self, image_ids: dict, version: str) -> Any:
|
250 | 250 | self.replacements = [(f'opensearchproject/{key}:{self.major_version_number}', value) for key, value in image_ids.items()]
|
251 | 251 |
|
252 | 252 | list(map(lambda r: self.inplace_change(self.target_yml_file, r[0], r[1]), self.replacements))
|
253 |
| - |
| 253 | + os.environ["OPENSEARCH_INITIAL_ADMIN_PASSWORD"] = get_password(str(version)) |
254 | 254 | # spin up containers
|
255 |
| - self.docker_compose_up = f'docker-compose -f {self.target_yml_file} up -d' |
| 255 | + services = "opensearch-node1 opensearch-node2" if "opensearch-dashboards" not in self.args.projects else "" |
| 256 | + self.docker_compose_up = f'docker-compose -f {self.target_yml_file} up -d {services}' |
256 | 257 | result = subprocess.run(self.docker_compose_up, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
257 | 258 | return ('returncode=0' in (str(result)), self.target_yml_file)
|
0 commit comments