From 5624254ae4f989ab3abce79dfed90b986e6b1db6 Mon Sep 17 00:00:00 2001 From: Levente Kale Date: Wed, 8 May 2019 13:08:50 +0200 Subject: [PATCH] Fixing UTs, and adding the new components to the SCM pipelines --- pkg/netadmit/validators.go | 5 +- scm/build/build.sh | 3 +- scm/ut/run_uts.sh | 2 +- test/stubs/netclient_stub.go | 6 +- test/utils/utils.go | 31 +++++---- test/uts/cnidel_test/cnidel_test.go | 18 ++--- test/uts/ipam_test/ipam_test.go | 102 +++++++++++++--------------- 7 files changed, 86 insertions(+), 81 deletions(-) diff --git a/pkg/netadmit/validators.go b/pkg/netadmit/validators.go index de6976c3..8e51b771 100644 --- a/pkg/netadmit/validators.go +++ b/pkg/netadmit/validators.go @@ -78,7 +78,7 @@ func validateAllocationPool(dnet *danmtypes.DanmNet) error { dnet.Spec.Options.Pool.Start = (ipam.Int2ip(ipam.Ip2int(ipnet.IP) + 1)).String() } if apEnd == "" { - dnet.Spec.Options.Pool.End = (ipam.Int2ip(ipam.Ip2int(getBroadcastAddress(ipnet)) - 1)).String() + dnet.Spec.Options.Pool.End = (ipam.Int2ip(ipam.Ip2int(GetBroadcastAddress(ipnet)) - 1)).String() } if !ipnet.Contains(net.ParseIP(apStart)) || !ipnet.Contains(net.ParseIP(apEnd)) { return errors.New("Allocation pool is outside of defined CIDR") @@ -89,8 +89,9 @@ func validateAllocationPool(dnet *danmtypes.DanmNet) error { return nil } -func getBroadcastAddress(subnet *net.IPNet) (net.IP) { +func GetBroadcastAddress(subnet *net.IPNet) (net.IP) { ip := make(net.IP, len(subnet.IP.To4())) + //Don't ask binary.BigEndian.PutUint32(ip, binary.BigEndian.Uint32(subnet.IP.To4())|^binary.BigEndian.Uint32(net.IP(subnet.Mask).To4())) return ip } diff --git a/scm/build/build.sh b/scm/build/build.sh index 22d0f833..56933eb9 100755 --- a/scm/build/build.sh +++ b/scm/build/build.sh @@ -19,4 +19,5 @@ go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/danm go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/netwatcher go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/fakeipam go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/svcwatcher -go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/cnitest \ No newline at end of file +go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/cnitest +go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/webhook \ No newline at end of file diff --git a/scm/ut/run_uts.sh b/scm/ut/run_uts.sh index 09962d1a..86836266 100755 --- a/scm/ut/run_uts.sh +++ b/scm/ut/run_uts.sh @@ -3,7 +3,7 @@ set -e cd $GOPATH/src/github.com/nokia/danm echo "" > coverage.out for d in $(go list ./... | grep -v vendor | grep -v crd); do - go test -covermode=count -v -coverprofile=profile.out -coverpkg=github.com/nokia/danm/pkg/cnidel,github.com/nokia/danm/pkg/bitarray,github.com/nokia/danm/pkg/ipam,github.com/nokia/danm/pkg/danmep,github.com/nokia/danm/pkg/netcontrol,github.com/nokia/danm/pkg/syncher,github.com/nokia/danm/pkg/metacni,github.com/nokia/danm/pkg/svccontrol $d + go test -covermode=count -v -coverprofile=profile.out -coverpkg=github.com/nokia/danm/pkg/cnidel,github.com/nokia/danm/pkg/bitarray,github.com/nokia/danm/pkg/ipam,github.com/nokia/danm/pkg/danmep,github.com/nokia/danm/pkg/netcontrol,github.com/nokia/danm/pkg/syncher,github.com/nokia/danm/pkg/metacni,github.com/nokia/danm/pkg/svccontrol,github.com/nokia/danm/pkg/netadmit $d if [ -f profile.out ]; then cat profile.out >> coverage.out rm profile.out diff --git a/test/stubs/netclient_stub.go b/test/stubs/netclient_stub.go index b94857f3..af7cd5c4 100644 --- a/test/stubs/netclient_stub.go +++ b/test/stubs/netclient_stub.go @@ -9,7 +9,7 @@ import ( watch "k8s.io/apimachinery/pkg/watch" danmtypes "github.com/nokia/danm/crd/apis/danm/v1" "github.com/nokia/danm/pkg/bitarray" - "github.com/nokia/danm/pkg/netcontrol" + "github.com/nokia/danm/pkg/ipam" ) const ( magicVersion = "42" @@ -33,13 +33,13 @@ func (netClient *NetClientStub) Update(obj *danmtypes.DanmNet) (*danmtypes.DanmN if obj.Spec.NetworkID == netReservation.NetworkId { ba := bitarray.NewBitArrayFromBase64(obj.Spec.Options.Alloc) _, ipnet, _ := net.ParseCIDR(obj.Spec.Options.Cidr) - ipnetNum := netcontrol.Ip2int(ipnet.IP) + ipnetNum := ipam.Ip2int(ipnet.IP) for _, reservation := range netReservation.Reservations { ip,_,err := net.ParseCIDR(reservation.Ip) if err != nil { continue } - ipInInt := netcontrol.Ip2int(ip) - ipnetNum + ipInInt := ipam.Ip2int(ip) - ipnetNum if !ipnet.Contains(ip) { continue } diff --git a/test/utils/utils.go b/test/utils/utils.go index 74cf48a8..96562e80 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -5,25 +5,32 @@ import ( "strings" danmtypes "github.com/nokia/danm/crd/apis/danm/v1" "github.com/nokia/danm/pkg/bitarray" - "github.com/nokia/danm/pkg/netcontrol" + "github.com/nokia/danm/pkg/ipam" + "github.com/nokia/danm/pkg/netadmit" ) func SetupAllocationPools(nets []danmtypes.DanmNet) error { - for index, net := range nets { - if net.Spec.Options.Cidr != "" { - bitArray, err := netcontrol.CreateAllocationArray(&net) + for index, dnet := range nets { + if dnet.Spec.Options.Cidr != "" { + bitArray, err := netadmit.CreateAllocationArray(&dnet) if err != nil { return err } - net.Spec.Options.Alloc = bitArray.Encode() - err = netcontrol.ValidateAllocationPool(&net) + dnet.Spec.Options.Alloc = bitArray.Encode() + _, ipnet, err := net.ParseCIDR(dnet.Spec.Options.Cidr) if err != nil { return err } - if strings.HasPrefix(net.Spec.NetworkID, "full") { - exhaustNetwork(&net) + if dnet.Spec.Options.Pool.Start == "" { + dnet.Spec.Options.Pool.Start = (ipam.Int2ip(ipam.Ip2int(ipnet.IP) + 1)).String() } - nets[index].Spec = net.Spec + if dnet.Spec.Options.Pool.End == "" { + dnet.Spec.Options.Pool.End = (ipam.Int2ip(ipam.Ip2int(netadmit.GetBroadcastAddress(ipnet)) - 1)).String() + } + if strings.HasPrefix(dnet.Spec.NetworkID, "full") { + exhaustNetwork(&dnet) + } + nets[index].Spec = dnet.Spec } } return nil @@ -32,9 +39,9 @@ func SetupAllocationPools(nets []danmtypes.DanmNet) error { func exhaustNetwork(netInfo *danmtypes.DanmNet) { ba := bitarray.NewBitArrayFromBase64(netInfo.Spec.Options.Alloc) _, ipnet, _ := net.ParseCIDR(netInfo.Spec.Options.Cidr) - ipnetNum := netcontrol.Ip2int(ipnet.IP) - begin := netcontrol.Ip2int(net.ParseIP(netInfo.Spec.Options.Pool.Start)) - ipnetNum - end := netcontrol.Ip2int(net.ParseIP(netInfo.Spec.Options.Pool.End)) - ipnetNum + ipnetNum := ipam.Ip2int(ipnet.IP) + begin := ipam.Ip2int(net.ParseIP(netInfo.Spec.Options.Pool.Start)) - ipnetNum + end := ipam.Ip2int(net.ParseIP(netInfo.Spec.Options.Pool.End)) - ipnetNum for i:=begin;i<=end;i++ { ba.Set(uint32(i)) } diff --git a/test/uts/cnidel_test/cnidel_test.go b/test/uts/cnidel_test/cnidel_test.go index f04d6983..f886c653 100644 --- a/test/uts/cnidel_test/cnidel_test.go +++ b/test/uts/cnidel_test/cnidel_test.go @@ -63,39 +63,39 @@ var testNets = []danmtypes.DanmNet { }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "ipamNeeded"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "cidr", Validation: true,}, + Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "cidr",}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "flannel-test"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "flannel", NetworkID: "flannel_conf", Validation: true,}, + Spec: danmtypes.DanmNetSpec{NetworkType: "flannel", NetworkID: "flannel_conf",}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "no-conf"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "flannel", NetworkID: "hulululu", Validation: true,}, + Spec: danmtypes.DanmNetSpec{NetworkType: "flannel", NetworkID: "hulululu",}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "no-binary"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "flanel", NetworkID: "flannel_conf", Validation: true,}, + Spec: danmtypes.DanmNetSpec{NetworkType: "flanel", NetworkID: "flannel_conf",}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "macvlan-v4"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "macvlan", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Device: "ens1f0"}}, + Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "macvlan", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Device: "ens1f0"}}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "macvlan-v6"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "macvlan", Validation: true, Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64", Device: "ens1f1"}}, + Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "macvlan", Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64", Device: "ens1f1"}}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "macvlan-ds"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "macvlan", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Net6: "2a00:8a00:a000:1193::/64", Device: "ens1f1"}}, + Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "macvlan", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Net6: "2a00:8a00:a000:1193::/64", Device: "ens1f1"}}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "sriov-test"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "sriov", NetworkID: "sriov-test", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Vlan: 500}}, + Spec: danmtypes.DanmNetSpec{NetworkType: "sriov", NetworkID: "sriov-test", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Vlan: 500}}, }, danmtypes.DanmNet { ObjectMeta: meta_v1.ObjectMeta {Name: "full-macvlan"}, - Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "full", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Device: "ens1f0"}}, + Spec: danmtypes.DanmNetSpec{NetworkType: "macvlan", NetworkID: "full", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26", Device: "ens1f0"}}, }, } diff --git a/test/uts/ipam_test/ipam_test.go b/test/uts/ipam_test/ipam_test.go index cf21b2de..e9094935 100644 --- a/test/uts/ipam_test/ipam_test.go +++ b/test/uts/ipam_test/ipam_test.go @@ -12,18 +12,16 @@ import ( ) var testNets = []danmtypes.DanmNet { - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "emptyVal"},Spec: danmtypes.DanmNetSpec{NetworkID: "emptyVal", }}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "falseVal"},Spec: danmtypes.DanmNetSpec{NetworkID: "falseVal", Validation: false}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "trueVal"},Spec: danmtypes.DanmNetSpec{NetworkID: "trueVal", Validation: true}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "cidr"},Spec: danmtypes.DanmNetSpec{NetworkID: "cidr", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "fullIpv4"},Spec: danmtypes.DanmNetSpec{NetworkID: "fullIpv4", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.0/30"}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "net6"},Spec: danmtypes.DanmNetSpec{NetworkID: "net6", Validation: true, Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64", Cidr: "192.168.1.64/26",}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "smallNet6"},Spec: danmtypes.DanmNetSpec{NetworkID: "smallNet6", Validation: true, Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/69"}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflict"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflict", Validation: true, Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64"}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflicterror"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflicterror", Validation: true, Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64"}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflictFree"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflictFree", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflicterrorFree"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflicterrorFree", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, - danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "error"},Spec: danmtypes.DanmNetSpec{NetworkID: "error", Validation: true, Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "l2"},Spec: danmtypes.DanmNetSpec{NetworkID: "l2"}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "cidr"},Spec: danmtypes.DanmNetSpec{NetworkID: "cidr", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "fullIpv4"},Spec: danmtypes.DanmNetSpec{NetworkID: "fullIpv4", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.0/30"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "net6"},Spec: danmtypes.DanmNetSpec{NetworkID: "net6", Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64", Cidr: "192.168.1.64/26",}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "smallNet6"},Spec: danmtypes.DanmNetSpec{NetworkID: "smallNet6", Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/69"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflict"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflict", Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflicterror"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflicterror", Options: danmtypes.DanmNetOption{Net6: "2a00:8a00:a000:1193::/64"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflictFree"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflictFree", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "conflicterrorFree"},Spec: danmtypes.DanmNetSpec{NetworkID: "conflicterrorFree", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, + danmtypes.DanmNet {ObjectMeta: meta_v1.ObjectMeta {Name: "error"},Spec: danmtypes.DanmNetSpec{NetworkID: "error", Options: danmtypes.DanmNetOption{Cidr: "192.168.1.64/26"}}}, } var reserveTcs = []struct { @@ -36,37 +34,35 @@ var reserveTcs = []struct { isErrorExpected bool isMacExpected bool }{ - {"emptyVal", 0, "", "", "", "", true, false}, - {"falseVal", 1, "", "", "", "", true, false}, - {"noIpsRequested", 2, "", "", "", "", false, true}, - {"noneIPv4", 2, "none", "", "", "", false, true}, - {"noneIPv6", 2, "", "none", "", "", false, true}, - {"noneDualStack", 2, "none", "none", "", "", false, true}, - {"dynamicErrorIPv4", 2, "dynamic", "", "", "", true, false}, - {"dynamicErrorIPv6", 2, "", "dynamic", "", "", true, false}, - {"dynamicErrorDualStack", 2, "dynamic", "dynamic", "", "", true, false}, - {"dynamicIPv4Success", 3, "dynamic", "", "192.168.1.65/26", "", false, true}, - {"dynamicIPv4Exhausted", 4, "dynamic", "", "", "", true, false}, - {"staticInvalidIPv4", 4, "hululululu", "", "", "", true, false}, - {"staticInvalidNoCidrIPv4", 4, "192.168.1.1", "", "", "", true, false}, - {"staticL2IPv4", 2, "192.168.1.1/26", "", "", "", true, false}, - {"staticNetmaskMismatchIPv4", 4, "192.168.1.1/32", "", "", "", true, false}, - {"staticAlreadyUsedIPv4", 4, "192.168.1.2/30", "", "", "", true, false}, - {"staticSuccessLastIPv4", 3, "192.168.1.126/26", "", "192.168.1.126/26", "", false, true}, - {"staticSuccessFirstIPv4", 3, "192.168.1.65/26", "", "192.168.1.65/26", "", false, true}, - {"staticFailAfterLastIPv4", 3, "192.168.1.127/26", "", "", "", true, false}, - {"staticFailBeforeFirstIPv4", 3, "192.168.1.64/26", "", "", "", true, false}, - {"dynamicIPv6Success", 5, "", "dynamic", "", "2a00:8a00:a000:1193", false, true}, - {"dynamicNotSupportedCidrSizeIPv6", 6, "", "dynamic", "", "", true, false}, //basically anything smaller than /64. Restriction must be fixed some day! - {"staticL2IPv6", 4, "", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", "", "", true, false}, - {"staticInvalidIPv6", 5, "", "2a00:8a00:a000:1193:hulu:lulu:lulu:lulu/64", "", "", true, false}, - {"staticNetmaskMismatchIPv6", 5, "", "2a00:8a00:a000:2193:f816:3eff:fe24:e348/64", "", "", true, false}, - {"staticIPv6Success", 5, "", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", "", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", false, false}, - {"dynamicDualStackSuccess", 5, "dynamic", "dynamic", "192.168.1.65/26", "2a00:8a00:a000:1193", false, true}, - {"staticDualStackSuccess", 5, "192.168.1.115/26", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", "192.168.1.115/26", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", false, true}, - {"resolvedConflictDuringUpdate", 7, "", "dynamic", "", "2a00:8a00:a000:1193", false, true}, - {"unresolvedConflictDuringUpdate", 8, "", "dynamic", "", "", true, false}, - {"errorUpdate", 11, "", "dynamic", "", "", true, false}, + {"noIpsRequested", 0, "", "", "", "", false, true}, + {"noneIPv4", 0, "none", "", "", "", false, true}, + {"noneIPv6", 0, "", "none", "", "", false, true}, + {"noneDualStack", 0, "none", "none", "", "", false, true}, + {"dynamicErrorIPv4", 0, "dynamic", "", "", "", true, false}, + {"dynamicErrorIPv6", 0, "", "dynamic", "", "", true, false}, + {"dynamicErrorDualStack", 0, "dynamic", "dynamic", "", "", true, false}, + {"dynamicIPv4Success", 1, "dynamic", "", "192.168.1.65/26", "", false, true}, + {"dynamicIPv4Exhausted", 2, "dynamic", "", "", "", true, false}, + {"staticInvalidIPv4", 2, "hululululu", "", "", "", true, false}, + {"staticInvalidNoCidrIPv4", 2, "192.168.1.1", "", "", "", true, false}, + {"staticL2IPv4", 0, "192.168.1.1/26", "", "", "", true, false}, + {"staticNetmaskMismatchIPv4", 2, "192.168.1.1/32", "", "", "", true, false}, + {"staticAlreadyUsedIPv4", 2, "192.168.1.2/30", "", "", "", true, false}, + {"staticSuccessLastIPv4", 1, "192.168.1.126/26", "", "192.168.1.126/26", "", false, true}, + {"staticSuccessFirstIPv4", 1, "192.168.1.65/26", "", "192.168.1.65/26", "", false, true}, + {"staticFailAfterLastIPv4", 1, "192.168.1.127/26", "", "", "", true, false}, + {"staticFailBeforeFirstIPv4", 1, "192.168.1.64/26", "", "", "", true, false}, + {"dynamicIPv6Success", 3, "", "dynamic", "", "2a00:8a00:a000:1193", false, true}, + {"dynamicNotSupportedCidrSizeIPv6", 4, "", "dynamic", "", "", true, false}, //basically anything smaller than /64. Restriction must be fixed some day! + {"staticL2IPv6", 2, "", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", "", "", true, false}, + {"staticInvalidIPv6", 3, "", "2a00:8a00:a000:1193:hulu:lulu:lulu:lulu/64", "", "", true, false}, + {"staticNetmaskMismatchIPv6", 3, "", "2a00:8a00:a000:2193:f816:3eff:fe24:e348/64", "", "", true, false}, + {"staticIPv6Success", 3, "", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", "", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", false, false}, + {"dynamicDualStackSuccess", 3, "dynamic", "dynamic", "192.168.1.65/26", "2a00:8a00:a000:1193", false, true}, + {"staticDualStackSuccess", 3, "192.168.1.115/26", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", "192.168.1.115/26", "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", false, true}, + {"resolvedConflictDuringUpdate", 5, "", "dynamic", "", "2a00:8a00:a000:1193", false, true}, + {"unresolvedConflictDuringUpdate", 6, "", "dynamic", "", "", true, false}, + {"errorUpdate", 9, "", "dynamic", "", "", true, false}, } var freeTcs = []struct { @@ -75,16 +71,16 @@ var freeTcs = []struct { allocatedIp string isErrorExpected bool }{ - {"l2Network", 2, "192.168.1.126/26", false}, - {"noAssignedIp", 3, "", false}, - {"successfulFree", 4, "192.168.1.2/30", false}, - {"noNetmask", 4, "192.168.1.2", false}, - {"outOfRange", 4, "192.168.1.10/30", false}, - {"invalidIp", 4, "192.168.hululu/30", false}, - {"ipv6", 4, "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", false}, - {"resolvedConflictDuringUpdate", 9, "192.168.1.69/26", false}, - {"unresolvedConflictDuringUpdate", 10, "192.168.1.69/26", true}, - {"errorUpdate", 11, "192.168.1.69/26", true}, + {"l2Network", 0, "192.168.1.126/26", false}, + {"noAssignedIp", 1, "", false}, + {"successfulFree", 2, "192.168.1.2/30", false}, + {"noNetmask", 2, "192.168.1.2", false}, + {"outOfRange", 2, "192.168.1.10/30", false}, + {"invalidIp", 2, "192.168.hululu/30", false}, + {"ipv6", 2, "2a00:8a00:a000:1193:f816:3eff:fe24:e348/64", false}, + {"resolvedConflictDuringUpdate", 7, "192.168.1.69/26", false}, + {"unresolvedConflictDuringUpdate", 8, "192.168.1.69/26", true}, + {"errorUpdate", 9, "192.168.1.69/26", true}, } var gcTcs = []struct {