Also adds internal network tests for bridge network
Signed-off-by: Chun Chen <ramichen@tencent.com>
| ... | ... |
@@ -164,6 +164,7 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
|
| 164 | 164 |
r.Options = nw.Info().DriverOptions() |
| 165 | 165 |
r.Containers = make(map[string]types.EndpointResource) |
| 166 | 166 |
buildIpamResources(r, nw) |
| 167 |
+ r.Internal = nw.Info().Internal() |
|
| 167 | 168 |
|
| 168 | 169 |
epl := nw.Endpoints() |
| 169 | 170 |
for _, e := range epl {
|
| ... | ... |
@@ -105,6 +105,7 @@ This section lists each version from latest to oldest. Each listing includes a |
| 105 | 105 |
[Docker Remote API v1.23](docker_remote_api_v1.23.md) documentation |
| 106 | 106 |
|
| 107 | 107 |
* `GET /containers/json` returns the state of the container, one of `created`, `restarting`, `running`, `paused`, `exited` or `dead`. |
| 108 |
+* `GET /networks/(name)` now returns an `Internal` field showing whether the network is internal or not. |
|
| 108 | 109 |
|
| 109 | 110 |
|
| 110 | 111 |
### v1.22 API changes |
| ... | ... |
@@ -621,6 +621,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkInspectCustomSpecified(c *check.C) |
| 621 | 621 |
c.Assert(nr.IPAM.Config[0].Subnet, checker.Equals, "172.28.0.0/16") |
| 622 | 622 |
c.Assert(nr.IPAM.Config[0].IPRange, checker.Equals, "172.28.5.0/24") |
| 623 | 623 |
c.Assert(nr.IPAM.Config[0].Gateway, checker.Equals, "172.28.5.254") |
| 624 |
+ c.Assert(nr.Internal, checker.False) |
|
| 624 | 625 |
dockerCmd(c, "network", "rm", "br0") |
| 625 | 626 |
assertNwNotAvailable(c, "test01") |
| 626 | 627 |
} |
| ... | ... |
@@ -1387,3 +1388,19 @@ func (s *DockerSuite) TestDockerNetworkConnectFailsNoInspectChange(c *check.C) {
|
| 1387 | 1387 |
ns1 := inspectField(c, "bb", "NetworkSettings.Networks.bridge") |
| 1388 | 1388 |
c.Assert(ns1, check.Equals, ns0) |
| 1389 | 1389 |
} |
| 1390 |
+ |
|
| 1391 |
+func (s *DockerNetworkSuite) TestDockerNetworkInternalMode(c *check.C) {
|
|
| 1392 |
+ dockerCmd(c, "network", "create", "--driver=bridge", "--internal", "internal") |
|
| 1393 |
+ assertNwIsAvailable(c, "internal") |
|
| 1394 |
+ nr := getNetworkResource(c, "internal") |
|
| 1395 |
+ c.Assert(nr.Internal, checker.True) |
|
| 1396 |
+ |
|
| 1397 |
+ dockerCmd(c, "run", "-d", "--net=internal", "--name=first", "busybox", "top") |
|
| 1398 |
+ c.Assert(waitRun("first"), check.IsNil)
|
|
| 1399 |
+ dockerCmd(c, "run", "-d", "--net=internal", "--name=second", "busybox", "top") |
|
| 1400 |
+ c.Assert(waitRun("second"), check.IsNil)
|
|
| 1401 |
+ _, _, err := dockerCmdWithError("exec", "first", "ping", "-c", "1", "www.google.com")
|
|
| 1402 |
+ c.Assert(err, check.NotNil) |
|
| 1403 |
+ _, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
|
|
| 1404 |
+ c.Assert(err, check.IsNil) |
|
| 1405 |
+} |