mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #37044 from yongtang/03112018-TestDockerNetworkConnectAlias-name
Avoid unique name usage in TestDockerNetworkConnectAlias
This commit is contained in:
commit
829dcefa9d
1 changed files with 9 additions and 9 deletions
|
@ -20,14 +20,14 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
name := "test-alias"
|
name := t.Name() + "test-alias"
|
||||||
_, err := client.NetworkCreate(ctx, name, types.NetworkCreate{
|
_, err := client.NetworkCreate(ctx, name, types.NetworkCreate{
|
||||||
Driver: "overlay",
|
Driver: "overlay",
|
||||||
Attachable: true,
|
Attachable: true,
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
container.Create(t, ctx, client, container.WithName("ng1"), func(c *container.TestContainerConfig) {
|
cID1 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
|
||||||
c.NetworkingConfig = &network.NetworkingConfig{
|
c.NetworkingConfig = &network.NetworkingConfig{
|
||||||
map[string]*network.EndpointSettings{
|
map[string]*network.EndpointSettings{
|
||||||
name: {},
|
name: {},
|
||||||
|
@ -35,22 +35,22 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
err = client.NetworkConnect(ctx, name, "ng1", &network.EndpointSettings{
|
err = client.NetworkConnect(ctx, name, cID1, &network.EndpointSettings{
|
||||||
Aliases: []string{
|
Aliases: []string{
|
||||||
"aaa",
|
"aaa",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
err = client.ContainerStart(ctx, "ng1", types.ContainerStartOptions{})
|
err = client.ContainerStart(ctx, cID1, types.ContainerStartOptions{})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
ng1, err := client.ContainerInspect(ctx, "ng1")
|
ng1, err := client.ContainerInspect(ctx, cID1)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Check(t, is.Equal(len(ng1.NetworkSettings.Networks[name].Aliases), 2))
|
assert.Check(t, is.Equal(len(ng1.NetworkSettings.Networks[name].Aliases), 2))
|
||||||
assert.Check(t, is.Equal(ng1.NetworkSettings.Networks[name].Aliases[0], "aaa"))
|
assert.Check(t, is.Equal(ng1.NetworkSettings.Networks[name].Aliases[0], "aaa"))
|
||||||
|
|
||||||
container.Create(t, ctx, client, container.WithName("ng2"), func(c *container.TestContainerConfig) {
|
cID2 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
|
||||||
c.NetworkingConfig = &network.NetworkingConfig{
|
c.NetworkingConfig = &network.NetworkingConfig{
|
||||||
map[string]*network.EndpointSettings{
|
map[string]*network.EndpointSettings{
|
||||||
name: {},
|
name: {},
|
||||||
|
@ -58,17 +58,17 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
err = client.NetworkConnect(ctx, name, "ng2", &network.EndpointSettings{
|
err = client.NetworkConnect(ctx, name, cID2, &network.EndpointSettings{
|
||||||
Aliases: []string{
|
Aliases: []string{
|
||||||
"bbb",
|
"bbb",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
err = client.ContainerStart(ctx, "ng2", types.ContainerStartOptions{})
|
err = client.ContainerStart(ctx, cID2, types.ContainerStartOptions{})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
ng2, err := client.ContainerInspect(ctx, "ng2")
|
ng2, err := client.ContainerInspect(ctx, cID2)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Check(t, is.Equal(len(ng2.NetworkSettings.Networks[name].Aliases), 2))
|
assert.Check(t, is.Equal(len(ng2.NetworkSettings.Networks[name].Aliases), 2))
|
||||||
assert.Check(t, is.Equal(ng2.NetworkSettings.Networks[name].Aliases[0], "bbb"))
|
assert.Check(t, is.Equal(ng2.NetworkSettings.Networks[name].Aliases[0], "bbb"))
|
||||||
|
|
Loading…
Reference in a new issue