integration: change network.CreateNoError signature to fix linting
Line 30: warning: context.Context should be the first parameter of a function (golint) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1d5748d975
commit
caec45a37f
10 changed files with 40 additions and 41 deletions
|
@ -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
|
||||
|
|
|
@ -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...)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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(),
|
||||
)
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue