Skip to content

Commit

Permalink
add log to migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
aojea committed Jun 27, 2024
1 parent 1017222 commit 6639411
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/integration/servicecidr/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,22 @@ func TestMigrateServiceCIDR(t *testing.T) {
if svc.Name == "kubernetes" {
continue
}

if err := client1.CoreV1().Services(svc.Namespace).Delete(context.Background(), svc.Name, metav1.DeleteOptions{}); err != nil {
t.Fatalf("got unexpected error: %v", err)
}
t.Logf("Deleted Service with IP %s", svc.Spec.ClusterIP)

// wipe the necessary fields so we can recreate the Service
svc.ResourceVersion = ""
svc.Spec.ClusterIP = ""
svc.Spec.ClusterIPs = nil
svc.Status = v1.ServiceStatus{}
if err := client1.CoreV1().Services(svc.Namespace).Delete(context.Background(), svc.Name, metav1.DeleteOptions{}); err != nil {
t.Fatalf("got unexpected error: %v", err)
}
svc, err := client1.CoreV1().Services(svc.Namespace).Create(context.Background(), &svc, metav1.CreateOptions{})
if err != nil {
t.Fatalf("got unexpected error: %v", err)
}
t.Logf("Created Service with IP %s", svc.Spec.ClusterIP)
if !cidrContainsIP(cidr2, svc.Spec.ClusterIP) {
t.Fatalf("Service expected to have an ip in range 10.168.0.0/24, got %s", svc.Spec.ClusterIP)
}
Expand Down Expand Up @@ -233,19 +237,23 @@ func TestMigrateServiceCIDR(t *testing.T) {
}

if len(cidr.Spec.CIDRs) == 0 {
t.Logf("No CIDR available")
return false, nil
}

if cidr.Spec.CIDRs[0] != cidr2 {
t.Logf("CIDR expected %s got %s", cidr2, cidr.Spec.CIDRs[0])
return false, nil
}

if len(cidr.Finalizers) == 0 {
t.Logf("Expected finalizer to be set")
return false, nil
}

for _, condition := range cidr.Status.Conditions {
if condition.Type == networkingv1alpha1.ServiceCIDRConditionReady {
t.Logf("Expected Condition %s to be %s", condition.Status, metav1.ConditionTrue)
return condition.Status == metav1.ConditionTrue, nil
}
}
Expand Down

0 comments on commit 6639411

Please sign in to comment.