2015-02-24 21:49:08 -05:00
|
|
|
package bridge
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"testing"
|
|
|
|
|
2015-04-13 14:40:42 -04:00
|
|
|
"github.com/docker/libnetwork/netutils"
|
2015-02-24 21:49:08 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetupFixedCIDRv6(t *testing.T) {
|
2015-04-13 14:40:42 -04:00
|
|
|
defer netutils.SetupTestNetNS(t)()
|
2015-02-24 21:49:08 -05:00
|
|
|
|
2015-05-22 13:56:36 -04:00
|
|
|
config := &networkConfiguration{}
|
2015-04-15 01:25:42 -04:00
|
|
|
br := newInterface(config)
|
2015-02-24 21:49:08 -05:00
|
|
|
|
2015-04-15 01:25:42 -04:00
|
|
|
_, config.FixedCIDRv6, _ = net.ParseCIDR("2002:db8::/48")
|
|
|
|
if err := setupDevice(config, br); err != nil {
|
2015-02-24 21:49:08 -05:00
|
|
|
t.Fatalf("Bridge creation failed: %v", err)
|
|
|
|
}
|
2015-04-15 01:25:42 -04:00
|
|
|
if err := setupBridgeIPv4(config, br); err != nil {
|
2015-02-24 21:49:08 -05:00
|
|
|
t.Fatalf("Assign IPv4 to bridge failed: %v", err)
|
|
|
|
}
|
|
|
|
|
2015-04-15 01:25:42 -04:00
|
|
|
if err := setupBridgeIPv6(config, br); err != nil {
|
2015-02-24 21:49:08 -05:00
|
|
|
t.Fatalf("Assign IPv4 to bridge failed: %v", err)
|
|
|
|
}
|
|
|
|
|
2015-04-15 01:25:42 -04:00
|
|
|
if err := setupFixedCIDRv6(config, br); err != nil {
|
2015-02-24 21:49:08 -05:00
|
|
|
t.Fatalf("Failed to setup bridge FixedCIDRv6: %v", err)
|
|
|
|
}
|
|
|
|
|
2015-04-15 01:25:42 -04:00
|
|
|
if ip, err := ipAllocator.RequestIP(config.FixedCIDRv6, nil); err != nil {
|
2015-02-24 21:49:08 -05:00
|
|
|
t.Fatalf("Failed to request IP to allocator: %v", err)
|
|
|
|
} else if expected := "2002:db8::1"; ip.String() != expected {
|
|
|
|
t.Fatalf("Expected allocated IP %s, got %s", expected, ip)
|
|
|
|
}
|
|
|
|
}
|