Skip to content

Commit

Permalink
refactored network integration tests under integration/network/servic…
Browse files Browse the repository at this point in the history
…e_test.go to use network package

Signed-off-by: Arash Deshmeh <[email protected]>
  • Loading branch information
adshmh committed Jun 12, 2018
1 parent a9fbbdc commit 6940471
Showing 1 changed file with 19 additions and 36 deletions.
55 changes: 19 additions & 36 deletions integration/network/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
swarmtypes "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/network"
"github.com/docker/docker/integration/internal/swarm"
"github.com/docker/docker/internal/test/daemon"
"github.com/gotestyourself/gotestyourself/assert"
Expand Down Expand Up @@ -66,24 +67,18 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {

// Create a bridge network and verify its subnet is the second default pool
name := "elango"
networkCreate := types.NetworkCreate{
CheckDuplicate: false,
}
networkCreate.Driver = "bridge"
_, err = cli.NetworkCreate(context.Background(), name, networkCreate)
assert.NilError(t, err)
network.CreateNoError(t, context.Background(), cli, name,
network.WithDriver("bridge"),
)
out, err = cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Equal(t, out.IPAM.Config[0].Subnet, "175.33.0.0/24")

// Create a bridge network and verify its subnet is the third default pool
name = "saanvi"
networkCreate = types.NetworkCreate{
CheckDuplicate: false,
}
networkCreate.Driver = "bridge"
_, err = cli.NetworkCreate(context.Background(), name, networkCreate)
assert.NilError(t, err)
network.CreateNoError(t, context.Background(), cli, name,
network.WithDriver("bridge"),
)
out, err = cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
assert.Equal(t, out.IPAM.Config[0].Subnet, "175.33.1.0/24")
Expand All @@ -105,12 +100,9 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {

// Create a bridge network
name := "elango"
networkCreate := types.NetworkCreate{
CheckDuplicate: false,
}
networkCreate.Driver = "bridge"
_, err = cli.NetworkCreate(context.Background(), name, networkCreate)
assert.NilError(t, err)
network.CreateNoError(t, context.Background(), cli, name,
network.WithDriver("bridge"),
)
out, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
networkip := out.IPAM.Config[0].Subnet
Expand Down Expand Up @@ -140,24 +132,18 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {

// Create a bridge network
name := "elango"
networkCreate := types.NetworkCreate{
CheckDuplicate: false,
}
networkCreate.Driver = "bridge"
_, err = cli.NetworkCreate(context.Background(), name, networkCreate)
assert.NilError(t, err)
network.CreateNoError(t, context.Background(), cli, name,
network.WithDriver("bridge"),
)
out, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
networkip := out.IPAM.Config[0].Subnet

// Create a bridge network
name = "sthira"
networkCreate = types.NetworkCreate{
CheckDuplicate: false,
}
networkCreate.Driver = "bridge"
_, err = cli.NetworkCreate(context.Background(), name, networkCreate)
assert.NilError(t, err)
network.CreateNoError(t, context.Background(), cli, name,
network.WithDriver("bridge"),
)
out, err = cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)
networkip2 := out.IPAM.Config[0].Subnet
Expand All @@ -169,12 +155,9 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {

// Create a bridge network
name = "saanvi"
networkCreate = types.NetworkCreate{
CheckDuplicate: false,
}
networkCreate.Driver = "bridge"
_, err = cli.NetworkCreate(context.Background(), name, networkCreate)
assert.NilError(t, err)
network.CreateNoError(t, context.Background(), cli, name,
network.WithDriver("bridge"),
)
out1, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
assert.NilError(t, err)

Expand Down

0 comments on commit 6940471

Please sign in to comment.