forked from pool/docker
- docker-test: improvements to test packaging (we don't need to ship around the
entire source tree, and we also need to build the born-again integration/ tests which contain a suite-per-directory). We also need a new patch which fixes the handling of *-test images. bsc#1128746 + bsc1128746-0001-integration-cli-don-t-build-test-images-if-they-alre.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=301
This commit is contained in:
parent
228cbfd32b
commit
aa89492db8
@ -0,0 +1,95 @@
|
|||||||
|
From 911af815ea12dacb81afef0a6704c73d48df01d3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aleksa Sarai <asarai@suse.de>
|
||||||
|
Date: Tue, 12 Mar 2019 18:48:38 +1100
|
||||||
|
Subject: [PATCH] integration-cli: don't build -test images if they already
|
||||||
|
exist
|
||||||
|
|
||||||
|
There's no need to try to re-build the test images if they already
|
||||||
|
exist. This change makes basically no difference to the upstream
|
||||||
|
integration test-suite running, but for users who want to run the
|
||||||
|
integration-cli suite on a host machine (such as distributions doing
|
||||||
|
tests) this change allows images to be pre-loaded such that compilers
|
||||||
|
aren't needed on the test machine.
|
||||||
|
|
||||||
|
SUSE-Bugs: bsc#1128746
|
||||||
|
Signed-off-by: Aleksa Sarai <asarai@suse.de>
|
||||||
|
---
|
||||||
|
.../fixtures_linux_daemon_test.go | 20 +++++++++++--------
|
||||||
|
.../internal/test/environment/environment.go | 20 +++++++++++++++++++
|
||||||
|
2 files changed, 32 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/components/engine/integration-cli/fixtures_linux_daemon_test.go b/components/engine/integration-cli/fixtures_linux_daemon_test.go
|
||||||
|
index 2387a9ebee2b..ae01180d8523 100644
|
||||||
|
--- a/components/engine/integration-cli/fixtures_linux_daemon_test.go
|
||||||
|
+++ b/components/engine/integration-cli/fixtures_linux_daemon_test.go
|
||||||
|
@@ -24,17 +24,13 @@ type logT interface {
|
||||||
|
Logf(string, ...interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
-var ensureSyscallTestOnce sync.Once
|
||||||
|
-
|
||||||
|
func ensureSyscallTest(c *check.C) {
|
||||||
|
- var doIt bool
|
||||||
|
- ensureSyscallTestOnce.Do(func() {
|
||||||
|
- doIt = true
|
||||||
|
- })
|
||||||
|
- if !doIt {
|
||||||
|
+ defer testEnv.ProtectImage(c, "syscall-test:latest")
|
||||||
|
+
|
||||||
|
+ // If the image already exists, there's nothing left to do.
|
||||||
|
+ if testEnv.HasExistingImage(c, "syscall-test:latest") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
- defer testEnv.ProtectImage(c, "syscall-test:latest")
|
||||||
|
|
||||||
|
// if no match, must build in docker, which is significantly slower
|
||||||
|
// (slower mostly because of the vfs graphdriver)
|
||||||
|
@@ -93,6 +89,14 @@ func ensureSyscallTestBuild(c *check.C) {
|
||||||
|
|
||||||
|
func ensureNNPTest(c *check.C) {
|
||||||
|
defer testEnv.ProtectImage(c, "nnp-test:latest")
|
||||||
|
+
|
||||||
|
+ // If the image already exists, there's nothing left to do.
|
||||||
|
+ if testEnv.HasExistingImage(c, "nnp-test:latest") {
|
||||||
|
+ return
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // if no match, must build in docker, which is significantly slower
|
||||||
|
+ // (slower mostly because of the vfs graphdriver)
|
||||||
|
if testEnv.OSType != runtime.GOOS {
|
||||||
|
ensureNNPTestBuild(c)
|
||||||
|
return
|
||||||
|
diff --git a/components/engine/internal/test/environment/environment.go b/components/engine/internal/test/environment/environment.go
|
||||||
|
index 74c8e2ce0ad7..56692a4f6594 100644
|
||||||
|
--- a/components/engine/internal/test/environment/environment.go
|
||||||
|
+++ b/components/engine/internal/test/environment/environment.go
|
||||||
|
@@ -145,6 +145,26 @@ func (e *Execution) APIClient() client.APIClient {
|
||||||
|
return e.client
|
||||||
|
}
|
||||||
|
|
||||||
|
+// HasExistingImage checks whether there is an image with the given reference.
|
||||||
|
+// Note that this is done by filtering and then checking whether there were any
|
||||||
|
+// results -- so ambiguous references might result in false-positives.
|
||||||
|
+func (e *Execution) HasExistingImage(t TestingT, reference string) bool {
|
||||||
|
+ if ht, ok := t.(test.HelperT); ok {
|
||||||
|
+ ht.Helper()
|
||||||
|
+ }
|
||||||
|
+ client := e.APIClient()
|
||||||
|
+ filter := filters.NewArgs()
|
||||||
|
+ filter.Add("dangling", "false")
|
||||||
|
+ filter.Add("reference", reference)
|
||||||
|
+ imageList, err := client.ImageList(context.Background(), types.ImageListOptions{
|
||||||
|
+ All: true,
|
||||||
|
+ Filters: filter,
|
||||||
|
+ })
|
||||||
|
+ assert.NilError(t, err, "failed to list images")
|
||||||
|
+
|
||||||
|
+ return len(imageList) > 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
// EnsureFrozenImagesLinux loads frozen test images into the daemon
|
||||||
|
// if they aren't already loaded
|
||||||
|
func EnsureFrozenImagesLinux(testEnv *Execution) error {
|
||||||
|
--
|
||||||
|
2.21.0
|
||||||
|
|
@ -3,7 +3,9 @@ Sun Mar 10 21:12:09 UTC 2019 - Aleksa Sarai <asarai@suse.com>
|
|||||||
|
|
||||||
- docker-test: improvements to test packaging (we don't need to ship around the
|
- docker-test: improvements to test packaging (we don't need to ship around the
|
||||||
entire source tree, and we also need to build the born-again integration/
|
entire source tree, and we also need to build the born-again integration/
|
||||||
tests which contain a suite-per-directory).
|
tests which contain a suite-per-directory). We also need a new patch which
|
||||||
|
fixes the handling of *-test images. bsc#1128746
|
||||||
|
+ bsc1128746-0001-integration-cli-don-t-build-test-images-if-they-alre.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Feb 26 09:39:57 UTC 2019 - Michal Jura <mjura@suse.com>
|
Tue Feb 26 09:39:57 UTC 2019 - Michal Jura <mjura@suse.com>
|
||||||
|
22
docker.spec
22
docker.spec
@ -90,6 +90,8 @@ Patch405: bsc1001161-0002-cli-add-a-separate-domainname-flag.patch
|
|||||||
# SUSE-FEATURE: Add support to mirror inofficial/private registries
|
# SUSE-FEATURE: Add support to mirror inofficial/private registries
|
||||||
# (https://github.com/docker/docker/pull/34319)
|
# (https://github.com/docker/docker/pull/34319)
|
||||||
Patch500: private-registry-0001-Add-private-registry-mirror-support.patch
|
Patch500: private-registry-0001-Add-private-registry-mirror-support.patch
|
||||||
|
# SUSE-BACKPORT: Backport of test-only patch https://github.com/moby/moby/pull/38853. bsc1128746
|
||||||
|
Patch900: bsc1128746-0001-integration-cli-don-t-build-test-images-if-they-alre.patch
|
||||||
BuildRequires: audit
|
BuildRequires: audit
|
||||||
BuildRequires: bash-completion
|
BuildRequires: bash-completion
|
||||||
BuildRequires: ca-certificates
|
BuildRequires: ca-certificates
|
||||||
@ -273,6 +275,8 @@ docker container runtime configuration for kubeadm
|
|||||||
# PATCH-SUSE: Mirror patch.
|
# PATCH-SUSE: Mirror patch.
|
||||||
%patch500 -p1
|
%patch500 -p1
|
||||||
%endif
|
%endif
|
||||||
|
# bsc#1128746
|
||||||
|
%patch900 -p1
|
||||||
|
|
||||||
cp %{SOURCE7} .
|
cp %{SOURCE7} .
|
||||||
|
|
||||||
@ -371,12 +375,6 @@ install -Dd -m 0755 \
|
|||||||
install -D -m0644 components/cli/contrib/completion/bash/docker "%{buildroot}%{_sysconfdir}/bash_completion.d/%{realname}"
|
install -D -m0644 components/cli/contrib/completion/bash/docker "%{buildroot}%{_sysconfdir}/bash_completion.d/%{realname}"
|
||||||
install -D -m0644 components/cli/contrib/completion/zsh/_docker "%{buildroot}%{_sysconfdir}/zsh_completion.d/%{realname}"
|
install -D -m0644 components/cli/contrib/completion/zsh/_docker "%{buildroot}%{_sysconfdir}/zsh_completion.d/%{realname}"
|
||||||
|
|
||||||
# We only need all our built tests.main, contrib/, and hack/ for testing purposes.
|
|
||||||
install -d %{buildroot}%{_prefix}/src/docker/
|
|
||||||
install -D -m0755 %{SOURCE9} %{buildroot}%{_prefix}/src/docker/tests.sh
|
|
||||||
cp -a components/engine/{hack,contrib,integration{,-cli}} %{buildroot}%{_prefix}/src/docker/
|
|
||||||
echo "%{version}" > %{buildroot}%{_prefix}/src/docker/VERSION
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# systemd service
|
# systemd service
|
||||||
#
|
#
|
||||||
@ -409,6 +407,18 @@ install -p -m 644 components/cli/man/man5/Dockerfile.5 %{buildroot}%{_mandir}/ma
|
|||||||
install -d %{buildroot}%{_mandir}/man8
|
install -d %{buildroot}%{_mandir}/man8
|
||||||
install -p -m 644 components/cli/man/man8/*.8 %{buildroot}%{_mandir}/man8
|
install -p -m 644 components/cli/man/man8/*.8 %{buildroot}%{_mandir}/man8
|
||||||
|
|
||||||
|
# install docker-test files -- we want to avoid installing the entire source tree.
|
||||||
|
install -d %{buildroot}%{_prefix}/src/docker/
|
||||||
|
install -D -m0755 %{SOURCE9} %{buildroot}%{_prefix}/src/docker/tests.sh
|
||||||
|
# We need hack/, contrib/, profiles/, and the integration*/ trees.
|
||||||
|
cp -a components/engine/{hack,contrib,profiles,integration{,-cli}} %{buildroot}%{_prefix}/src/docker/
|
||||||
|
echo "%{version}" > %{buildroot}%{_prefix}/src/docker/VERSION
|
||||||
|
# And now we can remove all *_test.go files -- since we already have test
|
||||||
|
# binaries. Due to a lot of hacks within the Docker integration tests, we can't
|
||||||
|
# really do a bigger cleanup than this.
|
||||||
|
find %{buildroot}%{_prefix}/src/docker \
|
||||||
|
-type f -name '*_test.go' -delete
|
||||||
|
|
||||||
%if "%flavour" == "kubic"
|
%if "%flavour" == "kubic"
|
||||||
# place kubelet.env in fillupdir (for kubeadm-criconfig)
|
# place kubelet.env in fillupdir (for kubeadm-criconfig)
|
||||||
install -D -m 0644 %{SOURCE5} %{buildroot}%{_fillupdir}/sysconfig.kubelet
|
install -D -m 0644 %{SOURCE5} %{buildroot}%{_fillupdir}/sysconfig.kubelet
|
||||||
|
42
tests.sh
42
tests.sh
@ -11,10 +11,8 @@ SCRIPTS_DIR="$DOCKER_DIR/hack"
|
|||||||
VERSION="$(cat "$DOCKER_DIR/VERSION")"
|
VERSION="$(cat "$DOCKER_DIR/VERSION")"
|
||||||
|
|
||||||
# working dirs
|
# working dirs
|
||||||
TEST_TMPDIR=/tmp/docker-int-tests
|
FROZEN_IMAGES_DIR="/tmp/docker-frozen-images"
|
||||||
FROZEN_IMAGES_DIR="$TEST_TMPDIR/frozen-images"
|
|
||||||
FROZEN_IMAGES_LINK=/docker-frozen-images
|
FROZEN_IMAGES_LINK=/docker-frozen-images
|
||||||
BUNDLES_DIR="$TEST_TMPDIR/run/bundles"
|
|
||||||
|
|
||||||
readarray -t TESTS < <(find "$DOCKER_DIR/integration-cli" -type f -executable -name 'tests.main')
|
readarray -t TESTS < <(find "$DOCKER_DIR/integration-cli" -type f -executable -name 'tests.main')
|
||||||
CHECK_TIMEOUT="${CHECK_TIMEOUT:-15m}"
|
CHECK_TIMEOUT="${CHECK_TIMEOUT:-15m}"
|
||||||
@ -46,17 +44,6 @@ bundle() {
|
|||||||
set "-$oldFlags"
|
set "-$oldFlags"
|
||||||
}
|
}
|
||||||
|
|
||||||
fix_expected() {
|
|
||||||
EXPECTED="$1"
|
|
||||||
EXISTING="$2"
|
|
||||||
|
|
||||||
exp_base="$(basename "$EXPECTED")"
|
|
||||||
exp_dir="$(dirname "$EXPECTED")"
|
|
||||||
[ -d "$exp_dir" ] || mkdir -p "$exp_dir"
|
|
||||||
rm -f "$exp_dir/$exp_base"
|
|
||||||
( cd "$exp_dir" && ln -sf "$EXISTING" "$exp_base" )
|
|
||||||
}
|
|
||||||
|
|
||||||
save_backup() {
|
save_backup() {
|
||||||
for x in $@ ; do
|
for x in $@ ; do
|
||||||
if [ ! -f "$x" ] ; then
|
if [ ! -f "$x" ] ; then
|
||||||
@ -130,11 +117,6 @@ fi
|
|||||||
/usr/sbin/groupadd -r docker >/dev/null 2>&1 || /bin/true
|
/usr/sbin/groupadd -r docker >/dev/null 2>&1 || /bin/true
|
||||||
/usr/sbin/useradd --create-home --gid docker unprivilegeduser >/dev/null 2>&1 || /bin/true
|
/usr/sbin/useradd --create-home --gid docker unprivilegeduser >/dev/null 2>&1 || /bin/true
|
||||||
|
|
||||||
# prepare some expected dirs, files, etc...
|
|
||||||
fix_expected "$TEST_TMPDIR/contrib" "$DOCKER_DIR/contrib"
|
|
||||||
fix_expected "$DEST/fixtures" "$DOCKER_DIR/integration-cli/fixtures"
|
|
||||||
fix_expected "$DEST/../Dockerfile" "$DOCKER_DIR/Dockerfile"
|
|
||||||
|
|
||||||
export DOCKER_TEST_HOST="tcp://127.0.0.1:2375"
|
export DOCKER_TEST_HOST="tcp://127.0.0.1:2375"
|
||||||
export PATH="/usr/local/bin:$PATH"
|
export PATH="/usr/local/bin:$PATH"
|
||||||
export TZ=utc
|
export TZ=utc
|
||||||
@ -186,17 +168,16 @@ CFG_DOCKER_EOF
|
|||||||
systemctl restart docker.service
|
systemctl restart docker.service
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
log "Restoring the Docker service..."
|
log "Restoring configuration files..."
|
||||||
restore_backup "$CFG_DOCKER"
|
restore_backup /etc/subuid /etc/subgid "$CFG_DOCKER"
|
||||||
systemctl restart docker.service
|
rm -f "$FROZEN_IMAGES_LINK"
|
||||||
|
|
||||||
log "Removing images and containers..."
|
log "Removing images and containers..."
|
||||||
docker ps -aq | xargs docker rm -f &>/dev/null || :
|
docker ps -aq | xargs docker rm -f &>/dev/null || :
|
||||||
docker images -q | xargs docker rmi -f &>/dev/null || :
|
docker images -q | xargs docker rmi -f &>/dev/null || :
|
||||||
|
|
||||||
log "Removing extra files and restoring backups..."
|
log "Restarting the Docker service in a pristine state..."
|
||||||
restore_backup /etc/subuid /etc/subgid
|
systemctl restart docker.service
|
||||||
rm -f "$TEST_TMPDIR/contrib" "$DEST/fixtures" "$FROZEN_IMAGES_LINK"
|
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
@ -225,6 +206,17 @@ ln -sf "$FROZEN_IMAGES_DIR" "$FROZEN_IMAGES_LINK"
|
|||||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||||
|
|
||||||
|
# The code within integration-cli which handles building *-test images doesn't
|
||||||
|
# appear to work within our setup, not to mention we don't want to Require: a
|
||||||
|
# bunch of build tools so we just use the provided Dockerfile and
|
||||||
|
# buildpack-deps.
|
||||||
|
tar -cC "$FROZEN_IMAGES_DIR" . | docker load
|
||||||
|
for dir in "$DOCKER_DIR"/contrib/*-test
|
||||||
|
do
|
||||||
|
log "Building *-test images ($dir)..."
|
||||||
|
docker build -t "$(basename "$dir")" "$dir"
|
||||||
|
done
|
||||||
|
|
||||||
rm -f "$TEST_LOG"
|
rm -f "$TEST_LOG"
|
||||||
for TEST in "${TESTS[@]}"
|
for TEST in "${TESTS[@]}"
|
||||||
do
|
do
|
||||||
|
Loading…
Reference in New Issue
Block a user