Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conformance/utils/config/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ package config
import "time"

type TimeoutConfig struct {
// TestIsolation represents the time block between test cases to enhance test isolation.
// Max value for conformant implementation: None
TestIsolation time.Duration

// CreateTimeout represents the maximum time for a Kubernetes object to be created.
// Max value for conformant implementation: None
CreateTimeout time.Duration
Expand Down
17 changes: 14 additions & 3 deletions conformance/utils/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,8 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) er

// run all tests and collect the test results for conformance reporting
results := make(map[string]testResult)
sleepForTestIsolation := false
for _, test := range tests {
succeeded := t.Run(test.ShortName, func(t *testing.T) {
test.Run(t, suite)
})
res := testSucceeded
if suite.SkipTests.Has(test.ShortName) {
res = testSkipped
Expand All @@ -404,6 +402,16 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) er
res = testNotSupported
}

// TODO(wstcliyu): need a better long term solution for test isolation
// https://github.com/kubernetes-sigs/gateway-api/issues/3233
if res != testSkipped && res != testNotSupported && sleepForTestIsolation {
tlog.Logf(t, "Sleeping %v for test isolation", suite.TimeoutConfig.TestIsolation)
time.Sleep(suite.TimeoutConfig.TestIsolation)
}

succeeded := t.Run(test.ShortName, func(t *testing.T) {
test.Run(t, suite)
})
if !succeeded {
res = testFailed
}
Expand All @@ -412,6 +420,9 @@ func (suite *ConformanceTestSuite) Run(t *testing.T, tests []ConformanceTest) er
test: test,
result: res,
}
if res == testSucceeded || res == testFailed {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Would be good to skip this step when you're finishing the last step - presumably it's only useful in between tests and not after the last one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. The sleep is performed for the last test as well. We should perform some checks on the test index.

Copy link
Copy Markdown
Contributor Author

@wstcliyu wstcliyu Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments. I've updated the code here to sleep before running each test case that is not skipped except the first test case. Please review again

sleepForTestIsolation = true
}
}

// now that the tests have completed, mark the test suite as not running
Expand Down