mirror of
https://github.com/moby/moby.git
synced 2025-12-09 10:01:25 +03:00
integ-cli: also preserve SystemRoot env var
Windows CI fails to dial remote test host over tcp in the test cases where we clear environment variables during `exec(dockerBinary, ...)` in the absence of `SystemRoot` environment variable (typically points to `c:\windows`). This fixes tests: - `TestRunEnvironmentErase` - `TestRunEnvironmentOverride` Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
This commit is contained in:
@@ -919,12 +919,23 @@ func setupRegistry(t *testing.T) func() {
|
||||
return func() { reg.Close() }
|
||||
}
|
||||
|
||||
// appendDockerHostEnv adds given env slice DOCKER_HOST value if set in the
|
||||
// environment. Useful when environment is cleared but we want to preserve DOCKER_HOST
|
||||
// to execute tests against a remote daemon.
|
||||
func appendDockerHostEnv(env []string) []string {
|
||||
if dockerHost := os.Getenv("DOCKER_HOST"); dockerHost != "" {
|
||||
env = append(env, fmt.Sprintf("DOCKER_HOST=%s", dockerHost))
|
||||
// appendBaseEnv appends the minimum set of environment variables to exec the
|
||||
// docker cli binary for testing with correct configuration to the given env
|
||||
// list.
|
||||
func appendBaseEnv(env []string) []string {
|
||||
preserveList := []string{
|
||||
// preserve remote test host
|
||||
"DOCKER_HOST",
|
||||
|
||||
// windows: requires preserving SystemRoot, otherwise dial tcp fails
|
||||
// with "GetAddrInfoW: A non-recoverable error occurred during a database lookup."
|
||||
"SystemRoot",
|
||||
}
|
||||
|
||||
for _, key := range preserveList {
|
||||
if val := os.Getenv(key); val != "" {
|
||||
env = append(env, fmt.Sprintf("%s=%s", key, val))
|
||||
}
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user