Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions integration-cli/final/cli/hyper_cli_load_local_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
84 changes: 84 additions & 0 deletions integration-cli/final/cli/hyper_cli_logs_ext_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
}
8 changes: 4 additions & 4 deletions integration-cli/hyper_cli_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion integration-cli/hyper_cli_load_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
31 changes: 0 additions & 31 deletions integration-cli/hyper_cli_load_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
65 changes: 0 additions & 65 deletions integration-cli/hyper_cli_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions integration-cli/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down