mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
refactored integration tests under integration/network/macvlan to use network.Create
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
This commit is contained in:
parent
0e3012cfff
commit
0418893f0b
1 changed files with 50 additions and 89 deletions
|
@ -7,9 +7,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/network"
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/docker/docker/integration/internal/container"
|
"github.com/docker/docker/integration/internal/container"
|
||||||
|
net "github.com/docker/docker/integration/internal/network"
|
||||||
n "github.com/docker/docker/integration/network"
|
n "github.com/docker/docker/integration/network"
|
||||||
"github.com/docker/docker/internal/test/daemon"
|
"github.com/docker/docker/internal/test/daemon"
|
||||||
"github.com/gotestyourself/gotestyourself/assert"
|
"github.com/gotestyourself/gotestyourself/assert"
|
||||||
|
@ -33,16 +33,13 @@ func TestDockerNetworkMacvlanPersistance(t *testing.T) {
|
||||||
client, err := d.NewClient()
|
client, err := d.NewClient()
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
_, err = client.NetworkCreate(context.Background(), "dm-persist", types.NetworkCreate{
|
netName := "dm-persist"
|
||||||
Driver: "macvlan",
|
net.CreateNoError(t, context.Background(), client, netName,
|
||||||
Options: map[string]string{
|
net.WithMacvlan("dm-dummy0.60"),
|
||||||
"parent": "dm-dummy0.60",
|
)
|
||||||
},
|
assert.Check(t, n.IsNetworkAvailable(client, netName))
|
||||||
})
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Check(t, n.IsNetworkAvailable(client, "dm-persist"))
|
|
||||||
d.Restart(t)
|
d.Restart(t)
|
||||||
assert.Check(t, n.IsNetworkAvailable(client, "dm-persist"))
|
assert.Check(t, n.IsNetworkAvailable(client, netName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDockerNetworkMacvlan(t *testing.T) {
|
func TestDockerNetworkMacvlan(t *testing.T) {
|
||||||
|
@ -91,29 +88,25 @@ func testMacvlanOverlapParent(client client.APIClient) func(*testing.T) {
|
||||||
n.CreateMasterDummy(t, master)
|
n.CreateMasterDummy(t, master)
|
||||||
defer n.DeleteInterface(t, master)
|
defer n.DeleteInterface(t, master)
|
||||||
|
|
||||||
_, err := client.NetworkCreate(context.Background(), "dm-subinterface", types.NetworkCreate{
|
netName := "dm-subinterface"
|
||||||
Driver: "macvlan",
|
parentName := "dm-dummy0.40"
|
||||||
Options: map[string]string{
|
net.CreateNoError(t, context.Background(), client, netName,
|
||||||
"parent": "dm-dummy0.40",
|
net.WithMacvlan(parentName),
|
||||||
},
|
)
|
||||||
})
|
assert.Check(t, n.IsNetworkAvailable(client, netName))
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Check(t, n.IsNetworkAvailable(client, "dm-subinterface"))
|
|
||||||
|
|
||||||
_, err = client.NetworkCreate(context.Background(), "dm-parent-net-overlap", types.NetworkCreate{
|
_, err := net.Create(context.Background(), client, "dm-parent-net-overlap",
|
||||||
Driver: "macvlan",
|
net.WithMacvlan(parentName),
|
||||||
Options: map[string]string{
|
)
|
||||||
"parent": "dm-dummy0.40",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
assert.Check(t, err != nil)
|
assert.Check(t, err != nil)
|
||||||
|
|
||||||
// delete the network while preserving the parent link
|
// delete the network while preserving the parent link
|
||||||
err = client.NetworkRemove(context.Background(), "dm-subinterface")
|
err = client.NetworkRemove(context.Background(), netName)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
assert.Check(t, n.IsNetworkNotAvailable(client, "dm-subinterface"))
|
assert.Check(t, n.IsNetworkNotAvailable(client, netName))
|
||||||
// verify the network delete did not delete the predefined link
|
// verify the network delete did not delete the predefined link
|
||||||
n.LinkExists(t, "dm-dummy0")
|
n.LinkExists(t, master)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,26 +114,24 @@ func testMacvlanSubinterface(client client.APIClient) func(*testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
// verify the same parent interface cannot be used if already in use by an existing network
|
// verify the same parent interface cannot be used if already in use by an existing network
|
||||||
master := "dm-dummy0"
|
master := "dm-dummy0"
|
||||||
|
parentName := "dm-dummy0.20"
|
||||||
n.CreateMasterDummy(t, master)
|
n.CreateMasterDummy(t, master)
|
||||||
defer n.DeleteInterface(t, master)
|
defer n.DeleteInterface(t, master)
|
||||||
n.CreateVlanInterface(t, master, "dm-dummy0.20", "20")
|
n.CreateVlanInterface(t, master, parentName, "20")
|
||||||
|
|
||||||
_, err := client.NetworkCreate(context.Background(), "dm-subinterface", types.NetworkCreate{
|
netName := "dm-subinterface"
|
||||||
Driver: "macvlan",
|
net.CreateNoError(t, context.Background(), client, netName,
|
||||||
Options: map[string]string{
|
net.WithMacvlan(parentName),
|
||||||
"parent": "dm-dummy0.20",
|
)
|
||||||
},
|
assert.Check(t, n.IsNetworkAvailable(client, netName))
|
||||||
})
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Check(t, n.IsNetworkAvailable(client, "dm-subinterface"))
|
|
||||||
|
|
||||||
// delete the network while preserving the parent link
|
// delete the network while preserving the parent link
|
||||||
err = client.NetworkRemove(context.Background(), "dm-subinterface")
|
err := client.NetworkRemove(context.Background(), netName)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
assert.Check(t, n.IsNetworkNotAvailable(client, "dm-subinterface"))
|
assert.Check(t, n.IsNetworkNotAvailable(client, netName))
|
||||||
// verify the network delete did not delete the predefined link
|
// verify the network delete did not delete the predefined link
|
||||||
n.LinkExists(t, "dm-dummy0.20")
|
n.LinkExists(t, parentName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,34 +181,17 @@ func testMacvlanInternalMode(client client.APIClient) func(*testing.T) {
|
||||||
|
|
||||||
func testMacvlanMultiSubnet(client client.APIClient) func(*testing.T) {
|
func testMacvlanMultiSubnet(client client.APIClient) func(*testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
_, err := client.NetworkCreate(context.Background(), "dualstackbridge", types.NetworkCreate{
|
netName := "dualstackbridge"
|
||||||
Driver: "macvlan",
|
net.CreateNoError(t, context.Background(), client, netName,
|
||||||
EnableIPv6: true,
|
net.WithMacvlan(""),
|
||||||
IPAM: &network.IPAM{
|
net.WithIPv6(),
|
||||||
Config: []network.IPAMConfig{
|
net.WithIPAM("172.28.100.0/24", ""),
|
||||||
{
|
net.WithIPAM("172.28.102.0/24", "172.28.102.254"),
|
||||||
Subnet: "172.28.100.0/24",
|
net.WithIPAM("2001:db8:abc2::/64", ""),
|
||||||
AuxAddress: map[string]string{},
|
net.WithIPAM("2001:db8:abc4::/64", "2001:db8:abc4::254"),
|
||||||
},
|
)
|
||||||
{
|
|
||||||
Subnet: "172.28.102.0/24",
|
assert.Check(t, n.IsNetworkAvailable(client, netName))
|
||||||
Gateway: "172.28.102.254",
|
|
||||||
AuxAddress: map[string]string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Subnet: "2001:db8:abc2::/64",
|
|
||||||
AuxAddress: map[string]string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Subnet: "2001:db8:abc4::/64",
|
|
||||||
Gateway: "2001:db8:abc4::254",
|
|
||||||
AuxAddress: map[string]string{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Check(t, n.IsNetworkAvailable(client, "dualstackbridge"))
|
|
||||||
|
|
||||||
// start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.100.0/24 and 2001:db8:abc2::/64
|
// start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.100.0/24 and 2001:db8:abc2::/64
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -276,28 +250,15 @@ func testMacvlanMultiSubnet(client client.APIClient) func(*testing.T) {
|
||||||
func testMacvlanAddressing(client client.APIClient) func(*testing.T) {
|
func testMacvlanAddressing(client client.APIClient) func(*testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
// Ensure the default gateways, next-hops and default dev devices are properly set
|
// Ensure the default gateways, next-hops and default dev devices are properly set
|
||||||
_, err := client.NetworkCreate(context.Background(), "dualstackbridge", types.NetworkCreate{
|
netName := "dualstackbridge"
|
||||||
Driver: "macvlan",
|
net.CreateNoError(t, context.Background(), client, netName,
|
||||||
EnableIPv6: true,
|
net.WithMacvlan(""),
|
||||||
Options: map[string]string{
|
net.WithIPv6(),
|
||||||
"macvlan_mode": "bridge",
|
net.WithOption("macvlan_mode", "bridge"),
|
||||||
},
|
net.WithIPAM("172.28.130.0/24", ""),
|
||||||
IPAM: &network.IPAM{
|
net.WithIPAM("2001:db8:abca::/64", "2001:db8:abca::254"),
|
||||||
Config: []network.IPAMConfig{
|
)
|
||||||
{
|
assert.Check(t, n.IsNetworkAvailable(client, netName))
|
||||||
Subnet: "172.28.130.0/24",
|
|
||||||
AuxAddress: map[string]string{},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Subnet: "2001:db8:abca::/64",
|
|
||||||
Gateway: "2001:db8:abca::254",
|
|
||||||
AuxAddress: map[string]string{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
assert.NilError(t, err)
|
|
||||||
assert.Check(t, n.IsNetworkAvailable(client, "dualstackbridge"))
|
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
id1 := container.Run(t, ctx, client,
|
id1 := container.Run(t, ctx, client,
|
||||||
|
|
Loading…
Add table
Reference in a new issue