Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit f1c1cd436ae1252778417121e77d084172f628a1)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -307,10 +307,10 @@ pipeline {
|
| 307 | 307 |
TEST_INTEGRATION_DEST=1 CONTAINER_NAME=${CONTAINER_NAME}-1 TEST_SKIP_INTEGRATION_CLI=1 run_tests test-integration-flaky &
|
| 308 | 308 |
|
| 309 | 309 |
# integration-cli first set |
| 310 |
- 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 &
|
|
| 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 &
|
|
| 311 | 311 |
|
| 312 | 312 |
# integration-cli second set |
| 313 |
- TEST_INTEGRATION_DEST=3 CONTAINER_NAME=${CONTAINER_NAME}-3 TEST_SKIP_INTEGRATION=1 TESTFLAGS="-test.run /(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 &
|
|
| 314 | 314 |
|
| 315 | 315 |
set +x |
| 316 | 316 |
c=0 |
| ... | ... |
@@ -174,13 +174,13 @@ flag's value is passed as arguments to the `go test` command. For example, from |
| 174 | 174 |
your local host you can run the `TestBuild` test with this command: |
| 175 | 175 |
|
| 176 | 176 |
```bash |
| 177 |
-$ TESTFLAGS='-test.run /DockerSuite/TestBuild*' make test-integration |
|
| 177 |
+$ TESTFLAGS='-test.run TestDockerSuite/TestBuild*' make test-integration |
|
| 178 | 178 |
``` |
| 179 | 179 |
|
| 180 | 180 |
To run the same test inside your Docker development container, you do this: |
| 181 | 181 |
|
| 182 | 182 |
```bash |
| 183 |
-# TESTFLAGS='-test.run /DockerSuite/TestBuild*' hack/make.sh binary test-integration |
|
| 183 |
+# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' hack/make.sh binary test-integration |
|
| 184 | 184 |
``` |
| 185 | 185 |
|
| 186 | 186 |
## Test the Windows binary against a Linux daemon |
| ... | ... |
@@ -228,11 +228,11 @@ run a Bash terminal on Windows. |
| 228 | 228 |
``` |
| 229 | 229 |
|
| 230 | 230 |
Should you wish to run a single test such as one with the name |
| 231 |
- 'TestExample', you can pass in `TESTFLAGS='-test.run //TestExample'`. For |
|
| 231 |
+ 'TestExample', you can pass in `TESTFLAGS='-test.run /TestExample'`. For |
|
| 232 | 232 |
example |
| 233 | 233 |
|
| 234 | 234 |
```bash |
| 235 |
- $ TESTFLAGS='-test.run //TestExample' hack/make.sh binary test-integration |
|
| 235 |
+ $ TESTFLAGS='-test.run /TestExample' hack/make.sh binary test-integration |
|
| 236 | 236 |
``` |
| 237 | 237 |
|
| 238 | 238 |
You can now choose to make changes to the Moby source or the tests. If you |
| ... | ... |
@@ -3,7 +3,7 @@ |
| 3 | 3 |
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want |
| 4 | 4 |
# to run certain tests on your local host, you should run with command: |
| 5 | 5 |
# |
| 6 |
-# TESTFLAGS='-test.run /DockerSuite/TestBuild*' ./hack/make.sh binary test-integration |
|
| 6 |
+# TESTFLAGS='-test.run TestDockerSuite/TestBuild*' ./hack/make.sh binary test-integration |
|
| 7 | 7 |
# |
| 8 | 8 |
|
| 9 | 9 |
if [ -z "${MAKEDIR}" ]; then
|
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"os" |
| 10 | 10 |
"path" |
| 11 | 11 |
"path/filepath" |
| 12 |
- "runtime" |
|
| 13 | 12 |
"strconv" |
| 14 | 13 |
"sync" |
| 15 | 14 |
"syscall" |
| ... | ... |
@@ -45,6 +44,8 @@ var ( |
| 45 | 45 |
|
| 46 | 46 |
// the docker client binary to use |
| 47 | 47 |
dockerBinary = "" |
| 48 |
+ |
|
| 49 |
+ testEnvOnce sync.Once |
|
| 48 | 50 |
) |
| 49 | 51 |
|
| 50 | 52 |
func init() {
|
| ... | ... |
@@ -74,25 +75,72 @@ func TestMain(m *testing.M) {
|
| 74 | 74 |
os.Exit(m.Run()) |
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 |
-func Test(t *testing.T) {
|
|
| 78 |
- cli.SetTestEnvironment(testEnv) |
|
| 79 |
- fakestorage.SetTestEnvironment(&testEnv.Execution) |
|
| 80 |
- ienv.ProtectAll(t, &testEnv.Execution) |
|
| 77 |
+func ensureTestEnvSetup(t *testing.T) {
|
|
| 78 |
+ testEnvOnce.Do(func() {
|
|
| 79 |
+ cli.SetTestEnvironment(testEnv) |
|
| 80 |
+ fakestorage.SetTestEnvironment(&testEnv.Execution) |
|
| 81 |
+ ienv.ProtectAll(t, &testEnv.Execution) |
|
| 82 |
+ }) |
|
| 83 |
+} |
|
| 84 |
+ |
|
| 85 |
+func TestDockerSuite(t *testing.T) {
|
|
| 86 |
+ ensureTestEnvSetup(t) |
|
| 81 | 87 |
suite.Run(t, &DockerSuite{})
|
| 88 |
+} |
|
| 89 |
+ |
|
| 90 |
+func TestDockerRegistrySuite(t *testing.T) {
|
|
| 91 |
+ ensureTestEnvSetup(t) |
|
| 82 | 92 |
suite.Run(t, &DockerRegistrySuite{ds: &DockerSuite{}})
|
| 93 |
+} |
|
| 94 |
+ |
|
| 95 |
+func TestDockerSchema1RegistrySuite(t *testing.T) {
|
|
| 96 |
+ ensureTestEnvSetup(t) |
|
| 83 | 97 |
suite.Run(t, &DockerSchema1RegistrySuite{ds: &DockerSuite{}})
|
| 98 |
+} |
|
| 99 |
+ |
|
| 100 |
+func TestDockerRegistryAuthHtpasswdSuite(t *testing.T) {
|
|
| 101 |
+ ensureTestEnvSetup(t) |
|
| 84 | 102 |
suite.Run(t, &DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}})
|
| 103 |
+} |
|
| 104 |
+ |
|
| 105 |
+func TestDockerRegistryAuthTokenSuite(t *testing.T) {
|
|
| 106 |
+ ensureTestEnvSetup(t) |
|
| 85 | 107 |
suite.Run(t, &DockerRegistryAuthTokenSuite{ds: &DockerSuite{}})
|
| 108 |
+} |
|
| 109 |
+ |
|
| 110 |
+func TestDockerDaemonSuite(t *testing.T) {
|
|
| 111 |
+ ensureTestEnvSetup(t) |
|
| 86 | 112 |
suite.Run(t, &DockerDaemonSuite{ds: &DockerSuite{}})
|
| 113 |
+} |
|
| 114 |
+ |
|
| 115 |
+func TestDockerSwarmSuite(t *testing.T) {
|
|
| 116 |
+ ensureTestEnvSetup(t) |
|
| 87 | 117 |
suite.Run(t, &DockerSwarmSuite{ds: &DockerSuite{}})
|
| 118 |
+} |
|
| 119 |
+ |
|
| 120 |
+func TestDockerPluginSuite(t *testing.T) {
|
|
| 121 |
+ ensureTestEnvSetup(t) |
|
| 88 | 122 |
suite.Run(t, &DockerPluginSuite{ds: &DockerSuite{}})
|
| 89 |
- if runtime.GOOS != "windows" {
|
|
| 90 |
- suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
|
|
| 91 |
- suite.Run(t, &DockerNetworkSuite{ds: &DockerSuite{}})
|
|
| 92 |
- // FIXME. Temporarily turning this off for Windows as GH16039 was breaking |
|
| 93 |
- // Windows to Linux CI @icecrime |
|
| 94 |
- suite.Run(t, newDockerHubPullSuite()) |
|
| 95 |
- } |
|
| 123 |
+} |
|
| 124 |
+ |
|
| 125 |
+func TestDockerExternalVolumeSuite(t *testing.T) {
|
|
| 126 |
+ ensureTestEnvSetup(t) |
|
| 127 |
+ testRequires(t, DaemonIsLinux) |
|
| 128 |
+ suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
|
|
| 129 |
+} |
|
| 130 |
+ |
|
| 131 |
+func TestDockerNetworkSuite(t *testing.T) {
|
|
| 132 |
+ ensureTestEnvSetup(t) |
|
| 133 |
+ testRequires(t, DaemonIsLinux) |
|
| 134 |
+ suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
|
|
| 135 |
+} |
|
| 136 |
+ |
|
| 137 |
+func TestDockerHubPullSuite(t *testing.T) {
|
|
| 138 |
+ ensureTestEnvSetup(t) |
|
| 139 |
+ // FIXME. Temporarily turning this off for Windows as GH16039 was breaking |
|
| 140 |
+ // Windows to Linux CI @icecrime |
|
| 141 |
+ testRequires(t, DaemonIsLinux) |
|
| 142 |
+ suite.Run(t, newDockerHubPullSuite()) |
|
| 96 | 143 |
} |
| 97 | 144 |
|
| 98 | 145 |
type DockerSuite struct {
|
| ... | ... |
@@ -30,13 +30,12 @@ func Run(t *testing.T, suite interface{}) {
|
| 30 | 30 |
}() |
| 31 | 31 |
|
| 32 | 32 |
methodFinder := reflect.TypeOf(suite) |
| 33 |
- suiteName := methodFinder.Elem().Name() |
|
| 34 | 33 |
for index := 0; index < methodFinder.NumMethod(); index++ {
|
| 35 | 34 |
method := methodFinder.Method(index) |
| 36 | 35 |
if !methodFilter(method.Name, method.Type) {
|
| 37 | 36 |
continue |
| 38 | 37 |
} |
| 39 |
- t.Run(suiteName+"/"+method.Name, func(t *testing.T) {
|
|
| 38 |
+ t.Run(method.Name, func(t *testing.T) {
|
|
| 40 | 39 |
defer failOnPanic(t) |
| 41 | 40 |
|
| 42 | 41 |
if !suiteSetupDone {
|