1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #39911 from tiborvass/gotestsum-integration-cli

hack: have integration-cli use gotestsum codepath
This commit is contained in:
Brian Goff 2019-09-19 08:01:25 -07:00 committed by GitHub
commit 0f18e434b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 34 deletions

4
Jenkinsfile vendored
View file

@ -307,10 +307,10 @@ pipeline {
TEST_INTEGRATION_DEST=1 CONTAINER_NAME=${CONTAINER_NAME}-1 TEST_SKIP_INTEGRATION_CLI=1 run_tests test-integration-flaky & TEST_INTEGRATION_DEST=1 CONTAINER_NAME=${CONTAINER_NAME}-1 TEST_SKIP_INTEGRATION_CLI=1 run_tests test-integration-flaky &
# integration-cli first set # integration-cli first set
TEST_INTEGRATION_DEST=2 CONTAINER_NAME=${CONTAINER_NAME}-2 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run /(DockerSuite|DockerNetworkSuite|DockerHubPullSuite|DockerRegistrySuite|DockerSchema1RegistrySuite|DockerRegistryAuthTokenSuite|DockerRegistryAuthHtpasswdSuite)/" run_tests & 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 &
# integration-cli second set # integration-cli second set
TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run /(DockerSwarmSuite|DockerDaemonSuite|DockerExternalVolumeSuite)/" run_tests & TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run Test(DockerSwarmSuite|DockerDaemonSuite|DockerExternalVolumeSuite)/" run_tests &
set +x set +x
c=0 c=0

View file

@ -174,13 +174,13 @@ flag's value is passed as arguments to the `go test` command. For example, from
your local host you can run the `TestBuild` test with this command: your local host you can run the `TestBuild` test with this command:
```bash ```bash
$ TESTFLAGS='-test.run /DockerSuite/TestBuild*' make test-integration $ TESTFLAGS='-test.run TestDockerSuite/TestBuild*' make test-integration
``` ```
To run the same test inside your Docker development container, you do this: To run the same test inside your Docker development container, you do this:
```bash ```bash
# TESTFLAGS='-test.run /DockerSuite/TestBuild*' hack/make.sh binary test-integration # TESTFLAGS='-test.run TestDockerSuite/TestBuild*' hack/make.sh binary test-integration
``` ```
## Test the Windows binary against a Linux daemon ## Test the Windows binary against a Linux daemon
@ -228,11 +228,11 @@ run a Bash terminal on Windows.
``` ```
Should you wish to run a single test such as one with the name Should you wish to run a single test such as one with the name
'TestExample', you can pass in `TESTFLAGS='-test.run //TestExample'`. For 'TestExample', you can pass in `TESTFLAGS='-test.run /TestExample'`. For
example example
```bash ```bash
$ TESTFLAGS='-test.run //TestExample' hack/make.sh binary test-integration $ TESTFLAGS='-test.run /TestExample' hack/make.sh binary test-integration
``` ```
You can now choose to make changes to the Moby source or the tests. If you You can now choose to make changes to the Moby source or the tests. If you

View file

@ -3,7 +3,7 @@
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want # For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
# to run certain tests on your local host, you should run with command: # to run certain tests on your local host, you should run with command:
# #
# TESTFLAGS='-test.run /DockerSuite/TestBuild*' ./hack/make.sh binary test-integration # TESTFLAGS='-test.run TestDockerSuite/TestBuild*' ./hack/make.sh binary test-integration
# #
if [ -z "${MAKEDIR}" ]; then if [ -z "${MAKEDIR}" ]; then
@ -47,16 +47,17 @@ integration_api_dirs="${TEST_INTEGRATION_DIR:-$(go list -test -f '{{- if ne .Fo
run_test_integration() { run_test_integration() {
set_platform_timeout set_platform_timeout
if [ -z "${TEST_SKIP_INTEGRATION}" ]; then if [ -z "${TEST_SKIP_INTEGRATION}" ]; then
run_test_integration_suites run_test_integration_suites "${integration_api_dirs}"
fi fi
if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
run_test_integration_legacy_suites TIMEOUT=360m run_test_integration_suites integration-cli
fi fi
} }
run_test_integration_suites() { run_test_integration_suites() {
local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS" local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS"
for dir in ${integration_api_dirs}; do local dirs="$1"
for dir in ${dirs}; do
if ! ( if ! (
cd "$dir" cd "$dir"
# Create a useful package name based on the tests's $dir. We need to take # Create a useful package name based on the tests's $dir. We need to take
@ -84,16 +85,6 @@ run_test_integration_suites() {
done done
} }
run_test_integration_legacy_suites() {
(
flags="-test.v -test.timeout=360m $TESTFLAGS"
cd integration-cli
echo "Running $PWD flags=${flags}"
# shellcheck disable=SC2086
test_env ./test.main $flags
)
}
build_test_suite_binaries() { build_test_suite_binaries() {
if [ -n "${DOCKER_INTEGRATION_TESTS_VERIFIED}" ]; then if [ -n "${DOCKER_INTEGRATION_TESTS_VERIFIED}" ]; then
echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set" echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set"

View file

@ -9,7 +9,6 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime"
"strconv" "strconv"
"sync" "sync"
"syscall" "syscall"
@ -45,6 +44,8 @@ var (
// the docker client binary to use // the docker client binary to use
dockerBinary = "" dockerBinary = ""
testEnvOnce sync.Once
) )
func init() { func init() {
@ -74,26 +75,73 @@ func TestMain(m *testing.M) {
os.Exit(m.Run()) os.Exit(m.Run())
} }
func Test(t *testing.T) { func ensureTestEnvSetup(t *testing.T) {
testEnvOnce.Do(func() {
cli.SetTestEnvironment(testEnv) cli.SetTestEnvironment(testEnv)
fakestorage.SetTestEnvironment(&testEnv.Execution) fakestorage.SetTestEnvironment(&testEnv.Execution)
ienv.ProtectAll(t, &testEnv.Execution) ienv.ProtectAll(t, &testEnv.Execution)
})
}
func TestDockerSuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerSuite{}) suite.Run(t, &DockerSuite{})
}
func TestDockerRegistrySuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerRegistrySuite{ds: &DockerSuite{}}) suite.Run(t, &DockerRegistrySuite{ds: &DockerSuite{}})
}
func TestDockerSchema1RegistrySuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerSchema1RegistrySuite{ds: &DockerSuite{}}) suite.Run(t, &DockerSchema1RegistrySuite{ds: &DockerSuite{}})
}
func TestDockerRegistryAuthHtpasswdSuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}}) suite.Run(t, &DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}})
}
func TestDockerRegistryAuthTokenSuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerRegistryAuthTokenSuite{ds: &DockerSuite{}}) suite.Run(t, &DockerRegistryAuthTokenSuite{ds: &DockerSuite{}})
}
func TestDockerDaemonSuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerDaemonSuite{ds: &DockerSuite{}}) suite.Run(t, &DockerDaemonSuite{ds: &DockerSuite{}})
}
func TestDockerSwarmSuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerSwarmSuite{ds: &DockerSuite{}}) suite.Run(t, &DockerSwarmSuite{ds: &DockerSuite{}})
}
func TestDockerPluginSuite(t *testing.T) {
ensureTestEnvSetup(t)
suite.Run(t, &DockerPluginSuite{ds: &DockerSuite{}}) suite.Run(t, &DockerPluginSuite{ds: &DockerSuite{}})
if runtime.GOOS != "windows" { }
func TestDockerExternalVolumeSuite(t *testing.T) {
ensureTestEnvSetup(t)
testRequires(t, DaemonIsLinux)
suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}}) suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
suite.Run(t, &DockerNetworkSuite{ds: &DockerSuite{}}) }
func TestDockerNetworkSuite(t *testing.T) {
ensureTestEnvSetup(t)
testRequires(t, DaemonIsLinux)
suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
}
func TestDockerHubPullSuite(t *testing.T) {
ensureTestEnvSetup(t)
// FIXME. Temporarily turning this off for Windows as GH16039 was breaking // FIXME. Temporarily turning this off for Windows as GH16039 was breaking
// Windows to Linux CI @icecrime // Windows to Linux CI @icecrime
testRequires(t, DaemonIsLinux)
suite.Run(t, newDockerHubPullSuite()) suite.Run(t, newDockerHubPullSuite())
} }
}
type DockerSuite struct { type DockerSuite struct {
} }

View file

@ -30,13 +30,12 @@ func Run(t *testing.T, suite interface{}) {
}() }()
methodFinder := reflect.TypeOf(suite) methodFinder := reflect.TypeOf(suite)
suiteName := methodFinder.Elem().Name()
for index := 0; index < methodFinder.NumMethod(); index++ { for index := 0; index < methodFinder.NumMethod(); index++ {
method := methodFinder.Method(index) method := methodFinder.Method(index)
if !methodFilter(method.Name, method.Type) { if !methodFilter(method.Name, method.Type) {
continue continue
} }
t.Run(suiteName+"/"+method.Name, func(t *testing.T) { t.Run(method.Name, func(t *testing.T) {
defer failOnPanic(t) defer failOnPanic(t)
if !suiteSetupDone { if !suiteSetupDone {