Skip to content

Commit

Permalink
Cleanup deb/rpm integTest uninstallation properly (opensearch-project…
Browse files Browse the repository at this point in the history
…#4557)

Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Mar 21, 2024
1 parent 30ce49a commit 0649dce
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ RUN dnf install -y sudo && \
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
usermod -a -G adm $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, `which rm`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ RUN apt-get install -y sudo && \
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
usermod -a -G adm $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which apt`, `which apt-get`, `which apt-key`, `which dpkg`, `which chmod`, `which kill`, `which curl`, `which tee`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which apt`, `which apt-get`, `which apt-key`, `which dpkg`, `which chmod`, `which kill`, `which curl`, `which tee`, `which rm`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ RUN dnf install -y sudo && \
usermod -a -G opensearch $CONTAINER_USER && \
usermod -a -G adm $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, `which rm`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion src/test_workflow/integ_test/distribution_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ def start_cmd(self) -> str:

def uninstall(self) -> None:
logging.info(f"Uninstall {self.filename} package after the test")
subprocess.check_call(f"sudo dpkg --purge {self.filename}", shell=True)
subprocess.check_call(f"sudo dpkg --purge {self.filename} && sudo rm -rf {os.path.dirname(self.config_path)} {self.log_dir}", shell=True)
2 changes: 1 addition & 1 deletion src/test_workflow/integ_test/distribution_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def start_cmd(self) -> str:

def uninstall(self) -> None:
logging.info(f"Uninstall {self.filename} package after the test")
subprocess.check_call(f"sudo yum remove -y {self.filename}", shell=True)
subprocess.check_call(f"sudo yum remove -y {self.filename} && sudo rm -rf {os.path.dirname(self.config_path)} {self.log_dir}", shell=True)
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def test_uninstall(self, check_call_mock: Mock) -> None:
args_list = check_call_mock.call_args_list

self.assertEqual(check_call_mock.call_count, 1)
self.assertEqual("sudo dpkg --purge opensearch", args_list[0][0][0])
self.assertEqual(f"sudo dpkg --purge opensearch && sudo rm -rf {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.log_dir}", args_list[0][0][0])
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def test_uninstall(self, check_call_mock: Mock) -> None:
args_list = check_call_mock.call_args_list

self.assertEqual(check_call_mock.call_count, 1)
self.assertEqual("sudo yum remove -y opensearch", args_list[0][0][0])
self.assertEqual(f"sudo yum remove -y opensearch && sudo rm -rf {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.log_dir}", args_list[0][0][0])

0 comments on commit 0649dce

Please sign in to comment.