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

Commit 9cd0a4c

Browse files
authored
Merge pull request #231 from Jimmy-Xu/markup-basic-test-case
markup basic test case
2 parents 2059080 + 150f979 commit 9cd0a4c

39 files changed

+643
-204
lines changed

Dockerfile.dev

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN yum install -y\
1313

1414

1515
## Install Go
16-
ENV GO_VERSION 1.7.4
16+
ENV GO_VERSION 1.8.3
1717
RUN wget http://golangtc.com/static/go/${GO_VERSION}/go${GO_VERSION}.linux-amd64.tar.gz
1818
#RUN wget http://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
1919
RUN tar -xzf go${GO_VERSION}.linux-amd64.tar.gz -C /usr/local

Dockerfile.qa

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN yum install -y\
1313

1414

1515
## Install Go
16-
ENV GO_VERSION 1.7.4
16+
ENV GO_VERSION 1.8.3
1717
RUN wget http://golangtc.com/static/go/${GO_VERSION}/go${GO_VERSION}.linux-amd64.tar.gz
1818
#RUN wget http://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
1919
RUN tar -xzf go${GO_VERSION}.linux-amd64.tar.gz -C /usr/local

integration-cli/README.md

100755100644
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Functional test for hyper cli.
4343
- [ ] cli_attach_unix_test
4444
- [x] cli_config_test
4545
- [x] cli_create_test
46+
- [x] cli_commit_test
4647
- [x] cli_exec_test
4748
- [x] cli_exec_unix_test
4849
- [x] cli_fip_test
@@ -64,6 +65,7 @@ Functional test for hyper cli.
6465
- [x] cli_port_test
6566
- [x] cli_ps_test
6667
- [x] cli_pull_test
68+
- [x] cli_push_test
6769
- [x] cli_rename_test
6870
- [x] cli_restart_test
6971
- [x] cli_rm_test
@@ -103,13 +105,12 @@ Functional test for hyper cli.
103105

104106
## skip
105107

106-
> not support build, commit, push, tag
108+
> not support build, tag
107109
108110
- [ ] cli_authz_unix_test
109111
- [ ] cli_build_test
110112
- [ ] cli_build_unix_test
111113
- [ ] cli_by_digest_test
112-
- [ ] cli_commit_test
113114
- [ ] cli_cp_from_container_test
114115
- [ ] cli_cp_test
115116
- [ ] cli_cp_to_container_test
@@ -130,7 +131,6 @@ Functional test for hyper cli.
130131
- [ ] cli_proxy_test
131132
- [ ] cli_pull_local_test
132133
- [ ] cli_pull_trusted_test
133-
- [ ] cli_push_test
134134
- [ ] cli_save_load_test
135135
- [ ] cli_save_load_unix_test
136136
- [ ] cli_sni_test
@@ -147,6 +147,7 @@ Functional test for hyper cli.
147147

