Skip to content

Commit

Permalink
E2E: dump info when the test fails
Browse files Browse the repository at this point in the history
We want to be able to triage why a test failed, so we dump whenever a
failure happens.

Signed-off-by: Federico Paolinelli <[email protected]>
  • Loading branch information
fedepaol committed Jun 30, 2023
1 parent 39ce2c5 commit bb41b12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion e2etests/e2etest_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"testing"

"github.com/metallb/frrk8stests/pkg/dump"
"github.com/metallb/frrk8stests/pkg/infra"
_ "github.com/metallb/frrk8stests/tests"
"github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -53,6 +54,7 @@ func handleFlags() {
if _, res := os.LookupEnv("RUN_FRR_CONTAINER_ON_HOST_NETWORK"); res {
runOnHost = true
}
dump.ReportPath = reportPath
}

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -100,7 +102,6 @@ var _ = ginkgo.BeforeSuite(func() {
*/
}

//reporter := k8s.InitReporter(framework.TestContext.KubeConfig, reportPath, metallb.Namespace)
})

var _ = ginkgo.AfterSuite(func() {
Expand Down
16 changes: 10 additions & 6 deletions e2etests/tests/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

frrk8sv1beta1 "github.com/metallb/frrk8s/api/v1beta1"
"github.com/metallb/frrk8stests/pkg/config"
"github.com/metallb/frrk8stests/pkg/dump"
"github.com/metallb/frrk8stests/pkg/infra"
"github.com/metallb/frrk8stests/pkg/k8s"
frrconfig "go.universe.tf/e2etest/pkg/frr/config"
"go.universe.tf/e2etest/pkg/ipfamily"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -19,24 +21,26 @@ import (
admissionapi "k8s.io/pod-security-admission/api"
)

var (
updater *config.Updater
)

var _ = ginkgo.Describe("FRR k8s", func() {
var cs clientset.Interface
var f *framework.Framework

defer ginkgo.GinkgoRecover()
clientconfig, err := framework.LoadConfig()
framework.ExpectNoError(err)
updater, err = config.NewUpdater(clientconfig)
updater, err := config.NewUpdater(clientconfig)
framework.ExpectNoError(err)
reporter := dump.NewK8sReporter(framework.TestContext.KubeConfig, k8s.FRRK8sNamespace)

f = framework.NewDefaultFramework("bgpfrr")
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged

ginkgo.AfterEach(func() {
// TODO: dump the failure information via a reporter
if ginkgo.CurrentSpecReport().Failed() {
testName := ginkgo.CurrentSpecReport().LeafNodeText
dump.K8sInfo(testName, reporter)
dump.BGPInfo(testName, infra.FRRContainers, f.ClientSet, f)
}
})

ginkgo.BeforeEach(func() {
Expand Down

0 comments on commit bb41b12

Please sign in to comment.