From e6759223d0869560e2dd8177ef4e33251164dd8d Mon Sep 17 00:00:00 2001 From: zirain Date: Mon, 12 May 2025 07:44:16 +0800 Subject: [PATCH] conformance: add Hook in ConformanceTestSuite --- conformance/utils/suite/suite.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conformance/utils/suite/suite.go b/conformance/utils/suite/suite.go index 53700d6c53..8e5e458e48 100644 --- a/conformance/utils/suite/suite.go +++ b/conformance/utils/suite/suite.go @@ -74,6 +74,7 @@ type ConformanceTestSuite struct { SkipTests sets.Set[string] SkipProvisionalTests bool RunTest string + Hook func(t *testing.T, test ConformanceTest, suite *ConformanceTestSuite) ManifestFS []fs.FS UsableNetworkAddresses []v1beta1.GatewaySpecAddress UnusableNetworkAddresses []v1beta1.GatewaySpecAddress @@ -470,6 +471,13 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) er if res == testSucceeded || res == testFailed { sleepForTestIsolation = true } + + // call the hook function if it was provided, + // this's useful for running custom logic after each test, + // such as collecting current state of the cluster for debugging. + if suite.Hook != nil { + suite.Hook(t, test, suite) + } } // now that the tests have completed, mark the test suite as not running