Skip to content

Commit 60d36dd

Browse files
committed
fix(push): fix tests
1 parent 11ecbaf commit 60d36dd

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

commands_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2948,7 +2948,8 @@ var _ = Describe("Commands", func() {
29482948

29492949
res, err = client.HPTTL(ctx, "myhash", "key1", "key2", "key200").Result()
29502950
Expect(err).NotTo(HaveOccurred())
2951-
Expect(res[0]).To(BeNumerically("~", 10*time.Second.Milliseconds(), 1))
2951+
// overhead of the push notification check is about 1-2ms for 100 commands
2952+
Expect(res[0]).To(BeNumerically("~", 10*time.Second.Milliseconds(), 2))
29522953
})
29532954

29542955
It("should HGETDEL", Label("hash", "HGETDEL"), func() {

push/push_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ func TestErrors(t *testing.T) {
14661466
t.Error("ErrHandlerExists should not return nil")
14671467
}
14681468

1469-
expectedMsg := "cannot overwrite existing handler for push notification: TEST_NOTIFICATION"
1469+
expectedMsg := "handler register failed for 'TEST_NOTIFICATION': cannot overwrite existing handler"
14701470
if err.Error() != expectedMsg {
14711471
t.Errorf("ErrHandlerExists message should be '%s', got: %s", expectedMsg, err.Error())
14721472
}
@@ -1480,7 +1480,7 @@ func TestErrors(t *testing.T) {
14801480
t.Error("ErrProtectedHandler should not return nil")
14811481
}
14821482

1483-
expectedMsg := "cannot unregister protected handler for push notification: PROTECTED_NOTIFICATION"
1483+
expectedMsg := "handler unregister failed for 'PROTECTED_NOTIFICATION': handler is protected"
14841484
if err.Error() != expectedMsg {
14851485
t.Errorf("ErrProtectedHandler message should be '%s', got: %s", expectedMsg, err.Error())
14861486
}
@@ -1494,7 +1494,7 @@ func TestErrors(t *testing.T) {
14941494
t.Error("ErrVoidProcessorRegister should not return nil")
14951495
}
14961496

1497-
expectedMsg := "cannot register push notification handler 'VOID_TEST': push notifications are disabled (using void processor)"
1497+
expectedMsg := "void_processor register failed for 'VOID_TEST': push notifications are disabled"
14981498
if err.Error() != expectedMsg {
14991499
t.Errorf("ErrVoidProcessorRegister message should be '%s', got: %s", expectedMsg, err.Error())
15001500
}
@@ -1508,7 +1508,7 @@ func TestErrors(t *testing.T) {
15081508
t.Error("ErrVoidProcessorUnregister should not return nil")
15091509
}
15101510

1511-
expectedMsg := "cannot unregister push notification handler 'VOID_TEST': push notifications are disabled (using void processor)"
1511+
expectedMsg := "void_processor unregister failed for 'VOID_TEST': push notifications are disabled"
15121512
if err.Error() != expectedMsg {
15131513
t.Errorf("ErrVoidProcessorUnregister message should be '%s', got: %s", expectedMsg, err.Error())
15141514
}

redis.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,9 @@ func (c *baseClient) processPushNotifications(ctx context.Context, cn *pool.Conn
11031103
// Use WithReader to access the reader and process push notifications
11041104
// This is critical for hitless upgrades to work properly
11051105
// NOTE: almost no timeouts are set for this read, so it should not block
1106-
// longer than necessary, 50us should be plenty of time to read if there are any push notifications
1107-
// on the socket
1108-
return cn.WithReader(ctx, 50*time.Microsecond, func(rd *proto.Reader) error {
1106+
// longer than necessary, 10us should be plenty of time to read if there are any push notifications
1107+
// on the socket. Even if it was not enough time, the next read will just read the push notifications again.
1108+
return cn.WithReader(ctx, 10*time.Microsecond, func(rd *proto.Reader) error {
11091109
// Create handler context with client, connection pool, and connection information
11101110
handlerCtx := c.pushNotificationHandlerContext(cn)
11111111
return c.pushProcessor.ProcessPendingNotifications(ctx, handlerCtx, rd)

0 commit comments

Comments
 (0)