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

Commit 443d696

Browse files
committed
[fix-integration-test] fix test case
1 parent c9c8ca5 commit 443d696

File tree

3 files changed

+52
-30
lines changed

3 files changed

+52
-30
lines changed

integration-cli/hyper_cli_region_test.go renamed to integration-cli/final/cli/hyper_cli_region_test.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,10 @@ func (s *DockerSuite) TestCliRegionBasic(c *check.C) {
2828
anotherRegion = "us-west-1"
2929
}
3030

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-
4431
////////////////////////////////////////////
4532
//pull image with default region
46-
cmd = exec.Command(dockerBinary, "pull", "busybox")
47-
out, _, err = runCommandWithOutput(cmd)
33+
cmd := exec.Command(dockerBinary, "pull", "busybox")
34+
out, _, err := runCommandWithOutput(cmd)
4835
if err != nil {
4936
c.Fatal(err, out)
5037
}

integration-cli/hyper_cli_config_test.go

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import (
99
"github.com/go-check/check"
1010
"github.com/hyperhq/hypercli/cliconfig"
1111
"github.com/hyperhq/hypercli/pkg/homedir"
12+
"os/exec"
1213
)
1314

1415
func (s *DockerSuite) TestCliConfigAndRewrite(c *check.C) {
1516
printTestCaseName()
1617
defer printTestDuration(time.Now())
1718

18-
out, _ := dockerCmd(c, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443")
19+
cmd := exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443")
20+
out, _, _, err := runCommandWithStdoutStderr(cmd)
21+
c.Assert(err, checker.IsNil)
1922
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
2023

2124
configDir := filepath.Join(homedir.Get(), ".hyper")
@@ -24,20 +27,37 @@ func (s *DockerSuite) TestCliConfigAndRewrite(c *check.C) {
2427
c.Assert(conf.CloudConfig["tcp://127.0.0.1:6443"].AccessKey, checker.Equals, "xx", check.Commentf("Should get xx, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6443"].AccessKey))
2528
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))
2629

27-
out, _ = dockerCmd(c, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6443")
30+
31+
cmd = exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6443")
32+
out, _, _, err = runCommandWithStdoutStderr(cmd)
33+
c.Assert(err, checker.IsNil)
2834
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
2935

3036
conf, err = cliconfig.Load(configDir)
3137
c.Assert(err, checker.IsNil)
3238
c.Assert(conf.CloudConfig["tcp://127.0.0.1:6443"].AccessKey, checker.Equals, "yy", check.Commentf("Should get yy, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6443"].AccessKey))
3339
c.Assert(conf.CloudConfig["tcp://127.0.0.1:6443"].SecretKey, checker.Equals, "yyyy", check.Commentf("Should get yyyy, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6443"].SecretKey))
40+
41+
//patch
42+
cmd = exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", os.Getenv("ACCESS_KEY"), "--secretkey", os.Getenv("SECRET_KEY"), os.Getenv("DOCKER_HOST"))
43+
out, _, _, err = runCommandWithStdoutStderr(cmd)
44+
c.Assert(err, checker.IsNil)
45+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
46+
47+
cmd = exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", os.Getenv("ACCESS_KEY"), "--secretkey", os.Getenv("SECRET_KEY"))
48+
out, _, _, err = runCommandWithStdoutStderr(cmd)
49+
c.Assert(err, checker.IsNil)
50+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
3451
}
3552

3653
func (s *DockerSuite) TestCliConfigMultiHostBasic(c *check.C) {
3754
printTestCaseName()
3855
defer printTestDuration(time.Now())
3956

40-
out, _ := dockerCmd(c, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443")
57+
58+
cmd := exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443")
59+
out, _, _, err := runCommandWithStdoutStderr(cmd)
60+
c.Assert(err, checker.IsNil)
4161
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
4262

4363
configDir := filepath.Join(homedir.Get(), ".hyper")
@@ -46,11 +66,24 @@ func (s *DockerSuite) TestCliConfigMultiHostBasic(c *check.C) {
4666
c.Assert(conf.CloudConfig["tcp://127.0.0.1:6443"].AccessKey, checker.Equals, "xx", check.Commentf("Should get xx, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6443"].AccessKey))
4767
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))
4868

