Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 5eee319

Browse files
authored
Merge pull request #121 from Jimmy-Xu/integration-test
[integration-test] update test case for image load
2 parents 9fd0e52 + 7d9bc25 commit 5eee319

File tree

3 files changed

+78
-20
lines changed

3 files changed

+78
-20
lines changed

integration-cli/final/cli/hyper_cli_save_load_test.go

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"github.com/docker/docker/pkg/integration/checker"
88
"github.com/go-check/check"
9+
"strings"
910
)
1011

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

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

69-
const MAX_LENGTH = 2147483647
70+
const MAX_LENGTH = 4294967295
7071
output, exitCode, err := dockerCmdWithError("load", "-i", "http://image-tarball.s3.amazonaws.com/test/public/emptyfile.tar")
71-
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))
72+
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))
7273
c.Assert(exitCode, checker.Equals, 1)
7374
c.Assert(err, checker.NotNil)
7475
}
@@ -78,7 +79,7 @@ func (s *DockerSuite) TestLoadFromInvalidContentUnrelated(c *check.C) {
7879
testRequires(c, DaemonIsLinux)
7980

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

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

110111
deleteAllImages()
111112

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

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

123-
deleteAllImages()
124-
*/
125126

126127
url = "http://image-tarball.s3.amazonaws.com/test/public/helloworld-no-layer.tgz"
127128
output, exitCode, err = dockerCmdWithError("load", "-i", url)
@@ -364,3 +365,21 @@ func (s *DockerSuite) TestLoadFromPublicURLWithQuota(c *check.C) {
364365
out, _ = dockerCmd(c, "info")
365366
c.Assert(out, checker.Contains, "Images: 2")
366367
}
368+
369+
func (s *DockerSuite) TestLoadFromLargeImageArchiveFile(c *check.C) {
370+
printTestCaseName(); defer printTestDuration(time.Now())
371+
testRequires(c, DaemonIsLinux)
372+
373+
imageName := "consol/centos-xfce-vnc";
374+
imageUrl := "http://image-tarball.s3.amazonaws.com/test/public/consol_centos-xfce-vnc.tar"; //1.53GB
375+
376+
output, exitCode, err := dockerCmdWithError("load", "-i", imageUrl)
377+
c.Assert(output, checker.Contains, "Start to download and load the image archive, please wait...\n")
378+
c.Assert(output, checker.Contains, "has been loaded.\n")
379+
c.Assert(exitCode, checker.Equals, 0)
380+
c.Assert(err, checker.IsNil)
381+
382+
images, _ := dockerCmd(c, "images")
383+
c.Assert(images, checker.Contains, imageName)
384+
c.Assert(len(strings.Split(images, "\n")), checker.Equals, 3)
385+
}

integration-cli/passed/api/hyper_api_images_test.go

100644100755
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/docker/docker/pkg/integration/checker"
88
"github.com/go-check/check"
9+
"strings"
910
)
1011

1112
func (s *DockerSuite) TestApiImagesSearchJSONContentType(c *check.C) {
@@ -20,3 +21,24 @@ func (s *DockerSuite) TestApiImagesSearchJSONContentType(c *check.C) {
2021
c.Assert(res.StatusCode, checker.Equals, http.StatusOK)
2122
c.Assert(res.Header.Get("Content-Type"), checker.Equals, "application/json")
2223
}
24+
25+
func (s *DockerSuite) TestApiLoadImage(c *check.C) {
26+
printTestCaseName()
27+
defer printTestDuration(time.Now())
28+
29+
postData := map[string]interface{}{
30+
"fromSrc": "http://image-tarball.s3.amazonaws.com/test/public/helloworld.tar.gz",
31+
"quiet": false,
32+
}
33+
//debugEndpoint = "/images/load"
34+
35+
status, resp, err := sockRequest("POST", "/images/load", postData)
36+
c.Assert(err, check.IsNil)
37+
c.Assert(status, check.Equals, http.StatusOK)
38+
39+
expected := "{\"status\":\"Start to download and load the image archive, please wait...\"}"
40+
c.Assert(strings.TrimSpace(string(resp)), checker.Contains, expected)
41+
42+
expected = "has been loaded.\"}"
43+
c.Assert(strings.TrimSpace(string(resp)), checker.Contains, expected)
44+
}

integration-cli/util.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,35 @@ cd ${WORKDIR}
2121
# ensure util.conf
2222
if [ ! -s ${WORKDIR}/util.conf ];then
2323
cat > ${WORKDIR}/util.conf <<EOF
24+
#########################################
25+
#packet env
26+
#########################################
2427
#apirouter service
2528
DOCKER_HOST=tcp://147.75.195.39:6443
2629
27-
#Hyper Credentials(from ~/.hyper/config.json)
30+
#Hyper Credentials
2831
ACCESS_KEY=
2932
SECRET_KEY=
3033
31-
##For test load image from S3 Pre-Signed URL
32-
#AWS Credentials(from ~/.aws/credentials)
34+
35+
#########################################
36+
#zenlayer env
37+
#########################################
38+
#apirouter service
39+
#DOCKER_HOST=tcp://us-west-1.hyper.sh:443
40+
41+
#Hyper Credentials
42+
#ACCESS_KEY=
43+
#SECRET_KEY=
44+
45+
46+
#########################################
47+
##AWS Credentials
48+
#########################################
3349
AWS_ACCESS_KEY=
3450
AWS_SECRET_KEY=
3551
52+
3653
##For test load image from basic auth url
3754
URL_WITH_BASIC_AUTH=http://username:password@test.xx.xx/ubuntu.tar.gz
3855
EOF

0 commit comments

Comments
 (0)