From c467a112050d595ca0b48122cd4ce81fcf6cefde Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 18 Aug 2017 12:24:27 -0400 Subject: [PATCH] Remove config tests, which are now unit tests in docker/cli Signed-off-by: Daniel Nephin --- hack/make/.integration-daemon-start | 2 - hack/make/.integration-test-helpers | 1 - integration-cli/docker_api_test.go | 20 --- integration-cli/docker_cli_config_test.go | 150 ---------------------- 4 files changed, 173 deletions(-) delete mode 100644 integration-cli/docker_cli_config_test.go diff --git a/hack/make/.integration-daemon-start b/hack/make/.integration-daemon-start index b4e6684854..7314f71c5c 100644 --- a/hack/make/.integration-daemon-start +++ b/hack/make/.integration-daemon-start @@ -21,8 +21,6 @@ if ! command -v "$TEST_CLIENT_BINARY" &> /dev/null; then false fi -export DOCKER_CLI_VERSION=$(${TEST_CLIENT_BINARY} --version | awk '{ gsub(",", " "); print $3 }') - # This is a temporary hack for split-binary mode. It can be removed once # https://github.com/docker/docker/pull/22134 is merged into docker master if [ "$(go env GOOS)" = 'windows' ]; then diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index aaeec8706c..2a5bd5f218 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -71,7 +71,6 @@ test_env() { [ -n "$TESTDEBUG" ] && set -x env -i \ DEST="$ABS_DEST" \ - DOCKER_CLI_VERSION="$DOCKER_CLI_VERSION" \ DOCKER_API_VERSION="$DOCKER_API_VERSION" \ DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \ DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ diff --git a/integration-cli/docker_api_test.go b/integration-cli/docker_api_test.go index 3b8de03360..24a12d2783 100644 --- a/integration-cli/docker_api_test.go +++ b/integration-cli/docker_api_test.go @@ -4,17 +4,14 @@ import ( "fmt" "io/ioutil" "net/http" - "net/http/httptest" "runtime" "strconv" "strings" "github.com/docker/docker/api" "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/request" "github.com/docker/docker/pkg/testutil" - icmd "github.com/docker/docker/pkg/testutil/cmd" "github.com/go-check/check" ) @@ -60,23 +57,6 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) { c.Assert(strings.TrimSpace(string(content)), checker.Contains, expected) } -func (s *DockerSuite) TestAPIDockerAPIVersion(c *check.C) { - var svrVersion string - - server := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("API-Version", api.DefaultVersion) - url := r.URL.Path - svrVersion = url - })) - defer server.Close() - - // Test using the env var first - result := cli.Docker(cli.Args("-H="+server.URL[7:], "version"), cli.WithEnvironmentVariables(appendBaseEnv(false, "DOCKER_API_VERSION=xxx")...)) - c.Assert(result, icmd.Matches, icmd.Expected{Out: "API version: xxx", ExitCode: 1}) - c.Assert(svrVersion, check.Equals, "/vxxx/version", check.Commentf("%s", result.Compare(icmd.Success))) -} - func (s *DockerSuite) TestAPIErrorJSON(c *check.C) { httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{})) c.Assert(err, checker.IsNil) diff --git a/integration-cli/docker_cli_config_test.go b/integration-cli/docker_cli_config_test.go deleted file mode 100644 index 46fe456bd5..0000000000 --- a/integration-cli/docker_cli_config_test.go +++ /dev/null @@ -1,150 +0,0 @@ -package main - -import ( - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "path/filepath" - "runtime" - - "github.com/docker/docker/api" - "github.com/docker/docker/integration-cli/checker" - "github.com/docker/docker/pkg/homedir" - icmd "github.com/docker/docker/pkg/testutil/cmd" - "github.com/go-check/check" -) - -func (s *DockerSuite) TestConfigHTTPHeader(c *check.C) { - testRequires(c, UnixCli) // Can't set/unset HOME on windows right now - // We either need a level of Go that supports Unsetenv (for cases - // when HOME/USERPROFILE isn't set), or we need to be able to use - // os/user but user.Current() only works if we aren't statically compiling - - var headers map[string][]string - - server := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("API-Version", api.DefaultVersion) - headers = r.Header - })) - defer server.Close() - - homeKey := homedir.Key() - homeVal := homedir.Get() - tmpDir, err := ioutil.TempDir("", "fake-home") - c.Assert(err, checker.IsNil) - defer os.RemoveAll(tmpDir) - - dotDocker := filepath.Join(tmpDir, ".docker") - os.Mkdir(dotDocker, 0600) - tmpCfg := filepath.Join(dotDocker, "config.json") - - defer func() { os.Setenv(homeKey, homeVal) }() - os.Setenv(homeKey, tmpDir) - - data := `{ - "HttpHeaders": { "MyHeader": "MyValue" } - }` - - err = ioutil.WriteFile(tmpCfg, []byte(data), 0600) - c.Assert(err, checker.IsNil) - - result := icmd.RunCommand(dockerBinary, "-H="+server.URL[7:], "ps") - result.Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - }) - - c.Assert(headers["User-Agent"], checker.NotNil, check.Commentf("Missing User-Agent")) - - c.Assert(headers["User-Agent"][0], checker.Equals, "Docker-Client/"+os.Getenv("DOCKER_CLI_VERSION")+" ("+runtime.GOOS+")", check.Commentf("Badly formatted User-Agent,out:%v", result.Combined())) - - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("Missing/bad header,out:%v", result.Combined())) - -} - -func (s *DockerSuite) TestConfigDir(c *check.C) { - cDir, err := ioutil.TempDir("", "fake-home") - c.Assert(err, checker.IsNil) - defer os.RemoveAll(cDir) - - // First make sure pointing to empty dir doesn't generate an error - dockerCmd(c, "--config", cDir, "ps") - - // Test with env var too - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "ps"}, - Env: appendBaseEnv(true, "DOCKER_CONFIG="+cDir), - }).Assert(c, icmd.Success) - - // Start a server so we can check to see if the config file was - // loaded properly - var headers map[string][]string - - server := httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - headers = r.Header - })) - defer server.Close() - - // Create a dummy config file in our new config dir - data := `{ - "HttpHeaders": { "MyHeader": "MyValue" } - }` - - tmpCfg := filepath.Join(cDir, "config.json") - err = ioutil.WriteFile(tmpCfg, []byte(data), 0600) - c.Assert(err, checker.IsNil, check.Commentf("Err creating file")) - - env := appendBaseEnv(false) - - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"}, - Env: env, - }).Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - }) - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps3 - Missing header")) - - // Reset headers and try again using env var this time - headers = map[string][]string{} - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"}, - Env: append(env, "DOCKER_CONFIG="+cDir), - }).Assert(c, icmd.Expected{ - ExitCode: 1, - }) - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps4 - Missing header")) - - // FIXME(vdemeester) should be a unit test - // Reset headers and make sure flag overrides the env var - headers = map[string][]string{} - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", cDir, "-H=" + server.URL[7:], "ps"}, - Env: append(env, "DOCKER_CONFIG=MissingDir"), - }).Assert(c, icmd.Expected{ - ExitCode: 1, - }) - c.Assert(headers["Myheader"], checker.NotNil) - c.Assert(headers["Myheader"][0], checker.Equals, "MyValue", check.Commentf("ps5 - Missing header")) - - // FIXME(vdemeester) should be a unit test - // Reset headers and make sure flag overrides the env var. - // Almost same as previous but make sure the "MissingDir" isn't - // ignore - we don't want to default back to the env var. - headers = map[string][]string{} - icmd.RunCmd(icmd.Cmd{ - Command: []string{dockerBinary, "--config", "MissingDir", "-H=" + server.URL[7:], "ps"}, - Env: append(env, "DOCKER_CONFIG="+cDir), - }).Assert(c, icmd.Expected{ - ExitCode: 1, - Error: "exit status 1", - }) - - c.Assert(headers["Myheader"], checker.IsNil, check.Commentf("ps6 - Headers shouldn't be the expected value")) -}