Skip to content

Commit

Permalink
Support new deb/rpm permissions changes in opensearch-project#4043 on…
Browse files Browse the repository at this point in the history
… integTest

Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon committed Mar 14, 2024
1 parent 8f0fd59 commit ec7369f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/test_workflow/integ_test/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def config_path(self) -> str:
"""
pass

@property
def log_dir(self) -> str:
"""
Return the log directory for the distribution
"""
pass

@abstractmethod
def install(self, bundle_name: str) -> None:
"""
Expand Down
8 changes: 7 additions & 1 deletion src/test_workflow/integ_test/distribution_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def install_dir(self) -> str:
def config_path(self) -> str:
return os.path.join(os.sep, "etc", self.filename, self.config_filename)

@property
def log_dir(self) -> str:
return os.path.join(os.sep, "var", "log", self.filename)

def install(self, bundle_name: str) -> None:
logging.info(f"Installing {bundle_name} in {self.install_dir}")
logging.info("deb installation requires sudo, script will exit if current user does not have sudo access")
Expand All @@ -42,7 +46,9 @@ def install(self, bundle_name: str) -> None:
'--install',
bundle_name,
'&&',
f'sudo chmod 0666 {self.config_path}'
f'sudo chmod 0666 {self.config_path}',
'&&',
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
]
)
subprocess.check_call(deb_install_cmd, cwd=self.work_dir, shell=True)
Expand Down
8 changes: 7 additions & 1 deletion src/test_workflow/integ_test/distribution_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def install_dir(self) -> str:
def config_path(self) -> str:
return os.path.join(os.sep, "etc", self.filename, self.config_filename)

@property
def log_dir(self) -> str:
return os.path.join(os.sep, "var", "log", self.filename)

def install(self, bundle_name: str) -> None:
logging.info(f"Installing {bundle_name} in {self.install_dir}")
logging.info("rpm installation requires sudo, script will exit if current user does not have sudo access")
Expand All @@ -44,7 +48,9 @@ def install(self, bundle_name: str) -> None:
'-y',
bundle_name,
'&&',
f'sudo chmod 0666 {self.config_path}'
f'sudo chmod 0666 {self.config_path}',
'&&',
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
]
)
subprocess.check_call(rpm_install_cmd, cwd=self.work_dir, shell=True)
Expand Down
4 changes: 4 additions & 0 deletions src/test_workflow/integ_test/distribution_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def install_dir(self) -> str:
def config_path(self) -> str:
return os.path.join(self.install_dir, "config", self.config_filename)

@property
def log_dir(self) -> str:
return os.path.join(self.install_dir, "logs")

def install(self, bundle_name: str) -> None:
logging.info(f"Installing {bundle_name} in {self.install_dir}")
with tarfile.open(bundle_name, 'r:gz') as bundle_tar:
Expand Down
4 changes: 4 additions & 0 deletions src/test_workflow/integ_test/distribution_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def install_dir(self) -> str:
def config_path(self) -> str:
return os.path.join(self.install_dir, "config", self.config_filename)

@property
def log_dir(self) -> str:
return os.path.join(self.install_dir, "logs")

def install(self, bundle_name: str) -> None:
logging.info(f"Installing {bundle_name} in {self.install_dir}")
with ZipFile(bundle_name, "r") as zip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def test_install(self, check_call_mock: Mock) -> None:
"sudo dpkg --purge opensearch && "
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"dpkg --install opensearch.deb && "
f"sudo chmod 0666 {self.distribution_deb.config_path}"
f"sudo chmod 0666 {self.distribution_deb.config_path} && "
"sudo chmod 0755 /etc/opensearch /var/log/opensearch"
),
args_list[0][0][0],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def test_install(self, check_call_mock: Mock) -> None:
"sudo yum remove -y opensearch && "
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"yum install -y opensearch.rpm && "
f"sudo chmod 0666 {self.distribution_rpm.config_path}"
f"sudo chmod 0666 {self.distribution_rpm.config_path} && "
"sudo chmod 0755 /etc/opensearch /var/log/opensearch"
),
args_list[0][0][0],
)
Expand Down

0 comments on commit ec7369f

Please sign in to comment.