Skip to content

Commit 6559130

Browse files
author
Bhargav Dodla
committed
fix: Added tests
1 parent 02ed4e1 commit 6559130

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

osscluster_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,38 @@ var _ = Describe("ClusterClient", func() {
556556
AfterEach(func() {})
557557

558558
assertPipeline()
559+
560+
It("doesn't fail node with context.Canceled error", func() {
561+
ctx, cancel := context.WithCancel(context.Background())
562+
cancel()
563+
pipe.Set(ctx, "A", "A_value", 0)
564+
cmds, err := pipe.Exec(ctx)
565+
Expect(cmds).To(HaveLen(1))
566+
Expect(err).To(Equal(context.Canceled))
567+
568+
clientNodes, _ := client.Nodes(ctx, "A")
569+
570+
for _, node := range clientNodes {
571+
Expect(node.Failing()).To(BeFalse())
572+
}
573+
})
574+
575+
It("doesn't fail node with context.DeadlineExceeded error", func() {
576+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
577+
defer cancel()
578+
579+
pipe.Set(ctx, "A", "A_value", 0)
580+
_, err := pipe.Exec(ctx)
581+
582+
Expect(err).To(HaveOccurred())
583+
Expect(errors.Is(err, context.DeadlineExceeded)).To(BeTrue())
584+
585+
clientNodes, _ := client.Nodes(ctx, "A")
586+
587+
for _, node := range clientNodes {
588+
Expect(node.Failing()).To(BeFalse())
589+
}
590+
})
559591
})
560592

561593
Describe("with TxPipeline", func() {

0 commit comments

Comments
 (0)