@@ -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