mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
tests: retry deferred test assertion in t.Cleanup
Just like all other test assertions, this one should also be retried until it succeeds or times out. It seems this wasn't a problem before, but with the upcoming changes to Icinga 2.16, this assertion will fail occasionally since the queries are now sent with a bit of delay. By retrying the assertion, we can ensure that it will eventually succeed once the queries are processed or time out after a reasonable period.
This commit is contained in:
parent
bf448666a4
commit
7497d4c317
1 changed files with 10 additions and 2 deletions
|
|
@ -319,7 +319,11 @@ func TestObjectSync(t *testing.T) {
|
|||
t.Run("Dependency", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Cleanup(func() { assertNoDependencyDanglingReferences(t, r, db) })
|
||||
t.Cleanup(func() {
|
||||
eventually.Assert(t, func(t require.TestingT) {
|
||||
assertNoDependencyDanglingReferences(t, r, db)
|
||||
}, 20*time.Second, 200*time.Millisecond)
|
||||
})
|
||||
|
||||
for _, dependencyGroupTest := range data.DependencyGroups {
|
||||
t.Run(dependencyGroupTest.TestName, func(t *testing.T) {
|
||||
|
|
@ -715,7 +719,11 @@ func TestObjectSync(t *testing.T) {
|
|||
// parent test (Dependencies) teardown process. Note, this isn't the same as using plain defer ..., as
|
||||
// all the subtests runs in parallel, and we want to make sure that the check is performed after all of
|
||||
// them have completed and not when this closure returns.
|
||||
t.Cleanup(func() { assertNoDependencyDanglingReferences(t, r, db) })
|
||||
t.Cleanup(func() {
|
||||
eventually.Assert(t, func(t require.TestingT) {
|
||||
assertNoDependencyDanglingReferences(t, r, db)
|
||||
}, 20*time.Second, 200*time.Millisecond)
|
||||
})
|
||||
|
||||
for _, testCase := range makeRuntimeDependencyGroupTestCases() {
|
||||
t.Run("CreateAndDelete-"+testCase.TestName, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue