Accepting request 683640 from home:cyphar:containers:docker-test
improvements to tests.sh OBS-URL: https://build.opensuse.org/request/show/683640 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=293
This commit is contained in:
parent
da5c1b9837
commit
cc89a2459e
20
docker.spec
20
docker.spec
@ -94,7 +94,7 @@ BuildRequires: audit
|
|||||||
BuildRequires: bash-completion
|
BuildRequires: bash-completion
|
||||||
BuildRequires: ca-certificates
|
BuildRequires: ca-certificates
|
||||||
BuildRequires: device-mapper-devel >= 1.2.68
|
BuildRequires: device-mapper-devel >= 1.2.68
|
||||||
BuildRequires: glibc-devel-static
|
BuildRequires: fdupes
|
||||||
BuildRequires: libapparmor-devel
|
BuildRequires: libapparmor-devel
|
||||||
BuildRequires: libbtrfs-devel >= 3.8
|
BuildRequires: libbtrfs-devel >= 3.8
|
||||||
BuildRequires: libseccomp-devel >= 2.2
|
BuildRequires: libseccomp-devel >= 2.2
|
||||||
@ -217,21 +217,11 @@ Zsh command line completion support for %{name}.
|
|||||||
%package test
|
%package test
|
||||||
%global __requires_exclude ^libgo.so.*$
|
%global __requires_exclude ^libgo.so.*$
|
||||||
Summary: Test package for docker
|
Summary: Test package for docker
|
||||||
Group: System/Management
|
|
||||||
BuildRequires: fdupes
|
|
||||||
Requires: apparmor-parser
|
|
||||||
Requires: bash-completion
|
|
||||||
Requires: device-mapper-devel >= 1.2.68
|
|
||||||
Requires: glibc-devel-static
|
|
||||||
Requires: libapparmor-devel
|
|
||||||
Requires: libbtrfs-devel >= 3.8
|
|
||||||
Requires: procps
|
|
||||||
Requires: sqlite3-devel
|
|
||||||
Requires: golang(API) = 1.8
|
|
||||||
# KUBIC-SPECIFIC: This was required when upgrading from the original kubic
|
# KUBIC-SPECIFIC: This was required when upgrading from the original kubic
|
||||||
# packaging, when everything was renamed to -kubic. It also is
|
# packaging, when everything was renamed to -kubic. It also is
|
||||||
# used to ensure that nothing complains too much when using
|
# used to ensure that nothing complains too much when using
|
||||||
# -kubic packages. Hopfully it can be removed one day.
|
# -kubic packages. Hopfully it can be removed one day.
|
||||||
|
Group: System/Management
|
||||||
%if "%flavour" == "kubic"
|
%if "%flavour" == "kubic"
|
||||||
# Obsolete old packege without the -kubic suffix
|
# Obsolete old packege without the -kubic suffix
|
||||||
Obsoletes: %{realname}-test = 1.12.6
|
Obsoletes: %{realname}-test = 1.12.6
|
||||||
@ -377,10 +367,12 @@ 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 and hack/ for testing purposes.
|
# We only need all our built tests.main, contrib/, and hack/ for testing purposes.
|
||||||
install -d %{buildroot}%{_prefix}/src/docker/
|
install -d %{buildroot}%{_prefix}/src/docker/
|
||||||
install -D -m0755 %{SOURCE9} %{buildroot}%{_prefix}/src/docker/tests.sh
|
install -D -m0755 %{SOURCE9} %{buildroot}%{_prefix}/src/docker/tests.sh
|
||||||
cp -a components/engine/{hack,integration{,-cli}}/ %{buildroot}%{_prefix}/src/docker/
|
cp -a components/engine/{hack,contrib,integration{,-cli}} %{buildroot}%{_prefix}/src/docker/
|
||||||
|
echo "%{version}" > %{buildroot}%{_prefix}/src/docker/VERSION
|
||||||
|
|
||||||
find %{buildroot}%{_prefix}/src/docker/ \
|
find %{buildroot}%{_prefix}/src/docker/ \
|
||||||
\( -type f -name '*_test.go' \) -delete
|
\( -type f -name '*_test.go' \) -delete
|
||||||
find %{buildroot}%{_prefix}/src/docker/ \
|
find %{buildroot}%{_prefix}/src/docker/ \
|
||||||
|
122
tests.sh
122
tests.sh
@ -4,7 +4,7 @@
|
|||||||
# XXX: We currently only support running integration-cli.
|
# XXX: We currently only support running integration-cli.
|
||||||
#
|
#
|
||||||
|
|
||||||
#set -x
|
set -Eeuxo pipefail
|
||||||
|
|
||||||
DOCKER_DIR=/usr/src/docker
|
DOCKER_DIR=/usr/src/docker
|
||||||
SCRIPTS_DIR=$DOCKER_DIR/hack
|
SCRIPTS_DIR=$DOCKER_DIR/hack
|
||||||
@ -16,30 +16,15 @@ TESTS_DIR=/tmp/docker-int-tests
|
|||||||
BUNDLES_DIR=$TESTS_DIR/run/bundles
|
BUNDLES_DIR=$TESTS_DIR/run/bundles
|
||||||
FAKE_GOPATH=$TESTS_DIR/go
|
FAKE_GOPATH=$TESTS_DIR/go
|
||||||
|
|
||||||
# some test expect the containerd socket here
|
|
||||||
CONTAINERD_SOCK=/run/containerd/containerd.sock
|
|
||||||
EXPECTED_CONTAINERD_SOCK=/var/run/docker/libcontainerd/docker-containerd.sock
|
|
||||||
|
|
||||||
# ... and some programs
|
|
||||||
CONTAINERD_CTR=/usr/sbin/containerd-ctr
|
|
||||||
EXPECTED_CONTAINERD_CTR=/usr/local/bin/docker-containerd-ctr
|
|
||||||
|
|
||||||
CHECK_TIMEOUT="${CHECK_TIMEOUT:-5m}"
|
CHECK_TIMEOUT="${CHECK_TIMEOUT:-5m}"
|
||||||
TEST_TIMEOUT="${TEST_TIMEOUT:-60m}"
|
TEST_TIMEOUT="${TEST_TIMEOUT:-60m}"
|
||||||
TEST_ARGS="-check.vv -check.timeout=${CHECK_TIMEOUT} -test.timeout=${TEST_TIMEOUT}"
|
TEST_ARGS="-check.vv -check.timeout=${CHECK_TIMEOUT} -test.timeout=${TEST_TIMEOUT}"
|
||||||
TEST_SELECT=
|
TEST_SELECT=
|
||||||
TEST_LOG=/tmp/docker-tests.log
|
TEST_LOG=/tmp/docker-tests.log
|
||||||
ENABLE_XUNIT=${ENABLE_XUNIT:-yes}
|
ENABLE_XUNIT="${ENABLE_XUNIT:=yes}"
|
||||||
|
|
||||||
# the sysconfig file for Docker
|
# the config file for Docker
|
||||||
SYSCFG_DOCKER=/etc/sysconfig/docker
|
CFG_DOCKER=/etc/docker/daemon.json
|
||||||
|
|
||||||
# some vars from the Dockerfile
|
|
||||||
ENABLE_NOTARY=${ENABLE_NOTARY:-}
|
|
||||||
ENABLE_REGISTRY=${ENABLE_REGISTRY:-}
|
|
||||||
REGISTRY_COMMIT_SCHEMA1=ec87e9b6971d831f0eff752ddb54fb64693e51cd
|
|
||||||
REGISTRY_COMMIT=47a064d4195a9b56133891bbb13620c3ac83a827
|
|
||||||
NOTARY_VERSION=v0.3.0
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
@ -66,7 +51,6 @@ set_opts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_docker_opts() { set_opts "DOCKER_OPTS" "$DOCKER_OPTS" /etc/sysconfig/docker ; }
|
set_docker_opts() { set_opts "DOCKER_OPTS" "$DOCKER_OPTS" /etc/sysconfig/docker ; }
|
||||||
set_containerd_opts() { set_opts "CONTAINERD_OPTS" "$CONTAINERD_OPTS" /etc/sysconfig/containerd ; }
|
|
||||||
|
|
||||||
fix_expected() {
|
fix_expected() {
|
||||||
EXPECTED=$1
|
EXPECTED=$1
|
||||||
@ -111,8 +95,6 @@ require_git() { git version >/dev/null 2>&1 ; }
|
|||||||
[ -x $TESTS_EXE ] || abort "integration tests executable not found at $TESTS_EXE"
|
[ -x $TESTS_EXE ] || abort "integration tests executable not found at $TESTS_EXE"
|
||||||
[ $EUID -eq 0 ] || abort "this script must be run as root"
|
[ $EUID -eq 0 ] || abort "this script must be run as root"
|
||||||
[ -n "$VERSION" ] || abort "could not obtain version"
|
[ -n "$VERSION" ] || abort "could not obtain version"
|
||||||
[ -e $CONTAINERD_SOCK ] || abort "containerd socket not found at $CONTAINERD_SOCK"
|
|
||||||
[ -x $CONTAINERD_CTR ] || abort "containerd-ctr not found at $CONTAINERD_CTR"
|
|
||||||
|
|
||||||
if [ $# -gt 0 ] ; then
|
if [ $# -gt 0 ] ; then
|
||||||
# run only some specific tests
|
# run only some specific tests
|
||||||
@ -132,64 +114,6 @@ DEST="$BUNDLES_DIR/$VERSION/"
|
|||||||
mkdir -p "$DEST"
|
mkdir -p "$DEST"
|
||||||
export DEST=$(realpath $DEST)
|
export DEST=$(realpath $DEST)
|
||||||
|
|
||||||
# create a fake go path
|
|
||||||
rm -rf $FAKE_GOPATH
|
|
||||||
mkdir -p $FAKE_GOPATH/src/github.com/docker
|
|
||||||
(cd $FAKE_GOPATH/src/github.com/docker && ln -sf $DOCKER_DIR docker)
|
|
||||||
|
|
||||||
if [ -n "$ENABLE_REGISTRY" ] ; then
|
|
||||||
# build the Docker registry
|
|
||||||
if [ ! -x /usr/local/bin/registry-v2 ] ; then
|
|
||||||
log "Building registry (commit:$REGISTRY_COMMIT)"
|
|
||||||
|
|
||||||
require_git || abort "git is not installed"
|
|
||||||
require_go || abort "the Go compiler is not installed"
|
|
||||||
|
|
||||||
export GOPATH="$(mktemp -d)"
|
|
||||||
|
|
||||||
git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution"
|
|
||||||
(cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT")
|
|
||||||
GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
|
|
||||||
go build -o /usr/local/bin/registry-v2 github.com/docker/distribution/cmd/registry
|
|
||||||
(cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1")
|
|
||||||
GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
|
|
||||||
go build -o /usr/local/bin/registry-v2-schema1 github.com/docker/distribution/cmd/registry
|
|
||||||
|
|
||||||
chmod 755 /usr/local/bin/registry-v2
|
|
||||||
[ -x /usr/local/bin/registry-v2 ] || abort "registry-v2 could not be built"
|
|
||||||
|
|
||||||
rm -rf "$GOPATH"
|
|
||||||
export -n GOPATH
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$ENABLE_NOTARY" ] ; then
|
|
||||||
# build the Docker notary
|
|
||||||
if [ ! -x /usr/local/bin/notary-server ] ; then
|
|
||||||
export GO15VENDOREXPERIMENT=1
|
|
||||||
export GOPATH="$(mktemp -d)"
|
|
||||||
|
|
||||||
require_git || abort "git is not installed"
|
|
||||||
require_go || abort "the Go compiler is not installed"
|
|
||||||
|
|
||||||
log "Building notary (version:$NOTARY_VERSION)"
|
|
||||||
git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary"
|
|
||||||
(cd "$GOPATH/src/github.com/docker/notary" && git checkout -q "$NOTARY_VERSION")
|
|
||||||
GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \
|
|
||||||
go build -o /usr/local/bin/notary-server github.com/docker/notary/cmd/notary-server
|
|
||||||
GOPATH="$GOPATH/src/github.com/docker/notary/vendor:$GOPATH" \
|
|
||||||
go build -o /usr/local/bin/notary github.com/docker/notary/cmd/notary
|
|
||||||
|
|
||||||
chmod 755 /usr/local/bin/notary-server
|
|
||||||
[ -x /usr/local/bin/notary-server ] || abort "notary could not be built"
|
|
||||||
|
|
||||||
export -n GO15VENDOREXPERIMENT
|
|
||||||
|
|
||||||
rm -rf "$GOPATH"
|
|
||||||
export -n GOPATH
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$ENABLE_XUNIT" ] ; then
|
if [ -n "$ENABLE_XUNIT" ] ; then
|
||||||
if [ ! -x /usr/local/bin/go2xunit ] ; then
|
if [ ! -x /usr/local/bin/go2xunit ] ; then
|
||||||
echo >&2 "Installing go2xunit."
|
echo >&2 "Installing go2xunit."
|
||||||
@ -215,8 +139,6 @@ fi
|
|||||||
# prepare some expected dirs, files, etc...
|
# prepare some expected dirs, files, etc...
|
||||||
fix_expected $TESTS_DIR/contrib $DOCKER_DIR/contrib
|
fix_expected $TESTS_DIR/contrib $DOCKER_DIR/contrib
|
||||||
fix_expected $DEST/fixtures $DOCKER_DIR/integration-cli/fixtures
|
fix_expected $DEST/fixtures $DOCKER_DIR/integration-cli/fixtures
|
||||||
fix_expected $EXPECTED_CONTAINERD_SOCK $CONTAINERD_SOCK
|
|
||||||
fix_expected $EXPECTED_CONTAINERD_CTR $CONTAINERD_CTR
|
|
||||||
|
|
||||||
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
|
||||||
@ -247,28 +169,34 @@ groupadd dockremap >/dev/null 2>&1 || /bin/true
|
|||||||
useradd -g dockremap dockremap >/dev/null 2>&1 || /bin/true
|
useradd -g dockremap dockremap >/dev/null 2>&1 || /bin/true
|
||||||
|
|
||||||
# make sure Docker is stopped, set our config file and then start again
|
# make sure Docker is stopped, set our config file and then start again
|
||||||
save_backup $SYSCFG_DOCKER
|
save_backup $CFG_DOCKER
|
||||||
cat <<SYSCFG_DOCKER_EOF > $SYSCFG_DOCKER
|
cat <<CFG_DOCKER_EOF > $CFG_DOCKER
|
||||||
DOCKER_OPTS="--log-level=debug \
|
{
|
||||||
--pidfile=$DEST/docker.pid \
|
"log-level": "debug",
|
||||||
-H tcp://127.0.0.1:2375 \
|
"log-driver": "json-file",
|
||||||
--storage-driver=$DOCKER_GRAPHDRIVER \
|
"log-opts": {
|
||||||
--userland-proxy=$DOCKER_USERLANDPROXY"
|
"max-size": "50m",
|
||||||
DOCKER_NETWORK_OPTIONS=""
|
"max-file": "5"
|
||||||
SYSCFG_DOCKER_EOF
|
},
|
||||||
systemctl reload-or-restart docker.service
|
"pidfile": "$DEST/docker.pid",
|
||||||
|
"host": [
|
||||||
|
"tcp://127.0.0.1:2375"
|
||||||
|
],
|
||||||
|
"storage-driver": "$DOCKER_GRAPHDRIVER",
|
||||||
|
"userland-proxy": $DOCKER_USERLANDPROXY
|
||||||
|
}
|
||||||
|
CFG_DOCKER_EOF
|
||||||
|
systemctl restart docker.service
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
log "Restoring the Docker service..."
|
log "Restoring the Docker service..."
|
||||||
restore_backup $SYSCFG_DOCKER
|
restore_backup $CFG_DOCKER
|
||||||
systemctl reload-or-restart docker.service
|
systemctl restart docker.service
|
||||||
|
|
||||||
log "Removing extra files and restoring backups..."
|
log "Removing extra files and restoring backups..."
|
||||||
restore_backup /etc/subuid /etc/subgid
|
restore_backup /etc/subuid /etc/subgid
|
||||||
rm -f $TESTS_DIR/contrib \
|
rm -f $TESTS_DIR/contrib \
|
||||||
$DEST/fixtures \
|
$DEST/fixtures
|
||||||
$EXPECTED_CONTAINERD_SOCK \
|
|
||||||
$EXPECTED_CONTAINERD_CTR
|
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user