test: Print cluster information when a test fails
This may help us find out why some tests time out.
@@ -45,6 +45,8 @@ var _ = SynchronizedBeforeSuite(func() []byte {
}, func(randomSuffix []byte) {
var err error
+ RegisterFailHandler(FailWithReport)
+
nodeSuffix = fmt.Sprintf("%d-%s",
config.GinkgoConfig.ParallelNode, string(randomSuffix))
nodeTmpDir, err = ioutil.TempDir("", "carrier-"+nodeSuffix)
@@ -229,3 +231,24 @@ func checkDependencies() error {
return errors.New("Please check your PATH, some of our dependencies were not found")
}
+
+func FailWithReport(message string, callerSkip ...int) {
+ fmt.Println("\nA test failed. You may find the following information useful for debugging:")
+ fmt.Println("The cluster pods: ")
+ out, err := helpers.Kubectl("get pods --all-namespaces")
+ if err != nil {
+ fmt.Print(err.Error())
+ } else {
+ fmt.Print(out)
+ }
+
+ fmt.Println("The cluster deployments: ")
+ out, err = helpers.Kubectl("get deployments --all-namespaces")
+ if err != nil {
+ fmt.Print(err.Error())
+ } else {
+ fmt.Print(out)
+ }
+
+ Fail(message, callerSkip...)
+}
