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

Commit 2059080

Browse files
authored
Merge pull request #227 from carmark/test_fip_name
add fip name test case
2 parents 71f0d5d + 2138d6d commit 2059080

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

integration-cli/hyper_cli_fip_test.go

100755100644
Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (s *DockerSuite) TestCliFipAssociateUsedIP(c *check.C) {
3131
c.Assert(out, checker.Equals, firstIP+"\n")
3232
}
3333

34-
func (s *DockerSuite) TestCliFipAssociateConfedContainer(c *check.C) {
34+
func (s *DockerSuite) TestCliFipAttachConfedContainer(c *check.C) {
3535
printTestCaseName()
3636
defer printTestDuration(time.Now())
3737

@@ -55,7 +55,7 @@ func (s *DockerSuite) TestCliFipAssociateConfedContainer(c *check.C) {
5555
c.Assert(out, checker.Equals, firstIP+"\n")
5656
}
5757

58-
func (s *DockerSuite) TestCliFipDisattachUnconfedContainer(c *check.C) {
58+
func (s *DockerSuite) TestCliFipDettachUnconfedContainer(c *check.C) {
5959
printTestCaseName()
6060
defer printTestDuration(time.Now())
6161

@@ -97,3 +97,39 @@ func (s *DockerSuite) TestCliFipReleaseInvalidIP(c *check.C) {
9797
out, _, err = dockerCmdWithError("fip", "release", "0.0.0.0")
9898
c.Assert(err, checker.NotNil, check.Commentf("Should fail.", out, err))
9999
}
100+
101+
func (s *DockerSuite) TestCliFipName(c *check.C) {
102+
printTestCaseName()
103+
defer printTestDuration(time.Now())
104+
105+
out, _ := dockerCmd(c, "fip", "allocate", "-y", "1")
106+
firstIP := strings.TrimSpace(out)
107+
fipList := []string{firstIP}
108+
109+
out, _ = dockerCmd(c, "fip", "allocate", "-y", "1")
110+
secondIP := strings.TrimSpace(out)
111+
fipList = append(fipList, secondIP)
112+
113+
defer releaseFip(c, fipList)
114+
115+
pullImageIfNotExist("busybox")
116+
out, _ = runSleepingContainer(c, "-d")
117+
firstContainerID := strings.TrimSpace(out)
118+
119+
// multiple FIPs without name, attach one with container
120+
dockerCmd(c, "fip", "attach", secondIP, firstContainerID)
121+
out, _ = dockerCmd(c, "fip", "detach", firstContainerID)
122+
c.Assert(out, checker.Equals, secondIP+"\n")
123+
124+
// multiple FIPs (one FIP has name), attach one with container
125+
dockerCmd(c, "fip", "name", secondIP, "ip2")
126+
dockerCmd(c, "fip", "attach", secondIP, firstContainerID)
127+
out, _ = dockerCmd(c, "fip", "detach", firstContainerID)
128+
c.Assert(out, checker.Equals, secondIP+"\n")
129+
130+
// multiple FIPs (two FIPs have name), attach one with container
131+
dockerCmd(c, "fip", "name", firstIP, "ip1")
132+
dockerCmd(c, "fip", "attach", secondIP, firstContainerID)
133+
out, _ = dockerCmd(c, "fip", "detach", firstContainerID)
134+
c.Assert(out, checker.Equals, secondIP+"\n")
135+
}

0 commit comments

Comments
 (0)