Browse code

Windows: Workaround for CI

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2015/08/06 01:21:45
Showing 7 changed files
... ...
@@ -169,14 +169,15 @@ To run the same test inside your Docker development container, you do this:
169 169
 
170 170
     root@5f8630b873fe:/go/src/github.com/docker/docker# TESTFLAGS='-check.f TestBuild*' hack/make.sh binary test-integration-cli
171 171
 
172
-## Testing just the Windows client
172
+## Testing the Windows binary against a Linux daemon
173 173
 
174
-This explains how to test the Windows client on a Windows server set up as a
175
-development environment.  You'll use the **Git Bash** came with the Git for
176
-Windows installation.  **Git Bash** just as it sounds allows you to run a Bash
177
-terminal on Windows. 
174
+This explains how to test the Windows binary on a Windows machine set up as a
175
+development environment.  The tests will be run against a docker daemon 
176
+running on a remote Linux machine. You'll use  **Git Bash** that came with the 
177
+Git for Windows installation.  **Git Bash**, just as it sounds, allows you to
178
+run a Bash terminal on Windows. 
178 179
 
179
-1.  If you don't have one, start a Git Bash terminal.
180
+1.  If you don't have one open already, start a Git Bash terminal.
180 181
 
181 182
 	 ![Git Bash](/project/images/git_bash.png)
182 183
 
... ...
@@ -184,27 +185,31 @@ terminal on Windows.
184 184
 
185 185
 		$ cd /c/gopath/src/github.com/docker/docker
186 186
     
187
-3. Set `DOCKER_CLIENTONLY` as follows:
187
+3. Set `DOCKER_REMOTE_DAEMON` as follows:
188
+
189
+		$ export DOCKER_REMOTE_DAEMON=1
188 190
 
189
-		$ export DOCKER_CLIENTONLY=1
190
-     
191
-	This ensures you are building only the client binary instead of both the
192
-	binary and the daemon.
193
-	
194 191
 4. Set `DOCKER_TEST_HOST` to the `tcp://IP_ADDRESS:2376` value; substitute your
195
-machine's actual IP address, for example:
192
+Linux machines actual IP address. For example:
196 193
 
197 194
 		$ export DOCKER_TEST_HOST=tcp://263.124.23.200:2376
198 195
 
199
-5. Make the binary and the test:
196
+5. Make the binary and run the tests:
200 197
 
201 198
 		$ hack/make.sh binary test-integration-cli
202 199
   	
203
-   Many tests are skipped on Windows for various reasons. You see which tests
204
-   were skipped by re-running the make and passing in the 
205
-   `TESTFLAGS='-test.v'` value.
200
+   Some tests are skipped on Windows for various reasons. You can see which
201
+   tests were skipped by re-running the make and passing in the 
202
+   `TESTFLAGS='-test.v'` value. For example 
203
+
204
+		$ TESTFLAGS='-test.v' hack/make.sh binary test-integration-cli
205
+		
206
+	Should you wish to run a single test such as one with the name 
207
+	'TestExample', you can pass in `TESTFLAGS='-check.f TestExample'`. For
208
+	example 
209
+	
210
+		$TESTFLAGS='-check.f TestExample' hack/make.sh binary test-integration-cli
206 211
         
207
-
208 212
 You can now choose to make changes to the Docker source or the tests. If you
209 213
 make any changes just run these commands again.
210 214
 
... ...
@@ -220,6 +220,7 @@ test_env() {
220 220
 		DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \
221 221
 		DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \
222 222
 		DOCKER_HOST="$DOCKER_HOST" \
223
+		DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \
223 224
 		GOPATH="$GOPATH" \
224 225
 		HOME="$ABS_DEST/fake-HOME" \
225 226
 		PATH="$PATH" \
... ...
@@ -1,4 +1,4 @@
1
-// +build daemon,experimental
1
+// +build daemon,experimental,!windows
2 2
 
3 3
 package main
4 4
 
... ...
@@ -22,6 +22,7 @@ func assertNetwork(c *check.C, d *Daemon, name string) {
22 22
 }
23 23
 
24 24
 func (s *DockerDaemonSuite) TestDaemonDefaultNetwork(c *check.C) {
25
+	testRequires(c, SameHostDaemon)
25 26
 	d := s.d
26 27
 
27 28
 	networkName := "testdefault"
... ...
@@ -1,4 +1,4 @@
1
-// +build daemon
1
+// +build daemon,!windows
2 2
 
3 3
 package main
4 4
 
... ...
@@ -24,6 +24,10 @@ var (
24 24
 	execDriverPath = runtimePath + "/execdriver/native"
25 25
 
26 26
 	workingDirectory string
27
+
28
+	// isLocalDaemon is true if the daemon under test is on the same
29
+	// host as the CLI.
30
+	isLocalDaemon bool
27 31
 )
28 32
 
29 33
 func init() {
... ...
@@ -43,4 +47,26 @@ func init() {
43 43
 		privateRegistryURL = registry
44 44
 	}
45 45
 	workingDirectory, _ = os.Getwd()
46
+
47
+	// Deterministically working out the environment in which CI is running
48
+	// to evaluate whether the daemon is local or remote is not possible through
49
+	// a build tag.
50
+	//
51
+	// For example Windows CI under Jenkins test the 64-bit
52
+	// Windows binary build with the daemon build tag, but calls a remote
53
+	// Linux daemon.
54
+	//
55
+	// We can't just say if Windows then assume the daemon is local as at
56
+	// some point, we will be testing the Windows CLI against a Windows daemon.
57
+	//
58
+	// Similarly, it will be perfectly valid to also run CLI tests from
59
+	// a Linux CLI (built with the daemon tag) against a Windows daemon.
60
+	if len(os.Getenv("DOCKER_REMOTE_DAEMON")) > 0 {
61
+		fmt.Println("INFO: Testing against a remote daemon")
62
+		isLocalDaemon = false
63
+	} else {
64
+		fmt.Println("INFO: Testing against a local daemon")
65
+		isLocalDaemon = true
66
+	}
67
+
46 68
 }
47 69
deleted file mode 100644
... ...
@@ -1,8 +0,0 @@
1
-// +build !daemon
2
-
3
-package main
4
-
5
-const (
6
-	// tests should not assume daemon runs on the same machine as CLI
7
-	isLocalDaemon = false
8
-)
9 1
deleted file mode 100644
... ...
@@ -1,8 +0,0 @@
1
-// +build daemon
2
-
3
-package main
4
-
5
-const (
6
-	// tests can assume daemon runs on the same machine as CLI
7
-	isLocalDaemon = true
8
-)