Skip to content

Commit 0777247

Browse files
Added test case for CLIENT KILL with MAXAGE option (#2971)
* Added test case for CLIENT KILL with MAXAGE option * Fixed sleep value * Added additional condition to kill specific connection * Test commit * Test commit * Updated test case to handle timeouts --------- Co-authored-by: ofekshenawa <[email protected]>
1 parent a9b4c5c commit 0777247

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

commands_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,40 @@ var _ = Describe("Commands", func() {
193193
Expect(r.Val()).To(Equal(int64(0)))
194194
})
195195

196+
It("should ClientKillByFilter with MAXAGE", func() {
197+
var s []string
198+
started := make(chan bool)
199+
done := make(chan bool)
200+
201+
go func() {
202+
defer GinkgoRecover()
203+
204+
started <- true
205+
blpop := client.BLPop(ctx, 0, "list")
206+
Expect(blpop.Val()).To(Equal(s))
207+
done <- true
208+
}()
209+
<-started
210+
211+
select {
212+
case <-done:
213+
Fail("BLPOP is not blocked.")
214+
case <-time.After(2 * time.Second):
215+
// ok
216+
}
217+
218+
killed := client.ClientKillByFilter(ctx, "MAXAGE", "1")
219+
Expect(killed.Err()).NotTo(HaveOccurred())
220+
Expect(killed.Val()).To(Equal(int64(2)))
221+
222+
select {
223+
case <-done:
224+
// ok
225+
case <-time.After(time.Second):
226+
Fail("BLPOP is still blocked.")
227+
}
228+
})
229+
196230
It("should ClientID", func() {
197231
err := client.ClientID(ctx).Err()
198232
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)