Skip to content

Commit 771f16d

Browse files
committed
Add additional info to test failures
1 parent 224bd8e commit 771f16d

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

test/mainline_test.go

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,11 @@ func assertAvailable(ts *operator.TigeraStatus) error {
308308
available, degraded, progressing := readStatus(ts)
309309

310310
if progressing {
311-
return fmt.Errorf("TigeraStatus is still progressing")
311+
return fmt.Errorf("TigeraStatus is still progressing %v", ts)
312312
} else if degraded {
313-
return fmt.Errorf("TigeraStatus is degraded")
313+
return fmt.Errorf("TigeraStatus is degraded %v", ts)
314314
} else if !available {
315-
return fmt.Errorf("TigeraStatus is not available")
315+
return fmt.Errorf("TigeraStatus is not available %v", ts)
316316
}
317317
return nil
318318
}
@@ -321,11 +321,11 @@ func assertDegraded(ts *operator.TigeraStatus) error {
321321
available, degraded, progressing := readStatus(ts)
322322

323323
if progressing {
324-
return fmt.Errorf("TigeraStatus is still progressing")
324+
return fmt.Errorf("TigeraStatus is still progressing %v", ts)
325325
} else if !degraded {
326-
return fmt.Errorf("TigeraStatus is not degraded")
326+
return fmt.Errorf("TigeraStatus is not degraded %v", ts)
327327
} else if available {
328-
return fmt.Errorf("TigeraStatus is available")
328+
return fmt.Errorf("TigeraStatus is available %v", ts)
329329
}
330330
return nil
331331
}
@@ -486,7 +486,33 @@ func removeInstallation(ctx context.Context, c client.Client, name string) {
486486
return err
487487
}
488488
return fmt.Errorf("Installation still exists")
489-
}, 120*time.Second).ShouldNot(HaveOccurred())
489+
}, 120*time.Second).ShouldNot(HaveOccurred(), func() string {
490+
// Collect debugging information for failure message
491+
var debugInfo strings.Builder
492+
debugInfo.WriteString("Installation instance still exists:\n")
493+
debugInfo.WriteString(fmt.Sprintf("Instance: %+v\n", instance))
494+
495+
// Get calico-system namespace
496+
ns := &corev1.Namespace{}
497+
if err := c.Get(ctx, client.ObjectKey{Name: "calico-system"}, ns); err != nil {
498+
debugInfo.WriteString(fmt.Sprintf("Failed to get calico-system namespace: %v\n", err))
499+
} else {
500+
debugInfo.WriteString(fmt.Sprintf("calico-system namespace: %+v\n", ns))
501+
}
502+
503+
// Get all pods in calico-system namespace
504+
pods := &corev1.PodList{}
505+
if err := c.List(ctx, pods, client.InNamespace("calico-system")); err != nil {
506+
debugInfo.WriteString(fmt.Sprintf("Failed to list pods in calico-system namespace: %v\n", err))
507+
} else {
508+
debugInfo.WriteString(fmt.Sprintf("Pods in calico-system namespace (%d pods):\n", len(pods.Items)))
509+
for i, pod := range pods.Items {
510+
debugInfo.WriteString(fmt.Sprintf(" Pod %d: Name=%s, Phase=%s, Ready=%v\n", i+1, pod.Name, pod.Status.Phase, pod.Status.ContainerStatuses))
511+
}
512+
}
513+
514+
return debugInfo.String()
515+
})
490516
}
491517

492518
func verifyAPIServerHasDeployed(c client.Client) {
@@ -556,7 +582,7 @@ func verifyCalicoHasDeployed(c client.Client) {
556582
return err
557583
}
558584
return assertAvailable(ts)
559-
}, 60*time.Second).Should(BeNil())
585+
}, 60*time.Second).Should(BeNil(), "expect calico TigeraStatus to be available")
560586
}
561587

562588
func verifyCRDsExist(c client.Client, variant operator.ProductVariant) {

0 commit comments

Comments
 (0)