Skip to content

Commit

Permalink
Merge branch 'fix_pgrep' into 110-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
hughesjj committed Sep 26, 2024
2 parents 9bcccae + 1be78d6 commit 64e3295
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN rpm --import https://yum.puppet.com/RPM-GPG-KEY-puppet-20250406
ARG PUPPET_RELEASE="6"
RUN rpm -Uvh https://yum.puppet.com/puppet${PUPPET_RELEASE}-release-sles-15.noarch.rpm && \
zypper --gpg-auto-import-keys -n refresh && \
zypper install -y puppet-agent
zypper install -y puppet-agent procps

RUN wget -O /tmp/nodejs.tar.gz https://nodejs.org/dist/v16.20.2/node-v16.20.2-linux-x64.tar.gz && \
mkdir -p /opt/ && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV container docker
RUN sed -i 's|download.opensuse.org|provo-mirror.opensuse.org|' /etc/zypp/repos.d/*.repo
RUN zypper -n install -l curl dbus-1 systemd-sysvinit tar wget python3-pip ca-certificates gzip

RUN zypper install -y salt salt-minion salt-master
RUN zypper install -y salt salt-minion salt-master procps

RUN wget -O /tmp/nodejs.tar.gz https://nodejs.org/dist/v16.20.2/node-v16.20.2-linux-x64.tar.gz && \
mkdir -p /opt/ && \
Expand Down
11 changes: 7 additions & 4 deletions internal/buildscripts/packaging/tests/helpers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from contextlib import contextmanager
from io import BytesIO
from pathlib import Path
from typing import Optional, Tuple

import docker

Expand Down Expand Up @@ -121,7 +122,7 @@ def run_distro_container(distro, arch="amd64", dockerfile=None, path=TESTS_DIR,
container.remove(force=True, v=True)


def run_container_cmd(container, cmd, env=None, exit_code=0, timeout=None, user='', workdir=None):
def run_container_cmd(container, cmd, env=None, exit_code:Optional[int]=0, timeout=None, user='', workdir=None) -> Tuple[int, bytes]:
if timeout:
cmd = f"timeout {timeout} {cmd}"
print(f"Running '{cmd}' ...")
Expand Down Expand Up @@ -181,9 +182,11 @@ def ensure_always(test, timeout=DEFAULT_TIMEOUT, interval=1):


def service_is_running(container, service_name=SERVICE_NAME, service_owner=SERVICE_OWNER, process=OTELCOL_BIN):
cmd = f"sh -ec 'systemctl status {service_name} && pgrep -a -u {service_owner} -f {process}'"
code, _ = run_container_cmd(container, cmd, exit_code=None)
return code == 0
cmd = f"""sh -ec 'systemctl status {service_name}'"""
sysctl_code, _ = run_container_cmd(container, cmd, exit_code=None)
cmd = f"""sh -ec 'pgrep -a -u {service_owner} -f {process}'"""
pgrep_code, _ = run_container_cmd(container, cmd, exit_code=None)
return (sysctl_code | pgrep_code) == 0


def verify_package_version(container, package, version, old_version=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ENV container docker

RUN sed -i 's|download.opensuse.org|provo-mirror.opensuse.org|' /etc/zypp/repos.d/*.repo
RUN zypper -n install -l curl dbus-1 systemd-sysvinit tar wget
RUN zypper -n install -y procps

RUN (cd /usr/lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \
"systemd-tmpfiles-setup.service" ] || rm -f $i; done); \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ENV container docker

RUN sed -i 's|download.opensuse.org|provo-mirror.opensuse.org|' /etc/zypp/repos.d/*.repo
RUN zypper -n install -l curl dbus-1 gzip python3 systemd-sysvinit tar wget
RUN zypper -n install procps

RUN (cd /usr/lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \
"systemd-tmpfiles-setup.service" ] || rm -f $i; done); \
Expand Down

0 comments on commit 64e3295

Please sign in to comment.