diff --git a/integration/container/run_linux_test.go b/integration/container/run_linux_test.go index e2c1c524a4..2cb806f13f 100644 --- a/integration/container/run_linux_test.go +++ b/integration/container/run_linux_test.go @@ -108,7 +108,7 @@ func TestHostnameDnsResolution(t *testing.T) { // using user defined network as we want to use internal DNS netName := "foobar-net" - net.CreateNoError(t, context.Background(), client, netName, net.WithDriver("bridge")) + net.CreateNoError(context.Background(), t, client, netName, net.WithDriver("bridge")) cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) { c.Config.Hostname = hostname diff --git a/integration/internal/network/network.go b/integration/internal/network/network.go index 07d366433b..c8194d7898 100644 --- a/integration/internal/network/network.go +++ b/integration/internal/network/network.go @@ -26,8 +26,7 @@ func Create(ctx context.Context, client client.APIClient, name string, ops ...fu } // CreateNoError creates a network with the specified options and verifies there were no errors -// nolint: golint -func CreateNoError(t *testing.T, ctx context.Context, client client.APIClient, name string, ops ...func(*types.NetworkCreate)) string { // nolint: golint +func CreateNoError(ctx context.Context, t *testing.T, client client.APIClient, name string, ops ...func(*types.NetworkCreate)) string { // nolint: golint t.Helper() name, err := createNetwork(ctx, client, name, ops...) diff --git a/integration/network/delete_test.go b/integration/network/delete_test.go index 5989eba169..fd200e4fce 100644 --- a/integration/network/delete_test.go +++ b/integration/network/delete_test.go @@ -28,9 +28,9 @@ func containsNetwork(nws []types.NetworkResource, networkID string) bool { // // After successful creation, properties of all three networks is returned func createAmbiguousNetworks(t *testing.T, ctx context.Context, client dclient.APIClient) (string, string, string) { // nolint: golint - testNet := network.CreateNoError(t, ctx, client, "testNet") - idPrefixNet := network.CreateNoError(t, ctx, client, testNet[:12]) - fullIDNet := network.CreateNoError(t, ctx, client, testNet) + testNet := network.CreateNoError(ctx, t, client, "testNet") + idPrefixNet := network.CreateNoError(ctx, t, client, testNet[:12]) + fullIDNet := network.CreateNoError(ctx, t, client, testNet) nws, err := client.NetworkList(ctx, types.NetworkListOptions{}) assert.NilError(t, err) @@ -49,7 +49,7 @@ func TestNetworkCreateDelete(t *testing.T) { ctx := context.Background() netName := "testnetwork_" + t.Name() - network.CreateNoError(t, ctx, client, netName, + network.CreateNoError(ctx, t, client, netName, network.WithCheckDuplicate(), ) assert.Check(t, IsNetworkAvailable(client, netName)) diff --git a/integration/network/inspect_test.go b/integration/network/inspect_test.go index 02d2b754f5..dabf96926f 100644 --- a/integration/network/inspect_test.go +++ b/integration/network/inspect_test.go @@ -21,7 +21,7 @@ func TestInspectNetwork(t *testing.T) { defer c.Close() networkName := "Overlay" + t.Name() - overlayID := network.CreateNoError(t, context.Background(), c, networkName, + overlayID := network.CreateNoError(context.Background(), t, c, networkName, network.WithDriver("overlay"), network.WithCheckDuplicate(), ) diff --git a/integration/network/ipvlan/ipvlan_test.go b/integration/network/ipvlan/ipvlan_test.go index 9b98ace41d..60cf610794 100644 --- a/integration/network/ipvlan/ipvlan_test.go +++ b/integration/network/ipvlan/ipvlan_test.go @@ -36,7 +36,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) { // create a network specifying the desired sub-interface name netName := "di-persist" - net.CreateNoError(t, context.Background(), c, netName, + net.CreateNoError(context.Background(), t, c, netName, net.WithIPvlan("di-dummy0.70", ""), ) @@ -102,7 +102,7 @@ func testIpvlanSubinterface(client dclient.APIClient) func(*testing.T) { defer n.DeleteInterface(t, master) netName := "di-subinterface" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan("di-dummy0.60", ""), ) assert.Check(t, n.IsNetworkAvailable(client, netName)) @@ -127,7 +127,7 @@ func testIpvlanOverlapParent(client dclient.APIClient) func(*testing.T) { n.CreateVlanInterface(t, master, parent, "30") netName := "di-subinterface" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan(parent, ""), ) assert.Check(t, n.IsNetworkAvailable(client, netName)) @@ -144,7 +144,7 @@ func testIpvlanL2NilParent(client dclient.APIClient) func(*testing.T) { return func(t *testing.T) { // ipvlan l2 mode - dummy parent interface is provisioned dynamically netName := "di-nil-parent" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan("", ""), ) assert.Check(t, n.IsNetworkAvailable(client, netName)) @@ -161,7 +161,7 @@ func testIpvlanL2NilParent(client dclient.APIClient) func(*testing.T) { func testIpvlanL2InternalMode(client dclient.APIClient) func(*testing.T) { return func(t *testing.T) { netName := "di-internal" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan("", ""), net.WithInternal(), ) @@ -186,7 +186,7 @@ func testIpvlanL2InternalMode(client dclient.APIClient) func(*testing.T) { func testIpvlanL3NilParent(client dclient.APIClient) func(*testing.T) { return func(t *testing.T) { netName := "di-nil-parent-l3" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan("", "l3"), net.WithIPAM("172.28.230.0/24", ""), net.WithIPAM("172.28.220.0/24", ""), @@ -211,7 +211,7 @@ func testIpvlanL3NilParent(client dclient.APIClient) func(*testing.T) { func testIpvlanL3InternalMode(client dclient.APIClient) func(*testing.T) { return func(t *testing.T) { netName := "di-internal-l3" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan("", "l3"), net.WithInternal(), net.WithIPAM("172.28.230.0/24", ""), @@ -244,7 +244,7 @@ func testIpvlanL3InternalMode(client dclient.APIClient) func(*testing.T) { func testIpvlanL2MultiSubnet(client dclient.APIClient) func(*testing.T) { return func(t *testing.T) { netName := "dualstackl2" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan("", ""), net.WithIPv6(), net.WithIPAM("172.28.200.0/24", ""), @@ -311,7 +311,7 @@ func testIpvlanL2MultiSubnet(client dclient.APIClient) func(*testing.T) { func testIpvlanL3MultiSubnet(client dclient.APIClient) func(*testing.T) { return func(t *testing.T) { netName := "dualstackl3" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithIPvlan("", "l3"), net.WithIPv6(), net.WithIPAM("172.28.10.0/24", ""), @@ -380,7 +380,7 @@ func testIpvlanAddressing(client dclient.APIClient) func(*testing.T) { // Verify ipvlan l2 mode sets the proper default gateway routes via netlink // for either an explicitly set route by the user or inferred via default IPAM netNameL2 := "dualstackl2" - net.CreateNoError(t, context.Background(), client, netNameL2, + net.CreateNoError(context.Background(), t, client, netNameL2, net.WithIPvlan("", "l2"), net.WithIPv6(), net.WithIPAM("172.28.140.0/24", "172.28.140.254"), @@ -403,7 +403,7 @@ func testIpvlanAddressing(client dclient.APIClient) func(*testing.T) { // Validate ipvlan l3 mode sets the v4 gateway to dev eth0 and disregards any explicit or inferred next-hops netNameL3 := "dualstackl3" - net.CreateNoError(t, context.Background(), client, netNameL3, + net.CreateNoError(context.Background(), t, client, netNameL3, net.WithIPvlan("", "l3"), net.WithIPv6(), net.WithIPAM("172.28.160.0/24", "172.28.160.254"), diff --git a/integration/network/macvlan/macvlan_test.go b/integration/network/macvlan/macvlan_test.go index 164dc4d0db..8927abe007 100644 --- a/integration/network/macvlan/macvlan_test.go +++ b/integration/network/macvlan/macvlan_test.go @@ -33,7 +33,7 @@ func TestDockerNetworkMacvlanPersistance(t *testing.T) { c := d.NewClientT(t) netName := "dm-persist" - net.CreateNoError(t, context.Background(), c, netName, + net.CreateNoError(context.Background(), t, c, netName, net.WithMacvlan("dm-dummy0.60"), ) assert.Check(t, n.IsNetworkAvailable(c, netName)) @@ -86,7 +86,7 @@ func testMacvlanOverlapParent(client client.APIClient) func(*testing.T) { netName := "dm-subinterface" parentName := "dm-dummy0.40" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithMacvlan(parentName), ) assert.Check(t, n.IsNetworkAvailable(client, netName)) @@ -116,7 +116,7 @@ func testMacvlanSubinterface(client client.APIClient) func(*testing.T) { n.CreateVlanInterface(t, master, parentName, "20") netName := "dm-subinterface" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithMacvlan(parentName), ) assert.Check(t, n.IsNetworkAvailable(client, netName)) @@ -135,7 +135,7 @@ func testMacvlanNilParent(client client.APIClient) func(*testing.T) { return func(t *testing.T) { // macvlan bridge mode - dummy parent interface is provisioned dynamically netName := "dm-nil-parent" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithMacvlan(""), ) assert.Check(t, n.IsNetworkAvailable(client, netName)) @@ -153,7 +153,7 @@ func testMacvlanInternalMode(client client.APIClient) func(*testing.T) { return func(t *testing.T) { // macvlan bridge mode - dummy parent interface is provisioned dynamically netName := "dm-internal" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithMacvlan(""), net.WithInternal(), ) @@ -178,7 +178,7 @@ func testMacvlanInternalMode(client client.APIClient) func(*testing.T) { func testMacvlanMultiSubnet(client client.APIClient) func(*testing.T) { return func(t *testing.T) { netName := "dualstackbridge" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithMacvlan(""), net.WithIPv6(), net.WithIPAM("172.28.100.0/24", ""), @@ -247,7 +247,7 @@ func testMacvlanAddressing(client client.APIClient) func(*testing.T) { return func(t *testing.T) { // Ensure the default gateways, next-hops and default dev devices are properly set netName := "dualstackbridge" - net.CreateNoError(t, context.Background(), client, netName, + net.CreateNoError(context.Background(), t, client, netName, net.WithMacvlan(""), net.WithIPv6(), net.WithOption("macvlan_mode", "bridge"), diff --git a/integration/network/service_test.go b/integration/network/service_test.go index 8c5bc80a0e..26c2b4a620 100644 --- a/integration/network/service_test.go +++ b/integration/network/service_test.go @@ -71,7 +71,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) { // Create a bridge network and verify its subnet is the second default pool name := "elango" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("bridge"), ) out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}) @@ -80,7 +80,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) { // Create a bridge network and verify its subnet is the third default pool name = "saanvi" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("bridge"), ) out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}) @@ -103,7 +103,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) { // Create a bridge network name := "elango" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("bridge"), ) @@ -136,7 +136,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { // Create a bridge network name := "elango" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("bridge"), ) @@ -147,7 +147,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { // Create a bridge network name = "sthira" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("bridge"), ) out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}) @@ -162,7 +162,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { // Create a bridge network name = "saanvi" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("bridge"), ) out1, err := c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}) @@ -341,7 +341,7 @@ func TestServiceWithDataPathPortInit(t *testing.T) { // Create a overlay network name := "saanvisthira" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("overlay")) var instances uint64 = 1 @@ -367,7 +367,7 @@ func TestServiceWithDataPathPortInit(t *testing.T) { // Create a overlay network name = "saanvisthira" + t.Name() - network.CreateNoError(t, context.Background(), c, name, + network.CreateNoError(context.Background(), t, c, name, network.WithDriver("overlay")) serviceID = swarm.CreateService(t, d, @@ -400,7 +400,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) { // Create a overlay network name := "saanvisthira" + t.Name() - network.CreateNoError(t, context.Background(), cli, name, + network.CreateNoError(context.Background(), t, cli, name, network.WithDriver("overlay")) var instances uint64 = 1 diff --git a/integration/service/create_test.go b/integration/service/create_test.go index 625ad93302..47e1b3f4dc 100644 --- a/integration/service/create_test.go +++ b/integration/service/create_test.go @@ -84,7 +84,7 @@ func TestCreateServiceMultipleTimes(t *testing.T) { ctx := context.Background() overlayName := "overlay1_" + t.Name() - overlayID := network.CreateNoError(t, ctx, client, overlayName, + overlayID := network.CreateNoError(ctx, t, client, overlayName, network.WithCheckDuplicate(), network.WithDriver("overlay"), ) @@ -175,11 +175,11 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) { ctx := context.Background() name := "foo_" + t.Name() - n1 := network.CreateNoError(t, ctx, client, name, network.WithDriver("bridge")) - n2 := network.CreateNoError(t, ctx, client, name, network.WithDriver("bridge")) + n1 := network.CreateNoError(ctx, t, client, name, network.WithDriver("bridge")) + n2 := network.CreateNoError(ctx, t, client, name, network.WithDriver("bridge")) // Duplicates with name but with different driver - n3 := network.CreateNoError(t, ctx, client, name, network.WithDriver("overlay")) + n3 := network.CreateNoError(ctx, t, client, name, network.WithDriver("overlay")) // Create Service with the same name var instances uint64 = 1 diff --git a/integration/service/network_test.go b/integration/service/network_test.go index 4e8f90fe0e..9a2c4bfe1b 100644 --- a/integration/service/network_test.go +++ b/integration/service/network_test.go @@ -24,7 +24,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) { ctx := context.Background() name := t.Name() + "test-alias" - net.CreateNoError(t, ctx, client, name, + net.CreateNoError(ctx, t, client, name, net.WithDriver("overlay"), net.WithAttachable(), ) diff --git a/integration/service/update_test.go b/integration/service/update_test.go index 8575e56857..93e2ab44df 100644 --- a/integration/service/update_test.go +++ b/integration/service/update_test.go @@ -207,7 +207,7 @@ func TestServiceUpdateNetwork(t *testing.T) { // Create a overlay network testNet := "testNet" + t.Name() - overlayID := network.CreateNoError(t, ctx, cli, testNet, + overlayID := network.CreateNoError(ctx, t, cli, testNet, network.WithDriver("overlay")) var instances uint64 = 1