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
53 changes: 36 additions & 17 deletions integration-cli/final/cli/hyper_cli_save_load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
"strings"
)

/// test invalid url //////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -54,9 +55,9 @@ func (s *DockerSuite) TestLoadFromInvalidContentLengthTooLarge(c *check.C) {
printTestCaseName(); defer printTestDuration(time.Now())
testRequires(c, DaemonIsLinux)

const MAX_LENGTH = 2147483647
const MAX_LENGTH = 4294967295
output, exitCode, err := dockerCmdWithError("load", "-i", "http://image-tarball.s3.amazonaws.com/test/public/largefile.tar")
c.Assert(output, checker.Contains, fmt.Sprintf("should be greater than zero, less than or equal to %v\n", MAX_LENGTH))
c.Assert(output, checker.Contains, fmt.Sprintf("should be greater than zero and less than or equal to %v\n", MAX_LENGTH))
c.Assert(exitCode, checker.Equals, 1)
c.Assert(err, checker.NotNil)
}
Expand All @@ -66,9 +67,9 @@ func (s *DockerSuite) TestLoadFromInvalidContentLengthZero(c *check.C) {
printTestCaseName(); defer printTestDuration(time.Now())
testRequires(c, DaemonIsLinux)

const MAX_LENGTH = 2147483647
const MAX_LENGTH = 4294967295
output, exitCode, err := dockerCmdWithError("load", "-i", "http://image-tarball.s3.amazonaws.com/test/public/emptyfile.tar")
c.Assert(output, checker.Equals, fmt.Sprintf("Error response from daemon: Size of image archive is 0, should be greater than zero, less than or equal to %v\n", MAX_LENGTH))
c.Assert(output, checker.Equals, fmt.Sprintf("Error response from daemon: The size of the image archive file is 0, should be greater than zero and less than or equal to %v\n", MAX_LENGTH))
c.Assert(exitCode, checker.Equals, 1)
c.Assert(err, checker.NotNil)
}
Expand All @@ -78,7 +79,7 @@ func (s *DockerSuite) TestLoadFromInvalidContentUnrelated(c *check.C) {
testRequires(c, DaemonIsLinux)

output, exitCode, err := dockerCmdWithError("load", "-i", "http://image-tarball.s3.amazonaws.com/test/public/readme.tar")
c.Assert(output, checker.Equals, "invalid argument\n")
c.Assert(output, checker.Contains, "invalid argument\n")
c.Assert(exitCode, checker.Equals, 1)
c.Assert(err, checker.NotNil)
}
Expand All @@ -88,7 +89,7 @@ func (s *DockerSuite) TestLoadFromInvalidUntarFail(c *check.C) {
testRequires(c, DaemonIsLinux)

output, exitCode, err := dockerCmdWithError("load", "-i", "http://image-tarball.s3.amazonaws.com/test/public/nottar.tar")
c.Assert(output, checker.Equals, "Untar re-exec error: exit status 1: output: unexpected EOF\n")
c.Assert(output, checker.Contains, "Untar re-exec error: exit status 1: output: unexpected EOF\n")
c.Assert(exitCode, checker.Equals, 1)
c.Assert(err, checker.NotNil)
}
Expand All @@ -109,19 +110,19 @@ func (s *DockerSuite) TestLoadFromInvalidContentIncomplete(c *check.C) {

deleteAllImages()

/*
// load this image will be OK, but after delete this image, there is a residual image with <none> tag occur.
url = "http://image-tarball.s3.amazonaws.com/test/public/helloworld-no-manifest.tgz"
output, exitCode, err = dockerCmdWithError("load", "-i", url)
c.Assert(output, check.Not(checker.Contains), "has been loaded.")
c.Assert(exitCode, checker.Equals, 0)
c.Assert(err, checker.IsNil)

images, _ = dockerCmd(c, "images", "hello-world")
c.Assert(images, checker.Contains, "hello-world")
//// load this image will be OK, but after delete this image, there is a residual image with <none> tag occur.
//url = "http://image-tarball.s3.amazonaws.com/test/public/helloworld-no-manifest.tgz"
//output, exitCode, err = dockerCmdWithError("load", "-i", url)
//c.Assert(output, check.Not(checker.Contains), "has been loaded.")
//c.Assert(exitCode, checker.Equals, 0)
//c.Assert(err, checker.IsNil)
//
//images, _ = dockerCmd(c, "images", "hello-world")
//c.Assert(images, checker.Contains, "hello-world")
//
//deleteAllImages()

deleteAllImages()
*/

url = "http://image-tarball.s3.amazonaws.com/test/public/helloworld-no-layer.tgz"
output, exitCode, err = dockerCmdWithError("load", "-i", url)
Expand Down Expand Up @@ -364,3 +365,21 @@ func (s *DockerSuite) TestLoadFromPublicURLWithQuota(c *check.C) {
out, _ = dockerCmd(c, "info")
c.Assert(out, checker.Contains, "Images: 2")
}

func (s *DockerSuite) TestLoadFromLargeImageArchiveFile(c *check.C) {
printTestCaseName(); defer printTestDuration(time.Now())
testRequires(c, DaemonIsLinux)

imageName := "consol/centos-xfce-vnc";
imageUrl := "http://image-tarball.s3.amazonaws.com/test/public/consol_centos-xfce-vnc.tar"; //1.53GB

output, exitCode, err := dockerCmdWithError("load", "-i", imageUrl)
c.Assert(output, checker.Contains, "Start to download and load the image archive, please wait...\n")
c.Assert(output, checker.Contains, "has been loaded.\n")
c.Assert(exitCode, checker.Equals, 0)
c.Assert(err, checker.IsNil)

images, _ := dockerCmd(c, "images")
c.Assert(images, checker.Contains, imageName)
c.Assert(len(strings.Split(images, "\n")), checker.Equals, 3)
}
22 changes: 22 additions & 0 deletions integration-cli/passed/api/hyper_api_images_test.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
"strings"
)

