Sfoglia il codice sorgente

Merge pull request #15336 from Microsoft/fixwindowsci

Windows: Fix for CI
Alexander Morozov 10 anni fa
parent
commit
aec46ac0b2

+ 23 - 18
docs/project/test-and-docs.md

@@ -169,14 +169,15 @@ To run the same test inside your Docker development container, you do this:
 
     root@5f8630b873fe:/go/src/github.com/docker/docker# TESTFLAGS='-check.f TestBuild*' hack/make.sh binary test-integration-cli
 
-## Testing just the Windows client
+## Testing the Windows binary against a Linux daemon
 
-This explains how to test the Windows client on a Windows server set up as a
-development environment.  You'll use the **Git Bash** came with the Git for
-Windows installation.  **Git Bash** just as it sounds allows you to run a Bash
-terminal on Windows. 
+This explains how to test the Windows binary on a Windows machine set up as a
+development environment.  The tests will be run against a docker daemon 
+running on a remote Linux machine. You'll use  **Git Bash** that came with the 
+Git for Windows installation.  **Git Bash**, just as it sounds, allows you to
+run a Bash terminal on Windows. 
 
-1.  If you don't have one, start a Git Bash terminal.
+1.  If you don't have one open already, start a Git Bash terminal.
 
 	 ![Git Bash](/project/images/git_bash.png)
 
@@ -184,27 +185,31 @@ terminal on Windows.
 
 		$ cd /c/gopath/src/github.com/docker/docker
     
-3. Set `DOCKER_CLIENTONLY` as follows:
+3. Set `DOCKER_REMOTE_DAEMON` as follows:
+
+		$ export DOCKER_REMOTE_DAEMON=1
 
-		$ export DOCKER_CLIENTONLY=1
-     
-	This ensures you are building only the client binary instead of both the
-	binary and the daemon.
-	
 4. Set `DOCKER_TEST_HOST` to the `tcp://IP_ADDRESS:2376` value; substitute your
-machine's actual IP address, for example:
+Linux machines actual IP address. For example:
 
 		$ export DOCKER_TEST_HOST=tcp://263.124.23.200:2376
 
-5. Make the binary and the test:
+5. Make the binary and run the tests:
 
 		$ hack/make.sh binary test-integration-cli
   	
-   Many tests are skipped on Windows for various reasons. You see which tests
-   were skipped by re-running the make and passing in the 
-   `TESTFLAGS='-test.v'` value.
+   Some tests are skipped on Windows for various reasons. You can see which
+   tests were skipped by re-running the make and passing in the 
+   `TESTFLAGS='-test.v'` value. For example 
+
+		$ TESTFLAGS='-test.v' hack/make.sh binary test-integration-cli
+		
+	Should you wish to run a single test such as one with the name 
+	'TestExample', you can pass in `TESTFLAGS='-check.f TestExample'`. For
+	example 
+	
+		$TESTFLAGS='-check.f TestExample' hack/make.sh binary test-integration-cli
         
-
 You can now choose to make changes to the Docker source or the tests. If you
 make any changes just run these commands again.
 

+ 1 - 0
hack/make.sh

@@ -220,6 +220,7 @@ test_env() {
 		DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \
 		DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \
 		DOCKER_HOST="$DOCKER_HOST" \
+		DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \
 		GOPATH="$GOPATH" \
 		HOME="$ABS_DEST/fake-HOME" \
 		PATH="$PATH" \

+ 2 - 1
integration-cli/docker_cli_daemon_experimental_test.go

@@ -1,4 +1,4 @@
-// +build daemon,experimental
+// +build daemon,experimental,!windows
 
 package main
 
@@ -22,6 +22,7 @@ func assertNetwork(c *check.C, d *Daemon, name string) {
 }
 
 func (s *DockerDaemonSuite) TestDaemonDefaultNetwork(c *check.C) {
+	testRequires(c, SameHostDaemon)
 	d := s.d
 
 	networkName := "testdefault"

+ 1 - 1
integration-cli/docker_cli_daemon_test.go

@@ -1,4 +1,4 @@
-// +build daemon
+// +build daemon,!windows
 
 package main
 

+ 26 - 0
integration-cli/docker_test_vars.go

@@ -24,6 +24,10 @@ var (
 	execDriverPath = runtimePath + "/execdriver/native"
 
 	workingDirectory string
+
+	// isLocalDaemon is true if the daemon under test is on the same
+	// host as the CLI.
+	isLocalDaemon bool
 )
 
 func init() {
@@ -43,4 +47,26 @@ func init() {
 		privateRegistryURL = registry
 	}
 	workingDirectory, _ = os.Getwd()
+
+	// Deterministically working out the environment in which CI is running
+	// to evaluate whether the daemon is local or remote is not possible through
+	// a build tag.
+	//
+	// For example Windows CI under Jenkins test the 64-bit
+	// Windows binary build with the daemon build tag, but calls a remote
+	// Linux daemon.
+	//
+	// We can't just say if Windows then assume the daemon is local as at
+	// some point, we will be testing the Windows CLI against a Windows daemon.
+	//
+	// Similarly, it will be perfectly valid to also run CLI tests from
+	// a Linux CLI (built with the daemon tag) against a Windows daemon.
+	if len(os.Getenv("DOCKER_REMOTE_DAEMON")) > 0 {
+		fmt.Println("INFO: Testing against a remote daemon")
+		isLocalDaemon = false
+	} else {
+		fmt.Println("INFO: Testing against a local daemon")
+		isLocalDaemon = true
+	}
+
 }

+ 0 - 8
integration-cli/docker_test_vars_cli.go

@@ -1,8 +0,0 @@
-// +build !daemon
-
-package main
-
-const (
-	// tests should not assume daemon runs on the same machine as CLI
-	isLocalDaemon = false
-)

+ 0 - 8
integration-cli/docker_test_vars_daemon.go

@@ -1,8 +0,0 @@
-// +build daemon
-
-package main
-
-const (
-	// tests can assume daemon runs on the same machine as CLI
-	isLocalDaemon = true
-)