From 4f405a8709073721d8ae40b762d5642612053e10 Mon Sep 17 00:00:00 2001 From: jpic Date: Sun, 26 Jan 2020 19:57:41 +0100 Subject: [PATCH] QA & test update --- podctl/console_script.py | 5 ++++- podctl/visitors/packages.py | 4 ++-- tests/test_build_copy.sh | 4 +++- tests/test_build_packages.sh | 3 +++ tests/test_build_user.sh | 8 ++++++++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/podctl/console_script.py b/podctl/console_script.py index 0dbe3ac..b19e537 100644 --- a/podctl/console_script.py +++ b/podctl/console_script.py @@ -51,7 +51,10 @@ async def build(service=None, **kwargs): loop=loop, ) - prefix = '' if os.getenv('BUILDAH_ISOLATION') == 'chroot' else 'buildah unshare ' + if os.getenv('BUILDAH_ISOLATION') == 'chroot': + prefix = '' + else: + prefix = 'buildah unshare ' transport, protocol = await loop.subprocess_shell( protocol_factory, prefix + f'bash -eux {script}', diff --git a/podctl/visitors/packages.py b/podctl/visitors/packages.py index e22e922..01e5269 100644 --- a/podctl/visitors/packages.py +++ b/podctl/visitors/packages.py @@ -10,7 +10,7 @@ class Packages: ), dnf=dict( update='sudo dnf update', - upgrade='sudo dnf upgrade --exclude container-selinux --best --assumeyes', + upgrade='sudo dnf upgrade --exclude container-selinux --best --assumeyes', # noqa install='sudo dnf install --exclude container-selinux --setopt=install_weak_deps=False --best --assumeyes', # noqa ), yum=dict( @@ -22,7 +22,7 @@ class Packages: def __init__(self, *packages, **kwargs): self.packages = list(packages) - self.mgr = kwargs.pop('mgr') + self.mgr = kwargs.pop('mgr') if 'mgr' in kwargs else None def pre_build(self, script): base = script.container.variable('base') diff --git a/tests/test_build_copy.sh b/tests/test_build_copy.sh index d0f4556..269355f 100644 --- a/tests/test_build_copy.sh +++ b/tests/test_build_copy.sh @@ -12,4 +12,6 @@ umounts() { } trap umounts 0 ctr=$(buildah from $base) -mnt=$(buildah mount $ctr) \ No newline at end of file +mnt=$(buildah mount $ctr) +echo "Copy.init_build" +echo "Copy.build" \ No newline at end of file diff --git a/tests/test_build_packages.sh b/tests/test_build_packages.sh index 0350824..3e1bf17 100644 --- a/tests/test_build_packages.sh +++ b/tests/test_build_packages.sh @@ -13,9 +13,12 @@ umounts() { trap umounts 0 ctr=$(buildah from $base) mnt=$(buildah mount $ctr) +echo "Packages.pre_build" +echo "Packages.build" buildah run --user root $ctr -- mkdir -p /var/cache/apk mkdir -p $(pwd)/.cache/apk mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk +mounts=("$mnt/var/cache/apk" "${mounts[@]}") buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)" if [ -n "$old" ] || ! ls .cache/apk/APKINDEX.*; then diff --git a/tests/test_build_user.sh b/tests/test_build_user.sh index f7ee9f9..9bb2278 100644 --- a/tests/test_build_user.sh +++ b/tests/test_build_user.sh @@ -13,9 +13,15 @@ umounts() { trap umounts 0 ctr=$(buildah from $base) mnt=$(buildah mount $ctr) +echo "User.init_build" +echo "User.init_build" +echo "Packages.pre_build" +echo "User.pre_build" +echo "Packages.build" buildah run --user root $ctr -- mkdir -p /var/cache/apk mkdir -p $(pwd)/.cache/apk mount -o bind $(pwd)/.cache/apk $mnt/var/cache/apk +mounts=("$mnt/var/cache/apk" "${mounts[@]}") buildah run $ctr -- ln -s /var/cache/apk /etc/apk/cache old="$(find .cache/apk/ -name APKINDEX.* -mtime +3)" if [ -n "$old" ] || ! ls .cache/apk/APKINDEX.*; then @@ -25,10 +31,12 @@ else fi buildah run --user root $ctr -- apk upgrade buildah run --user root $ctr -- apk add shadow +echo "User.build" if buildah run $ctr -- id 1000; then i=$(buildah run $ctr -- id -n 1000) buildah run $ctr -- usermod --home-dir /app --no-log-init 1000 $i else buildah run $ctr -- useradd --home-dir /app --uid 1000 app fi +echo "User.post_build" buildah config --user app $ctr \ No newline at end of file