Skip to content

Commit

Permalink
Add condition for OSD integ tests on deb and rpm (#4770)
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <zelinhao@amazon.com>
  • Loading branch information
zelinh authored Jun 12, 2024
1 parent da8d9dd commit 86b3470
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/test_workflow/integ_test/distribution_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def install(self, bundle_name: str) -> None:
'--install',
bundle_name,
'&&',
f'sudo chmod 0666 {self.config_path} {os.path.dirname(self.config_path)}/jvm.options',
f'sudo chmod 0666 {self.config_path} {os.path.dirname(self.config_path)}/jvm.options'
if self.filename == "opensearch" else f'sudo chmod 0666 {self.config_path}',
'&&',
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}',
'&&',
Expand Down
3 changes: 2 additions & 1 deletion src/test_workflow/integ_test/distribution_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def install(self, bundle_name: str) -> None:
'-y',
bundle_name,
'&&',
f'sudo chmod 0666 {self.config_path} {os.path.dirname(self.config_path)}/jvm.options',
f'sudo chmod 0666 {self.config_path} {os.path.dirname(self.config_path)}/jvm.options'
if self.filename == "opensearch" else f'sudo chmod 0666 {self.config_path}',
'&&',
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}',
'&&',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ def test_install(self, check_call_mock: Mock) -> None:
args_list[0][0][0],
)

@patch("subprocess.check_call")
def test_install_opensearch_dashboards(self, check_call_mock: Mock) -> None:
self.distribution_deb_dashboards.install("opensearch-dashboards.deb")
args_list = check_call_mock.call_args_list

self.assertEqual(check_call_mock.call_count, 1)
self.assertEqual(
(
"sudo dpkg --purge opensearch-dashboards && "
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"dpkg --install opensearch-dashboards.deb && "
f"sudo chmod 0666 {self.distribution_deb_dashboards.config_path} && "
f"sudo chmod 0755 {os.path.dirname(self.distribution_deb_dashboards.config_path)} {self.distribution_deb_dashboards.log_dir} && "
f"sudo usermod -a -G opensearch-dashboards `whoami` && "
f"sudo usermod -a -G adm `whoami`"
),
args_list[0][0][0],
)

def test_start_cmd(self) -> None:
self.assertEqual(self.distribution_deb.start_cmd, "sudo systemctl start opensearch")
self.assertEqual(self.distribution_deb_dashboards.start_cmd, "sudo systemctl start opensearch-dashboards")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ def test_install(self, check_call_mock: Mock) -> None:
args_list[0][0][0],
)

@patch("subprocess.check_call")
def test_install_opensearch_dashboards(self, check_call_mock: Mock) -> None:
self.distribution_rpm_dashboards.install("opensearch-dashboards.rpm")
args_list = check_call_mock.call_args_list

self.assertEqual(check_call_mock.call_count, 1)
self.assertEqual(
(
"sudo yum remove -y opensearch-dashboards && "
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"yum install -y opensearch-dashboards.rpm && "
f"sudo chmod 0666 {self.distribution_rpm_dashboards.config_path} && "
f"sudo chmod 0755 {os.path.dirname(self.distribution_rpm_dashboards.config_path)} {self.distribution_rpm_dashboards.log_dir} && "
f"sudo usermod -a -G opensearch-dashboards `whoami` && "
f"sudo usermod -a -G adm `whoami`"
),
args_list[0][0][0],
)

def test_start_cmd(self) -> None:
self.assertEqual(self.distribution_rpm.start_cmd, "sudo systemctl start opensearch")
self.assertEqual(self.distribution_rpm_dashboards.start_cmd, "sudo systemctl start opensearch-dashboards")
Expand Down

0 comments on commit 86b3470

Please sign in to comment.