Browse code

Use documentation IPv6 addresses (RFC 3849) in tests

Signed-off-by: Tim Düsterhus <tim@bastelstu.be>

Tim Düsterhus authored on 2015/11/16 02:28:53
Showing 5 changed files
... ...
@@ -69,7 +69,7 @@ func TestValidateAndIsV6(t *testing.T) {
69 69
 		t.Fatalf("incorrect ip version returned")
70 70
 	}
71 71
 	orig := i.Pool
72
-	if i.Pool, err = types.ParseCIDR("2003::33/64"); err != nil {
72
+	if i.Pool, err = types.ParseCIDR("2001:db8::33/64"); err != nil {
73 73
 		t.Fatal(err)
74 74
 	}
75 75
 	if !i.IsV6() {
... ...
@@ -83,7 +83,7 @@ func TestValidateAndIsV6(t *testing.T) {
83 83
 	}
84 84
 
85 85
 	// incongruent gw ver
86
-	if i.Gateway, err = types.ParseCIDR("2001::45/65"); err != nil {
86
+	if i.Gateway, err = types.ParseCIDR("2001:db8::45/65"); err != nil {
87 87
 		t.Fatal(err)
88 88
 	}
89 89
 	if err = i.Validate(); err == nil {
... ...
@@ -92,7 +92,7 @@ func TestValidateAndIsV6(t *testing.T) {
92 92
 	i.Gateway = nil
93 93
 
94 94
 	// incongruent secondary ip ver
95
-	if i.AuxAddresses["ip2"], err = types.ParseCIDR("2002::44/80"); err != nil {
95
+	if i.AuxAddresses["ip2"], err = types.ParseCIDR("2001:db8::44/80"); err != nil {
96 96
 		t.Fatal(err)
97 97
 	}
98 98
 	if err = i.Validate(); err == nil {
... ...
@@ -112,8 +112,8 @@ func TestCreateFullOptionsLabels(t *testing.T) {
112 112
 	}
113 113
 
114 114
 	bndIPs := "127.0.0.1"
115
-	nwV6s := "2100:2400:2600:2700:2800::/80"
116
-	gwV6s := "2100:2400:2600:2700:2800::25/80"
115
+	nwV6s := "2001:db8:2600:2700:2800::/80"
116
+	gwV6s := "2001:db8:2600:2700:2800::25/80"
117 117
 	nwV6, _ := types.ParseCIDR(nwV6s)
118 118
 	gwV6, _ := types.ParseCIDR(gwV6s)
119 119
 
... ...
@@ -191,7 +191,7 @@ func TestCreateFullOptionsLabels(t *testing.T) {
191 191
 	if !nwV6.Contains(te.Interface().AddressIPv6().IP) {
192 192
 		t.Fatalf("endpoint got assigned address outside of container network(%s): %s", nwV6.String(), te.Interface().AddressIPv6())
193 193
 	}
194
-	if te.Interface().AddressIPv6().IP.String() != "2100:2400:2600:2700:2800:aabb:ccdd:eeff" {
194
+	if te.Interface().AddressIPv6().IP.String() != "2001:db8:2600:2700:2800:aabb:ccdd:eeff" {
195 195
 		t.Fatalf("Unexpected endpoint IPv6 address: %v", te.Interface().AddressIPv6().IP)
196 196
 	}
197 197
 }
... ...
@@ -724,18 +724,18 @@ func TestValidateConfig(t *testing.T) {
724 724
 	}
725 725
 
726 726
 	// Test v6 gw
727
-	_, v6nw, _ := net.ParseCIDR("2001:1234:ae:b004::/64")
727
+	_, v6nw, _ := net.ParseCIDR("2001:db8:ae:b004::/64")
728 728
 	c = networkConfiguration{
729 729
 		EnableIPv6:         true,
730 730
 		AddressIPv6:        v6nw,
731
-		DefaultGatewayIPv6: net.ParseIP("2001:1234:ac:b004::bad:a55"),
731
+		DefaultGatewayIPv6: net.ParseIP("2001:db8:ac:b004::bad:a55"),
732 732
 	}
733 733
 	err = c.Validate()
734 734
 	if err == nil {
735 735
 		t.Fatalf("Failed to detect invalid v6 default gateway")
736 736
 	}
737 737
 
738
-	c.DefaultGatewayIPv6 = net.ParseIP("2001:1234:ae:b004::bad:a55")
738
+	c.DefaultGatewayIPv6 = net.ParseIP("2001:db8:ae:b004::bad:a55")
739 739
 	err = c.Validate()
740 740
 	if err != nil {
741 741
 		t.Fatalf("Unexpected validation error on v6 default gateway")
... ...
@@ -86,7 +86,7 @@ func TestGetAddressVersion(t *testing.T) {
86 86
 	if v6 != getAddressVersion(net.ParseIP("ff01::1")) {
87 87
 		t.Fatalf("Failed to detect IPv6 version")
88 88
 	}
89
-	if v6 != getAddressVersion(net.ParseIP("2001:56::76:51")) {
89
+	if v6 != getAddressVersion(net.ParseIP("2001:db8::76:51")) {
90 90
 		t.Fatalf("Failed to detect IPv6 version")
91 91
 	}
92 92
 }
... ...
@@ -523,11 +523,11 @@ func TestRemoveSubnet(t *testing.T) {
523 523
 		{localAddressSpace, "192.168.0.0/16", false},
524 524
 		{localAddressSpace, "172.17.0.0/16", false},
525 525
 		{localAddressSpace, "10.0.0.0/8", false},
526
-		{localAddressSpace, "2002:1:2:3:4:5:ffff::/112", false},
526
+		{localAddressSpace, "2001:db8:1:2:3:4:ffff::/112", false},
527 527
 		{"splane", "172.17.0.0/16", false},
528 528
 		{"splane", "10.0.0.0/8", false},
529
-		{"splane", "2002:1:2:3:4:5:6::/112", true},
530
-		{"splane", "2002:1:2:3:4:5:ffff::/112", true},
529
+		{"splane", "2001:db8:1:2:3:4:5::/112", true},
530
+		{"splane", "2001:db8:1:2:3:4:ffff::/112", true},
531 531
 	}
532 532
 
533 533
 	poolIDs := make([]string, len(input))
... ...
@@ -179,7 +179,7 @@ func printIpamInfo(list []*IpamInfo) string {
179 179
 }
180 180
 
181 181
 func TestEndpointMarshalling(t *testing.T) {
182
-	ip, nw6, err := net.ParseCIDR("2001:3002:4003::122/64")
182
+	ip, nw6, err := net.ParseCIDR("2001:db8:4003::122/64")
183 183
 	if err != nil {
184 184
 		t.Fatal(err)
185 185
 	}
... ...
@@ -180,13 +180,13 @@ func TestCompareIPMask(t *testing.T) {
180 180
 			ms:   0,
181 181
 		},
182 182
 		{ // ip and mask as v6
183
-			ip:   net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"),
183
+			ip:   net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
184 184
 			mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0},
185 185
 			is:   0,
186 186
 			ms:   0,
187 187
 		},
188 188
 		{
189
-			ip:    net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"),
189
+			ip:    net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
190 190
 			mask:  []byte{0xff, 0xff, 0xff, 0},
191 191
 			isErr: true,
192 192
 		},
... ...
@@ -244,7 +244,7 @@ func TestUtilGetHostPortionIP(t *testing.T) {
244 244
 			host: net.IPv4(0, 0, 0, 4)[12:],
245 245
 		},
246 246
 		{ // ip and mask as v6
247
-			ip:   net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"),
247
+			ip:   net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
248 248
 			mask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0},
249 249
 			host: net.ParseIP("0::AB:00CD"),
250 250
 		},
... ...
@@ -261,7 +261,7 @@ func TestUtilGetHostPortionIP(t *testing.T) {
261 261
 	}
262 262
 
263 263
 	// ip as v6 and mask as v4 are not compatible
264
-	if _, err := GetHostPartIP(net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil {
264
+	if _, err := GetHostPartIP(net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil {
265 265
 		t.Fatalf("Unexpected success")
266 266
 	}
267 267
 	// ip as v4 and non conventional mask
... ...
@@ -326,9 +326,9 @@ func TestUtilGetBroadcastIP(t *testing.T) {
326 326
 			bcast: net.IPv4(172, 28, 255, 255)[12:],
327 327
 		},
328 328
 		{ // ip and mask as v6
329
-			ip:    net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"),
329
+			ip:    net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"),
330 330
 			mask:  []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0},
331
-			bcast: net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEFF:FFFF"),
331
+			bcast: net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEFF:FFFF"),
332 332
 		},
333 333
 	}
334 334
 
... ...
@@ -343,7 +343,7 @@ func TestUtilGetBroadcastIP(t *testing.T) {
343 343
 	}
344 344
 
345 345
 	// ip as v6 and mask as v4 are not compatible
346
-	if _, err := GetBroadcastIP(net.ParseIP("2005:2004:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil {
346
+	if _, err := GetBroadcastIP(net.ParseIP("2001:DB8:2002:2001:FFFF:ABCD:EEAB:00CD"), []byte{0xff, 0xff, 0xff, 0}); err == nil {
347 347
 		t.Fatalf("Unexpected success")
348 348
 	}
349 349
 	// ip as v4 and non conventional mask