2015-02-25 02:41:17 +00:00
|
|
|
package bridge
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2015-09-07 17:33:28 +00:00
|
|
|
"github.com/docker/libnetwork/testutils"
|
2015-02-25 02:41:17 +00:00
|
|
|
"github.com/vishvananda/netlink"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestInterfaceDefaultName(t *testing.T) {
|
2015-09-07 17:33:28 +00:00
|
|
|
defer testutils.SetupTestOSContext(t)()
|
2015-02-25 02:41:17 +00:00
|
|
|
|
2016-05-16 18:51:40 +00:00
|
|
|
nh, err := netlink.NewHandle()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2015-05-22 17:56:36 +00:00
|
|
|
config := &networkConfiguration{}
|
2016-09-05 11:36:59 +00:00
|
|
|
_, err = newInterface(nh, config)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("newInterface() failed: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.BridgeName != DefaultBridgeName {
|
2015-04-15 05:25:42 +00:00
|
|
|
t.Fatalf("Expected default interface name %q, got %q", DefaultBridgeName, config.BridgeName)
|
2015-02-25 02:41:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddressesEmptyInterface(t *testing.T) {
|
2015-09-07 17:33:28 +00:00
|
|
|
defer testutils.SetupTestOSContext(t)()
|
2015-02-25 02:41:17 +00:00
|
|
|
|
2016-05-16 18:51:40 +00:00
|
|
|
nh, err := netlink.NewHandle()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2016-09-05 11:36:59 +00:00
|
|
|
inf, err := newInterface(nh, &networkConfiguration{})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("newInterface() failed: %v", err)
|
|
|
|
}
|
|
|
|
|
2016-09-17 05:40:44 +00:00
|
|
|
addrsv4, addrsv6, err := inf.addresses()
|
2015-02-25 02:41:17 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to get addresses of default interface: %v", err)
|
|
|
|
}
|
2016-09-17 05:40:44 +00:00
|
|
|
if len(addrsv4) != 0 {
|
|
|
|
t.Fatalf("Default interface has unexpected IPv4: %s", addrsv4)
|
2015-02-25 02:41:17 +00:00
|
|
|
}
|
|
|
|
if len(addrsv6) != 0 {
|
|
|
|
t.Fatalf("Default interface has unexpected IPv6: %v", addrsv6)
|
|
|
|
}
|
|
|
|
}
|