Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass in strong password instead to fix integtest workflow #4302

Merged
merged 9 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion scripts/default/integtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,16 @@ then
SNAPSHOT="false"
fi

OPENSEARCH_REQUIRED_VERSION="2.12.0"
if [ -z "$CREDENTIAL" ]
then
CREDENTIAL="admin:admin"
# Starting in 2.12.0, security demo configuration script requires an initial admin password
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

USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'`
Expand Down
3 changes: 3 additions & 0 deletions src/test_workflow/integ_test/distribution_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +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!',
'&&',
'sudo',
'dpkg',
'--purge',
Expand Down
3 changes: 3 additions & 0 deletions src/test_workflow/integ_test/distribution_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +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!',
'&&',
'sudo',
'yum',
'remove',
Expand Down
2 changes: 1 addition & 1 deletion src/test_workflow/integ_test/distribution_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "export OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! && ./opensearch-tar-install.sh",
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
"opensearch-dashboards": "./opensearch-dashboards",
}
return start_cmd_map[self.filename]
Expand Down
2 changes: 1 addition & 1 deletion src/test_workflow/integ_test/distribution_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -40,7 +38,15 @@ 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(
(
"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],
)

def test_start_cmd(self) -> None:
self.assertEqual(self.distribution_deb.start_cmd, "sudo systemctl start opensearch")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -40,7 +38,15 @@ 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(
(
"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],
)

def test_start_cmd(self) -> None:
self.assertEqual(self.distribution_rpm.start_cmd, "sudo systemctl start opensearch")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading