From 03a719bec76042b2b01b308458d21b2670706d4c Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 21 Dec 2023 13:39:57 -0500 Subject: [PATCH 1/9] Pass in strong password instead to fix integtest workflow Signed-off-by: Derek Ho --- scripts/default/integtest.sh | 2 +- src/test_workflow/integ_test/distribution_deb.py | 4 ++++ src/test_workflow/integ_test/distribution_rpm.py | 4 ++++ src/test_workflow/integ_test/distribution_tar.py | 2 +- src/test_workflow/integ_test/distribution_zip.py | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/default/integtest.sh b/scripts/default/integtest.sh index eb12e34a0d..f526fd4c87 100755 --- a/scripts/default/integtest.sh +++ b/scripts/default/integtest.sh @@ -89,7 +89,7 @@ fi if [ -z "$CREDENTIAL" ] then - CREDENTIAL="admin:admin" + CREDENTIAL="admin:myStrongPassword123!" fi USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` diff --git a/src/test_workflow/integ_test/distribution_deb.py b/src/test_workflow/integ_test/distribution_deb.py index 06b14e7049..6d5c1b6f9f 100644 --- a/src/test_workflow/integ_test/distribution_deb.py +++ b/src/test_workflow/integ_test/distribution_deb.py @@ -30,6 +30,10 @@ def install(self, bundle_name: str) -> None: logging.info("deb installation requires sudo, script will exit if current user does not have sudo access") deb_install_cmd = " ".join( [ + 'sudo' + 'env' + 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!' + '&&' 'sudo', 'dpkg', '--purge', diff --git a/src/test_workflow/integ_test/distribution_rpm.py b/src/test_workflow/integ_test/distribution_rpm.py index 880074185d..e9ccfda9f9 100644 --- a/src/test_workflow/integ_test/distribution_rpm.py +++ b/src/test_workflow/integ_test/distribution_rpm.py @@ -30,6 +30,10 @@ def install(self, bundle_name: str) -> None: logging.info("rpm installation requires sudo, script will exit if current user does not have sudo access") rpm_install_cmd = " ".join( [ + 'sudo' + 'env' + 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!' + '&&' 'sudo', 'yum', 'remove', diff --git a/src/test_workflow/integ_test/distribution_tar.py b/src/test_workflow/integ_test/distribution_tar.py index d3317d1263..a8b3b8cbda 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": "./opensearch-tar-install.sh", + "opensearch": "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/distribution_zip.py b/src/test_workflow/integ_test/distribution_zip.py index ad3c2c09ba..9dcb80b355 100644 --- a/src/test_workflow/integ_test/distribution_zip.py +++ b/src/test_workflow/integ_test/distribution_zip.py @@ -33,7 +33,7 @@ def install(self, bundle_name: str) -> None: @property def start_cmd(self) -> str: start_cmd_map = { - "opensearch": ".\\opensearch-windows-install.bat", + "opensearch": "set OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! .\\opensearch-windows-install.bat", "opensearch-dashboards": ".\\opensearch-dashboards.bat", } return start_cmd_map[self.filename] From 1048e381cbe72ce50861b0d439cdbde1fc2612c8 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 21 Dec 2023 16:00:18 -0500 Subject: [PATCH 2/9] Modify commands and fix tests Signed-off-by: Derek Ho --- src/test_workflow/integ_test/distribution_deb.py | 3 +-- src/test_workflow/integ_test/distribution_rpm.py | 3 +-- src/test_workflow/integ_test/distribution_tar.py | 2 +- .../test_integ_workflow/integ_test/test_distribution_deb.py | 2 +- .../test_integ_workflow/integ_test/test_distribution_rpm.py | 2 +- .../test_integ_workflow/integ_test/test_distribution_tar.py | 2 +- .../test_integ_workflow/integ_test/test_distribution_zip.py | 2 +- .../test_integ_workflow/integ_test/test_service_opensearch.py | 2 +- 8 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/test_workflow/integ_test/distribution_deb.py b/src/test_workflow/integ_test/distribution_deb.py index 6d5c1b6f9f..5a34d1881e 100644 --- a/src/test_workflow/integ_test/distribution_deb.py +++ b/src/test_workflow/integ_test/distribution_deb.py @@ -30,8 +30,7 @@ def install(self, bundle_name: str) -> None: logging.info("deb installation requires sudo, script will exit if current user does not have sudo access") deb_install_cmd = " ".join( [ - 'sudo' - 'env' + 'export' 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!' '&&' 'sudo', diff --git a/src/test_workflow/integ_test/distribution_rpm.py b/src/test_workflow/integ_test/distribution_rpm.py index e9ccfda9f9..71b9e68b14 100644 --- a/src/test_workflow/integ_test/distribution_rpm.py +++ b/src/test_workflow/integ_test/distribution_rpm.py @@ -30,8 +30,7 @@ def install(self, bundle_name: str) -> None: logging.info("rpm installation requires sudo, script will exit if current user does not have sudo access") rpm_install_cmd = " ".join( [ - 'sudo' - 'env' + 'export' 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!' '&&' 'sudo', diff --git a/src/test_workflow/integ_test/distribution_tar.py b/src/test_workflow/integ_test/distribution_tar.py index a8b3b8cbda..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": "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_deb.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py index 3a4b7028a8..ea17db98ff 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py @@ -40,7 +40,7 @@ def test_install(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual(f"sudo dpkg --purge opensearch && sudo dpkg --install opensearch.deb && sudo chmod 0666 {self.distribution_deb.config_path}", args_list[0][0][0]) + self.assertEqual(f"export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && sudo dpkg --purge opensearch && sudo dpkg --install opensearch.deb && sudo chmod 0666 {self.distribution_deb.config_path}", args_list[0][0][0]) def test_start_cmd(self) -> None: self.assertEqual(self.distribution_deb.start_cmd, "sudo systemctl start opensearch") diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py index 19de5d2f2e..8987ac6263 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py @@ -40,7 +40,7 @@ def test_install(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual(f"sudo yum remove -y opensearch && sudo yum install -y opensearch.rpm && sudo chmod 0666 {self.distribution_rpm.config_path}", args_list[0][0][0]) + self.assertEqual(f"export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && sudo yum remove -y opensearch && sudo yum install -y opensearch.rpm && sudo chmod 0666 {self.distribution_rpm.config_path}", args_list[0][0][0]) def test_start_cmd(self) -> None: self.assertEqual(self.distribution_rpm.start_cmd, "sudo systemctl start opensearch") 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 488ccf8d88..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, "./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_distribution_zip.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py index fbd5b53695..b4113939e5 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py @@ -47,7 +47,7 @@ def test_install(self) -> None: mock_zipfile_extractall.assert_called_with(self.work_dir) def test_start_cmd(self) -> None: - self.assertEqual(self.distribution_zip.start_cmd, ".\\opensearch-windows-install.bat") + self.assertEqual(self.distribution_zip.start_cmd, "set OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! .\\opensearch-windows-install.bat") @patch("subprocess.check_call") def test_uninstall(self, check_call_mock: Mock) -> None: 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 0b8cf02621..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("./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) From 545ddd973db8b1952b807c4af25d7458750a41a4 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 21 Dec 2023 16:34:39 -0500 Subject: [PATCH 3/9] Fix linting issue Signed-off-by: Derek Ho --- .../integ_test/test_distribution_deb.py | 12 +++++++----- .../integ_test/test_distribution_rpm.py | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py index ea17db98ff..1f577aa7fd 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py @@ -13,16 +13,14 @@ class TestDistributionDeb(unittest.TestCase): - def setUp(self) -> None: - self.work_dir = os.path.join(os.path.dirname(__file__), "data") self.distribution_deb = DistributionDeb("opensearch", "1.3.0", self.work_dir) self.distribution_deb_dashboards = DistributionDeb("opensearch-dashboards", "1.3.0", self.work_dir) def test_distribution_deb_vars(self) -> None: - self.assertEqual(self.distribution_deb.filename, 'opensearch') - self.assertEqual(self.distribution_deb.version, '1.3.0') + self.assertEqual(self.distribution_deb.filename, "opensearch") + self.assertEqual(self.distribution_deb.version, "1.3.0") self.assertEqual(self.distribution_deb.work_dir, self.work_dir) self.assertEqual(self.distribution_deb.require_sudo, True) @@ -40,7 +38,11 @@ def test_install(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual(f"export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && sudo dpkg --purge opensearch && sudo dpkg --install opensearch.deb && sudo chmod 0666 {self.distribution_deb.config_path}", args_list[0][0][0]) + self.assertEqual( + "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " + + f"&& sudo dpkg --purge opensearch && sudo dpkg --install opensearch.deb && sudo chmod 0666 {self.distribution_deb.config_path}", + args_list[0][0][0], + ) def test_start_cmd(self) -> None: self.assertEqual(self.distribution_deb.start_cmd, "sudo systemctl start opensearch") diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py index 8987ac6263..5a71cac9ce 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py @@ -13,16 +13,14 @@ class TestDistributionRpm(unittest.TestCase): - def setUp(self) -> None: - self.work_dir = os.path.join(os.path.dirname(__file__), "data") self.distribution_rpm = DistributionRpm("opensearch", "1.3.0", self.work_dir) self.distribution_rpm_dashboards = DistributionRpm("opensearch-dashboards", "1.3.0", self.work_dir) def test_distribution_rpm_vars(self) -> None: - self.assertEqual(self.distribution_rpm.filename, 'opensearch') - self.assertEqual(self.distribution_rpm.version, '1.3.0') + self.assertEqual(self.distribution_rpm.filename, "opensearch") + self.assertEqual(self.distribution_rpm.version, "1.3.0") self.assertEqual(self.distribution_rpm.work_dir, self.work_dir) self.assertEqual(self.distribution_rpm.require_sudo, True) @@ -40,7 +38,11 @@ def test_install(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual(f"export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && sudo yum remove -y opensearch && sudo yum install -y opensearch.rpm && sudo chmod 0666 {self.distribution_rpm.config_path}", args_list[0][0][0]) + self.assertEqual( + "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " + + f"&& sudo yum remove -y opensearch && sudo yum install -y opensearch.rpm && sudo chmod 0666 {self.distribution_rpm.config_path}", + args_list[0][0][0], + ) def test_start_cmd(self) -> None: self.assertEqual(self.distribution_rpm.start_cmd, "sudo systemctl start opensearch") From 6722ec8cb9abd4a33b0cd4794f983543ea7626f1 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 28 Dec 2023 16:12:44 -0500 Subject: [PATCH 4/9] Add logic to differentiate between versions Signed-off-by: Derek Ho --- scripts/default/integtest.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/default/integtest.sh b/scripts/default/integtest.sh index f526fd4c87..0bec585392 100755 --- a/scripts/default/integtest.sh +++ b/scripts/default/integtest.sh @@ -89,7 +89,12 @@ fi if [ -z "$CREDENTIAL" ] then - CREDENTIAL="admin:myStrongPassword123!" + # OpenSearch 2.12 onwards security plugins requires a password to be set to setup admin user + if [ "$(echo "${VERSION} 2.12" | awk '{print ($1 >= $2)}')" -eq 1 ]; then + CREDENTIAL="admin:myStrongPassword123!" + else + CREDENTIAL="admin:admin" + fi fi USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` From e601645d3212d1e443ce123709964864b5e7a111 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 28 Dec 2023 16:28:19 -0500 Subject: [PATCH 5/9] Fix test formatting Signed-off-by: Derek Ho --- .../integ_test/test_distribution_deb.py | 8 ++++++-- .../integ_test/test_distribution_rpm.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py index 1f577aa7fd..0b01dbddf5 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py @@ -39,8 +39,12 @@ def test_install(self, check_call_mock: Mock) -> None: self.assertEqual(check_call_mock.call_count, 1) self.assertEqual( - "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " - + f"&& sudo dpkg --purge opensearch && sudo dpkg --install opensearch.deb && sudo chmod 0666 {self.distribution_deb.config_path}", + ( + "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && " + "sudo dpkg --purge opensearch && " + "sudo dpkg --install opensearch.deb && " + f"sudo chmod 0666 {self.distribution_deb.config_path}" + ), args_list[0][0][0], ) diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py index 5a71cac9ce..25e165584f 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py @@ -39,8 +39,12 @@ def test_install(self, check_call_mock: Mock) -> None: self.assertEqual(check_call_mock.call_count, 1) self.assertEqual( - "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! " - + f"&& sudo yum remove -y opensearch && sudo yum install -y opensearch.rpm && sudo chmod 0666 {self.distribution_rpm.config_path}", + ( + "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && " + "sudo yum remove -y opensearch && " + "sudo yum install -y opensearch.rpm && " + f"sudo chmod 0666 {self.distribution_rpm.config_path}" + ), args_list[0][0][0], ) From 48a40e2cb9a74be1387eeb2a82f4c73e22fb07b2 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 28 Dec 2023 16:37:09 -0500 Subject: [PATCH 6/9] Add in commas Signed-off-by: Derek Ho --- src/test_workflow/integ_test/distribution_deb.py | 6 +++--- src/test_workflow/integ_test/distribution_rpm.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test_workflow/integ_test/distribution_deb.py b/src/test_workflow/integ_test/distribution_deb.py index 5a34d1881e..7d20642b2a 100644 --- a/src/test_workflow/integ_test/distribution_deb.py +++ b/src/test_workflow/integ_test/distribution_deb.py @@ -30,9 +30,9 @@ def install(self, bundle_name: str) -> None: logging.info("deb installation requires sudo, script will exit if current user does not have sudo access") deb_install_cmd = " ".join( [ - 'export' - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!' - '&&' + 'export', + 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!', + '&&', 'sudo', 'dpkg', '--purge', diff --git a/src/test_workflow/integ_test/distribution_rpm.py b/src/test_workflow/integ_test/distribution_rpm.py index 71b9e68b14..e6339e8548 100644 --- a/src/test_workflow/integ_test/distribution_rpm.py +++ b/src/test_workflow/integ_test/distribution_rpm.py @@ -30,9 +30,9 @@ def install(self, bundle_name: str) -> None: logging.info("rpm installation requires sudo, script will exit if current user does not have sudo access") rpm_install_cmd = " ".join( [ - 'export' - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!' - '&&' + 'export', + 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!', + '&&', 'sudo', 'yum', 'remove', From e9b23eabe024d2e4e3426d7e88b2ea19d8a64059 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 29 Dec 2023 11:18:53 -0500 Subject: [PATCH 7/9] Udpate script logic Signed-off-by: Derek Ho --- scripts/default/integtest.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/default/integtest.sh b/scripts/default/integtest.sh index 0bec585392..02350d83bc 100755 --- a/scripts/default/integtest.sh +++ b/scripts/default/integtest.sh @@ -87,10 +87,13 @@ then SNAPSHOT="false" fi + IFS='.' read -ra version_array <<< "$OPENSEARCH_VERSION" + + if [ -z "$CREDENTIAL" ] then - # OpenSearch 2.12 onwards security plugins requires a password to be set to setup admin user - if [ "$(echo "${VERSION} 2.12" | awk '{print ($1 >= $2)}')" -eq 1 ]; then + # Starting in 2.12.0, security demo configuration script requires an initial admin password + if (( ${version_array[0]} > 2 || (${version_array[0]} == 2 && ${version_array[1]} >= 12) )); then CREDENTIAL="admin:myStrongPassword123!" else CREDENTIAL="admin:admin" From 7480dde2a05f95ac25de7c9644b7197239e1875f Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 8 Jan 2024 15:20:23 -0500 Subject: [PATCH 8/9] Add numeral comparison logic from Peter Signed-off-by: Derek Ho --- scripts/default/integtest.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/default/integtest.sh b/scripts/default/integtest.sh index 02350d83bc..7a600d4cf8 100755 --- a/scripts/default/integtest.sh +++ b/scripts/default/integtest.sh @@ -87,16 +87,15 @@ then SNAPSHOT="false" fi - IFS='.' read -ra version_array <<< "$OPENSEARCH_VERSION" - - +OPENSEARCH_REQUIRED_VERSION="2.12.0" if [ -z "$CREDENTIAL" ] then # Starting in 2.12.0, security demo configuration script requires an initial admin password - if (( ${version_array[0]} > 2 || (${version_array[0]} == 2 && ${version_array[1]} >= 12) )); then - CREDENTIAL="admin:myStrongPassword123!" - else + COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` + if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then CREDENTIAL="admin:admin" + else + CREDENTIAL="admin:myStrongPassword123!" fi fi From 00fa11f15bb1ceb8c016c1a3de04b91f52bb0c68 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 8 Jan 2024 18:15:41 -0500 Subject: [PATCH 9/9] Revert rpm/deb changes pending decision Signed-off-by: Derek Ho --- src/test_workflow/integ_test/distribution_deb.py | 3 --- src/test_workflow/integ_test/distribution_rpm.py | 3 --- .../integ_test/test_distribution_deb.py | 16 +++++----------- .../integ_test/test_distribution_rpm.py | 16 +++++----------- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/test_workflow/integ_test/distribution_deb.py b/src/test_workflow/integ_test/distribution_deb.py index 7d20642b2a..06b14e7049 100644 --- a/src/test_workflow/integ_test/distribution_deb.py +++ b/src/test_workflow/integ_test/distribution_deb.py @@ -30,9 +30,6 @@ def install(self, bundle_name: str) -> None: logging.info("deb installation requires sudo, script will exit if current user does not have sudo access") deb_install_cmd = " ".join( [ - 'export', - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!', - '&&', 'sudo', 'dpkg', '--purge', diff --git a/src/test_workflow/integ_test/distribution_rpm.py b/src/test_workflow/integ_test/distribution_rpm.py index e6339e8548..880074185d 100644 --- a/src/test_workflow/integ_test/distribution_rpm.py +++ b/src/test_workflow/integ_test/distribution_rpm.py @@ -30,9 +30,6 @@ def install(self, bundle_name: str) -> None: logging.info("rpm installation requires sudo, script will exit if current user does not have sudo access") rpm_install_cmd = " ".join( [ - 'export', - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!', - '&&', 'sudo', 'yum', 'remove', diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py index 0b01dbddf5..3a4b7028a8 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py @@ -13,14 +13,16 @@ class TestDistributionDeb(unittest.TestCase): + def setUp(self) -> None: + self.work_dir = os.path.join(os.path.dirname(__file__), "data") self.distribution_deb = DistributionDeb("opensearch", "1.3.0", self.work_dir) self.distribution_deb_dashboards = DistributionDeb("opensearch-dashboards", "1.3.0", self.work_dir) def test_distribution_deb_vars(self) -> None: - self.assertEqual(self.distribution_deb.filename, "opensearch") - self.assertEqual(self.distribution_deb.version, "1.3.0") + self.assertEqual(self.distribution_deb.filename, 'opensearch') + self.assertEqual(self.distribution_deb.version, '1.3.0') self.assertEqual(self.distribution_deb.work_dir, self.work_dir) self.assertEqual(self.distribution_deb.require_sudo, True) @@ -38,15 +40,7 @@ def test_install(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual( - ( - "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && " - "sudo dpkg --purge opensearch && " - "sudo dpkg --install opensearch.deb && " - f"sudo chmod 0666 {self.distribution_deb.config_path}" - ), - args_list[0][0][0], - ) + self.assertEqual(f"sudo dpkg --purge opensearch && sudo dpkg --install opensearch.deb && sudo chmod 0666 {self.distribution_deb.config_path}", args_list[0][0][0]) def test_start_cmd(self) -> None: self.assertEqual(self.distribution_deb.start_cmd, "sudo systemctl start opensearch") diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py index 25e165584f..19de5d2f2e 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py @@ -13,14 +13,16 @@ class TestDistributionRpm(unittest.TestCase): + def setUp(self) -> None: + self.work_dir = os.path.join(os.path.dirname(__file__), "data") self.distribution_rpm = DistributionRpm("opensearch", "1.3.0", self.work_dir) self.distribution_rpm_dashboards = DistributionRpm("opensearch-dashboards", "1.3.0", self.work_dir) def test_distribution_rpm_vars(self) -> None: - self.assertEqual(self.distribution_rpm.filename, "opensearch") - self.assertEqual(self.distribution_rpm.version, "1.3.0") + self.assertEqual(self.distribution_rpm.filename, 'opensearch') + self.assertEqual(self.distribution_rpm.version, '1.3.0') self.assertEqual(self.distribution_rpm.work_dir, self.work_dir) self.assertEqual(self.distribution_rpm.require_sudo, True) @@ -38,15 +40,7 @@ def test_install(self, check_call_mock: Mock) -> None: args_list = check_call_mock.call_args_list self.assertEqual(check_call_mock.call_count, 1) - self.assertEqual( - ( - "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && " - "sudo yum remove -y opensearch && " - "sudo yum install -y opensearch.rpm && " - f"sudo chmod 0666 {self.distribution_rpm.config_path}" - ), - args_list[0][0][0], - ) + self.assertEqual(f"sudo yum remove -y opensearch && sudo yum install -y opensearch.rpm && sudo chmod 0666 {self.distribution_rpm.config_path}", args_list[0][0][0]) def test_start_cmd(self) -> None: self.assertEqual(self.distribution_rpm.start_cmd, "sudo systemctl start opensearch")