|
@@ -21,9 +21,9 @@ import (
|
|
|
"github.com/docker/libnetwork/datastore"
|
|
|
"github.com/docker/libnetwork/driverapi"
|
|
|
"github.com/docker/libnetwork/netlabel"
|
|
|
- "github.com/docker/libnetwork/netutils"
|
|
|
"github.com/docker/libnetwork/options"
|
|
|
"github.com/docker/libnetwork/osl"
|
|
|
+ "github.com/docker/libnetwork/testutils"
|
|
|
"github.com/docker/libnetwork/types"
|
|
|
"github.com/vishvananda/netlink"
|
|
|
"github.com/vishvananda/netns"
|
|
@@ -256,8 +256,8 @@ func TestHost(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestBridge(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
|
@@ -329,8 +329,8 @@ func TestBridge(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestUnknownDriver(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
_, err := createTestNetwork("unknowndriver", "testnetwork", options.Generic{})
|
|
@@ -356,8 +356,8 @@ func TestNilRemoteDriver(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestDuplicateNetwork(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
// Creating a default bridge name network (can't be removed)
|
|
@@ -377,8 +377,8 @@ func TestDuplicateNetwork(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestNetworkName(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
netOption := options.Generic{
|
|
@@ -414,8 +414,8 @@ func TestNetworkName(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestNetworkType(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
netOption := options.Generic{
|
|
@@ -441,8 +441,8 @@ func TestNetworkType(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestNetworkID(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
netOption := options.Generic{
|
|
@@ -468,8 +468,8 @@ func TestNetworkID(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
netOption := options.Generic{
|
|
@@ -509,8 +509,8 @@ func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestUnknownNetwork(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
netOption := options.Generic{
|
|
@@ -541,8 +541,8 @@ func TestUnknownNetwork(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestUnknownEndpoint(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
|
@@ -589,8 +589,8 @@ func TestUnknownEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestNetworkEndpointsWalkers(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
// Create network 1 and add 2 endpoint: ep11, ep12
|
|
@@ -721,8 +721,8 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestDuplicateEndpoint(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
netOption := options.Generic{
|
|
@@ -771,8 +771,8 @@ func TestDuplicateEndpoint(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestControllerQuery(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
// Create network 1
|
|
@@ -875,8 +875,8 @@ func TestControllerQuery(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestNetworkQuery(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
// Create network 1 and add 2 endpoint: ep11, ep12
|
|
@@ -997,8 +997,8 @@ func checkSandbox(t *testing.T, info libnetwork.EndpointInfo) {
|
|
|
}
|
|
|
|
|
|
func TestEndpointJoin(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
// Create network 1 and add 2 endpoint: ep11, ep12
|
|
@@ -1189,8 +1189,8 @@ func (f *fakeSandbox) Delete() error {
|
|
|
}
|
|
|
|
|
|
func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
|
@@ -1253,8 +1253,8 @@ func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestEndpointMultipleJoins(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
n, err := createTestNetwork(bridgeNetType, "testmultiple", options.Generic{
|
|
@@ -1325,8 +1325,8 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestLeaveAll(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
|
@@ -1389,8 +1389,8 @@ func TestLeaveAll(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestontainerInvalidLeave(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
|
@@ -1456,8 +1456,8 @@ func TestontainerInvalidLeave(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestEndpointUpdateParent(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
n, err := createTestNetwork("bridge", "testnetwork", options.Generic{
|
|
@@ -1542,8 +1542,8 @@ func TestEndpointUpdateParent(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestEnableIPv6(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\nnameserver 2001:4860:4860::8888\n")
|
|
@@ -1638,8 +1638,8 @@ func TestEnableIPv6(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestResolvConfHost(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
tmpResolvConf := []byte("search localhost.net\nnameserver 127.0.0.1\nnameserver 2001:4860:4860::8888\n")
|
|
@@ -1717,8 +1717,8 @@ func TestResolvConfHost(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestResolvConf(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
- defer osl.SetupTestOSContext(t)()
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
+ defer testutils.SetupTestOSContext(t)()
|
|
|
}
|
|
|
|
|
|
tmpResolvConf1 := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\nnameserver 2001:4860:4860::8888\n")
|
|
@@ -1870,7 +1870,7 @@ func TestResolvConf(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestInvalidRemoteDriver(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
t.Skip("Skipping test when not running inside a Container")
|
|
|
}
|
|
|
|
|
@@ -1920,7 +1920,7 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestValidRemoteDriver(t *testing.T) {
|
|
|
- if !netutils.IsRunningInContainer() {
|
|
|
+ if !testutils.IsRunningInContainer() {
|
|
|
t.Skip("Skipping test when not running inside a Container")
|
|
|
}
|
|
|
|
|
@@ -1999,7 +1999,7 @@ func createGlobalInstance(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
|
- if netutils.IsRunningInContainer() {
|
|
|
+ if testutils.IsRunningInContainer() {
|
|
|
testns = origns
|
|
|
} else {
|
|
|
testns, err = netns.New()
|