148148
- TestCliConfig
149149
- TestCliCreate
150+
- TestCliCommit
150151
- TestCliExec
151152
- TestCliFip
152153
- TestCliHelp
@@ -162,6 +163,7 @@ Functional test for hyper cli.
162163
- TestCliPort
163164
- TestCliPs
164165
- TestCliPull
166+
- TestCliPush
165167
- TestCliRename
166168
- TestCliRestart
167169
- TestCliRmi
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"strings"
7+
"time"
8+
9+
"github.com/go-check/check"
10+
"github.com/hyperhq/hypercli/pkg/integration/checker"
11+
)
12+
13+
func (s *DockerSuite) TestCliPush(c *check.C) {
14+
printTestCaseName()
15+
defer printTestDuration(time.Now())
16+
testRequires(c, DaemonIsLinux)
17+
18+
var (
19+
out string
20+
err error
21+
newImage = fmt.Sprintf("%v/busybox:latest", os.Getenv("DOCKERHUB_USERNAME"))
22+
)
23+
pullImageIfNotExist("busybox")
24+
out, _ = dockerCmd(c, "run", "-d", "busybox", "bash", "-c", "touch", "test")
25+
cleanedContainerID := strings.TrimSpace(out)
26+
27+
_, _, err = dockerCmdWithError("commit", cleanedContainerID, newImage)
28+
c.Assert(err, checker.IsNil)
29+
30+
//login dockerhub
31+
out, _ = dockerCmd(c, "login", "-e", os.Getenv("DOCKERHUB_EMAIL"), "-u", os.Getenv("DOCKERHUB_USERNAME"), "-p", os.Getenv("DOCKERHUB_PASSWD"))
32+
c.Assert(out, checker.Contains, "Login Succeeded")
33+
34+
//push to dockerhub
35+
out, _, err = dockerCmdWithError("push", newImage)
36+
c.Assert(out, checker.Contains, "digest:")
37+
c.Assert(err, checker.IsNil)
38+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
"time"
6+
7+
"github.com/docker/docker/pkg/integration/checker"
8+
"github.com/go-check/check"
9+
)
10+
11+
func (s *DockerSuite) TestCliCommitAfterContainerIsDone(c *check.C) {
12+
printTestCaseName()
13+
defer printTestDuration(time.Now())
14+
testRequires(c, DaemonIsLinux)
15+
16+
pullImageIfNotExist("busybox")
17+
out, _ := dockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
18+
19+
cleanedContainerID := strings.TrimSpace(out)
20+
21+
dockerCmd(c, "wait", cleanedContainerID)
22+
23+
out, _ = dockerCmd(c, "commit", cleanedContainerID)
24+
25+
cleanedImageID := strings.TrimSpace(out)
26+
27+
dockerCmd(c, "inspect", cleanedImageID)
28+
}
29+
30+
func (s *DockerSuite) TestCliCommitRunningContainer(c *check.C) {
31+
printTestCaseName()
32+
defer printTestDuration(time.Now())
33+
testRequires(c, DaemonIsLinux)
34+
35+
pullImageIfNotExist("busybox")
36+
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
37+
cleanedContainerID := strings.TrimSpace(out)
38+
39+
out, _, err := dockerCmdWithError("commit", cleanedContainerID)
40+
c.Assert(err, checker.NotNil)
41+
c.Assert(out, checker.Equals, "Error response from daemon: Bad request parameters: only stopped container could be committed\n")
42+
}
43+
44+
func (s *DockerSuite) TestCliCommitNewFileBasic(c *check.C) {
45+
printTestCaseName()
46+
defer printTestDuration(time.Now())
47+
testRequires(c, DaemonIsLinux)
48+
49+
pullImageIfNotExist("busybox")
50+
dockerCmd(c, "run", "--name", "commiter", "busybox", "/bin/sh", "-c", "echo koye > /foo")
51+
52+
imageID, _ := dockerCmd(c, "commit", "commiter")
53+
imageID = strings.TrimSpace(imageID)
54+
55+
out, _ := dockerCmd(c, "run", imageID, "cat", "/foo")
56+
actual := strings.TrimSpace(out)
57+
c.Assert(actual, checker.Equals, "koye")
58+
}
59+
60+
func (s *DockerSuite) TestCliCommitChange(c *check.C) {
61+
printTestCaseName()
62+
defer printTestDuration(time.Now())
63+
testRequires(c, DaemonIsLinux)
64+
65+
pullImageIfNotExist("busybox")
66+
dockerCmd(c, "run", "--name", "test", "busybox", "true")
67+
68+
imageID, _ := dockerCmd(c, "commit",
69+
"--change", "EXPOSE 8080",
70+
"--change", "ENV DEBUG true",
71+
"--change", "ENV test 1",
72+
"--change", "ENV PATH /foo",
73+
"--change", "LABEL foo bar",
74+
"--change", "CMD [\"/bin/sh\"]",
75+
"--change", "WORKDIR /opt",
76+
"--change", "ENTRYPOINT [\"/bin/sh\"]",
77+
"--change", "USER testuser",
78+
"--change", "VOLUME /var/lib/docker",
79+
"test", "test-commit",
80+
)
81+
imageID = strings.TrimSpace(imageID)
82+
83+
expected := map[string]string{
84+
"Config.ExposedPorts": "map[8080/tcp:{}]",
85+
"Config.Env": "[DEBUG=true test=1 PATH=/foo]",
86+
"Config.Labels": "map[foo:bar]",
87+
"Config.Cmd": "[/bin/sh]",
88+
"Config.WorkingDir": "/opt",
89+
"Config.Entrypoint": "[/bin/sh]",
90+
"Config.User": "testuser",
91+
"Config.Volumes": "map[/var/lib/docker:{}]",
92+
}
93+
94+
for conf, value := range expected {
95+
res := inspectField(c, imageID, conf)
96+
if res != value {
97+
c.Errorf("%s('%s'), expected %s", conf, res, value)
98+
}
99+
}
100+
}

