From e1ad15a3cbac8ca5a26774717afeac97dfacdde9 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 09:38:27 -0500 Subject: [PATCH 01/24] Change password based on version in integtest health check Signed-off-by: Derek Ho --- src/test_workflow/integ_test/service_opensearch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test_workflow/integ_test/service_opensearch.py b/src/test_workflow/integ_test/service_opensearch.py index 3f6d23790c..a425ecdeaf 100644 --- a/src/test_workflow/integ_test/service_opensearch.py +++ b/src/test_workflow/integ_test/service_opensearch.py @@ -40,6 +40,7 @@ def __init__( self.dist = Distributions.get_distribution("opensearch", distribution, version, work_dir) self.dependency_installer = dependency_installer self.install_dir = self.dist.install_dir + self.password = 'myStrongPassword123!' if float('.'.join("3.0.0".split('.')[:2])) >= 2.12 else 'admin' def start(self) -> None: self.dist.install(self.download()) @@ -65,7 +66,7 @@ def url(self, path: str = "") -> str: def get_service_response(self) -> Response: url = self.url("/_cluster/health") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", "admin")) + return requests.get(url, verify=False, auth=("admin", self.password)) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_yml_path, "a") as yamlfile: From 46cd35bf3582d661e3753f90ca5f0075f9051960 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 09:46:12 -0500 Subject: [PATCH 02/24] Remove hard coded 3 Signed-off-by: Derek Ho --- src/test_workflow/integ_test/service_opensearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test_workflow/integ_test/service_opensearch.py b/src/test_workflow/integ_test/service_opensearch.py index a425ecdeaf..0f9cef9413 100644 --- a/src/test_workflow/integ_test/service_opensearch.py +++ b/src/test_workflow/integ_test/service_opensearch.py @@ -40,7 +40,7 @@ def __init__( self.dist = Distributions.get_distribution("opensearch", distribution, version, work_dir) self.dependency_installer = dependency_installer self.install_dir = self.dist.install_dir - self.password = 'myStrongPassword123!' if float('.'.join("3.0.0".split('.')[:2])) >= 2.12 else 'admin' + self.password = 'myStrongPassword123!' if float('.'.join(self.version.split('.')[:2])) >= 2.12 else 'admin' def start(self) -> None: self.dist.install(self.download()) From a7ba5e45632da8abf88dedbd812be91de971209e Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 13:18:10 -0500 Subject: [PATCH 03/24] Add version check same as benchmark Signed-off-by: Derek Ho --- .../perf_test/perf_test_cluster.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/test_workflow/perf_test/perf_test_cluster.py b/src/test_workflow/perf_test/perf_test_cluster.py index 93213f0402..d50a34eb53 100644 --- a/src/test_workflow/perf_test/perf_test_cluster.py +++ b/src/test_workflow/perf_test/perf_test_cluster.py @@ -15,6 +15,7 @@ from typing import Any, Generator, List import requests +import semver from requests.auth import HTTPBasicAuth from retry.api import retry_call # type: ignore @@ -108,11 +109,18 @@ def dependencies(self) -> List[Service]: return [] def wait_for_processing(self, tries: int = 3, delay: int = 15, backoff: int = 2) -> None: - # Should be invoked only if the endpoint is public. - assert self.is_endpoint_public, "wait_for_processing should be invoked only when cluster is public" - logging.info("Waiting for domain to be up") - url = "".join([self.endpoint_with_port, "/_cluster/health"]) - retry_call(requests.get, fkwargs={"url": url, "auth": HTTPBasicAuth('admin', 'admin'), "verify": False}, + password = 'admin' + if self.manifest: + if semver.compare(self.manifest.build.version, '2.12.0') != -1: + password = 'myStrongPassword123!' + else: + if semver.compare(self.args.distribution_version, '2.12.0') != -1: + password = 'myStrongPassword123!' + + logging.info(f"Waiting for domain at {self.endpoint} to be up") + protocol = "http://" if self.args.insecure else "https://" + url = "".join([protocol, self.endpoint, "/_cluster/health"]) + retry_call(requests.get, fkwargs={"url": url, "auth": HTTPBasicAuth('admin', password), "verify": False}, tries=tries, delay=delay, backoff=backoff) @abc.abstractmethod From 3097bbccff1d4dff68bae9db73b82f71ce5513e7 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 13:20:14 -0500 Subject: [PATCH 04/24] Fix to minimize changes Signed-off-by: Derek Ho --- src/test_workflow/perf_test/perf_test_cluster.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test_workflow/perf_test/perf_test_cluster.py b/src/test_workflow/perf_test/perf_test_cluster.py index d50a34eb53..23530b9934 100644 --- a/src/test_workflow/perf_test/perf_test_cluster.py +++ b/src/test_workflow/perf_test/perf_test_cluster.py @@ -117,9 +117,10 @@ def wait_for_processing(self, tries: int = 3, delay: int = 15, backoff: int = 2) if semver.compare(self.args.distribution_version, '2.12.0') != -1: password = 'myStrongPassword123!' + # Should be invoked only if the endpoint is public. + assert self.is_endpoint_public, "wait_for_processing should be invoked only when cluster is public" logging.info(f"Waiting for domain at {self.endpoint} to be up") - protocol = "http://" if self.args.insecure else "https://" - url = "".join([protocol, self.endpoint, "/_cluster/health"]) + url = "".join([self.endpoint_with_port, "/_cluster/health"]) retry_call(requests.get, fkwargs={"url": url, "auth": HTTPBasicAuth('admin', password), "verify": False}, tries=tries, delay=delay, backoff=backoff) From f493f24993e7b7e09fc207999d245dd7880a6d97 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 13:21:16 -0500 Subject: [PATCH 05/24] Revert logging line Signed-off-by: Derek Ho --- src/test_workflow/perf_test/perf_test_cluster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test_workflow/perf_test/perf_test_cluster.py b/src/test_workflow/perf_test/perf_test_cluster.py index 23530b9934..e7832c96c0 100644 --- a/src/test_workflow/perf_test/perf_test_cluster.py +++ b/src/test_workflow/perf_test/perf_test_cluster.py @@ -119,7 +119,7 @@ def wait_for_processing(self, tries: int = 3, delay: int = 15, backoff: int = 2) # Should be invoked only if the endpoint is public. assert self.is_endpoint_public, "wait_for_processing should be invoked only when cluster is public" - logging.info(f"Waiting for domain at {self.endpoint} to be up") + logging.info("Waiting for domain to be up") url = "".join([self.endpoint_with_port, "/_cluster/health"]) retry_call(requests.get, fkwargs={"url": url, "auth": HTTPBasicAuth('admin', password), "verify": False}, tries=tries, delay=delay, backoff=backoff) From 5d7f0606184d2b4f550a171e79c57cfea895abe8 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 13:24:01 -0500 Subject: [PATCH 06/24] Remove non-existent args param Signed-off-by: Derek Ho --- src/test_workflow/perf_test/perf_test_cluster.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test_workflow/perf_test/perf_test_cluster.py b/src/test_workflow/perf_test/perf_test_cluster.py index e7832c96c0..6a034a0d9b 100644 --- a/src/test_workflow/perf_test/perf_test_cluster.py +++ b/src/test_workflow/perf_test/perf_test_cluster.py @@ -113,9 +113,6 @@ def wait_for_processing(self, tries: int = 3, delay: int = 15, backoff: int = 2) if self.manifest: if semver.compare(self.manifest.build.version, '2.12.0') != -1: password = 'myStrongPassword123!' - else: - if semver.compare(self.args.distribution_version, '2.12.0') != -1: - password = 'myStrongPassword123!' # Should be invoked only if the endpoint is public. assert self.is_endpoint_public, "wait_for_processing should be invoked only when cluster is public" From 9ae642eece82eb593b70b48a6038882a3ccd3bc2 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 15:38:10 -0500 Subject: [PATCH 07/24] try adding a test to increase codecov Signed-off-by: Derek Ho --- .../perf_test/test_perf_test_cluster.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 632a772c9a..1ad86b5b3d 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -7,7 +7,7 @@ import os import unittest -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock, Mock, patch from manifests.bundle_manifest import BundleManifest from test_workflow.perf_test.perf_test_cluster import PerfTestCluster @@ -37,6 +37,13 @@ def test_create(self) -> None: mock_chdir.assert_called_once_with(os.path.join(self.perf_test_cluster.current_workspace, "test_dir")) self.assertEqual(mock_check_call.call_count, 1) + def test_wait_for_processing(self, mock_url: Mock, mock_requests_get: Mock) -> None: + mock_url_result = MagicMock() + mock_url.return_value = mock_url_result + self.perf_test_cluster.wait_for_processing() + mock_url.assert_called_once_with("/_cluster/health") + mock_requests_get.assert_called_once_with(mock_url_result, verify=False, auth=('admin', 'admin')) + def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From 574e40a5fbdf8f810a8f701643d49c73b84db7b7 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 16:09:18 -0500 Subject: [PATCH 08/24] Add test Signed-off-by: Derek Ho --- .../perf_test/test_perf_test_cluster.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 1ad86b5b3d..6cc752d3aa 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -7,7 +7,8 @@ import os import unittest -from unittest.mock import MagicMock, Mock, patch +from typing import Any +from unittest.mock import MagicMock, patch from manifests.bundle_manifest import BundleManifest from test_workflow.perf_test.perf_test_cluster import PerfTestCluster @@ -37,12 +38,12 @@ def test_create(self) -> None: mock_chdir.assert_called_once_with(os.path.join(self.perf_test_cluster.current_workspace, "test_dir")) self.assertEqual(mock_check_call.call_count, 1) - def test_wait_for_processing(self, mock_url: Mock, mock_requests_get: Mock) -> None: - mock_url_result = MagicMock() - mock_url.return_value = mock_url_result + @patch("requests.get") + @patch("PerfTestCluster.manifest.build.version", return_value='1.0.0') + @patch("PerfTestcluster.endpoint_with_port", return_value='') + def test_wait_for_processing(self, *mocks: Any) -> None: self.perf_test_cluster.wait_for_processing() - mock_url.assert_called_once_with("/_cluster/health") - mock_requests_get.assert_called_once_with(mock_url_result, verify=False, auth=('admin', 'admin')) + self.assert_called_once_with("/_cluster/health") def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From 034f0cb869fc637a265610d3c6daddbc08913efd Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 16:15:54 -0500 Subject: [PATCH 09/24] Fix test Signed-off-by: Derek Ho --- .../perf_test/test_perf_test_cluster.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 6cc752d3aa..38cb6aea12 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -7,8 +7,7 @@ import os import unittest -from typing import Any -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock, Mock, patch from manifests.bundle_manifest import BundleManifest from test_workflow.perf_test.perf_test_cluster import PerfTestCluster @@ -41,9 +40,14 @@ def test_create(self) -> None: @patch("requests.get") @patch("PerfTestCluster.manifest.build.version", return_value='1.0.0') @patch("PerfTestcluster.endpoint_with_port", return_value='') - def test_wait_for_processing(self, *mocks: Any) -> None: + def test_wait_for_processing(self, mock_url: Mock, mock_requests_get: Mock) -> None: + mock_url_result = MagicMock() + mock_url.return_value = mock_url_result + + self.perf_test_cluster.wait_for_processing() + + mock_url.assert_called_once_with("/_cluster/health") self.perf_test_cluster.wait_for_processing() - self.assert_called_once_with("/_cluster/health") def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From 4aac0c2a3ed3bb106f0d6b0371af17ddc595f974 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 16:20:40 -0500 Subject: [PATCH 10/24] fix capital Signed-off-by: Derek Ho --- .../test_perf_workflow/perf_test/test_perf_test_cluster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 38cb6aea12..18075e37fb 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -39,7 +39,7 @@ def test_create(self) -> None: @patch("requests.get") @patch("PerfTestCluster.manifest.build.version", return_value='1.0.0') - @patch("PerfTestcluster.endpoint_with_port", return_value='') + @patch("PerfTestCluster.endpoint_with_port", return_value='') def test_wait_for_processing(self, mock_url: Mock, mock_requests_get: Mock) -> None: mock_url_result = MagicMock() mock_url.return_value = mock_url_result From d6fa3d56db299ed009bc0f8a57e8ab205b399c71 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 16:27:14 -0500 Subject: [PATCH 11/24] remove extra line Signed-off-by: Derek Ho --- .../test_perf_workflow/perf_test/test_perf_test_cluster.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 18075e37fb..65746874d8 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -47,7 +47,6 @@ def test_wait_for_processing(self, mock_url: Mock, mock_requests_get: Mock) -> N self.perf_test_cluster.wait_for_processing() mock_url.assert_called_once_with("/_cluster/health") - self.perf_test_cluster.wait_for_processing() def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From 3185ebe44c655399f0611edd7649485c7640f2f6 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 16:42:58 -0500 Subject: [PATCH 12/24] Fix test Signed-off-by: Derek Ho --- .../perf_test/test_perf_test_cluster.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 65746874d8..533244ec52 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -38,15 +38,9 @@ def test_create(self) -> None: self.assertEqual(mock_check_call.call_count, 1) @patch("requests.get") - @patch("PerfTestCluster.manifest.build.version", return_value='1.0.0') - @patch("PerfTestCluster.endpoint_with_port", return_value='') - def test_wait_for_processing(self, mock_url: Mock, mock_requests_get: Mock) -> None: - mock_url_result = MagicMock() - mock_url.return_value = mock_url_result - + def test_get_service_response(self, mock_requests_get: Mock) -> None: self.perf_test_cluster.wait_for_processing() - - mock_url.assert_called_once_with("/_cluster/health") + mock_requests_get.assert_called_once_with('', verify=False, auth=('admin', 'admin')) def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From 2d77952b0ebeb058206c98517a1fb676b20a5962 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 16:48:48 -0500 Subject: [PATCH 13/24] Fix test Signed-off-by: Derek Ho --- .../test_perf_workflow/perf_test/test_perf_test_cluster.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 533244ec52..23debd80f0 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -39,6 +39,8 @@ def test_create(self) -> None: @patch("requests.get") def test_get_service_response(self, mock_requests_get: Mock) -> None: + self.perf_test_cluster.is_endpoint_public = True + self.perf_test_cluster.cluster_endpoint_with_port = '' self.perf_test_cluster.wait_for_processing() mock_requests_get.assert_called_once_with('', verify=False, auth=('admin', 'admin')) From 42fccb259dc741f35f148438cb10610e332b6735 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 16:58:02 -0500 Subject: [PATCH 14/24] Fix test Signed-off-by: Derek Ho --- .../test_perf_workflow/perf_test/test_perf_test_cluster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 23debd80f0..9ee8f3bfe0 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -42,7 +42,7 @@ def test_get_service_response(self, mock_requests_get: Mock) -> None: self.perf_test_cluster.is_endpoint_public = True self.perf_test_cluster.cluster_endpoint_with_port = '' self.perf_test_cluster.wait_for_processing() - mock_requests_get.assert_called_once_with('', verify=False, auth=('admin', 'admin')) + mock_requests_get.assert_called_with(url='/_cluster/health', verify=False, auth=HTTPBasicAuth('admin', 'admin'))) def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From d76d9b2bde9d44c68e3be5be8efc6dfec117612b Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 17:01:24 -0500 Subject: [PATCH 15/24] Fix test Signed-off-by: Derek Ho --- .../test_perf_workflow/perf_test/test_perf_test_cluster.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 9ee8f3bfe0..4e23220121 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -9,6 +9,8 @@ import unittest from unittest.mock import MagicMock, Mock, patch +from requests.auth import HTTPBasicAuth + from manifests.bundle_manifest import BundleManifest from test_workflow.perf_test.perf_test_cluster import PerfTestCluster from test_workflow.perf_test.perf_test_cluster_config import PerfTestClusterConfig @@ -42,7 +44,7 @@ def test_get_service_response(self, mock_requests_get: Mock) -> None: self.perf_test_cluster.is_endpoint_public = True self.perf_test_cluster.cluster_endpoint_with_port = '' self.perf_test_cluster.wait_for_processing() - mock_requests_get.assert_called_with(url='/_cluster/health', verify=False, auth=HTTPBasicAuth('admin', 'admin'))) + mock_requests_get.assert_called_with(url='/_cluster/health', verify=False, auth=HTTPBasicAuth('admin', 'admin')) def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From c2b1374709d11f80b1759d7ffe1f1a91a348b7bf Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 17:08:53 -0500 Subject: [PATCH 16/24] Fix version to hit more lines Signed-off-by: Derek Ho --- .../test_perf_workflow/perf_test/data/bundle_manifest.yml | 2 +- .../test_perf_workflow/perf_test/test_perf_test_cluster.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/data/bundle_manifest.yml b/tests/tests_test_workflow/test_perf_workflow/perf_test/data/bundle_manifest.yml index 425c1fa2a3..b819854cee 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/data/bundle_manifest.yml +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/data/bundle_manifest.yml @@ -5,7 +5,7 @@ build: id: 41d5ae25183d4e699e92debfbe3f83bd location: https://artifacts.opensearch.org/bundles/1.0.0/41d5ae25183d4e699e92debfbe3f83bd/opensearch-1.0.0-linux-x64.tar.gz name: OpenSearch - version: 1.0.0 + version: 3.0.0 components: - commit_id: fb25458f38c30a7ab06de21b0068f1fe3ad56134 location: https://artifacts.opensearch.org/builds/1.0.0/41d5ae25183d4e699e92debfbe3f83bd/bundle/opensearch-min-1.0.0-linux-x64.tar.gz diff --git a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py index 4e23220121..f31fbebb53 100644 --- a/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py +++ b/tests/tests_test_workflow/test_perf_workflow/perf_test/test_perf_test_cluster.py @@ -44,7 +44,7 @@ def test_get_service_response(self, mock_requests_get: Mock) -> None: self.perf_test_cluster.is_endpoint_public = True self.perf_test_cluster.cluster_endpoint_with_port = '' self.perf_test_cluster.wait_for_processing() - mock_requests_get.assert_called_with(url='/_cluster/health', verify=False, auth=HTTPBasicAuth('admin', 'admin')) + mock_requests_get.assert_called_with(url='/_cluster/health', verify=False, auth=HTTPBasicAuth('admin', 'myStrongPassword123!')) def test_endpoint(self) -> None: self.assertEqual(self.perf_test_cluster.endpoint_with_port, None) From 48fbe247b25ffe7a6235ca185a877d76ef1f9aed Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 20:24:17 -0500 Subject: [PATCH 17/24] Update password based on version for OSD Signed-off-by: Derek Ho --- src/test_workflow/integ_test/service_opensearch_dashboards.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test_workflow/integ_test/service_opensearch_dashboards.py b/src/test_workflow/integ_test/service_opensearch_dashboards.py index 0180b0ae54..fc8315265e 100644 --- a/src/test_workflow/integ_test/service_opensearch_dashboards.py +++ b/src/test_workflow/integ_test/service_opensearch_dashboards.py @@ -38,6 +38,7 @@ def __init__( super().__init__(work_dir, version, distribution, security_enabled, additional_config, dependency_installer) self.dist = Distributions.get_distribution("opensearch-dashboards", distribution, version, work_dir) self.install_dir = self.dist.install_dir + self.password = 'myStrongPassword123!' if float('.'.join(self.version.split('.')[:2])) >= 2.12 else 'admin' def start(self) -> None: self.dist.install(self.download()) @@ -86,7 +87,7 @@ def url(self, path: str = "") -> str: def get_service_response(self) -> Response: url = self.url("/api/status") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", "admin") if self.security_enabled else None) + return requests.get(url, verify=False, auth=("admin", self.password) if self.security_enabled else None) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_dashboards_yml_path, "a") as yamlfile: From e4509573913a0def330ceded2b37c6dd0427d932 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 9 Jan 2024 21:07:09 -0500 Subject: [PATCH 18/24] change to semver impl Signed-off-by: Derek Ho --- src/test_workflow/integ_test/service_opensearch.py | 7 +++++-- .../integ_test/service_opensearch_dashboards.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/test_workflow/integ_test/service_opensearch.py b/src/test_workflow/integ_test/service_opensearch.py index 0f9cef9413..411d6deacf 100644 --- a/src/test_workflow/integ_test/service_opensearch.py +++ b/src/test_workflow/integ_test/service_opensearch.py @@ -9,6 +9,7 @@ import os import requests +import semver import yaml from requests.models import Response @@ -40,7 +41,6 @@ def __init__( self.dist = Distributions.get_distribution("opensearch", distribution, version, work_dir) self.dependency_installer = dependency_installer self.install_dir = self.dist.install_dir - self.password = 'myStrongPassword123!' if float('.'.join(self.version.split('.')[:2])) >= 2.12 else 'admin' def start(self) -> None: self.dist.install(self.download()) @@ -64,9 +64,12 @@ def url(self, path: str = "") -> str: return f'{"https" if self.security_enabled else "http"}://{self.endpoint()}:{self.port()}{path}' def get_service_response(self) -> Response: + password = "admin" + if semver.compare(self.version, '2.12.0') != -1: + password = "myStrongPassword123!" url = self.url("/_cluster/health") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", self.password)) + return requests.get(url, verify=False, auth=("admin", password)) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_yml_path, "a") as yamlfile: diff --git a/src/test_workflow/integ_test/service_opensearch_dashboards.py b/src/test_workflow/integ_test/service_opensearch_dashboards.py index fc8315265e..7df9eae3e8 100644 --- a/src/test_workflow/integ_test/service_opensearch_dashboards.py +++ b/src/test_workflow/integ_test/service_opensearch_dashboards.py @@ -10,6 +10,7 @@ import subprocess import requests +import semver import yaml from requests.models import Response @@ -38,7 +39,6 @@ def __init__( super().__init__(work_dir, version, distribution, security_enabled, additional_config, dependency_installer) self.dist = Distributions.get_distribution("opensearch-dashboards", distribution, version, work_dir) self.install_dir = self.dist.install_dir - self.password = 'myStrongPassword123!' if float('.'.join(self.version.split('.')[:2])) >= 2.12 else 'admin' def start(self) -> None: self.dist.install(self.download()) @@ -85,9 +85,12 @@ def url(self, path: str = "") -> str: return f'http://{self.endpoint()}:{self.port()}{path}' def get_service_response(self) -> Response: + password = "admin" + if semver.compare(self.version, '2.12.0') != -1: + password = "myStrongPassword123!" url = self.url("/api/status") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", self.password) if self.security_enabled else None) + return requests.get(url, verify=False, auth=("admin", password) if self.security_enabled else None) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_dashboards_yml_path, "a") as yamlfile: From 0dcfd3dba30bfeedde2c1e33b8bdbfa039a5489f Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 10 Jan 2024 10:13:03 -0500 Subject: [PATCH 19/24] Reorg into utils and test and change export to env Signed-off-by: Derek Ho --- src/test_workflow/integ_test/distribution_tar.py | 2 +- .../integ_test/service_opensearch.py | 7 ++----- .../integ_test/service_opensearch_dashboards.py | 7 ++----- src/test_workflow/integ_test/utils.py | 16 ++++++++++++++++ .../integ_test/test_distribution_tar.py | 2 +- .../test_integ_workflow/integ_test/test_utils.py | 16 ++++++++++++++++ 6 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 src/test_workflow/integ_test/utils.py create mode 100644 tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py diff --git a/src/test_workflow/integ_test/distribution_tar.py b/src/test_workflow/integ_test/distribution_tar.py index 4c8ed65336..7303148f7b 100644 --- a/src/test_workflow/integ_test/distribution_tar.py +++ b/src/test_workflow/integ_test/distribution_tar.py @@ -33,7 +33,7 @@ def install(self, bundle_name: str) -> None: @property def start_cmd(self) -> str: start_cmd_map = { - "opensearch": "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh", + "opensearch": "env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! ./opensearch-tar-install.sh", "opensearch-dashboards": "./opensearch-dashboards", } return start_cmd_map[self.filename] diff --git a/src/test_workflow/integ_test/service_opensearch.py b/src/test_workflow/integ_test/service_opensearch.py index 411d6deacf..3e5647f1a0 100644 --- a/src/test_workflow/integ_test/service_opensearch.py +++ b/src/test_workflow/integ_test/service_opensearch.py @@ -9,9 +9,9 @@ import os import requests -import semver import yaml from requests.models import Response +from utils import get_password from test_workflow.dependency_installer import DependencyInstaller from test_workflow.integ_test.distribution import Distribution @@ -64,12 +64,9 @@ def url(self, path: str = "") -> str: return f'{"https" if self.security_enabled else "http"}://{self.endpoint()}:{self.port()}{path}' def get_service_response(self) -> Response: - password = "admin" - if semver.compare(self.version, '2.12.0') != -1: - password = "myStrongPassword123!" url = self.url("/_cluster/health") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", password)) + return requests.get(url, verify=False, auth=("admin", get_password(self.version))) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_yml_path, "a") as yamlfile: diff --git a/src/test_workflow/integ_test/service_opensearch_dashboards.py b/src/test_workflow/integ_test/service_opensearch_dashboards.py index 7df9eae3e8..081aad47d0 100644 --- a/src/test_workflow/integ_test/service_opensearch_dashboards.py +++ b/src/test_workflow/integ_test/service_opensearch_dashboards.py @@ -10,9 +10,9 @@ import subprocess import requests -import semver import yaml from requests.models import Response +from utils import get_password from system.os import current_platform from test_workflow.dependency_installer import DependencyInstaller @@ -85,12 +85,9 @@ def url(self, path: str = "") -> str: return f'http://{self.endpoint()}:{self.port()}{path}' def get_service_response(self) -> Response: - password = "admin" - if semver.compare(self.version, '2.12.0') != -1: - password = "myStrongPassword123!" url = self.url("/api/status") logging.info(f"Pinging {url}") - return requests.get(url, verify=False, auth=("admin", password) if self.security_enabled else None) + return requests.get(url, verify=False, auth=("admin", get_password(self.version)) if self.security_enabled else None) def __add_plugin_specific_config(self, additional_config: dict) -> None: with open(self.opensearch_dashboards_yml_path, "a") as yamlfile: diff --git a/src/test_workflow/integ_test/utils.py b/src/test_workflow/integ_test/utils.py new file mode 100644 index 0000000000..737e0abb51 --- /dev/null +++ b/src/test_workflow/integ_test/utils.py @@ -0,0 +1,16 @@ +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +import semver + + +def get_password(version: str) -> str: + # Starting in 2.12.0, demo configuration setup script requires a strong password + if semver.compare(version, '2.12.0') != -1: + return "myStrongPassword123!" + else: + return "admin" diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py index 0b52fdc65a..83d842a699 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py @@ -45,7 +45,7 @@ def test_install(self) -> None: mock_tarfile_extractall.assert_called_with(self.work_dir) def test_start_cmd(self) -> None: - self.assertEqual(self.distribution_tar.start_cmd, "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh") + self.assertEqual(self.distribution_tar.start_cmd, "env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! ./opensearch-tar-install.sh") self.assertEqual(self.distribution_tar_dashboards.start_cmd, "./opensearch-dashboards") @patch("subprocess.check_call") diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py new file mode 100644 index 0000000000..2e1a74116d --- /dev/null +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py @@ -0,0 +1,16 @@ +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +import unittest + +from utils import get_password + + +class TestUtils(unittest.TestCase): + def test_strong_password(self) -> None: + self.assertEqual("admin", get_password("2.11.1")) + self.assertEqual("myStrongPassword123!", get_password("3.0.0")) From 207be45a0173b74b9c1c05c069672f6fa00fb2fe Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 10 Jan 2024 10:23:49 -0500 Subject: [PATCH 20/24] hello Signed-off-by: Derek Ho --- src/test_workflow/integ_test/service_opensearch.py | 2 +- src/test_workflow/integ_test/service_opensearch_dashboards.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test_workflow/integ_test/service_opensearch.py b/src/test_workflow/integ_test/service_opensearch.py index 3e5647f1a0..86e7d4b7b7 100644 --- a/src/test_workflow/integ_test/service_opensearch.py +++ b/src/test_workflow/integ_test/service_opensearch.py @@ -11,12 +11,12 @@ import requests import yaml from requests.models import Response -from utils import get_password from test_workflow.dependency_installer import DependencyInstaller from test_workflow.integ_test.distribution import Distribution from test_workflow.integ_test.distributions import Distributions from test_workflow.integ_test.service import Service +from test_workflow.integ_test.utils import get_password class ServiceOpenSearch(Service): diff --git a/src/test_workflow/integ_test/service_opensearch_dashboards.py b/src/test_workflow/integ_test/service_opensearch_dashboards.py index 081aad47d0..4acf116ee9 100644 --- a/src/test_workflow/integ_test/service_opensearch_dashboards.py +++ b/src/test_workflow/integ_test/service_opensearch_dashboards.py @@ -12,13 +12,13 @@ import requests import yaml from requests.models import Response -from utils import get_password from system.os import current_platform from test_workflow.dependency_installer import DependencyInstaller from test_workflow.integ_test.distribution import Distribution from test_workflow.integ_test.distributions import Distributions from test_workflow.integ_test.service import Service +from test_workflow.integ_test.utils import get_password class ServiceOpenSearchDashboards(Service): From ec6a0a03c46f920059dd6fdcfa38957dca25c168 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 10 Jan 2024 10:30:02 -0500 Subject: [PATCH 21/24] Fix import Signed-off-by: Derek Ho --- .../test_integ_workflow/integ_test/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py index 2e1a74116d..907e7306b3 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_utils.py @@ -7,7 +7,7 @@ import unittest -from utils import get_password +from test_workflow.integ_test.utils import get_password class TestUtils(unittest.TestCase): From 20be6ff2a82f5ccdb2bd264db62d8799f2f31ae1 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 10 Jan 2024 10:34:57 -0500 Subject: [PATCH 22/24] fix test assertion Signed-off-by: Derek Ho --- .../test_integ_workflow/integ_test/test_service_opensearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py index b17a379b4f..e6952c378a 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py @@ -62,7 +62,7 @@ def test_start(self, mock_tarfile_open: Mock, mock_dump: Mock, mock_file: Mock, # call test target function service.start() - mock_process.assert_called_once_with("export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh", os.path.join(self.work_dir, "opensearch-1.1.0"), False) + mock_process.assert_called_once_with("env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh", os.path.join(self.work_dir, "opensearch-1.1.0"), False) mock_dump.assert_called_once_with(self.additional_config) From 5d8d69961af26f42b24eb8a01a8870ac03b8aa9c Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 10 Jan 2024 11:34:38 -0500 Subject: [PATCH 23/24] Fix assertion Signed-off-by: Derek Ho --- .../test_integ_workflow/integ_test/test_service_opensearch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py index e6952c378a..96761a494d 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py @@ -62,7 +62,7 @@ def test_start(self, mock_tarfile_open: Mock, mock_dump: Mock, mock_file: Mock, # call test target function service.start() - mock_process.assert_called_once_with("env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh", os.path.join(self.work_dir, "opensearch-1.1.0"), False) + mock_process.assert_called_once_with("env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! ./opensearch-tar-install.sh", os.path.join(self.work_dir, "opensearch-1.1.0"), False) mock_dump.assert_called_once_with(self.additional_config) From 6bd68e95c67ab10f26dd4e12be1b9cc70f2026b6 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 10 Jan 2024 14:15:44 -0500 Subject: [PATCH 24/24] revert changes to export after checking logs to see that admin password succcesfully set Signed-off-by: Derek Ho --- src/test_workflow/integ_test/distribution_tar.py | 2 +- .../test_integ_workflow/integ_test/test_distribution_tar.py | 2 +- .../test_integ_workflow/integ_test/test_service_opensearch.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test_workflow/integ_test/distribution_tar.py b/src/test_workflow/integ_test/distribution_tar.py index 7303148f7b..4c8ed65336 100644 --- a/src/test_workflow/integ_test/distribution_tar.py +++ b/src/test_workflow/integ_test/distribution_tar.py @@ -33,7 +33,7 @@ def install(self, bundle_name: str) -> None: @property def start_cmd(self) -> str: start_cmd_map = { - "opensearch": "env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! ./opensearch-tar-install.sh", + "opensearch": "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh", "opensearch-dashboards": "./opensearch-dashboards", } return start_cmd_map[self.filename] diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py index 83d842a699..0b52fdc65a 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py @@ -45,7 +45,7 @@ def test_install(self) -> None: mock_tarfile_extractall.assert_called_with(self.work_dir) def test_start_cmd(self) -> None: - self.assertEqual(self.distribution_tar.start_cmd, "env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! ./opensearch-tar-install.sh") + self.assertEqual(self.distribution_tar.start_cmd, "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh") self.assertEqual(self.distribution_tar_dashboards.start_cmd, "./opensearch-dashboards") @patch("subprocess.check_call") diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py index 96761a494d..b17a379b4f 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_service_opensearch.py @@ -62,7 +62,7 @@ def test_start(self, mock_tarfile_open: Mock, mock_dump: Mock, mock_file: Mock, # call test target function service.start() - mock_process.assert_called_once_with("env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! ./opensearch-tar-install.sh", os.path.join(self.work_dir, "opensearch-1.1.0"), False) + mock_process.assert_called_once_with("export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh", os.path.join(self.work_dir, "opensearch-1.1.0"), False) mock_dump.assert_called_once_with(self.additional_config)