diff --git a/integration-cli/hyper_cli_load_large_test.go b/integration-cli/final/cli/hyper_cli_load_large_test.go similarity index 100% rename from integration-cli/hyper_cli_load_large_test.go rename to integration-cli/final/cli/hyper_cli_load_large_test.go diff --git a/integration-cli/final/cli/hyper_cli_load_local_ext_test.go b/integration-cli/final/cli/hyper_cli_load_local_ext_test.go index 384e6f08b..4b5bd8717 100755 --- a/integration-cli/final/cli/hyper_cli_load_local_ext_test.go +++ b/integration-cli/final/cli/hyper_cli_load_local_ext_test.go @@ -33,3 +33,34 @@ func (s *DockerSuite) TestCliLoadFromLocalDocker(c *check.C) { images, _ := dockerCmd(c, "images", "hello-world") c.Assert(images, checker.Contains, "hello-world") } + +func (s *DockerSuite) TestCliLoadFromLocalTarSize600MB(c *check.C) { + printTestCaseName() + defer printTestDuration(time.Now()) + testRequires(c, DaemonIsLinux) + + publicURL := "http://image-tarball.s3.amazonaws.com/test/public/jenkins.tar" + imagePath := fmt.Sprintf("%s/jenkins.tar", os.Getenv("IMAGE_DIR")) + + //download image tar + wgetCmd := exec.Command("wget", "-cO", imagePath, publicURL) + output, exitCode, err := runCommandWithOutput(wgetCmd) + c.Assert(exitCode, checker.Equals, 0) + c.Assert(err, checker.IsNil) + c.Assert(pathExist(imagePath), checker.Equals, true) + + //ensure jenkins:latest not exist + dockerCmdWithError("rmi", "jenkins:latest") + images, _ := dockerCmd(c, "images", "jenkins:latest") + c.Assert(images, checker.Not(checker.Contains), "jenkins") + + //load image tar + output, exitCode, err = dockerCmdWithError("load", "-i", imagePath) + c.Assert(output, checker.Contains, "has been loaded.") + c.Assert(err, checker.IsNil) + c.Assert(exitCode, checker.Equals, 0) + + //check image + images, _ = dockerCmd(c, "images", "jenkins:latest") + c.Assert(images, checker.Contains, "jenkins") +} \ No newline at end of file diff --git a/integration-cli/final/cli/hyper_cli_logs_ext_test.go b/integration-cli/final/cli/hyper_cli_logs_ext_test.go new file mode 100755 index 000000000..3f292608e --- /dev/null +++ b/integration-cli/final/cli/hyper_cli_logs_ext_test.go @@ -0,0 +1,84 @@ +package main + +import ( + //"encoding/json" + "fmt" + //"io" + "os" + "os/exec" + "regexp" + "strconv" + "strings" + "time" + + "github.com/docker/docker/pkg/integration/checker" + "github.com/docker/docker/pkg/jsonlog" + "github.com/go-check/check" +) + +//TODO: get exited container log +// Regression test for #8832 +func (s *DockerSuite) TestCliLogsFollowSlowStdoutConsumer(c *check.C) { + printTestCaseName() + defer printTestDuration(time.Now()) + testRequires(c, DaemonIsLinux) + pullImageIfNotExist("busybox") + out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", `usleep 600000;yes X | head -c 200000`) + time.Sleep(10 * time.Second) + id := strings.TrimSpace(out) + + stopSlowRead := make(chan bool) + + go func() { + exec.Command(dockerBinary, "stop", id).Run() + time.Sleep(10 * time.Second) + stopSlowRead <- true + }() + + logCmd := exec.Command(dockerBinary, "logs", "-f", id) + stdout, err := logCmd.StdoutPipe() + c.Assert(err, checker.IsNil) + c.Assert(logCmd.Start(), checker.IsNil) + + // First read slowly + bytes1, err := consumeWithSpeed(stdout, 10, 50*time.Millisecond, stopSlowRead) + c.Assert(err, checker.IsNil) + + // After the container has finished we can continue reading fast + bytes2, err := consumeWithSpeed(stdout, 32*1024, 0, nil) + c.Assert(err, checker.IsNil) + + actual := bytes1 + bytes2 + expected := 200000 + c.Assert(actual, checker.Equals, expected) +} + +//TODO: get exited container log +func (s *DockerSuite) TestCliLogsFollowStopped(c *check.C) { + printTestCaseName() + defer printTestDuration(time.Now()) + testRequires(c, DaemonIsLinux) + pullImageIfNotExist("busybox") + out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", "hello") + time.Sleep(5 * time.Second) + + id := strings.TrimSpace(out) + dockerCmd(c, "stop", id) + time.Sleep(5 * time.Second) + + logsCmd := exec.Command(dockerBinary, "logs", "-f", id) + c.Assert(logsCmd.Start(), checker.IsNil) + + errChan := make(chan error) + go func() { + errChan <- logsCmd.Wait() + close(errChan) + }() + + select { + case err := <-errChan: + c.Assert(err, checker.IsNil) + case <-time.After(10 * time.Second): + c.Fatal("Following logs is hanged") + } +} diff --git a/integration-cli/hyper_cli_config_test.go b/integration-cli/hyper_cli_config_test.go index 094b9c775..62963d6f1 100755 --- a/integration-cli/hyper_cli_config_test.go +++ b/integration-cli/hyper_cli_config_test.go @@ -15,7 +15,7 @@ func (s *DockerSuite) TestCliConfigAndRewrite(c *check.C) { defer printTestDuration(time.Now()) out, _ := dockerCmd(c, "config", "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443") - c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in /root/.hyper/config.json") + c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json") configDir := filepath.Join(homedir.Get(), ".hyper") conf, err := cliconfig.Load(configDir) @@ -24,7 +24,7 @@ func (s *DockerSuite) TestCliConfigAndRewrite(c *check.C) { c.Assert(conf.CloudConfig["tcp://127.0.0.1:6443"].SecretKey, checker.Equals, "xxxx", check.Commentf("Should get xxxx, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6443"].SecretKey)) out, _ = dockerCmd(c, "config", "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6443") - c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in /root/.hyper/config.json") + c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json") conf, err = cliconfig.Load(configDir) c.Assert(err, checker.IsNil) @@ -37,7 +37,7 @@ func (s *DockerSuite) TestCliConfigMultiHost(c *check.C) { defer printTestDuration(time.Now()) out, _ := dockerCmd(c, "config", "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443") - c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in /root/.hyper/config.json") + c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json") configDir := filepath.Join(homedir.Get(), ".hyper") conf, err := cliconfig.Load(configDir) @@ -46,7 +46,7 @@ func (s *DockerSuite) TestCliConfigMultiHost(c *check.C) { c.Assert(conf.CloudConfig["tcp://127.0.0.1:6443"].SecretKey, checker.Equals, "xxxx", check.Commentf("Should get xxxx, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6443"].SecretKey)) out, _ = dockerCmd(c, "config", "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6444") - c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in /root/.hyper/config.json") + c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json") conf, err = cliconfig.Load(configDir) c.Assert(err, checker.IsNil) diff --git a/integration-cli/hyper_cli_load_basic_test.go b/integration-cli/hyper_cli_load_basic_test.go index 78b0bab3b..5838db87c 100755 --- a/integration-cli/hyper_cli_load_basic_test.go +++ b/integration-cli/hyper_cli_load_basic_test.go @@ -26,7 +26,8 @@ func (s *DockerSuite) TestCliLoadFromUrlBasicFromInvalidUrlHost(c *check.C) { invalidHost := "invalidhost" invalidURL := "http://" + invalidHost + "/test/public/helloworld.tar" output, exitCode, err := dockerCmdWithError("load", "-i", invalidURL) - c.Assert(output, checker.Equals, "Error response from daemon: Bad request parameters: Get "+invalidURL+": dial tcp: lookup invalidhost: no such host\n") + c.Assert(output, checker.Contains, "Error response from daemon: Bad request parameters: Get "+invalidURL+": dial tcp: lookup invalidhost") + c.Assert(output, checker.Contains, "no such host\n") c.Assert(exitCode, checker.Equals, 1) c.Assert(err, checker.NotNil) } diff --git a/integration-cli/hyper_cli_load_local_test.go b/integration-cli/hyper_cli_load_local_test.go index 2ade5a59c..4d4b1829a 100755 --- a/integration-cli/hyper_cli_load_local_test.go +++ b/integration-cli/hyper_cli_load_local_test.go @@ -197,37 +197,6 @@ func (s *DockerSuite) TestCliLoadFromLocalTarSize100MB(c *check.C) { c.Assert(images, checker.Contains, "nginx") } -func (s *DockerSuite) TestCliLoadFromLocalTarSize600MB(c *check.C) { - printTestCaseName() - defer printTestDuration(time.Now()) - testRequires(c, DaemonIsLinux) - - publicURL := "http://image-tarball.s3.amazonaws.com/test/public/jenkins.tar" - imagePath := fmt.Sprintf("%s/jenkins.tar", os.Getenv("IMAGE_DIR")) - - //download image tar - wgetCmd := exec.Command("wget", "-cO", imagePath, publicURL) - output, exitCode, err := runCommandWithOutput(wgetCmd) - c.Assert(exitCode, checker.Equals, 0) - c.Assert(err, checker.IsNil) - c.Assert(pathExist(imagePath), checker.Equals, true) - - //ensure jenkins:latest not exist - dockerCmdWithError("rmi", "jenkins:latest") - images, _ := dockerCmd(c, "images", "jenkins:latest") - c.Assert(images, checker.Not(checker.Contains), "jenkins") - - //load image tar - output, exitCode, err = dockerCmdWithError("load", "-i", imagePath) - c.Assert(output, checker.Contains, "has been loaded.") - c.Assert(err, checker.IsNil) - c.Assert(exitCode, checker.Equals, 0) - - //check image - images, _ = dockerCmd(c, "images", "jenkins:latest") - c.Assert(images, checker.Contains, "jenkins") -} - func (s *DockerSuite) TestCliLoadFromLocalPullAndLoad(c *check.C) { printTestCaseName() defer printTestDuration(time.Now()) diff --git a/integration-cli/hyper_cli_logs_test.go b/integration-cli/hyper_cli_logs_test.go index b739e0e8d..c833b7271 100755 --- a/integration-cli/hyper_cli_logs_test.go +++ b/integration-cli/hyper_cli_logs_test.go @@ -170,35 +170,6 @@ func (s *DockerSuite) TestCliLogsTail(c *check.C) { c.Assert(lines, checker.HasLen, testLen+1) } -//TODO: get exited container log -func (s *DockerSuite) TestCliLogsFollowStopped(c *check.C) { - printTestCaseName() - defer printTestDuration(time.Now()) - testRequires(c, DaemonIsLinux) - pullImageIfNotExist("busybox") - out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", "hello") - time.Sleep(5 * time.Second) - - id := strings.TrimSpace(out) - dockerCmd(c, "stop", id) - time.Sleep(5 * time.Second) - - logsCmd := exec.Command(dockerBinary, "logs", "-f", id) - c.Assert(logsCmd.Start(), checker.IsNil) - - errChan := make(chan error) - go func() { - errChan <- logsCmd.Wait() - close(errChan) - }() - - select { - case err := <-errChan: - c.Assert(err, checker.IsNil) - case <-time.After(10 * time.Second): - c.Fatal("Following logs is hanged") - } -} //TODO: fix #46 func (s *DockerSuite) TestCliLogsSince(c *check.C) { @@ -265,42 +236,6 @@ func (s *DockerSuite) TestCliLogsSinceFutureFollow(c *check.C) { } } -//TODO: get exited container log -// Regression test for #8832 -func (s *DockerSuite) TestCliLogsFollowSlowStdoutConsumer(c *check.C) { - printTestCaseName() - defer printTestDuration(time.Now()) - testRequires(c, DaemonIsLinux) - pullImageIfNotExist("busybox") - out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", `usleep 600000;yes X | head -c 200000`) - time.Sleep(5 * time.Second) - id := strings.TrimSpace(out) - - stopSlowRead := make(chan bool) - - go func() { - exec.Command(dockerBinary, "stop", id).Run() - time.Sleep(5 * time.Second) - stopSlowRead <- true - }() - - logCmd := exec.Command(dockerBinary, "logs", "-f", id) - stdout, err := logCmd.StdoutPipe() - c.Assert(err, checker.IsNil) - c.Assert(logCmd.Start(), checker.IsNil) - - // First read slowly - bytes1, err := consumeWithSpeed(stdout, 10, 50*time.Millisecond, stopSlowRead) - c.Assert(err, checker.IsNil) - - // After the container has finished we can continue reading fast - bytes2, err := consumeWithSpeed(stdout, 32*1024, 0, nil) - c.Assert(err, checker.IsNil) - - actual := bytes1 + bytes2 - expected := 200000 - c.Assert(actual, checker.Equals, expected) -} //TODO: fix Goroutine in multi-tenancy environment /*func (s *DockerSuite) TestCliLogsFollowGoroutinesWithStdout(c *check.C) { diff --git a/integration-cli/util.sh b/integration-cli/util.sh index ce4c66a8f..b167087c2 100755 --- a/integration-cli/util.sh +++ b/integration-cli/util.sh @@ -96,6 +96,7 @@ case $1 in ;; test) export DOCKER_HOST=${HYPER_HOST} + export GOPATH=$GOPATH:`pwd`/../vendor mkdir -p ${IMAGE_DIR} shift if [ $# -ne 0 ];then