Skip to content

Commit

Permalink
new make target: test-integration-cli-parallel
Browse files Browse the repository at this point in the history
Usage: $ make test-integration-cli-parallel

parallel(1) needs to be installed.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Sep 18, 2016
1 parent beea4d9 commit 1cd85f5
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
@@ -1,4 +1,5 @@
bundles
bundles-parallel
.gopath
vendor/pkg
.go-pkg-cache
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,6 +13,7 @@
.go-pkg-cache/
autogen/
bundles/
bundles-parallel/
cmd/dockerd/dockerd
cmd/docker/docker
dockerversion/version_autogen.go
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Expand Up @@ -96,6 +96,9 @@ deb: build ## build the deb packages
docs: ## build the docs
$(MAKE) -C docs docs

echo-docker-run: ## echo DOCKER_RUN_DOCKER
@echo $(DOCKER_RUN_DOCKER)

help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

Expand Down Expand Up @@ -129,6 +132,10 @@ test-docker-py: build ## run the docker-py tests
test-integration-cli: build ## run the integration tests
$(DOCKER_RUN_DOCKER) hack/make.sh build-integration-test-binary dynbinary test-integration-cli

test-integration-cli-parallel: build ## run the integration tests in parallel (EXPERIMENTAL)
$(DOCKER_RUN_DOCKER) hack/make.sh build-integration-test-binary dynbinary
contrib/test-integration-cli-parallel.sh

test-unit: build ## run the unit tests
$(DOCKER_RUN_DOCKER) hack/make.sh test-unit

Expand Down
19 changes: 19 additions & 0 deletions contrib/.test-integration-cli-parallel
@@ -0,0 +1,19 @@
#!/bin/bash
# ARG1: job number (1..N)
# ARG2: regexp for test case (e.g. TestRunEchoStdout)
set -e
echo "ARGS: $@"
if [ -z $1 ]; then
echo "job number not set"
false
fi
if [ -z $2 ]; then
echo "test regexp not set"
false
fi
set -x
mkdir -p bundles-parallel/$1
# TODO: dedup binaries
cp -r bundles bundles-parallel/$1
$(BINDDIR="bundles-parallel/$1/bundles" make --silent echo-docker-run) sh -c "ln -s bundles-parallel/$1/bundles bundles ; KEEPBUNDLE=1 DOCKER_INTEGRATION_TESTS_VERIFIED=1 TESTFLAGS=\"-check.f $2\" hack/make.sh test-integration-cli"
set +x
26 changes: 26 additions & 0 deletions contrib/.test-integration-cli-parallel-commands
@@ -0,0 +1,26 @@
TestA
TestB
TestC
TestD
TestE
TestF
TestG
TestH
TestI
TestJ
TestK
TestL
TestM
TestN
TestO
TestP
TestQ
TestR
TestS
TestT
TestU
TestV
TestW
TestX
TestY
TestZ
23 changes: 23 additions & 0 deletions contrib/test-integration-cli-parallel.sh
@@ -0,0 +1,23 @@
#!/bin/bash
### Usage:
### $ sudo apt install parallel
### $ ./contrib/test-integration-cli-parallel.sh
set -e

: ${NJOBS=$(nproc)}
D=$(pwd)/bundles-parallel
RUNNER=$(pwd)/contrib/.test-integration-cli-parallel
INPUT=$(pwd)/contrib/.test-integration-cli-parallel-commands
PARALLEL=parallel

