From 79332951d55023926b5fdbe3335fb0ece3dc859c Mon Sep 17 00:00:00 2001 From: Karen Chen Date: Sun, 4 Aug 2024 20:18:56 -0400 Subject: [PATCH] one more UT --- v2/lockrenewer_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/v2/lockrenewer_test.go b/v2/lockrenewer_test.go index a41285a..ffb909e 100644 --- a/v2/lockrenewer_test.go +++ b/v2/lockrenewer_test.go @@ -559,7 +559,25 @@ func Test_RenewRetry(t *testing.T) { }, }, { - name: "should not retry if renew fails for an error other than context canceled", + name: "should not retry if renew fails for unknown error", + settler: &fakeSBRenewLockSettler{ + Err: fmt.Errorf("unknown error"), + }, + msgLockedUntil: to.Ptr(time.Now().Add(1 * time.Minute)), + renewTimeout: to.Ptr(100 * time.Millisecond), + verify: func(g Gomega, tc *testCase, metrics *processor.Informer) { + // should renew 3 times before message completes at 180ms + g.Eventually( + func(g Gomega) { g.Expect(tc.settler.RenewCalled.Load()).To(Equal(int32(3))) }, + 180*time.Millisecond, + 20*time.Millisecond).Should(Succeed()) + g.Expect(tc.gotMessageCtx.Err()).To(Equal(context.Canceled)) + // processor context healthy because we finished early + g.Expect(tc.processorCtx.Err()).To(BeNil()) + }, + }, + { + name: "should not retry if renew fails due to context timeout exceeded", settler: &fakeSBRenewLockSettler{ Err: context.DeadlineExceeded, },