Skip to content

Commit e839509

Browse files
committed
Add test case for shard failure detection
1 parent badfb2b commit e839509

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/e2e/example_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,35 @@ var _ = Describe("Example Controller", Label(checksumControllerName), func() {
209209
itShardShouldHaveState(lease, leases.Dead)
210210
itControllerRingShouldHaveAvailableShard(3)
211211
})
212+
213+
Describe("shard failure detection", Ordered, func() {
214+
lease := &coordinationv1.Lease{}
215+
216+
BeforeAll(func() {
217+
*lease = *newLease(10)
218+
})
219+
220+
itControllerRingShouldBeReady(3, 3)
221+
222+
itShouldCreateShardLease(lease)
223+
itShardShouldHaveState(lease, leases.Ready)
224+
itControllerRingShouldHaveAvailableShard(4)
225+
226+
It("should transition the shard lease to state expired", func(ctx SpecContext) {
227+
Eventually(ctx, Object(lease)).Should(
228+
HaveLabelWithValue(shardingv1alpha1.LabelState, leases.Expired.String()),
229+
)
230+
}, SpecTimeout(15*time.Second))
231+
232+
It("should acquire the shard lease", func(ctx SpecContext) {
233+
Eventually(ctx, Object(lease)).Should(And(
234+
HaveField("Spec.HolderIdentity", HaveValue(Equal(shardingv1alpha1.IdentityShardLeaseController))),
235+
HaveLabelWithValue(shardingv1alpha1.LabelState, leases.Dead.String()),
236+
), "lease should be acquired by sharder")
237+
}, SpecTimeout(15*time.Second))
238+
239+
itControllerRingShouldHaveAvailableShard(3)
240+
})
212241
})
213242

214243
func describeScaleController(text string, replicas int32) {

0 commit comments

Comments
 (0)