Skip to content

Commit

Permalink
Move the k8sreporter dump into FailHandler
Browse files Browse the repository at this point in the history
This commit moves the reporter.Dump() call into the FailHandler.
We do this because previously, having the reporter dump in the
ReportAfterEach, we didn't get the desired logs because
the test namesapce would be cleaned beforehand in the AfterEach/
AfterAll phase.

Signed-off-by: Lior Noy <[email protected]>
  • Loading branch information
liornoy committed Aug 28, 2023
1 parent dbb57ea commit d7a9dab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
22 changes: 9 additions & 13 deletions test/e2e/functional/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"testing"

. "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/v2/types"
. "github.com/onsi/gomega"

kniK8sReporter "github.com/openshift-kni/k8sreporter"

"github.com/metallb/metallb-operator/test/consts"
_ "github.com/metallb/metallb-operator/test/e2e/functional/tests"
"github.com/metallb/metallb-operator/test/e2e/k8sreporter"
kniK8sReporter "github.com/openshift-kni/k8sreporter"
)

var OperatorNameSpace = consts.DefaultOperatorNameSpace
Expand All @@ -35,7 +35,13 @@ func init() {
}

func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
RegisterFailHandler(
func(message string, callerSkip ...int) {
if r != nil {
k8sreporter.DumpInfo(r, CurrentSpecReport().FullText())
}
Fail(message, callerSkip...)
})

_, reporterConfig := GinkgoConfiguration()

Expand All @@ -51,13 +57,3 @@ func TestE2E(t *testing.T) {

RunSpecs(t, "Metallb Operator E2E Suite", reporterConfig)
}

var _ = ReportAfterEach(func(specReport types.SpecReport) {
if specReport.Failed() == false {
return
}

if *reportPath != "" {
k8sreporter.DumpInfo(r, specReport.FullText())
}
})
22 changes: 9 additions & 13 deletions test/e2e/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"testing"

. "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/v2/types"
. "github.com/onsi/gomega"

kniK8sReporter "github.com/openshift-kni/k8sreporter"

"github.com/metallb/metallb-operator/test/consts"
"github.com/metallb/metallb-operator/test/e2e/k8sreporter"
_ "github.com/metallb/metallb-operator/test/e2e/validation/tests"
kniK8sReporter "github.com/openshift-kni/k8sreporter"
)

var OperatorNameSpace = consts.DefaultOperatorNameSpace
Expand All @@ -35,7 +35,13 @@ func init() {
}

func TestValidation(t *testing.T) {
RegisterFailHandler(Fail)
RegisterFailHandler(
func(message string, callerSkip ...int) {
if r != nil {
k8sreporter.DumpInfo(r, CurrentSpecReport().FullText())
}
Fail(message, callerSkip...)
})

_, reporterConfig := GinkgoConfiguration()

Expand All @@ -51,13 +57,3 @@ func TestValidation(t *testing.T) {

RunSpecs(t, "Metallb Operator Validation Suite", reporterConfig)
}

var _ = ReportAfterEach(func(specReport types.SpecReport) {
if specReport.Failed() == false {
return
}

if *reportPath != "" {
k8sreporter.DumpInfo(r, specReport.FullText())
}
})

0 comments on commit d7a9dab

Please sign in to comment.