echo "Running tests in parallel. see $D for results."
set -x
rm -rf $D/results $D/joblog
mkdir -p $D
$PARALLEL \
--jobs $NJOBS \
--results $D/results \
--joblog $D/joblog \
--arg-file $INPUT \
$RUNNER "{#}" "{}"
set +x
2 changes: 1 addition & 1 deletion hack/make/.integration-test-helpers
Expand Up @@ -20,7 +20,7 @@ bundle_test_integration_cli() {
go_test_dir() {
dir=$1
precompiled=$2
testbinary="$DEST/test.main"
testbinary="$ABS_DEST/test.main"
testcover=()
testcoverprofile=()
(
Expand Down
2 changes: 1 addition & 1 deletion hack/make/build-integration-test-binary
Expand Up @@ -2,7 +2,7 @@
set -e

rm -rf "$DEST"
DEST="$DEST/../test-integration-cli"
DEST="$ABS_DEST/../test-integration-cli"

if [ -z $DOCKER_INTEGRATION_TESTS_VERIFIED ]; then
source ${MAKEDIR}/.integration-test-helpers
Expand Down

1 comment on commit 1cd85f5

@AkihiroSuda
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backup moby#26684 (will be updated soon)


What I did

Introduced make test-integration-cli-parallel, which executes multiple integration tests in parallel.

Experimental result: 3.8 times faster

on GCE n1-standard-32 (32 vCPUs, 120GB RAM, standard HDD)

  • DOCKER_INCREMENTAL_BINARY=1 make test-integration-cli: about 49 minutes
  • DOCKER_INCREMENTAL_BINARY=1 make test-integration-cli-parallel: about 13 minutes

Next steps

The next step is to improve the regexp strings (TestA, TestB, .., TestZ) to shorten the makespan (described below).

The further next step is to execute the tests in parallel across a Docker Swarm cluster, but I think it can/should be done in an external tool.
Actually I've been already working on such a tool for k8s, and the tool will soon support Docker Swarm as well: https://github.com/osrg/namazu-swarm

Also, the support for "privilged" services would be needed for running integration tests across a Docker Swarm cluster: moby#24862

How I did it

Executes equivalents of the following commands in parallel across multiple docker-dev containers, using parallel(1):

  • TESTFLAGS='-check.f TestA' make test-integration-cli
  • TESTFLAGS='-check.f TestB' make test-integration-cli
  • ..
  • TESTFLAGS='-check.f TestZ' make test-integration-cli

As you can see this regexp granularity is not sufficient yet, and we need to improve regexp strings.
I think we can shorten the makespan to less than 5 minutes.

How to verify it

$ sudo apt-get install parallel
$ make test-integration-cli-parallel
$ cat bundles-parallel/joblog
Seq     Host    Starttime       JobRuntime      Send    Receive Exitval Signal  Command
6       :       1474181385.858     107.385      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 6 TestF
26      :       1474181385.935     126.559      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 26 TestZ
15      :       1474181385.880     131.152      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 15 TestO
17      :       1474181385.886     159.350      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 17 TestQ
24      :       1474181385.920     163.412      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 24 TestX
25      :       1474181385.927     168.750      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 25 TestY
10      :       1474181385.866     173.161      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 10 TestJ
13      :       1474181385.874     191.733      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 13 TestM
23      :       1474181385.916     191.693      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 23 TestW
11      :       1474181385.869     198.926      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 11 TestK
7       :       1474181385.860     203.895      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 7 TestG
14      :       1474181385.877     206.988      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 14 TestN
8       :       1474181385.862     218.861      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 8 TestH
20      :       1474181385.897     243.567      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 20 TestT
22      :       1474181385.912     247.565      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 22 TestV
9       :       1474181385.864     302.562      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 9 TestI
21      :       1474181385.908     305.033      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 21 TestU
12      :       1474181385.872     328.861      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 12 TestL
5       :       1474181385.856     381.825      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 5 TestE
19      :       1474181385.893     414.353      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 19 TestS
3       :       1474181385.852     490.608      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 3 TestC
1       :       1474181385.848     625.009      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 1 TestA
16      :       1474181385.883     634.078      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 16 TestP
4       :       1474181385.854     641.451      0       0       1       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 4 TestD
18      :       1474181385.890     666.172      0       0       0       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 18 TestR
2       :       1474181385.850     767.139      0       0       1       0       /home/suda/gopath/src/github.com/docker/docker/contrib/.test-integration-cli-parallel 2 TestB
$ cat bundles-parallel/results/1/TestA/stdout
...

(TODO: rename bundles-parallel to bundles/test-integration-cli-parallel ?)

Observations from the result:

  • Even though Test[FJOQXYZ] does nothing, they consume a few minutes due to setting up the environment. We really need to remove these regexp strings and deduplicate the setup code.

  • TestB is long (767 seconds), but the longest test in TestB (TestBuildAddChangeOwnership) just takes 34 seconds.

  • Almost all the test cases complete within 30 seconds. A small number of exceptions:

    PASS: docker_cli_pull_test.go:201: DockerHubPullSuite.TestPullAllTagsFromCentralRegistry       116.797s
    PASS: docker_cli_health_test.go:53: DockerSuite.TestHealth     64.648s
    PASS: docker_cli_push_test.go:666: DockerRegistryAuthTokenSuite.TestPushMisconfiguredTokenServiceResponseError 50.14
    PASS: docker_cli_port_test.go:180: DockerSuite.TestUnpublishedPortsInPsOutput  42.324s
    PASS: docker_cli_pull_test.go:41: DockerHubPullSuite.TestPullNonExistingImage  35.059s
    PASS: docker_cli_build_unix_test.go:84: DockerSuite.TestBuildAddChangeOwnership        34.808s
    PASS: docker_cli_network_unix_test.go:1621: DockerSuite.TestDockerNetworkInternalMode  33.914s
    PASS: docker_cli_links_test.go:33: DockerSuite.TestLinksPingLinkedContainers   30.975s
    PASS: docker_cli_port_test.go:14: DockerSuite.TestPortList     30.037s

So I think we can shorten the makespan to less than 5 minutes.

Description for the changelog

new make target: test-integration-cli-parallel

A picture of a cute animal (not mandatory but encouraged)**

queue

Signed-off-by: Akihiro Suda suda.akihiro@lab.ntt.co.jp

Please sign in to comment.