Skip to content

Commit d54b205

Browse files
Allow current user to join os/osd group during deb/rpm test (#4548)
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
1 parent ee7db28 commit d54b205

7 files changed

+13
-7
lines changed

docker/ci/dockerfiles/current/test.almalinux8.systemd-base.x64.arm64.ppc64le.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ RUN dnf install -y sudo && \
111111
usermod -a -G opensearch $CONTAINER_USER && \
112112
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
113113
id && \
114-
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `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
114+
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
115115

116116
# Copy from Stage0
117117
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME

docker/ci/dockerfiles/current/test.ubuntu2004.systemd-base.x64.arm64.ppc64le.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ RUN apt-get install -y sudo && \
129129
usermod -a -G opensearch $CONTAINER_USER && \
130130
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
131131
id && \
132-
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `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
132+
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
133133

134134
# Copy from Stage0
135135
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME

docker/ci/dockerfiles/legacy/test.rockylinux8.systemd-base.x64.arm64.dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ RUN dnf install -y sudo && \
111111
usermod -a -G opensearch $CONTAINER_USER && \
112112
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
113113
id && \
114-
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `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
114+
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
115115

116116
# Copy from Stage0
117117
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME

src/test_workflow/integ_test/distribution_deb.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def install(self, bundle_name: str) -> None:
4848
'&&',
4949
f'sudo chmod 0666 {self.config_path}',
5050
'&&',
51-
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
51+
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}',
52+
'&&',
53+
f'sudo usermod -a -G {self.filename} `whoami`'
5254
]
5355
)
5456
subprocess.check_call(deb_install_cmd, cwd=self.work_dir, shell=True)

src/test_workflow/integ_test/distribution_rpm.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def install(self, bundle_name: str) -> None:
5050
'&&',
5151
f'sudo chmod 0666 {self.config_path}',
5252
'&&',
53-
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
53+
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}',
54+
'&&',
55+
f'sudo usermod -a -G {self.filename} `whoami`'
5456
]
5557
)
5658
subprocess.check_call(rpm_install_cmd, cwd=self.work_dir, shell=True)

tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_deb.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def test_install(self, check_call_mock: Mock) -> None:
4848
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
4949
"dpkg --install opensearch.deb && "
5050
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}"
51+
f"sudo chmod 0755 {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.log_dir} && "
52+
f"sudo usermod -a -G opensearch `whoami`"
5253
),
5354
args_list[0][0][0],
5455
)

tests/tests_test_workflow/test_integ_workflow/integ_test/test_distribution_rpm.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def test_install(self, check_call_mock: Mock) -> None:
4848
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
4949
"yum install -y opensearch.rpm && "
5050
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}"
51+
f"sudo chmod 0755 {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.log_dir} && "
52+
f"sudo usermod -a -G opensearch `whoami`"
5253
),
5354
args_list[0][0][0],
5455
)

0 commit comments

Comments
 (0)