@@ -958,31 +958,41 @@ func TestEgressCIDRAllocation(t *testing.T) {
958958 t .Fatalf ("%v" , err )
959959 }
960960
961- // Changing the EgressIPs of a namespace should drop the old allocation and create a new one
961+ // Changing/Removing the EgressIPs of a namespace should drop the old allocation and create a new one
962962 updateNetNamespaceEgress (eit , & networkapi.NetNamespace {
963963 NetID : 46 ,
964964 EgressIPs : []string {"172.17.0.202" }, // was 172.17.0.200
965965 })
966+ updateNetNamespaceEgress (eit , & networkapi.NetNamespace {
967+ NetID : 44 ,
968+ EgressIPs : []string {}, // was 172.17.1.1
969+ })
966970 err = w .assertChanges (
967971 "release 172.17.0.200 on 172.17.0.4" ,
968972 "namespace 46 dropped" ,
969973 "update egress CIDRs" ,
974+ "release 172.17.1.1 on 172.17.0.3" ,
975+ "namespace 44 normal" ,
976+ "update egress CIDRs" ,
970977 )
971978 if err != nil {
972979 t .Fatalf ("%v" , err )
973980 }
974981
975982 allocation = eit .ReallocateEgressIPs ()
976- for _ , ip := range allocation ["node-4" ] {
977- if ip == "172.17.0.200" {
978- t .Fatalf ("reallocation failed to drop unused egress IP 172.17.0.200: %#v" , allocation )
983+ for _ , nodeAllocation := range allocation {
984+ for _ , ip := range nodeAllocation {
985+ if ip == "172.17.1.1" || ip == "172.17.0.200" {
986+ t .Fatalf ("reallocation failed to drop unused egress IP %s: %#v" , ip , allocation )
987+ }
979988 }
980989 }
981990 updateAllocations (eit , allocation )
982991 err = w .assertChanges (
983992 "claim 172.17.0.202 on 172.17.0.4 for namespace 46" ,
984993 "namespace 46 via 172.17.0.202 on 172.17.0.4" ,
985994 "update egress CIDRs" ,
995+ "update egress CIDRs" ,
986996 )
987997 if err != nil {
988998 t .Fatalf ("%v" , err )
0 commit comments