mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 10:48:15 +00:00
proxy: cleanup UpdateServiceMapResult
Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
@@ -2966,16 +2966,11 @@ func TestBuildServiceMapAddRemove(t *testing.T) {
|
||||
for i := range services {
|
||||
fp.OnServiceAdd(services[i])
|
||||
}
|
||||
result := fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 10 {
|
||||
t.Errorf("expected service map length 10, got %v", fp.svcPortMap)
|
||||
}
|
||||
|
||||
if len(result.DeletedUDPClusterIPs) != 0 {
|
||||
// Services only added, so nothing stale yet
|
||||
t.Errorf("expected stale UDP services length 0, got %d", len(result.DeletedUDPClusterIPs))
|
||||
}
|
||||
|
||||
// The only-local-loadbalancer ones get added
|
||||
healthCheckNodePorts := fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 1 {
|
||||
@@ -3000,24 +2995,11 @@ func TestBuildServiceMapAddRemove(t *testing.T) {
|
||||
fp.OnServiceDelete(services[2])
|
||||
fp.OnServiceDelete(services[3])
|
||||
|
||||
result = fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 1 {
|
||||
t.Errorf("expected service map length 1, got %v", fp.svcPortMap)
|
||||
}
|
||||
|
||||
// All services but one were deleted. While you'd expect only the ClusterIPs
|
||||
// from the three deleted services here, we still have the ClusterIP for
|
||||
// the not-deleted service, because one of it's ServicePorts was deleted.
|
||||
expectedStaleUDPServices := []string{"172.30.55.10", "172.30.55.4", "172.30.55.11", "172.30.55.12"}
|
||||
if len(result.DeletedUDPClusterIPs) != len(expectedStaleUDPServices) {
|
||||
t.Errorf("expected stale UDP services length %d, got %v", len(expectedStaleUDPServices), result.DeletedUDPClusterIPs.UnsortedList())
|
||||
}
|
||||
for _, ip := range expectedStaleUDPServices {
|
||||
if !result.DeletedUDPClusterIPs.Has(ip) {
|
||||
t.Errorf("expected stale UDP service service %s", ip)
|
||||
}
|
||||
}
|
||||
|
||||
healthCheckNodePorts = fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 0 {
|
||||
t.Errorf("expected 0 healthcheck ports, got %v", healthCheckNodePorts)
|
||||
@@ -3041,15 +3023,11 @@ func TestBuildServiceMapServiceHeadless(t *testing.T) {
|
||||
)
|
||||
|
||||
// Headless service should be ignored
|
||||
result := fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 0 {
|
||||
t.Errorf("expected service map length 0, got %d", len(fp.svcPortMap))
|
||||
}
|
||||
|
||||
if len(result.DeletedUDPClusterIPs) != 0 {
|
||||
t.Errorf("expected stale UDP services length 0, got %d", len(result.DeletedUDPClusterIPs))
|
||||
}
|
||||
|
||||
// No proxied services, so no healthchecks
|
||||
healthCheckNodePorts := fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 0 {
|
||||
@@ -3070,13 +3048,10 @@ func TestBuildServiceMapServiceTypeExternalName(t *testing.T) {
|
||||
}),
|
||||
)
|
||||
|
||||
result := fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 0 {
|
||||
t.Errorf("expected service map length 0, got %v", fp.svcPortMap)
|
||||
}
|
||||
if len(result.DeletedUDPClusterIPs) != 0 {
|
||||
t.Errorf("expected stale UDP services length 0, got %v", result.DeletedUDPClusterIPs)
|
||||
}
|
||||
// No proxied services, so no healthchecks
|
||||
healthCheckNodePorts := fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 0 {
|
||||
@@ -3111,14 +3086,10 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
|
||||
|
||||
fp.OnServiceAdd(servicev1)
|
||||
|
||||
result := fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 2 {
|
||||
t.Errorf("expected service map length 2, got %v", fp.svcPortMap)
|
||||
}
|
||||
if len(result.DeletedUDPClusterIPs) != 0 {
|
||||
// Services only added, so nothing stale yet
|
||||
t.Errorf("expected stale UDP services length 0, got %d", len(result.DeletedUDPClusterIPs))
|
||||
}
|
||||
healthCheckNodePorts := fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 0 {
|
||||
t.Errorf("expected healthcheck ports length 0, got %v", healthCheckNodePorts)
|
||||
@@ -3126,13 +3097,10 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
|
||||
|
||||
// Change service to load-balancer
|
||||
fp.OnServiceUpdate(servicev1, servicev2)
|
||||
result = fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 2 {
|
||||
t.Errorf("expected service map length 2, got %v", fp.svcPortMap)
|
||||
}
|
||||
if len(result.DeletedUDPClusterIPs) != 0 {
|
||||
t.Errorf("expected stale UDP services length 0, got %v", result.DeletedUDPClusterIPs.UnsortedList())
|
||||
}
|
||||
healthCheckNodePorts = fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 1 {
|
||||
t.Errorf("expected healthcheck ports length 1, got %v", healthCheckNodePorts)
|
||||
@@ -3141,13 +3109,10 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
|
||||
// No change; make sure the service map stays the same and there are
|
||||
// no health-check changes
|
||||
fp.OnServiceUpdate(servicev2, servicev2)
|
||||
result = fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 2 {
|
||||
t.Errorf("expected service map length 2, got %v", fp.svcPortMap)
|
||||
}
|
||||
if len(result.DeletedUDPClusterIPs) != 0 {
|
||||
t.Errorf("expected stale UDP services length 0, got %v", result.DeletedUDPClusterIPs.UnsortedList())
|
||||
}
|
||||
healthCheckNodePorts = fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 1 {
|
||||
t.Errorf("expected healthcheck ports length 1, got %v", healthCheckNodePorts)
|
||||
@@ -3155,14 +3120,10 @@ func TestBuildServiceMapServiceUpdate(t *testing.T) {
|
||||
|
||||
// And back to ClusterIP
|
||||
fp.OnServiceUpdate(servicev2, servicev1)
|
||||
result = fp.svcPortMap.Update(fp.serviceChanges)
|
||||
fp.svcPortMap.Update(fp.serviceChanges)
|
||||
if len(fp.svcPortMap) != 2 {
|
||||
t.Errorf("expected service map length 2, got %v", fp.svcPortMap)
|
||||
}
|
||||
if len(result.DeletedUDPClusterIPs) != 0 {
|
||||
// Services only added, so nothing stale yet
|
||||
t.Errorf("expected stale UDP services length 0, got %d", len(result.DeletedUDPClusterIPs))
|
||||
}
|
||||
healthCheckNodePorts = fp.svcPortMap.HealthCheckNodePorts()
|
||||
if len(healthCheckNodePorts) != 0 {
|
||||
t.Errorf("expected healthcheck ports length 0, got %v", healthCheckNodePorts)
|
||||
|
||||
Reference in New Issue
Block a user