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

Commit 28ce86f

Browse files
committed
[region] add test case for region
1 parent 116dda3 commit 28ce86f

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-0
lines changed

hack/generate-hyper-conf-dev.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ if [ "$@" != "./build.sh" ];then
1111
{
1212
"clouds": {
1313
"${DOCKER_HOST}": {
14+
"accesskey": "${ACCESS_KEY}",
15+
"secretkey": "${SECRET_KEY}"
16+
},
17+
"tcp://*.hyper.sh:443": {
1418
"accesskey": "${ACCESS_KEY}",
1519
"secretkey": "${SECRET_KEY}",
1620
"region": "${REGION}"

hack/generate-hyper-conf-qa.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ if [[ "$@" != "./build.sh" ]];then
3535
{
3636
"clouds": {
3737
"${DOCKER_HOST}": {
38+
"accesskey": "${ACCESS_KEY}",
39+
"secretkey": "${SECRET_KEY}"
40+
},
41+
"tcp://*.hyper.sh:443": {
3842
"accesskey": "${ACCESS_KEY}",
3943
"secretkey": "${SECRET_KEY}",
4044
"region": "${REGION}"

integration-cli/README.md

100644100755
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Functional test for hyper cli.
6666
- [x] cli_ps_test
6767
- [x] cli_pull_test
6868
- [x] cli_push_test
69+
- [x] cli_region_test
6970
- [x] cli_rename_test
7071
- [x] cli_restart_test
7172
- [x] cli_rm_test
@@ -374,4 +375,19 @@ $ docker run -it --rm \
374375
-e http_proxy=${http_proxy} \
375376
-e https_proxy=${https_proxy} \
376377
hyperhq/hypercli-auto-test:qa go test -check.f TestCliInfo
378+
379+
//test with region(region name could be us-west-1/eu-central-1)
380+
$ docker run -it --rm \
381+
-e ACCESS_KEY=${ACCESS_KEY} \
382+
-e SECRET_KEY=${SECRET_KEY} \
383+
-e REGION=${REGION} \
384+
-e http_proxy=${http_proxy} \
385+
-e https_proxy=${https_proxy} \
386+
hyperhq/hypercli-auto-test:qa go test -check.f TestCliInfo
387+
388+
//test basic test case only
389+
$ docker run -it --rm \
390+
-e ACCESS_KEY=${ACCESS_KEY} \
391+
-e SECRET_KEY=${SECRET_KEY} \
392+
hyperhq/hypercli-auto-test:qa go test -check.f "TestCli.*Basic" -timeout 180m
377393
```
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package main
2+
3+
import (
4+
"time"
5+
"os"
6+
"os/exec"
7+
8+
"github.com/go-check/check"
9+
"github.com/docker/docker/pkg/integration/checker"
10+
)
11+
12+
func (s *DockerSuite) TestCliRegionBasic(c *check.C) {
13+
printTestCaseName()
14+
defer printTestDuration(time.Now())
15+
16+
var (
17+
defaultRegion = os.Getenv("REGION")
18+
anotherRegion = ""
19+
err error
20+
)
21+
switch defaultRegion {
22+
case "":
23+
defaultRegion = "us-west-1"
24+
anotherRegion = "eu-central-1"
25+
case "us-west-1":
26+
anotherRegion = "eu-central-1"
27+
case "eu-central-1":
28+
anotherRegion = "us-west-1"
29+
}
30+
31+
//delete busybox
32+
cmd := exec.Command(dockerBinary, "rmi", "-f", "busybox")
33+
runCommandWithOutput(cmd)
34+
cmd = exec.Command(dockerBinary, "images", "busybox")
35+
out, _, _ := runCommandWithOutput(cmd)
36+
c.Assert(out, checker.Not(checker.Contains), "busybox")
37+
//delete ubuntu
38+
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "rmi", "-f", "ubuntu")
39+
runCommandWithOutput(cmd)
40+
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "images", "ubuntu")
41+
out, _, _ = runCommandWithOutput(cmd)
42+
c.Assert(out, checker.Not(checker.Contains), "ubuntu")
43+
44+
////////////////////////////////////////////
45+
//pull image with default region
46+
cmd = exec.Command(dockerBinary, "pull", "busybox")
47+
out, _, err = runCommandWithOutput(cmd)
48+
if err != nil {
49+
c.Fatal(err, out)
50+
}
51+
c.Assert(out, checker.Contains, "Status: Downloaded newer image for busybox:latest")
52+
53+
cmd = exec.Command(dockerBinary, "run", "busybox", "echo", "test123")
54+
out, _, err = runCommandWithOutput(cmd)
55+
if err != nil {
56+
c.Fatal(err, out)
57+
}
58+
c.Assert(out, checker.Not(checker.Contains), "Unable to find image 'busybox:latest' in the current region")
59+
c.Assert(out, checker.Contains, "test123")
60+
61+
////////////////////////////////////////////
62+
//image not exist in another region
63+
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "images", "busybox")
64+
out, _, err = runCommandWithOutput(cmd)
65+
if err != nil {
66+
c.Fatal(err, out)
67+
}
68+
c.Assert(out, checker.Not(checker.Contains), "busybox")
69+
70+
////////////////////////////////////////////
71+
//pull image with specified region
72+
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "pull", "ubuntu")
73+
out, _, err = runCommandWithOutput(cmd)
74+
if err != nil {
75+
c.Fatal(err, out)
76+
}
77+
c.Assert(out, checker.Contains, "Status: Downloaded newer image for ubuntu:latest")
78+
79+
cmd = exec.Command(dockerBinary, "--region", anotherRegion, "run", "ubuntu", "echo", "test123")
80+
out, _, err = runCommandWithOutput(cmd)
81+
if err != nil {
82+
c.Fatal(err, out)
83+
}
84+
c.Assert(out, checker.Not(checker.Contains), "Unable to find image 'ubuntu:latest' in the current region")
85+
c.Assert(out, checker.Contains, "test123")
86+
}
87+
88+
func (s *DockerSuite) TestCliRegionWithFullEntrypoint(c *check.C) {
89+
printTestCaseName()
90+
defer printTestDuration(time.Now())
91+
cmd := exec.Command(dockerBinary, "--region", os.Getenv("DOCKER_HOST"), "pull", "busybox")
92+
out, _, err := runCommandWithOutput(cmd)
93+
if err != nil {
94+
c.Fatal(err, out)
95+
}
96+
c.Assert(out, checker.Contains, "Status: Downloaded newer image for busybox:latest")
97+
}

0 commit comments

Comments
 (0)