Add tests of unsupported network-scoped alias on default networks
| ... | ... |
@@ -801,8 +801,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *check.C) {
|
| 801 | 801 |
c.Assert(err, check.NotNil) |
| 802 | 802 |
} |
| 803 | 803 |
|
| 804 |
-func (s *DockerNetworkSuite) TestDockerNetworkLinkOndefaultNetworkOnly(c *check.C) {
|
|
| 805 |
- // Link feature must work only on default network, and not across networks |
|
| 804 |
+func (s *DockerNetworkSuite) TestDockerNetworkLinkOnDefaultNetworkOnly(c *check.C) {
|
|
| 805 |
+ // Legacy Link feature must work only on default network, and not across networks |
|
| 806 | 806 |
cnt1 := "container1" |
| 807 | 807 |
cnt2 := "container2" |
| 808 | 808 |
network := "anotherbridge" |
| ... | ... |
@@ -1314,6 +1314,19 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *check.C) {
|
| 1314 | 1314 |
c.Assert(networks, checker.Not(checker.Contains), "bridge", check.Commentf("Should not contain 'bridge' network"))
|
| 1315 | 1315 |
} |
| 1316 | 1316 |
|
| 1317 |
+func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(c *check.C) {
|
|
| 1318 |
+ testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) |
|
| 1319 |
+ |
|
| 1320 |
+ defaults := []string{"bridge", "host", "none"}
|
|
| 1321 |
+ out, _ := dockerCmd(c, "run", "-d", "--net=none", "busybox", "top") |
|
| 1322 |
+ containerID := strings.TrimSpace(out) |
|
| 1323 |
+ for _, net := range defaults {
|
|
| 1324 |
+ res, _, err := dockerCmdWithError("network", "connect", "--alias", "alias"+net, net, containerID)
|
|
| 1325 |
+ c.Assert(err, checker.NotNil) |
|
| 1326 |
+ c.Assert(res, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error()) |
|
| 1327 |
+ } |
|
| 1328 |
+} |
|
| 1329 |
+ |
|
| 1317 | 1330 |
func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *check.C) {
|
| 1318 | 1331 |
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) |
| 1319 | 1332 |
dockerCmd(c, "network", "create", "-d", "bridge", "net1") |
| ... | ... |
@@ -273,6 +273,17 @@ func (s *DockerSuite) TestUserDefinedNetworkLinksWithRestart(c *check.C) {
|
| 273 | 273 |
c.Assert(err, check.IsNil) |
| 274 | 274 |
} |
| 275 | 275 |
|
| 276 |
+func (s *DockerSuite) TestRunWithNetAliasOnDefaultNetworks(c *check.C) {
|
|
| 277 |
+ testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) |
|
| 278 |
+ |
|
| 279 |
+ defaults := []string{"bridge", "host", "none"}
|
|
| 280 |
+ for _, net := range defaults {
|
|
| 281 |
+ out, _, err := dockerCmdWithError("run", "-d", "--net", net, "--net-alias", "alias_"+net, "busybox", "top")
|
|
| 282 |
+ c.Assert(err, checker.NotNil) |
|
| 283 |
+ c.Assert(out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error()) |
|
| 284 |
+ } |
|
| 285 |
+} |
|
| 286 |
+ |
|
| 276 | 287 |
func (s *DockerSuite) TestUserDefinedNetworkAlias(c *check.C) {
|
| 277 | 288 |
testRequires(c, DaemonIsLinux, NotUserNamespace, NotArm) |
| 278 | 289 |
dockerCmd(c, "network", "create", "-d", "bridge", "net1") |