Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 1a7a263

Browse files
authored
Merge pull request #383 from thaJeztah/19.03_backport_test_fixes_2
[19.03 backport] Testing and Jenkinsfile changes [step 2] Upstream-commit: b6a7124855635a00c7aec05195fd133e940101e8 Component: engine
2 parents 93972ee + ff7a08b commit 1a7a263

135 files changed

Lines changed: 4348 additions & 7770 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/engine/Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ pipeline {
307307
TEST_INTEGRATION_DEST=1 CONTAINER_NAME=${CONTAINER_NAME}-1 TEST_SKIP_INTEGRATION_CLI=1 run_tests test-integration-flaky &
308308
309309
# integration-cli first set
310-
TEST_INTEGRATION_DEST=2 CONTAINER_NAME=${CONTAINER_NAME}-2 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-check.f ^(DockerSuite|DockerNetworkSuite|DockerHubPullSuite|DockerRegistrySuite|DockerSchema1RegistrySuite|DockerRegistryAuthTokenSuite|DockerRegistryAuthHtpasswdSuite)" run_tests &
310+
TEST_INTEGRATION_DEST=2 CONTAINER_NAME=${CONTAINER_NAME}-2 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run Test(DockerSuite|DockerNetworkSuite|DockerHubPullSuite|DockerRegistrySuite|DockerSchema1RegistrySuite|DockerRegistryAuthTokenSuite|DockerRegistryAuthHtpasswdSuite)/" run_tests &
311311
312312
# integration-cli second set
313-
TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-check.f ^(DockerSwarmSuite|DockerDaemonSuite|DockerExternalVolumeSuite)" run_tests &
313+
TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run Test(DockerSwarmSuite|DockerDaemonSuite|DockerExternalVolumeSuite)/" run_tests &
314314
315315
set +x
316316
c=0

components/engine/daemon/bindmount_unix.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

components/engine/daemon/volumes_unix.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ func (daemon *Daemon) mountVolumes(container *container.Container) error {
141141
if m.Writable {
142142
writeMode = "rw"
143143
}
144-
opts := strings.Join([]string{bindMode, writeMode}, ",")
145-
if err := mount.Mount(m.Source, dest, bindMountType, opts); err != nil {
146-
return err
147-
}
148144

149145
// mountVolumes() seems to be called for temporary mounts
150146
// outside the container. Soon these will be unmounted with
@@ -154,8 +150,9 @@ func (daemon *Daemon) mountVolumes(container *container.Container) error {
154150
// then these unmounts will propagate and unmount original
155151
// mount as well. So make all these mounts rprivate.
156152
// Do not use propagation property of volume as that should
157-
// apply only when mounting happen inside the container.
158-
if err := mount.MakeRPrivate(dest); err != nil {
153+
// apply only when mounting happens inside the container.
154+
opts := strings.Join([]string{bindMode, writeMode, "rprivate"}, ",")
155+
if err := mount.Mount(m.Source, dest, "", opts); err != nil {
159156
return err
160157
}
161158
}

components/engine/docs/contributing/test.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ flag's value is passed as arguments to the `go test` command. For example, from
174174
your local host you can run the `TestBuild` test with this command:
175175

176176
```bash
177-
$ TESTFLAGS='-check.f DockerSuite.TestBuild*' make test-integration
177+
$ TESTFLAGS='-test.run TestDockerSuite/TestBuild*' make test-integration
178178
```
179179

180180
To run the same test inside your Docker development container, you do this:
181181

182182
```bash
183-
# TESTFLAGS='-check.f TestBuild*' hack/make.sh binary test-integration
183+
# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' hack/make.sh binary test-integration
184184
```
185185

186186
## Test the Windows binary against a Linux daemon
@@ -228,11 +228,11 @@ run a Bash terminal on Windows.
228228
```
229229

230230
Should you wish to run a single test such as one with the name
231-
'TestExample', you can pass in `TESTFLAGS='-check.f TestExample'`. For
231+
'TestExample', you can pass in `TESTFLAGS='-test.run /TestExample'`. For
232232
example
233233

234234
```bash
235-
$ TESTFLAGS='-check.f TestExample' hack/make.sh binary test-integration
235+
$ TESTFLAGS='-test.run /TestExample' hack/make.sh binary test-integration
236236
```
237237

238238
You can now choose to make changes to the Moby source or the tests. If you

components/engine/hack/ci/windows.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -831,14 +831,13 @@ Try {
831831

832832
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
833833
$c = "go test "
834-
$c += "`"-check.v`" "
834+
$c += "`"-test.v`" "
835835
if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests
836-
$c += "`"-check.f`" "
836+
$c += "`"-test.run`" "
837837
$c += "`"$env:INTEGRATION_TEST_NAME`" "
838838
Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME"
839839
}
840840
$c += "`"-tags`" " + "`"autogen`" "
841-
$c += "`"-check.timeout`" " + "`"10m`" "
842841
$c += "`"-test.timeout`" " + "`"200m`" "
843842

844843
if ($null -ne $env:INTEGRATION_IN_CONTAINER) {
@@ -926,14 +925,13 @@ Try {
926925
} else {
927926
#https://blogs.technet.microsoft.com/heyscriptingguy/2011/09/20/solve-problems-with-external-command-lines-in-powershell/ is useful to see tokenising
928927
$c = "go test "
929-
$c += "`"-check.v`" "
928+
$c += "`"-test.v`" "
930929
if ($null -ne $env:INTEGRATION_TEST_NAME) { # Makes is quicker for debugging to be able to run only a subset of the integration tests
931-
$c += "`"-check.f`" "
930+
$c += "`"-test.run`" "
932931
$c += "`"$env:INTEGRATION_TEST_NAME`" "
933932
Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME"
934933
}
935934
$c += "`"-tags`" " + "`"autogen`" "
936-
$c += "`"-check.timeout`" " + "`"10m`" "
937935
$c += "`"-test.timeout`" " + "`"200m`" "
938936

939937
Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:"

components/engine/hack/make/.integration-test-helpers

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
44
# to run certain tests on your local host, you should run with command:
55
#
6-
# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration
6+
# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' ./hack/make.sh binary test-integration
77
#
88

9-
if [[ "${TESTFLAGS}" = *-check.f* ]]; then
10-
echo Skipping integration tests since TESTFLAGS includes integration-cli only flags
11-
TEST_SKIP_INTEGRATION=1
12-
fi
13-
14-
if [[ "${TESTFLAGS}" = *-test.run* ]]; then
15-
echo Skipping integration-cli tests since TESTFLAGS includes integration only flags
16-
TEST_SKIP_INTEGRATION_CLI=1
17-
fi
18-
19-
209
if [ -z "${MAKEDIR}" ]; then
2110
MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2211
export MAKEDIR
@@ -32,24 +21,22 @@ setup_integration_test_filter() {
3221
if [ -z "${TEST_FILTER}" ]; then
3322
return
3423
fi
24+
TESTFLAGS+="-test.run ${TEST_FILTER}"
3525

26+
local dirs
27+
dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq)
3628
if [ -z "${TEST_SKIP_INTEGRATION}" ]; then
37-
: "${TEST_INTEGRATION_DIR:=$(grep -rl "func\ .*${TEST_FILTER}.*\(t\ \*testing\.T\)" ./integration | grep '_test\.go' | xargs -I file dirname file | uniq)}"
29+
: "${TEST_INTEGRATION_DIR:=$(echo "$dirs" | grep -v '^\./integration-cli$')}"
3830
if [ -z "${TEST_INTEGRATION_DIR}" ]; then
3931
echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests"
4032
TEST_SKIP_INTEGRATION=1
41-
else
42-
TESTFLAGS_INTEGRATION+="-test.run ${TEST_FILTER}"
4333
fi
4434
fi
4535

4636
if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
47-
# ease up on the filtering here since CLI suites are namespaced by an object
48-
if grep -r "${TEST_FILTER}.*\(c\ \*check\.C\)" ./integration-cli | grep -q '_test\.go$'; then
37+
if echo "$dirs" | grep -vq '^./integration-cli$'; then
4938
TEST_SKIP_INTEGRATION_CLI=1
5039
echo "Skipping integration-cli tests since the supplied filter \"${TEST_FILTER}\" omits all integration-cli tests"
51-
else
52-
TESTFLAGS_INTEGRATION_CLI+="-check.f ${TEST_FILTER}"
5340
fi
5441
fi
5542
}
@@ -60,16 +47,17 @@ integration_api_dirs="${TEST_INTEGRATION_DIR:-$(go list -test -f '{{- if ne .Fo
6047
run_test_integration() {
6148
set_platform_timeout
6249
if [ -z "${TEST_SKIP_INTEGRATION}" ]; then
63-
run_test_integration_suites
50+
run_test_integration_suites "${integration_api_dirs}"
6451
fi
6552
if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
66-
run_test_integration_legacy_suites
53+
TIMEOUT=360m run_test_integration_suites integration-cli
6754
fi
6855
}
6956

7057
run_test_integration_suites() {
71-
local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS ${TESTFLAGS_INTEGRATION}"
72-
for dir in ${integration_api_dirs}; do
58+
local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS"
59+
local dirs="$1"
60+
for dir in ${dirs}; do
7361
if ! (
7462
cd "$dir"
7563
# Create a useful package name based on the tests's $dir. We need to take
@@ -97,16 +85,6 @@ run_test_integration_suites() {
9785
done
9886
}
9987

100-
run_test_integration_legacy_suites() {
101-
(
102-
flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS ${TESTFLAGS_INTEGRATION_CLI}"
103-
cd integration-cli
104-
echo "Running $PWD flags=${flags}"
105-
# shellcheck disable=SC2086
106-
test_env ./test.main $flags
107-
)
108-
}
109-
11088
build_test_suite_binaries() {
11189
if [ -n "${DOCKER_INTEGRATION_TESTS_VERIFIED}" ]; then
11290
echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set"

components/engine/hack/test/e2e-run.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
1818

1919
run_test_integration() {
2020
set_platform_timeout
21-
if [[ "$TESTFLAGS" != *-check.f* ]]; then
22-
run_test_integration_suites
23-
fi
24-
if [[ "$TESTFLAGS" != *-test.run* ]]; then
25-
run_test_integration_legacy_suites
26-
fi
21+
run_test_integration_suites
22+
run_test_integration_legacy_suites
2723
}
2824

2925
run_test_integration_suites() {
@@ -39,7 +35,7 @@ run_test_integration_suites() {
3935

4036
run_test_integration_legacy_suites() {
4137
(
42-
flags="-check.v -check.timeout=${TIMEOUT:-200m} -test.timeout=360m $TESTFLAGS"
38+
flags="-test.v -test.timeout=360m $TESTFLAGS"
4339
cd /tests/integration-cli
4440
echo "Running $PWD"
4541
test_env ./test.main $flags

components/engine/hack/test/unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
set -eu -o pipefail
1414

1515
BUILDFLAGS=( -tags 'netgo seccomp libdm_no_deferred_remove' )
16-
TESTFLAGS+="-test.timeout=${TIMEOUT:-5m}"
16+
TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
1717
TESTDIRS="${TESTDIRS:-./...}"
1818
exclude_paths='/vendor/|/integration'
1919
pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)")

components/engine/hack/validate/default

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1010
. ${SCRIPTDIR}/pkg-imports
1111
. ${SCRIPTDIR}/swagger
1212
. ${SCRIPTDIR}/swagger-gen
13-
. ${SCRIPTDIR}/test-imports
1413
. ${SCRIPTDIR}/toml
1514
. ${SCRIPTDIR}/changelog-well-formed
1615
. ${SCRIPTDIR}/changelog-date-descending

components/engine/hack/validate/test-imports

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)