mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #499 from calavera/move_test_files
Move test specific functions to a testutils package.
This commit is contained in:
commit
c2ba4664b3
41 changed files with 203 additions and 173 deletions
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/docker/libnetwork"
|
"github.com/docker/libnetwork"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/libnetwork/options"
|
"github.com/docker/libnetwork/options"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ func TestJson(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateDeleteNetwork(t *testing.T) {
|
func TestCreateDeleteNetwork(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, err := libnetwork.New()
|
c, err := libnetwork.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -256,7 +256,7 @@ func TestCreateDeleteNetwork(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetNetworksAndEndpoints(t *testing.T) {
|
func TestGetNetworksAndEndpoints(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, err := libnetwork.New()
|
c, err := libnetwork.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -529,7 +529,7 @@ func TestGetNetworksAndEndpoints(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcGetServices(t *testing.T) {
|
func TestProcGetServices(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, err := libnetwork.New()
|
c, err := libnetwork.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -702,7 +702,7 @@ func TestProcGetServices(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcGetService(t *testing.T) {
|
func TestProcGetService(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, nw := createTestNetwork(t, "network")
|
c, nw := createTestNetwork(t, "network")
|
||||||
ep1, err := nw.CreateEndpoint("db")
|
ep1, err := nw.CreateEndpoint("db")
|
||||||
|
@ -754,7 +754,7 @@ func TestProcGetService(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcPublishUnpublishService(t *testing.T) {
|
func TestProcPublishUnpublishService(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, _ := createTestNetwork(t, "network")
|
c, _ := createTestNetwork(t, "network")
|
||||||
vars := make(map[string]string)
|
vars := make(map[string]string)
|
||||||
|
@ -886,7 +886,7 @@ func TestProcPublishUnpublishService(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAttachDetachBackend(t *testing.T) {
|
func TestAttachDetachBackend(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, nw := createTestNetwork(t, "network")
|
c, nw := createTestNetwork(t, "network")
|
||||||
ep1, err := nw.CreateEndpoint("db")
|
ep1, err := nw.CreateEndpoint("db")
|
||||||
|
@ -1026,7 +1026,7 @@ func TestDetectGetNetworksInvalidQueryComposition(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDetectGetEndpointsInvalidQueryComposition(t *testing.T) {
|
func TestDetectGetEndpointsInvalidQueryComposition(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, _ := createTestNetwork(t, "network")
|
c, _ := createTestNetwork(t, "network")
|
||||||
|
|
||||||
|
@ -1038,7 +1038,7 @@ func TestDetectGetEndpointsInvalidQueryComposition(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDetectGetServicesInvalidQueryComposition(t *testing.T) {
|
func TestDetectGetServicesInvalidQueryComposition(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, _ := createTestNetwork(t, "network")
|
c, _ := createTestNetwork(t, "network")
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ func TestFindNetworkUtilPanic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindNetworkUtil(t *testing.T) {
|
func TestFindNetworkUtil(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, nw := createTestNetwork(t, "network")
|
c, nw := createTestNetwork(t, "network")
|
||||||
nid := nw.ID()
|
nid := nw.ID()
|
||||||
|
@ -1118,7 +1118,7 @@ func TestFindNetworkUtil(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateDeleteEndpoints(t *testing.T) {
|
func TestCreateDeleteEndpoints(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, err := libnetwork.New()
|
c, err := libnetwork.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1244,7 +1244,7 @@ func TestCreateDeleteEndpoints(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJoinLeave(t *testing.T) {
|
func TestJoinLeave(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, err := libnetwork.New()
|
c, err := libnetwork.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1403,7 +1403,7 @@ func TestJoinLeave(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindEndpointUtilPanic(t *testing.T) {
|
func TestFindEndpointUtilPanic(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
defer checkPanic(t)
|
defer checkPanic(t)
|
||||||
c, nw := createTestNetwork(t, "network")
|
c, nw := createTestNetwork(t, "network")
|
||||||
nid := nw.ID()
|
nid := nw.ID()
|
||||||
|
@ -1411,14 +1411,14 @@ func TestFindEndpointUtilPanic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindServiceUtilPanic(t *testing.T) {
|
func TestFindServiceUtilPanic(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
defer checkPanic(t)
|
defer checkPanic(t)
|
||||||
c, _ := createTestNetwork(t, "network")
|
c, _ := createTestNetwork(t, "network")
|
||||||
findService(c, "random_service", -1)
|
findService(c, "random_service", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindEndpointUtil(t *testing.T) {
|
func TestFindEndpointUtil(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, nw := createTestNetwork(t, "network")
|
c, nw := createTestNetwork(t, "network")
|
||||||
nid := nw.ID()
|
nid := nw.ID()
|
||||||
|
@ -1687,7 +1687,7 @@ func TestwriteJSON(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpHandlerUninit(t *testing.T) {
|
func TestHttpHandlerUninit(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
c, err := libnetwork.New()
|
c, err := libnetwork.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1756,7 +1756,7 @@ func TestHttpHandlerUninit(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpHandlerBadBody(t *testing.T) {
|
func TestHttpHandlerBadBody(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
rsp := newWriter()
|
rsp := newWriter()
|
||||||
|
|
||||||
|
@ -1788,7 +1788,7 @@ func TestHttpHandlerBadBody(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEndToEnd(t *testing.T) {
|
func TestEndToEnd(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
rsp := newWriter()
|
rsp := newWriter()
|
||||||
|
|
||||||
|
@ -2240,7 +2240,7 @@ func TestEndToEnd(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEndToEndErrorMessage(t *testing.T) {
|
func TestEndToEndErrorMessage(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
rsp := newWriter()
|
rsp := newWriter()
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package bitseq
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSequenceGetAvailableBit(t *testing.T) {
|
func TestSequenceGetAvailableBit(t *testing.T) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClientServiceInvalidCommand(t *testing.T) {
|
func TestClientServiceInvalidCommand(t *testing.T) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nopCloser is used to provide a dummy CallFunc for Cmd()
|
// nopCloser is used to provide a dummy CallFunc for Cmd()
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/netutils"
|
"github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const dnetCommandName = "dnet"
|
const dnetCommandName = "dnet"
|
||||||
|
@ -15,7 +15,7 @@ const dnetCommandName = "dnet"
|
||||||
var origStdOut = os.Stdout
|
var origStdOut = os.Stdout
|
||||||
|
|
||||||
func TestDnetDaemonCustom(t *testing.T) {
|
func TestDnetDaemonCustom(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
t.Skip("This test must run inside a container ")
|
t.Skip("This test must run inside a container ")
|
||||||
}
|
}
|
||||||
customPort := 4567
|
customPort := 4567
|
||||||
|
@ -36,7 +36,7 @@ func TestDnetDaemonCustom(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDnetDaemonInvalidCustom(t *testing.T) {
|
func TestDnetDaemonInvalidCustom(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
t.Skip("This test must run inside a container ")
|
t.Skip("This test must run inside a container ")
|
||||||
}
|
}
|
||||||
customPort := 4668
|
customPort := 4668
|
||||||
|
@ -57,7 +57,7 @@ func TestDnetDaemonInvalidCustom(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDnetDaemonInvalidParams(t *testing.T) {
|
func TestDnetDaemonInvalidParams(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
t.Skip("This test must run inside a container ")
|
t.Skip("This test must run inside a container ")
|
||||||
}
|
}
|
||||||
args := []string{dnetCommandName, "-d=false", "-H=tcp:/127.0.0.1:8080"}
|
args := []string{dnetCommandName, "-d=false", "-H=tcp:/127.0.0.1:8080"}
|
||||||
|
@ -74,7 +74,7 @@ func TestDnetDaemonInvalidParams(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDnetDefaultsWithFlags(t *testing.T) {
|
func TestDnetDefaultsWithFlags(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
t.Skip("This test must run inside a container ")
|
t.Skip("This test must run inside a container ")
|
||||||
}
|
}
|
||||||
doneChan := make(chan bool)
|
doneChan := make(chan bool)
|
||||||
|
@ -97,7 +97,7 @@ func TestDnetDefaultsWithFlags(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDnetMain(t *testing.T) {
|
func TestDnetMain(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
t.Skip("This test must run inside a container ")
|
t.Skip("This test must run inside a container ")
|
||||||
}
|
}
|
||||||
customPort := 4568
|
customPort := 4568
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInvalidConfig(t *testing.T) {
|
func TestInvalidConfig(t *testing.T) {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/config"
|
"github.com/docker/libnetwork/config"
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
|
||||||
"github.com/docker/libnetwork/options"
|
"github.com/docker/libnetwork/options"
|
||||||
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,13 @@ import (
|
||||||
"github.com/docker/libnetwork/iptables"
|
"github.com/docker/libnetwork/iptables"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/libnetwork/netutils"
|
"github.com/docker/libnetwork/netutils"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateFullOptions(t *testing.T) {
|
func TestCreateFullOptions(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
config := &configuration{
|
config := &configuration{
|
||||||
|
@ -69,7 +69,7 @@ func TestCreateFullOptions(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreate(t *testing.T) {
|
func TestCreate(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
if err := d.Config(nil); err != nil {
|
if err := d.Config(nil); err != nil {
|
||||||
|
@ -102,7 +102,7 @@ func TestCreate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateFail(t *testing.T) {
|
func TestCreateFail(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
if err := d.Config(nil); err != nil {
|
if err := d.Config(nil); err != nil {
|
||||||
|
@ -119,7 +119,7 @@ func TestCreateFail(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateMultipleNetworks(t *testing.T) {
|
func TestCreateMultipleNetworks(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
dd, _ := d.(*driver)
|
dd, _ := d.(*driver)
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ func TestQueryEndpointInfoHairpin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
|
func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
dd, _ := d.(*driver)
|
dd, _ := d.(*driver)
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateLinkWithOptions(t *testing.T) {
|
func TestCreateLinkWithOptions(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
if err := d.Config(nil); err != nil {
|
if err := d.Config(nil); err != nil {
|
||||||
|
@ -413,7 +413,7 @@ func getPortMapping() []types.PortBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkContainers(t *testing.T) {
|
func TestLinkContainers(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ func TestValidateConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetDefaultGw(t *testing.T) {
|
func TestSetDefaultGw(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
if err := d.Config(nil); err != nil {
|
if err := d.Config(nil); err != nil {
|
||||||
|
|
|
@ -3,12 +3,12 @@ package bridge
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInterfaceDefaultName(t *testing.T) {
|
func TestInterfaceDefaultName(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{}
|
config := &networkConfiguration{}
|
||||||
if _ = newInterface(config); config.BridgeName != DefaultBridgeName {
|
if _ = newInterface(config); config.BridgeName != DefaultBridgeName {
|
||||||
|
@ -17,7 +17,7 @@ func TestInterfaceDefaultName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddressesEmptyInterface(t *testing.T) {
|
func TestAddressesEmptyInterface(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
inf := newInterface(&networkConfiguration{})
|
inf := newInterface(&networkConfiguration{})
|
||||||
addrv4, addrsv6, err := inf.addresses()
|
addrv4, addrsv6, err := inf.addresses()
|
||||||
|
|
|
@ -5,12 +5,12 @@ import (
|
||||||
|
|
||||||
"github.com/docker/libnetwork/driverapi"
|
"github.com/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLinkCreate(t *testing.T) {
|
func TestLinkCreate(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
dr := d.(*driver)
|
dr := d.(*driver)
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ func TestLinkCreate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkCreateTwo(t *testing.T) {
|
func TestLinkCreateTwo(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
if err := d.Config(nil); err != nil {
|
if err := d.Config(nil); err != nil {
|
||||||
|
@ -145,7 +145,7 @@ func TestLinkCreateTwo(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkCreateNoEnableIPv6(t *testing.T) {
|
func TestLinkCreateNoEnableIPv6(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
if err := d.Config(nil); err != nil {
|
if err := d.Config(nil); err != nil {
|
||||||
|
@ -179,7 +179,7 @@ func TestLinkCreateNoEnableIPv6(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkDelete(t *testing.T) {
|
func TestLinkDelete(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
if err := d.Config(nil); err != nil {
|
if err := d.Config(nil); err != nil {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPortMappingConfig(t *testing.T) {
|
func TestPortMappingConfig(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
d := newDriver()
|
d := newDriver()
|
||||||
|
|
||||||
config := &configuration{
|
config := &configuration{
|
||||||
|
|
|
@ -6,12 +6,12 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/netutils"
|
"github.com/docker/libnetwork/netutils"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetupNewBridge(t *testing.T) {
|
func TestSetupNewBridge(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{BridgeName: DefaultBridgeName}
|
config := &networkConfiguration{BridgeName: DefaultBridgeName}
|
||||||
br := &bridgeInterface{}
|
br := &bridgeInterface{}
|
||||||
|
@ -31,7 +31,7 @@ func TestSetupNewBridge(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupNewNonDefaultBridge(t *testing.T) {
|
func TestSetupNewNonDefaultBridge(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{BridgeName: "test0"}
|
config := &networkConfiguration{BridgeName: "test0"}
|
||||||
br := &bridgeInterface{}
|
br := &bridgeInterface{}
|
||||||
|
@ -47,7 +47,7 @@ func TestSetupNewNonDefaultBridge(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupDeviceUp(t *testing.T) {
|
func TestSetupDeviceUp(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{BridgeName: DefaultBridgeName}
|
config := &networkConfiguration{BridgeName: DefaultBridgeName}
|
||||||
br := &bridgeInterface{}
|
br := &bridgeInterface{}
|
||||||
|
@ -66,7 +66,7 @@ func TestSetupDeviceUp(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenerateRandomMAC(t *testing.T) {
|
func TestGenerateRandomMAC(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
mac1 := netutils.GenerateRandomMAC()
|
mac1 := netutils.GenerateRandomMAC()
|
||||||
mac2 := netutils.GenerateRandomMAC()
|
mac2 := netutils.GenerateRandomMAC()
|
||||||
|
|
|
@ -4,11 +4,11 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetupFixedCIDRv4(t *testing.T) {
|
func TestSetupFixedCIDRv4(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{
|
config := &networkConfiguration{
|
||||||
BridgeName: DefaultBridgeName,
|
BridgeName: DefaultBridgeName,
|
||||||
|
@ -35,7 +35,7 @@ func TestSetupFixedCIDRv4(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupBadFixedCIDRv4(t *testing.T) {
|
func TestSetupBadFixedCIDRv4(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{
|
config := &networkConfiguration{
|
||||||
BridgeName: DefaultBridgeName,
|
BridgeName: DefaultBridgeName,
|
||||||
|
|
|
@ -4,11 +4,11 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetupFixedCIDRv6(t *testing.T) {
|
func TestSetupFixedCIDRv6(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config := &networkConfiguration{}
|
config := &networkConfiguration{}
|
||||||
br := newInterface(config)
|
br := newInterface(config)
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/iptables"
|
"github.com/docker/libnetwork/iptables"
|
||||||
"github.com/docker/libnetwork/osl"
|
|
||||||
"github.com/docker/libnetwork/portmapper"
|
"github.com/docker/libnetwork/portmapper"
|
||||||
|
"github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -15,7 +15,7 @@ const (
|
||||||
|
|
||||||
func TestProgramIPTable(t *testing.T) {
|
func TestProgramIPTable(t *testing.T) {
|
||||||
// Create a test bridge with a basic bridge configuration (name + IPv4).
|
// Create a test bridge with a basic bridge configuration (name + IPv4).
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
createTestBridge(getBasicTestConfig(), &bridgeInterface{}, t)
|
createTestBridge(getBasicTestConfig(), &bridgeInterface{}, t)
|
||||||
|
|
||||||
// Store various iptables chain rules we care for.
|
// Store various iptables chain rules we care for.
|
||||||
|
@ -39,7 +39,7 @@ func TestProgramIPTable(t *testing.T) {
|
||||||
|
|
||||||
func TestSetupIPChains(t *testing.T) {
|
func TestSetupIPChains(t *testing.T) {
|
||||||
// Create a test bridge with a basic bridge configuration (name + IPv4).
|
// Create a test bridge with a basic bridge configuration (name + IPv4).
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
driverconfig := &configuration{
|
driverconfig := &configuration{
|
||||||
EnableIPTables: true,
|
EnableIPTables: true,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/netutils"
|
"github.com/docker/libnetwork/netutils"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func setupTestInterface(t *testing.T) (*networkConfiguration, *bridgeInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupBridgeIPv4Fixed(t *testing.T) {
|
func TestSetupBridgeIPv4Fixed(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
ip, netw, err := net.ParseCIDR("192.168.1.1/24")
|
ip, netw, err := net.ParseCIDR("192.168.1.1/24")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -53,7 +53,7 @@ func TestSetupBridgeIPv4Fixed(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupBridgeIPv4Auto(t *testing.T) {
|
func TestSetupBridgeIPv4Auto(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
var toBeChosen *net.IPNet
|
var toBeChosen *net.IPNet
|
||||||
for _, n := range bridgeNetworks {
|
for _, n := range bridgeNetworks {
|
||||||
|
@ -90,7 +90,7 @@ func TestSetupBridgeIPv4Auto(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupGatewayIPv4(t *testing.T) {
|
func TestSetupGatewayIPv4(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
ip, nw, _ := net.ParseCIDR("192.168.0.24/16")
|
ip, nw, _ := net.ParseCIDR("192.168.0.24/16")
|
||||||
nw.IP = ip
|
nw.IP = ip
|
||||||
|
|
|
@ -7,12 +7,12 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetupIPv6(t *testing.T) {
|
func TestSetupIPv6(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
config, br := setupTestInterface(t)
|
config, br := setupTestInterface(t)
|
||||||
if err := setupBridgeIPv6(config, br); err != nil {
|
if err := setupBridgeIPv6(config, br); err != nil {
|
||||||
|
@ -48,7 +48,7 @@ func TestSetupIPv6(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupGatewayIPv6(t *testing.T) {
|
func TestSetupGatewayIPv6(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
_, nw, _ := net.ParseCIDR("2001:db8:ea9:9abc:ffff::/80")
|
_, nw, _ := net.ParseCIDR("2001:db8:ea9:9abc:ffff::/80")
|
||||||
gw := net.ParseIP("2001:db8:ea9:9abc:ffff::254")
|
gw := net.ParseIP("2001:db8:ea9:9abc:ffff::254")
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ func setupVerifyTest(t *testing.T) *bridgeInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupVerify(t *testing.T) {
|
func TestSetupVerify(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
addrv4 := net.IPv4(192, 168, 1, 1)
|
addrv4 := net.IPv4(192, 168, 1, 1)
|
||||||
inf := setupVerifyTest(t)
|
inf := setupVerifyTest(t)
|
||||||
|
@ -40,7 +40,7 @@ func TestSetupVerify(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupVerifyBad(t *testing.T) {
|
func TestSetupVerifyBad(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
addrv4 := net.IPv4(192, 168, 1, 1)
|
addrv4 := net.IPv4(192, 168, 1, 1)
|
||||||
inf := setupVerifyTest(t)
|
inf := setupVerifyTest(t)
|
||||||
|
@ -58,7 +58,7 @@ func TestSetupVerifyBad(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupVerifyMissing(t *testing.T) {
|
func TestSetupVerifyMissing(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
addrv4 := net.IPv4(192, 168, 1, 1)
|
addrv4 := net.IPv4(192, 168, 1, 1)
|
||||||
inf := setupVerifyTest(t)
|
inf := setupVerifyTest(t)
|
||||||
|
@ -71,7 +71,7 @@ func TestSetupVerifyMissing(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupVerifyIPv6(t *testing.T) {
|
func TestSetupVerifyIPv6(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
addrv4 := net.IPv4(192, 168, 1, 1)
|
addrv4 := net.IPv4(192, 168, 1, 1)
|
||||||
inf := setupVerifyTest(t)
|
inf := setupVerifyTest(t)
|
||||||
|
@ -92,7 +92,7 @@ func TestSetupVerifyIPv6(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupVerifyIPv6Missing(t *testing.T) {
|
func TestSetupVerifyIPv6Missing(t *testing.T) {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
addrv4 := net.IPv4(192, 168, 1, 1)
|
addrv4 := net.IPv4(192, 168, 1, 1)
|
||||||
inf := setupVerifyTest(t)
|
inf := setupVerifyTest(t)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package host
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package null
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/driverapi"
|
"github.com/docker/libnetwork/driverapi"
|
||||||
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type driverTester struct {
|
type driverTester struct {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugins"
|
"github.com/docker/docker/pkg/plugins"
|
||||||
"github.com/docker/libnetwork/driverapi"
|
"github.com/docker/libnetwork/driverapi"
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuildDefault(t *testing.T) {
|
func TestBuildDefault(t *testing.T) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
mapset "github.com/deckarep/golang-set"
|
mapset "github.com/deckarep/golang-set"
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/config"
|
"github.com/docker/libnetwork/config"
|
||||||
"github.com/docker/swarm/discovery"
|
"github.com/docker/swarm/discovery"
|
||||||
|
|
|
@ -3,7 +3,7 @@ package idm
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConversion(t *testing.T) {
|
func TestConversion(t *testing.T) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/docker/libnetwork/bitseq"
|
"github.com/docker/libnetwork/bitseq"
|
||||||
"github.com/docker/libnetwork/config"
|
"github.com/docker/libnetwork/config"
|
||||||
"github.com/docker/libnetwork/datastore"
|
"github.com/docker/libnetwork/datastore"
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ds datastore.DataStore
|
var ds datastore.DataStore
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const chainName = "DOCKEREST"
|
const chainName = "DOCKEREST"
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
"github.com/docker/libnetwork/datastore"
|
"github.com/docker/libnetwork/datastore"
|
||||||
"github.com/docker/libnetwork/driverapi"
|
"github.com/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/libnetwork/netutils"
|
|
||||||
"github.com/docker/libnetwork/options"
|
"github.com/docker/libnetwork/options"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/osl"
|
||||||
|
"github.com/docker/libnetwork/testutils"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"github.com/vishvananda/netns"
|
"github.com/vishvananda/netns"
|
||||||
|
@ -256,8 +256,8 @@ func TestHost(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBridge(t *testing.T) {
|
func TestBridge(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
||||||
|
@ -329,8 +329,8 @@ func TestBridge(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnknownDriver(t *testing.T) {
|
func TestUnknownDriver(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := createTestNetwork("unknowndriver", "testnetwork", options.Generic{})
|
_, err := createTestNetwork("unknowndriver", "testnetwork", options.Generic{})
|
||||||
|
@ -356,8 +356,8 @@ func TestNilRemoteDriver(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDuplicateNetwork(t *testing.T) {
|
func TestDuplicateNetwork(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creating a default bridge name network (can't be removed)
|
// Creating a default bridge name network (can't be removed)
|
||||||
|
@ -377,8 +377,8 @@ func TestDuplicateNetwork(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkName(t *testing.T) {
|
func TestNetworkName(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
netOption := options.Generic{
|
netOption := options.Generic{
|
||||||
|
@ -414,8 +414,8 @@ func TestNetworkName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkType(t *testing.T) {
|
func TestNetworkType(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
netOption := options.Generic{
|
netOption := options.Generic{
|
||||||
|
@ -441,8 +441,8 @@ func TestNetworkType(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkID(t *testing.T) {
|
func TestNetworkID(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
netOption := options.Generic{
|
netOption := options.Generic{
|
||||||
|
@ -468,8 +468,8 @@ func TestNetworkID(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
netOption := options.Generic{
|
netOption := options.Generic{
|
||||||
|
@ -509,8 +509,8 @@ func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnknownNetwork(t *testing.T) {
|
func TestUnknownNetwork(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
netOption := options.Generic{
|
netOption := options.Generic{
|
||||||
|
@ -541,8 +541,8 @@ func TestUnknownNetwork(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnknownEndpoint(t *testing.T) {
|
func TestUnknownEndpoint(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
ip, subnet, err := net.ParseCIDR("192.168.100.1/24")
|
||||||
|
@ -589,8 +589,8 @@ func TestUnknownEndpoint(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkEndpointsWalkers(t *testing.T) {
|
func TestNetworkEndpointsWalkers(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create network 1 and add 2 endpoint: ep11, ep12
|
// Create network 1 and add 2 endpoint: ep11, ep12
|
||||||
|
@ -721,8 +721,8 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDuplicateEndpoint(t *testing.T) {
|
func TestDuplicateEndpoint(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
netOption := options.Generic{
|
netOption := options.Generic{
|
||||||
|
@ -771,8 +771,8 @@ func TestDuplicateEndpoint(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestControllerQuery(t *testing.T) {
|
func TestControllerQuery(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create network 1
|
// Create network 1
|
||||||
|
@ -875,8 +875,8 @@ func TestControllerQuery(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkQuery(t *testing.T) {
|
func TestNetworkQuery(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create network 1 and add 2 endpoint: ep11, ep12
|
// 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) {
|
func TestEndpointJoin(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create network 1 and add 2 endpoint: ep11, ep12
|
// Create network 1 and add 2 endpoint: ep11, ep12
|
||||||
|
@ -1189,8 +1189,8 @@ func (f *fakeSandbox) Delete() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||||
|
@ -1253,8 +1253,8 @@ func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEndpointMultipleJoins(t *testing.T) {
|
func TestEndpointMultipleJoins(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := createTestNetwork(bridgeNetType, "testmultiple", options.Generic{
|
n, err := createTestNetwork(bridgeNetType, "testmultiple", options.Generic{
|
||||||
|
@ -1325,8 +1325,8 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLeaveAll(t *testing.T) {
|
func TestLeaveAll(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||||
|
@ -1389,8 +1389,8 @@ func TestLeaveAll(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestontainerInvalidLeave(t *testing.T) {
|
func TestontainerInvalidLeave(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
|
||||||
|
@ -1456,8 +1456,8 @@ func TestontainerInvalidLeave(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEndpointUpdateParent(t *testing.T) {
|
func TestEndpointUpdateParent(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := createTestNetwork("bridge", "testnetwork", options.Generic{
|
n, err := createTestNetwork("bridge", "testnetwork", options.Generic{
|
||||||
|
@ -1542,8 +1542,8 @@ func TestEndpointUpdateParent(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnableIPv6(t *testing.T) {
|
func TestEnableIPv6(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\nnameserver 2001:4860:4860::8888\n")
|
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) {
|
func TestResolvConfHost(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpResolvConf := []byte("search localhost.net\nnameserver 127.0.0.1\nnameserver 2001:4860:4860::8888\n")
|
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) {
|
func TestResolvConf(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpResolvConf1 := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\nnameserver 2001:4860:4860::8888\n")
|
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) {
|
func TestInvalidRemoteDriver(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
t.Skip("Skipping test when not running inside a Container")
|
t.Skip("Skipping test when not running inside a Container")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1920,7 +1920,7 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidRemoteDriver(t *testing.T) {
|
func TestValidRemoteDriver(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
t.Skip("Skipping test when not running inside a Container")
|
t.Skip("Skipping test when not running inside a Container")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1999,7 +1999,7 @@ func createGlobalInstance(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if netutils.IsRunningInContainer() {
|
if testutils.IsRunningInContainer() {
|
||||||
testns = origns
|
testns = origns
|
||||||
} else {
|
} else {
|
||||||
testns, err = netns.New()
|
testns, err = netns.New()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
43
libnetwork/ns/init_linux.go
Normal file
43
libnetwork/ns/init_linux.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package ns
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/vishvananda/netns"
|
||||||
|
)
|
||||||
|
|
||||||
|
var initNs netns.NsHandle
|
||||||
|
|
||||||
|
// Init initializes a new network namespace
|
||||||
|
func Init() {
|
||||||
|
var err error
|
||||||
|
initNs, err = netns.Get()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("could not get initial namespace: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNamespace sets the initial namespace handler
|
||||||
|
func SetNamespace() error {
|
||||||
|
if err := netns.Set(initNs); err != nil {
|
||||||
|
linkInfo, linkErr := getLink()
|
||||||
|
if linkErr != nil {
|
||||||
|
linkInfo = linkErr.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("failed to set to initial namespace, %v, initns fd %d: %v", linkInfo, initNs, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseHandlerInt transforms the namespace handler into a integer
|
||||||
|
func ParseHandlerInt() int {
|
||||||
|
return int(initNs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLink() (string, error) {
|
||||||
|
return os.Readlink(fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), syscall.Gettid()))
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGenerate(t *testing.T) {
|
func TestGenerate(t *testing.T) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
|
"github.com/docker/libnetwork/ns"
|
||||||
"github.com/docker/libnetwork/types"
|
"github.com/docker/libnetwork/types"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"github.com/vishvananda/netns"
|
"github.com/vishvananda/netns"
|
||||||
|
@ -27,7 +28,6 @@ var (
|
||||||
gpmCleanupPeriod = 60 * time.Second
|
gpmCleanupPeriod = 60 * time.Second
|
||||||
gpmChan = make(chan chan struct{})
|
gpmChan = make(chan chan struct{})
|
||||||
nsOnce sync.Once
|
nsOnce sync.Once
|
||||||
initNs netns.NsHandle
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The networkNamespace type is the linux implementation of the Sandbox
|
// The networkNamespace type is the linux implementation of the Sandbox
|
||||||
|
@ -244,30 +244,12 @@ func (n *networkNamespace) InvokeFunc(f func()) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLink() (string, error) {
|
|
||||||
return os.Readlink(fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), syscall.Gettid()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func nsInit() {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
if initNs, err = netns.Get(); err != nil {
|
|
||||||
log.Errorf("could not get initial namespace: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitOSContext initializes OS context while configuring network resources
|
// InitOSContext initializes OS context while configuring network resources
|
||||||
func InitOSContext() func() {
|
func InitOSContext() func() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
nsOnce.Do(nsInit)
|
nsOnce.Do(ns.Init)
|
||||||
if err := netns.Set(initNs); err != nil {
|
if err := ns.SetNamespace(); err != nil {
|
||||||
linkInfo, linkErr := getLink()
|
log.Error(err)
|
||||||
if linkErr != nil {
|
|
||||||
linkInfo = linkErr.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Errorf("failed to set to initial namespace, %v, initns fd %d: %v",
|
|
||||||
linkInfo, initNs, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return runtime.UnlockOSThread
|
return runtime.UnlockOSThread
|
||||||
|
@ -293,10 +275,10 @@ func nsInvoke(path string, prefunc func(nsFD int) error, postfunc func(callerFD
|
||||||
if err = netns.Set(netns.NsHandle(nsFD)); err != nil {
|
if err = netns.Set(netns.NsHandle(nsFD)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer netns.Set(initNs)
|
defer ns.SetNamespace()
|
||||||
|
|
||||||
// Invoked after the namespace switch.
|
// Invoked after the namespace switch.
|
||||||
return postfunc(int(initNs))
|
return postfunc(ns.ParseHandlerInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *networkNamespace) nsPath() string {
|
func (n *networkNamespace) nsPath() string {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
|
"github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
@ -16,7 +17,7 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSandboxCreate(t *testing.T) {
|
func TestSandboxCreate(t *testing.T) {
|
||||||
defer SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
key, err := newKey(t)
|
key, err := newKey(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -72,7 +73,7 @@ func TestSandboxCreate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSandboxCreateTwice(t *testing.T) {
|
func TestSandboxCreateTwice(t *testing.T) {
|
||||||
defer SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
key, err := newKey(t)
|
key, err := newKey(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -122,7 +123,7 @@ func TestSandboxGC(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddRemoveInterface(t *testing.T) {
|
func TestAddRemoveInterface(t *testing.T) {
|
||||||
defer SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
|
|
||||||
key, err := newKey(t)
|
key, err := newKey(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -7,9 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var ErrNotImplemented = errors.New("not implemented")
|
||||||
ErrNotImplemented = errors.New("not implemented")
|
|
||||||
)
|
|
||||||
|
|
||||||
func newKey(t *testing.T) (string, error) {
|
func newKey(t *testing.T) (string, error) {
|
||||||
return nil, ErrNotImplemented
|
return nil, ErrNotImplemented
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resetPortAllocator() {
|
func resetPortAllocator() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/iptables"
|
"github.com/docker/libnetwork/iptables"
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/ioutils"
|
"github.com/docker/docker/pkg/ioutils"
|
||||||
_ "github.com/docker/libnetwork/netutils"
|
_ "github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/libnetwork/netutils"
|
|
||||||
"github.com/docker/libnetwork/options"
|
"github.com/docker/libnetwork/options"
|
||||||
"github.com/docker/libnetwork/osl"
|
"github.com/docker/libnetwork/osl"
|
||||||
|
"github.com/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createEmptyCtrlr() *controller {
|
func createEmptyCtrlr() *controller {
|
||||||
|
@ -83,8 +83,8 @@ func TestSandboxAddEmpty(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSandboxAddMultiPrio(t *testing.T) {
|
func TestSandboxAddMultiPrio(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
c, nw, _ := getTestEnv(t)
|
c, nw, _ := getTestEnv(t)
|
||||||
|
@ -160,8 +160,8 @@ func TestSandboxAddMultiPrio(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSandboxAddSamePrio(t *testing.T) {
|
func TestSandboxAddSamePrio(t *testing.T) {
|
||||||
if !netutils.IsRunningInContainer() {
|
if !testutils.IsRunningInContainer() {
|
||||||
defer osl.SetupTestOSContext(t)()
|
defer testutils.SetupTestOSContext(t)()
|
||||||
}
|
}
|
||||||
|
|
||||||
c, nw1, nw2 := getTestEnv(t)
|
c, nw1, nw2 := getTestEnv(t)
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package osl
|
package testutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/libnetwork/ns"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetupTestOSContext joins a new network namespace, and returns its associated
|
// SetupTestOSContext joins a new network namespace, and returns its associated
|
||||||
|
@ -26,7 +28,7 @@ func SetupTestOSContext(t *testing.T) func() {
|
||||||
|
|
||||||
// Since we are switching to a new test namespace make
|
// Since we are switching to a new test namespace make
|
||||||
// sure to re-initialize initNs context
|
// sure to re-initialize initNs context
|
||||||
nsInit()
|
ns.Init()
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
if err := syscall.Close(fd); err != nil {
|
if err := syscall.Close(fd); err != nil {
|
|
@ -1,4 +1,4 @@
|
||||||
package netutils
|
package testutils
|
||||||
|
|
||||||
import "flag"
|
import "flag"
|
||||||
|
|
Loading…
Add table
Reference in a new issue