Change-Id: I7ac9ccb609a77ff5d0e4635c5d91e23cc88fd4ae
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
if r := recover(); r != nil {
if err, ok := r.(error); ok {
d.failReason = err.Error()
- d.changeStatus(DJ_FAIL)
- return
+ } else {
+ d.failReason = fmt.Sprintf("run panicked: %v", r)
}
- panic(r)
+ d.changeStatus(DJ_FAIL)
+ return
}
d.changeStatus(DJ_OK)
}()
}),
)
+ DescribeTable("should recover a panic and go to failed state",
+ func(f func()) {
+ f()
+ djSync <- struct{}{}
+ fail := DryadJobStatusChange{jobID, DJ_FAIL}
+ Eventually(changes).Should(Receive(Equal(fail)))
+ },
+ Entry("deploy", func() {
+ deploy.Do(func() { panic("deploy") })
+ boot.Times(0)
+ test.Times(0)
+ }),
+ Entry("boot", func() {
+ boot.Do(func() { panic("boot") })
+ test.Times(0)
+ }),
+ Entry("test", func() {
+ test.Do(func() { panic("test") })
+ }),
+ )
+
It("should return DryadJobInfo", func() {
djSync <- struct{}{}
info := dj.GetJobInfo()