Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ec7369f

Browse files
committedMar 14, 2024
Support new deb/rpm permissions changes in opensearch-project#4043 on integTest
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
1 parent 8f0fd59 commit ec7369f

File tree

7 files changed

+33
-4
lines changed

7 files changed

+33
-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

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def test_install(self, check_call_mock: Mock) -> None:
4343
"sudo dpkg --purge opensearch && "
4444
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
4545
"dpkg --install opensearch.deb && "
46-
f"sudo chmod 0666 {self.distribution_deb.config_path}"
46+
f"sudo chmod 0666 {self.distribution_deb.config_path} && "
47+
"sudo chmod 0755 /etc/opensearch /var/log/opensearch"
4748
),
4849
args_list[0][0][0],
4950
)

‎tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def test_install(self, check_call_mock: Mock) -> None:
4343
"sudo yum remove -y opensearch && "
4444
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
4545
"yum install -y opensearch.rpm && "
46-
f"sudo chmod 0666 {self.distribution_rpm.config_path}"
46+
f"sudo chmod 0666 {self.distribution_rpm.config_path} && "
47+
"sudo chmod 0755 /etc/opensearch /var/log/opensearch"
4748
),
4849
args_list[0][0][0],
4950
)

0 commit comments

Comments
 (0)
Please sign in to comment.