Skip to content

Commit

Permalink
Merge pull request #24737 from smarterclayton/catch_panic
Browse files Browse the repository at this point in the history
test: Catch panics in the main disruption body
  • Loading branch information
openshift-merge-robot committed Mar 22, 2020
2 parents 283f1bc + 4e1c090 commit 118a712
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 118a712

Please sign in to comment.