49-
out, _ = dockerCmd(c, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6444")
69+
cmd = exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6444")
70+
out, _, _, err = runCommandWithStdoutStderr(cmd)
71+
c.Assert(err, checker.IsNil)
5072
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
5173

5274
conf, err = cliconfig.Load(configDir)
5375
c.Assert(err, checker.IsNil)
5476
c.Assert(conf.CloudConfig["tcp://127.0.0.1:6444"].AccessKey, checker.Equals, "yy", check.Commentf("Should get yy, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6444"].AccessKey))
5577
c.Assert(conf.CloudConfig["tcp://127.0.0.1:6444"].SecretKey, checker.Equals, "yyyy", check.Commentf("Should get yyyy, but get %s\n", conf.CloudConfig["tcp://127.0.0.1:6444"].SecretKey))
78+
79+
//patch
80+
cmd = exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", os.Getenv("ACCESS_KEY"), "--secretkey", os.Getenv("SECRET_KEY"), os.Getenv("DOCKER_HOST"))
81+
out, _, _, err = runCommandWithStdoutStderr(cmd)
82+
c.Assert(err, checker.IsNil)
83+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
84+
85+
cmd = exec.Command(dockerBinary, "config", "--default-region" , os.Getenv("REGION"), "--accesskey", os.Getenv("ACCESS_KEY"), "--secretkey", os.Getenv("SECRET_KEY"))
86+
out, _, _, err = runCommandWithStdoutStderr(cmd)
87+
c.Assert(err, checker.IsNil)
88+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
5689
}

integration-cli/util.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ function show_usage() {
77
cat <<EOF
88
Usage: ./util.sh <action>
99
<action>:
10-
build-dev # build docker image 'hyperhq/hypercl' from Dockerfile.dev
11-
build-qa # build docker image 'hyperhq/hypercl' from Dockerfile.qa
12-
make # make hyper cli in container
13-
enter # enter container from hyperhq/hhypercli-auto-test:dev
14-
qa <branch> # run test case in hyperhq/hhypercli-auto-test:qa, default branch is 'master'
15-
test # test on host
10+
build-dev # build docker image 'hyperhq/hypercl' from Dockerfile.dev
11+
build-qa # build docker image 'hyperhq/hypercl' from Dockerfile.qa
12+
make # make hyper cli in container
13+
enter-dev # enter container from hyperhq/hhypercli-auto-test:dev
14+
enter-qa <branch> # enter container from hyperhq/hhypercli-auto-test:qa, default branch is 'master'
15+
test # test on host
1616
EOF
1717
}
1818

@@ -68,12 +68,12 @@ case $1 in
6868
-v $(pwd)/../:/go/src/github.com/hyperhq/hypercli \
6969
${IMAGE_NAME}:dev ./build.sh
7070
;;
71-
enter)
71+
enter-dev)
7272
docker run -it --rm \
7373
-e DOCKER_HOST=${HYPER_HOST} \
74+
-e REGION=${REGION} \
7475
-e ACCESS_KEY=${ACCESS_KEY} \
7576
-e SECRET_KEY=${SECRET_KEY} \
76-
-e REGION=${REGION} \
7777
-e AWS_ACCESS_KEY=${AWS_ACCESS_KEY} \
7878
-e AWS_SECRET_KEY=${AWS_SECRET_KEY} \
7979
-e URL_WITH_BASIC_AUTH=${URL_WITH_BASIC_AUTH} \
@@ -84,22 +84,24 @@ case $1 in
8484
-v $(pwd)/../:/go/src/github.com/hyperhq/hypercli \
8585
${IMAGE_NAME}:dev zsh
8686
;;
87-
qa)
87+
enter-qa)
8888
BRANCH=$2
8989
if [ "$BRANCH" == "" ];then
9090
BRANCH="master"
9191
fi
9292
docker run -it --rm \
9393
-e http_proxy=${http_proxy} \
9494
-e https_proxy=${https_proxy} \
95-
-e BRANCH=${BRANCH} \
9695
-e DOCKER_HOST=${HYPER_HOST} \
96+
-e REGION=${REGION} \
97+
-e BRANCH=${BRANCH} \
9798
-e ACCESS_KEY=${ACCESS_KEY} \
9899
-e SECRET_KEY=${SECRET_KEY} \
99100
-e DOCKERHUB_EMAIL=${DOCKERHUB_EMAIL} \
100101
-e DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME} \
101102
-e DOCKERHUB_PASSWD=${DOCKERHUB_PASSWD} \
102-
${IMAGE_NAME}:qa go test -check.f TestCli -timeout 180m
103+
${IMAGE_NAME}:qa /bin/bash
104+
# ${IMAGE_NAME}:qa go test -check.f TestCli -timeout 180m
103105
;;
104106
test)
105107
export DOCKER_HOST=${HYPER_HOST}

0 commit comments

Comments
 (0)