Quellcode durchsuchen

Add DOCKER_USERLANDPROXY test variable

Add an convenient way to switch --userland-proxy on and off in
integration tests.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Arnaud Porterie vor 10 Jahren
Ursprung
Commit
44de5fecce
3 geänderte Dateien mit 22 neuen und 0 gelöschten Zeilen
  1. 1 0
      hack/make.sh
  2. 2 0
      hack/make/.integration-daemon-start
  3. 19 0
      integration-cli/docker_utils.go

+ 1 - 0
hack/make.sh

@@ -198,6 +198,7 @@ test_env() {
 		DEST="$DEST" \
 		DOCKER_EXECDRIVER="$DOCKER_EXECDRIVER" \
 		DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \
+		DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \
 		DOCKER_HOST="$DOCKER_HOST" \
 		GOPATH="$GOPATH" \
 		HOME="$DEST/fake-HOME" \

+ 2 - 0
hack/make/.integration-daemon-start

@@ -14,6 +14,7 @@ exec 41>&1 42>&2
 
 export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs}
 export DOCKER_EXECDRIVER=${DOCKER_EXECDRIVER:-native}
+export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true}
 
 if [ -z "$DOCKER_TEST_HOST" ]; then
 	export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" # "pwd" tricks to make sure $DEST is an absolute path, not a relative one
@@ -23,6 +24,7 @@ if [ -z "$DOCKER_TEST_HOST" ]; then
 		--storage-driver "$DOCKER_GRAPHDRIVER" \
 		--exec-driver "$DOCKER_EXECDRIVER" \
 		--pidfile "$DEST/docker.pid" \
+		--userland-proxy="$DOCKER_USERLANDPROXY" \
 			&> "$DEST/docker.log"
 	) &
 	trap "source '${MAKEDIR}/.integration-daemon-stop'" EXIT # make sure that if the script exits unexpectedly, we stop this daemon we just started

+ 19 - 0
integration-cli/docker_utils.go

@@ -37,6 +37,16 @@ type Daemon struct {
 	storageDriver  string
 	execDriver     string
 	wait           chan error
+	userlandProxy  bool
+}
+
+func enableUserlandProxy() bool {
+	if env := os.Getenv("DOCKER_USERLANDPROXY"); env != "" {
+		if val, err := strconv.ParseBool(env); err != nil {
+			return val
+		}
+	}
+	return true
 }
 
 // NewDaemon returns a Daemon instance to be used for testing.
@@ -58,11 +68,19 @@ func NewDaemon(c *check.C) *Daemon {
 		c.Fatalf("Could not create %s/graph directory", daemonFolder)
 	}
 
+	userlandProxy := true
+	if env := os.Getenv("DOCKER_USERLANDPROXY"); env != "" {
+		if val, err := strconv.ParseBool(env); err != nil {
+			userlandProxy = val
+		}
+	}
+
 	return &Daemon{
 		c:             c,
 		folder:        daemonFolder,
 		storageDriver: os.Getenv("DOCKER_GRAPHDRIVER"),
 		execDriver:    os.Getenv("DOCKER_EXECDRIVER"),
+		userlandProxy: userlandProxy,
 	}
 }
 
@@ -79,6 +97,7 @@ func (d *Daemon) Start(arg ...string) error {
 		"--daemon",
 		"--graph", fmt.Sprintf("%s/graph", d.folder),
 		"--pidfile", fmt.Sprintf("%s/docker.pid", d.folder),
+		fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
 	}
 
 	// If we don't explicitly set the log-level or debug flag(-D) then