diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index eec98bf2790..3aaed7453f0 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -32,6 +32,7 @@ import ( "path" "path/filepath" "regexp" + "runtime/debug" "sort" "strconv" "strings" @@ -1359,16 +1360,28 @@ func RandomSuffix() string { // ExpectEqual expects the specified two are the same, otherwise an exception raises func ExpectEqual(actual interface{}, extra interface{}, explain ...interface{}) { + if isEqual, _ := gomega.Equal(extra).Match(actual); !isEqual { + e2elog.Logf("Unexpected unequal occurred: %v and %v", actual, extra) + debug.PrintStack() + } gomega.Expect(actual).To(gomega.Equal(extra), explain...) } // ExpectNotEqual expects the specified two are not the same, otherwise an exception raises func ExpectNotEqual(actual interface{}, extra interface{}, explain ...interface{}) { + if isEqual, _ := gomega.Equal(extra).Match(actual); isEqual { + e2elog.Logf("Expect to be unequal: %v and %v", actual, extra) + debug.PrintStack() + } gomega.Expect(actual).NotTo(gomega.Equal(extra), explain...) } // ExpectError expects an error happens, otherwise an exception raises func ExpectError(err error, explain ...interface{}) { + if err == nil { + e2elog.Logf("Expect error to occur.") + debug.PrintStack() + } gomega.Expect(err).To(gomega.HaveOccurred(), explain...) } @@ -1382,6 +1395,7 @@ func ExpectNoError(err error, explain ...interface{}) { func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{}) { if err != nil { e2elog.Logf("Unexpected error occurred: %v", err) + debug.PrintStack() } gomega.ExpectWithOffset(1+offset, err).NotTo(gomega.HaveOccurred(), explain...) } @@ -1396,6 +1410,9 @@ func ExpectNoErrorWithRetries(fn func() error, maxRetries int, explain ...interf } e2elog.Logf("(Attempt %d of %d) Unexpected error occurred: %v", i+1, maxRetries, err) } + if err != nil { + debug.PrintStack() + } gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred(), explain...) }