@@ -111,18 +111,35 @@ func TestCreateFullOptionsLabels(t *testing.T) {
111111 t .Fatalf ("Failed to setup driver config: %v" , err )
112112 }
113113
114+ bndIPs := "127.0.0.1"
115+ nwV6s := "2100:2400:2600:2700:2800::/80"
116+ gwV6s := "2100:2400:2600:2700:2800::25/80"
117+ nwV6 , _ := types .ParseCIDR (nwV6s )
118+ gwV6 , _ := types .ParseCIDR (gwV6s )
119+
114120 labels := map [string ]string {
115- BridgeName : "cu" ,
121+ BridgeName : DefaultBridgeName ,
122+ DefaultBridge : "true" ,
116123 netlabel .EnableIPv6 : "true" ,
117124 EnableICC : "true" ,
118125 EnableIPMasquerade : "true" ,
119- DefaultBindingIP : "127.0.0.1" ,
126+ DefaultBindingIP : bndIPs ,
120127 }
121128
122129 netOption := make (map [string ]interface {})
123130 netOption [netlabel .GenericData ] = labels
124131
125- err := d .CreateNetwork ("dummy" , netOption , getIPv4Data (t ), nil )
132+ ipdList := getIPv4Data (t )
133+ ipd6List := []driverapi.IPAMData {
134+ driverapi.IPAMData {
135+ Pool : nwV6 ,
136+ AuxAddresses : map [string ]* net.IPNet {
137+ DefaultGatewayV6AuxKey : gwV6 ,
138+ },
139+ },
140+ }
141+
142+ err := d .CreateNetwork ("dummy" , netOption , ipdList , ipd6List )
126143 if err != nil {
127144 t .Fatalf ("Failed to create bridge: %v" , err )
128145 }
@@ -132,7 +149,7 @@ func TestCreateFullOptionsLabels(t *testing.T) {
132149 t .Fatalf ("Cannot find dummy network in bridge driver" )
133150 }
134151
135- if nw .config .BridgeName != "cu" {
152+ if nw .config .BridgeName != DefaultBridgeName {
136153 t .Fatalf ("incongruent name in bridge network" )
137154 }
138155
@@ -147,6 +164,36 @@ func TestCreateFullOptionsLabels(t *testing.T) {
147164 if ! nw .config .EnableIPMasquerade {
148165 t .Fatalf ("incongruent EnableIPMasquerade in bridge network" )
149166 }
167+
168+ bndIP := net .ParseIP (bndIPs )
169+ if ! bndIP .Equal (nw .config .DefaultBindingIP ) {
170+ t .Fatalf ("Unexpected: %v" , nw .config .DefaultBindingIP )
171+ }
172+
173+ if ! types .CompareIPNet (nw .config .AddressIPv6 , nwV6 ) {
174+ t .Fatalf ("Unexpected: %v" , nw .config .AddressIPv6 )
175+ }
176+
177+ if ! gwV6 .IP .Equal (nw .config .DefaultGatewayIPv6 ) {
178+ t .Fatalf ("Unexpected: %v" , nw .config .DefaultGatewayIPv6 )
179+ }
180+
181+ // In short here we are testing --fixed-cidr-v6 daemon option
182+ // plus --mac-address run option
183+ mac , _ := net .ParseMAC ("aa:bb:cc:dd:ee:ff" )
184+ epOptions := map [string ]interface {}{netlabel .MacAddress : mac }
185+ te := newTestEndpoint (ipdList [0 ].Pool , 20 )
186+ err = d .CreateEndpoint ("dummy" , "ep1" , te .Interface (), epOptions )
187+ if err != nil {
188+ t .Fatal (err )
189+ }
190+
191+ if ! nwV6 .Contains (te .Interface ().AddressIPv6 ().IP ) {
192+ t .Fatalf ("endpoint got assigned address outside of container network(%s): %s" , nwV6 .String (), te .Interface ().AddressIPv6 ())
193+ }
194+ if te .Interface ().AddressIPv6 ().IP .String () != "2100:2400:2600:2700:2800:aabb:ccdd:eeff" {
195+ t .Fatalf ("Unexpected endpoint IPv6 address: %v" , te .Interface ().AddressIPv6 ().IP )
196+ }
150197}
151198
152199func TestCreate (t * testing.T ) {
0 commit comments