Skip to content

Commit e4a9750

Browse files
Support new deb/rpm permissions changes in #4043 on integTest (#4534)
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
1 parent 88dfb7f commit e4a9750

File tree

9 files changed

+50
-4
lines changed

9 files changed

+50
-4
lines changed

src/test_workflow/integ_test/distribution.py

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ def config_path(self) -> str:
4141
"""
4242
pass
4343

44+
@property
45+
def log_dir(self) -> str:
46+
"""
47+
Return the log directory for the distribution
48+
"""
49+
pass
50+
4451
@abstractmethod
4552
def install(self, bundle_name: str) -> None:
4653
"""

src/test_workflow/integ_test/distribution_deb.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def install_dir(self) -> str:
2525
def config_path(self) -> str:
2626
return os.path.join(os.sep, "etc", self.filename, self.config_filename)
2727

28+
@property
29+
def log_dir(self) -> str:
30+
return os.path.join(os.sep, "var", "log", self.filename)
31+
2832
def install(self, bundle_name: str) -> None:
2933
logging.info(f"Installing {bundle_name} in {self.install_dir}")
3034
logging.info("deb installation requires sudo, script will exit if current user does not have sudo access")
@@ -42,7 +46,9 @@ def install(self, bundle_name: str) -> None:
4246
'--install',
4347
bundle_name,
4448
'&&',
45-
f'sudo chmod 0666 {self.config_path}'
49+
f'sudo chmod 0666 {self.config_path}',
50+
'&&',
51+
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
4652
]
4753
)
4854
subprocess.check_call(deb_install_cmd, cwd=self.work_dir, shell=True)

src/test_workflow/integ_test/distribution_rpm.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def install_dir(self) -> str:
2525
def config_path(self) -> str:
2626
return os.path.join(os.sep, "etc", self.filename, self.config_filename)
2727

28+
@property
29+
def log_dir(self) -> str:
30+
return os.path.join(os.sep, "var", "log", self.filename)
31+
2832
def install(self, bundle_name: str) -> None:
2933
logging.info(f"Installing {bundle_name} in {self.install_dir}")
3034
logging.info("rpm installation requires sudo, script will exit if current user does not have sudo access")
@@ -44,7 +48,9 @@ def install(self, bundle_name: str) -> None:
4448
'-y',
4549
bundle_name,
4650
'&&',
47-
f'sudo chmod 0666 {self.config_path}'
51+
f'sudo chmod 0666 {self.config_path}',
52+
'&&',
53+
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
4854
]
4955
)
5056
subprocess.check_call(rpm_install_cmd, cwd=self.work_dir, shell=True)

src/test_workflow/integ_test/distribution_tar.py

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def install_dir(self) -> str:
2525
def config_path(self) -> str:
2626
return os.path.join(self.install_dir, "config", self.config_filename)
2727

28+
@property
29+
def log_dir(self) -> str:
30+
return os.path.join(self.install_dir, "logs")
31+
2832
def install(self, bundle_name: str) -> None:
2933
logging.info(f"Installing {bundle_name} in {self.install_dir}")
3034
with tarfile.open(bundle_name, 'r:gz') as bundle_tar:

src/test_workflow/integ_test/distribution_zip.py

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def install_dir(self) -> str:
2525
def config_path(self) -> str:
2626
return os.path.join(self.install_dir, "config", self.config_filename)
2727

28+
@property
29+
def log_dir(self) -> str:
30+
return os.path.join(self.install_dir, "logs")
31+
2832
def install(self, bundle_name: str) -> None:
2933
logging.info(f"Installing {bundle_name} in {self.install_dir}")
3034
with ZipFile(bundle_name, "r") as zip:

tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def test_config_path(self) -> None:
3232
self.assertEqual(self.distribution_deb.config_path, os.path.join(os.sep, "etc", "opensearch", "opensearch.yml"))
3333
self.assertEqual(self.distribution_deb_dashboards.config_path, os.path.join(os.sep, "etc", "opensearch-dashboards", "opensearch_dashboards.yml"))
3434

