Skip to content

Commit

Permalink
Test deleting all EgressIPs from auto-assigned NetNamespace
Browse files Browse the repository at this point in the history
  • Loading branch information
danwinship committed Aug 21, 2018
1 parent 6bb345b commit 31c3218
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/network/common/egressip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,31 +958,41 @@ func TestEgressCIDRAllocation(t *testing.T) {
t.Fatalf("%v", err)
}

// Changing the EgressIPs of a namespace should drop the old allocation and create a new one
// Changing/Removing the EgressIPs of a namespace should drop the old allocation and create a new one
updateNetNamespaceEgress(eit, &networkapi.NetNamespace{
NetID: 46,
EgressIPs: []string{"172.17.0.202"}, // was 172.17.0.200
})
updateNetNamespaceEgress(eit, &networkapi.NetNamespace{
NetID: 44,
EgressIPs: []string{}, // was 172.17.1.1
})
err = w.assertChanges(
"release 172.17.0.200 on 172.17.0.4",
"namespace 46 dropped",
"update egress CIDRs",
"release 172.17.1.1 on 172.17.0.3",
"namespace 44 normal",
"update egress CIDRs",
)
if err != nil {
t.Fatalf("%v", err)
}

allocation = eit.ReallocateEgressIPs()
for _, ip := range allocation["node-4"] {
if ip == "172.17.0.200" {
t.Fatalf("reallocation failed to drop unused egress IP 172.17.0.200: %#v", allocation)
for _, nodeAllocation := range allocation {
for _, ip := range nodeAllocation {
if ip == "172.17.1.1" || ip == "172.17.0.200" {
t.Fatalf("reallocation failed to drop unused egress IP %s: %#v", ip, allocation)
}
}
}
updateAllocations(eit, allocation)
err = w.assertChanges(
"claim 172.17.0.202 on 172.17.0.4 for namespace 46",
"namespace 46 via 172.17.0.202 on 172.17.0.4",
"update egress CIDRs",
"update egress CIDRs",
)
if err != nil {
t.Fatalf("%v", err)
Expand Down

0 comments on commit 31c3218

Please sign in to comment.