integration-cli/hyper_cli_config_test.go

100755100644
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (s *DockerSuite) TestCliConfigAndRewrite(c *check.C) {
1515
defer printTestDuration(time.Now())
1616

1717
out, _ := dockerCmd(c, "config", "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443")
18-
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json")
18+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
1919

2020
configDir := filepath.Join(homedir.Get(), ".hyper")
2121
conf, err := cliconfig.Load(configDir)
@@ -24,20 +24,20 @@ func (s *DockerSuite) TestCliConfigAndRewrite(c *check.C) {
2424
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))
2525

2626
out, _ = dockerCmd(c, "config", "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6443")
27-
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json")
27+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
2828

2929
conf, err = cliconfig.Load(configDir)
3030
c.Assert(err, checker.IsNil)
3131
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))
3232
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))
3333
}
3434

35-
func (s *DockerSuite) TestCliConfigMultiHost(c *check.C) {
35+
func (s *DockerSuite) TestCliConfigMultiHostBasic(c *check.C) {
3636
printTestCaseName()
3737
defer printTestDuration(time.Now())
3838

3939
out, _ := dockerCmd(c, "config", "--accesskey", "xx", "--secretkey", "xxxx", "tcp://127.0.0.1:6443")
40-
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json")
40+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
4141

4242
configDir := filepath.Join(homedir.Get(), ".hyper")
4343
conf, err := cliconfig.Load(configDir)
@@ -46,7 +46,7 @@ func (s *DockerSuite) TestCliConfigMultiHost(c *check.C) {
4646
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))
4747

4848
out, _ = dockerCmd(c, "config", "--accesskey", "yy", "--secretkey", "yyyy", "tcp://127.0.0.1:6444")
49-
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in " + homedir.Get() + "/.hyper/config.json")
49+
c.Assert(out, checker.Contains, "WARNING: Your login credentials has been saved in "+homedir.Get()+"/.hyper/config.json")
5050

5151
conf, err = cliconfig.Load(configDir)
5252
c.Assert(err, checker.IsNil)

integration-cli/hyper_cli_create_test.go

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (s *DockerSuite) TestCliCreateArgs(c *check.C) {
5858
}
5959

6060
// Make sure we can set hostconfig options too
61-
func (s *DockerSuite) TestCliCreateHostConfig(c *check.C) {
61+
func (s *DockerSuite) TestCliCreateHostConfigBasic(c *check.C) {
6262
printTestCaseName()
6363
defer printTestDuration(time.Now())
6464
pullImageIfNotExist("busybox")
@@ -84,7 +84,7 @@ func (s *DockerSuite) TestCliCreateHostConfig(c *check.C) {
8484
}
8585

8686
// "test123" should be printed by docker create + start
87-
func (s *DockerSuite) TestCliCreateEchoStdout(c *check.C) {
87+
func (s *DockerSuite) TestCliCreateEchoStdoutBasic(c *check.C) {
8888
printTestCaseName()
8989
defer printTestDuration(time.Now())
9090
pullImageIfNotExist("busybox")

integration-cli/hyper_cli_exec_test.go

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func (s *DockerSuite) TestCliExecBasic(c *check.C) {
2323
defer printTestDuration(time.Now())
2424

2525
testRequires(c, DaemonIsLinux)
26+
pullImageIfNotExist("busybox")
2627
dockerCmd(c, "run", "-d", "--name", "test", "busybox", "sh", "-c", "echo test > /tmp/file && top")
2728

2829
out, _ := dockerCmd(c, "exec", "test", "cat", "/tmp/file")

integration-cli/hyper_cli_exec_unix_test.go

100755100644
File mode changed.

integration-cli/hyper_cli_fip_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/go-check/check"
99
)
1010

11-
func (s *DockerSuite) TestCliFipAssociateUsedIP(c *check.C) {
11+
func (s *DockerSuite) TestCliFipAssociateUsedIPBasic(c *check.C) {
1212
printTestCaseName()
1313
defer printTestDuration(time.Now())
1414

0 commit comments

Comments
 (0)