35+
def test_log_dir(self) -> None:
36+
self.assertEqual(self.distribution_deb.log_dir, os.path.join(os.sep, "var", "log", "opensearch"))
37+
self.assertEqual(self.distribution_deb_dashboards.log_dir, os.path.join(os.sep, "var", "log", "opensearch-dashboards"))
38+
3539
@patch("subprocess.check_call")
3640
def test_install(self, check_call_mock: Mock) -> None:
3741
self.distribution_deb.install("opensearch.deb")
@@ -43,7 +47,8 @@ def test_install(self, check_call_mock: Mock) -> None:
4347
"sudo dpkg --purge opensearch && "
4448
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
4549
"dpkg --install opensearch.deb && "
46-
f"sudo chmod 0666 {self.distribution_deb.config_path}"
50+
f"sudo chmod 0666 {self.distribution_deb.config_path} && "
51+
f"sudo chmod 0755 {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.log_dir}"
4752
),
4853
args_list[0][0][0],
4954
)

tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def test_config_path(self) -> None:
3232
self.assertEqual(self.distribution_rpm.config_path, os.path.join(os.sep, "etc", "opensearch", "opensearch.yml"))
3333
self.assertEqual(self.distribution_rpm_dashboards.config_path, os.path.join(os.sep, "etc", "opensearch-dashboards", "opensearch_dashboards.yml"))
3434

35+
def test_log_dir(self) -> None:
36+
self.assertEqual(self.distribution_rpm.log_dir, os.path.join(os.sep, "var", "log", "opensearch"))
37+
self.assertEqual(self.distribution_rpm_dashboards.log_dir, os.path.join(os.sep, "var", "log", "opensearch-dashboards"))
38+
3539
@patch("subprocess.check_call")
3640
def test_install(self, check_call_mock: Mock) -> None:
3741
self.distribution_rpm.install("opensearch.rpm")
@@ -43,7 +47,8 @@ def test_install(self, check_call_mock: Mock) -> None:
4347
"sudo yum remove -y opensearch && "
4448
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
4549
"yum install -y opensearch.rpm && "
46-
f"sudo chmod 0666 {self.distribution_rpm.config_path}"
50+
f"sudo chmod 0666 {self.distribution_rpm.config_path} && "
51+
f"sudo chmod 0755 {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.log_dir}"
4752
),
4853
args_list[0][0][0],
4954
)

tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_tar.py

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def test_config_path(self) -> None:
3434
self.assertEqual(self.distribution_tar.config_path, os.path.join(self.work_dir, "opensearch-1.3.0", "config", "opensearch.yml"))
3535
self.assertEqual(self.distribution_tar_dashboards.config_path, os.path.join(self.work_dir, "opensearch-dashboards-1.3.0", "config", "opensearch_dashboards.yml"))
3636

37+
def test_log_dir(self) -> None:
38+
self.assertEqual(self.distribution_tar.log_dir, os.path.join(self.work_dir, "opensearch-1.3.0", "logs"))
39+
self.assertEqual(self.distribution_tar_dashboards.log_dir, os.path.join(self.work_dir, "opensearch-dashboards-1.3.0", "logs"))
40+
3741
def test_install(self) -> None:
3842
with patch("tarfile.open") as mock_tarfile_open:
3943
mock_tarfile_extractall = MagicMock()

tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_zip.py

+5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ def test_distribution_zip_vars(self) -> None:
3131

3232
def test_install_dir(self) -> None:
3333
self.assertEqual(self.distribution_zip.install_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}"))
34+
self.assertEqual(self.distribution_zip_dashboards.install_dir, os.path.join(self.work_dir, f"{self.product_dashboards}-{self.version}"))
3435

3536
def test_config_path(self) -> None:
3637
self.assertEqual(self.distribution_zip.config_path, os.path.join(self.work_dir, f"{self.product}-{self.version}", "config", "opensearch.yml"))
3738
self.assertEqual(self.distribution_zip_dashboards.config_path, os.path.join(self.work_dir, f"{self.product_dashboards}-{self.version}", "config", "opensearch_dashboards.yml"))
3839

40+
def test_log_dir(self) -> None:
41+
self.assertEqual(self.distribution_zip.log_dir, os.path.join(self.work_dir, f"{self.product}-{self.version}", "logs"))
42+
self.assertEqual(self.distribution_zip_dashboards.log_dir, os.path.join(self.work_dir, f"{self.product_dashboards}-{self.version}", "logs"))
43+
3944
def test_install(self) -> None:
4045
with patch("test_workflow.integ_test.distribution_zip.ZipFile") as mock_zipfile_open:
4146
mock_zipfile_extractall = MagicMock()

0 commit comments

Comments
 (0)