@@ -74,6 +74,7 @@ type ConformanceTestSuite struct {
74
74
SkipTests sets.Set [string ]
75
75
SkipProvisionalTests bool
76
76
RunTest string
77
+ Hook func (t * testing.T , test ConformanceTest , suite * ConformanceTestSuite )
77
78
ManifestFS []fs.FS
78
79
UsableNetworkAddresses []v1beta1.GatewaySpecAddress
79
80
UnusableNetworkAddresses []v1beta1.GatewaySpecAddress
@@ -121,7 +122,7 @@ type ConformanceTestSuite struct {
121
122
lock sync.RWMutex
122
123
}
123
124
124
- // Options can be used to initialize a ConformanceTestSuite.
125
+ // ConformanceOptions can be used to initialize a ConformanceTestSuite.
125
126
type ConformanceOptions struct {
126
127
Client client.Client
127
128
ClientOptions client.Options
@@ -152,7 +153,8 @@ type ConformanceOptions struct {
152
153
SkipProvisionalTests bool
153
154
// RunTest is a single test to run, mostly for development/debugging convenience.
154
155
RunTest string
155
-
156
+ // Hook is an optional function that can be used to run custom logic after each test at suite level.
157
+ Hook func (t * testing.T , test ConformanceTest , suite * ConformanceTestSuite )
156
158
ManifestFS []fs.FS
157
159
158
160
// UsableNetworkAddresses is an optional pool of usable addresses for
@@ -268,6 +270,7 @@ func NewConformanceTestSuite(options ConformanceOptions) (*ConformanceTestSuite,
268
270
mode : mode ,
269
271
apiVersion : apiVersion ,
270
272
apiChannel : apiChannel ,
273
+ Hook : options .Hook ,
271
274
}
272
275
273
276
for _ , conformanceProfileName := range options .ConformanceProfiles .UnsortedList () {
@@ -470,6 +473,13 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) er
470
473
if res == testSucceeded || res == testFailed {
471
474
sleepForTestIsolation = true
472
475
}
476
+
477
+ // call the hook function if it was provided,
478
+ // this's useful for running custom logic after each test at suite level,
479
+ // such as collecting current state of the cluster for debugging.
480
+ if suite .Hook != nil {
481
+ suite .Hook (t , test , suite )
482
+ }
473
483
}
474
484
475
485
// now that the tests have completed, mark the test suite as not running
0 commit comments