Signed-off-by: Aditya Mishra <mishraaditya675@gmail.com>
| ... | ... |
@@ -18,7 +18,6 @@ import ( |
| 18 | 18 |
"github.com/cloudflare/cfssl/csr" |
| 19 | 19 |
"github.com/cloudflare/cfssl/helpers" |
| 20 | 20 |
"github.com/cloudflare/cfssl/initca" |
| 21 |
- cerrdefs "github.com/containerd/errdefs" |
|
| 22 | 21 |
"github.com/moby/moby/api/types/container" |
| 23 | 22 |
"github.com/moby/moby/api/types/swarm" |
| 24 | 23 |
"github.com/moby/moby/client" |
| ... | ... |
@@ -1019,22 +1018,3 @@ func (s *DockerSwarmSuite) TestSwarmRepeatedRootRotation(c *testing.T) {
|
| 1019 | 1019 |
currentTrustRoot = clusterTLSInfo.TrustRoot |
| 1020 | 1020 |
} |
| 1021 | 1021 |
} |
| 1022 |
- |
|
| 1023 |
-func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *testing.T) {
|
|
| 1024 |
- ctx := testutil.GetContext(c) |
|
| 1025 |
- d := s.AddDaemon(ctx, c, true, true) |
|
| 1026 |
- |
|
| 1027 |
- name := "test-scoped-network" |
|
| 1028 |
- apiclient := d.NewClientT(c) |
|
| 1029 |
- |
|
| 1030 |
- create, err := apiclient.NetworkCreate(ctx, name, client.NetworkCreateOptions{Driver: "overlay"})
|
|
| 1031 |
- assert.NilError(c, err) |
|
| 1032 |
- |
|
| 1033 |
- inspect, err := apiclient.NetworkInspect(ctx, name, client.NetworkInspectOptions{})
|
|
| 1034 |
- assert.NilError(c, err) |
|
| 1035 |
- assert.Check(c, is.Equal("swarm", inspect.Network.Scope))
|
|
| 1036 |
- assert.Check(c, is.Equal(create.ID, inspect.Network.ID)) |
|
| 1037 |
- |
|
| 1038 |
- _, err = apiclient.NetworkInspect(ctx, name, client.NetworkInspectOptions{Scope: "local"})
|
|
| 1039 |
- assert.Check(c, is.ErrorType(err, cerrdefs.IsNotFound)) |
|
| 1040 |
-} |
| ... | ... |
@@ -6,8 +6,10 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"testing" |
| 8 | 8 |
|
| 9 |
+ cerrdefs "github.com/containerd/errdefs" |
|
| 9 | 10 |
networktypes "github.com/moby/moby/api/types/network" |
| 10 | 11 |
"github.com/moby/moby/client" |
| 12 |
+ "github.com/moby/moby/v2/integration/internal/swarm" |
|
| 11 | 13 |
"github.com/moby/moby/v2/internal/testutil" |
| 12 | 14 |
"github.com/moby/moby/v2/internal/testutil/request" |
| 13 | 15 |
"gotest.tools/v3/assert" |
| ... | ... |
@@ -144,3 +146,24 @@ func TestAPINetworkFilter(t *testing.T) {
|
| 144 | 144 |
} |
| 145 | 145 |
assert.Assert(t, found, fmt.Sprintf("%s is not found", networkName))
|
| 146 | 146 |
} |
| 147 |
+ |
|
| 148 |
+func TestNetworkInspectWithScope(t *testing.T) {
|
|
| 149 |
+ ctx := setupTest(t) |
|
| 150 |
+ |
|
| 151 |
+ d := swarm.NewSwarm(ctx, t, testEnv) |
|
| 152 |
+ defer d.Stop(t) |
|
| 153 |
+ |
|
| 154 |
+ cli := d.NewClientT(t) // IMPORTANT: talk to swarm daemon |
|
| 155 |
+ |
|
| 156 |
+ name := "test-scoped-network" |
|
| 157 |
+ create, err := cli.NetworkCreate(ctx, name, client.NetworkCreateOptions{Driver: "overlay"})
|
|
| 158 |
+ assert.NilError(t, err) |
|
| 159 |
+ |
|
| 160 |
+ inspect, err := cli.NetworkInspect(ctx, name, client.NetworkInspectOptions{})
|
|
| 161 |
+ assert.NilError(t, err) |
|
| 162 |
+ assert.Check(t, is.Equal("swarm", inspect.Network.Scope))
|
|
| 163 |
+ assert.Check(t, is.Equal(create.ID, inspect.Network.ID)) |
|
| 164 |
+ |
|
| 165 |
+ _, err = cli.NetworkInspect(ctx, name, client.NetworkInspectOptions{Scope: "local"})
|
|
| 166 |
+ assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound)) |
|
| 167 |
+} |