Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Catch panics in the main disruption body #24737

Merged
merged 1 commit into from
Mar 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/extended/util/disruption/disruption.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func Run(description, testname string, adapter TestData, invariants []upgrades.T
cm := chaosmonkey.New(func() {
start := time.Now()
defer finalizeTest(start, test, nil)
defer g.GinkgoRecover()
fn()
})
runChaosmonkey(cm, adapter, invariants, testSuite)
Expand Down Expand Up @@ -160,6 +161,7 @@ func finalizeTest(start time.Time, tc *junit.TestCase, f *framework.Framework) {
}
return
}
framework.Logf("recover: %v", r)

switch r := r.(type) {
case ginkgowrapper.FailurePanic:
Expand All @@ -181,6 +183,14 @@ func finalizeTest(start time.Time, tc *junit.TestCase, f *framework.Framework) {
},
}
}
// if we have a panic but it hasn't been recorded by ginkgo, panic now
if !g.CurrentGinkgoTestDescription().Failed {
framework.Logf("%q: panic: %v", tc.Name, r)
func() {
defer g.GinkgoRecover()
panic(r)
}()
}
}

// TODO: accept a default framework
Expand Down