func (s *DockerSuite) TestApiImagesSearchJSONContentType(c *check.C) {
Expand All @@ -20,3 +21,24 @@ func (s *DockerSuite) TestApiImagesSearchJSONContentType(c *check.C) {
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
c.Assert(res.Header.Get("Content-Type"), checker.Equals, "application/json")
}

func (s *DockerSuite) TestApiLoadImage(c *check.C) {
printTestCaseName()
defer printTestDuration(time.Now())

postData := map[string]interface{}{
"fromSrc": "http://image-tarball.s3.amazonaws.com/test/public/helloworld.tar.gz",
"quiet": false,
}
//debugEndpoint = "/images/load"

status, resp, err := sockRequest("POST", "/images/load", postData)
c.Assert(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusOK)

expected := "{\"status\":\"Start to download and load the image archive, please wait...\"}"
c.Assert(strings.TrimSpace(string(resp)), checker.Contains, expected)

expected = "has been loaded.\"}"
c.Assert(strings.TrimSpace(string(resp)), checker.Contains, expected)
}
23 changes: 20 additions & 3 deletions integration-cli/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,35 @@ cd ${WORKDIR}
# ensure util.conf
if [ ! -s ${WORKDIR}/util.conf ];then
cat > ${WORKDIR}/util.conf <<EOF
#########################################
#packet env
#########################################
#apirouter service
DOCKER_HOST=tcp://147.75.195.39:6443

#Hyper Credentials(from ~/.hyper/config.json)
#Hyper Credentials
ACCESS_KEY=
SECRET_KEY=

##For test load image from S3 Pre-Signed URL
#AWS Credentials(from ~/.aws/credentials)

#########################################
#zenlayer env
#########################################
#apirouter service
#DOCKER_HOST=tcp://us-west-1.hyper.sh:443

#Hyper Credentials
#ACCESS_KEY=
#SECRET_KEY=


#########################################
##AWS Credentials
#########################################
AWS_ACCESS_KEY=
AWS_SECRET_KEY=


##For test load image from basic auth url
URL_WITH_BASIC_AUTH=http://username:password@test.xx.xx/ubuntu.tar.gz
EOF
Expand Down