Skip to content

Commit 75ddeb3

Browse files
ndyakovelena-kolevskahtemelski-redis
authored
feat(e2e-testing): maintnotifications e2e and refactor (#3526)
* e2e wip * cleanup * remove unused fault injector mock * errChan in test * remove log messages tests * cleanup log messages * s/hitless/maintnotifications/ * fix moving when none * better logs * test with second client after action has started * Fixes Signed-off-by: Elena Kolevska <[email protected]> * Test fix Signed-off-by: Elena Kolevska <[email protected]> * feat(e2e-test): Extended e2e tests * imroved e2e test resiliency --------- Signed-off-by: Elena Kolevska <[email protected]> Co-authored-by: Elena Kolevska <[email protected]> Co-authored-by: Elena Kolevska <[email protected]> Co-authored-by: Hristo Temelski <[email protected]>
1 parent e6e52bc commit 75ddeb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+5848
-570
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ coverage.txt
99
**/coverage.txt
1010
.vscode
1111
tmp/*
12+
*.test
1213

13-
# Hitless upgrade documentation (temporary)
14-
hitless/docs/
14+
# maintenanceNotifications upgrade documentation (temporary)
15+
maintenanceNotifications/docs/

async_handoff_integration_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/redis/go-redis/v9/hitless"
10+
"github.com/redis/go-redis/v9/maintnotifications"
1111
"github.com/redis/go-redis/v9/internal/pool"
1212
"github.com/redis/go-redis/v9/logging"
1313
)
@@ -42,7 +42,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
4242
}
4343

4444
// Create processor with event-driven handoff support
45-
processor := hitless.NewPoolHook(baseDialer, "tcp", nil, nil)
45+
processor := maintnotifications.NewPoolHook(baseDialer, "tcp", nil, nil)
4646
defer processor.Shutdown(context.Background())
4747

4848
// Create a test pool with hooks
@@ -141,7 +141,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
141141
return &mockNetConn{addr: addr}, nil
142142
}
143143

144-
processor := hitless.NewPoolHook(baseDialer, "tcp", nil, nil)
144+
processor := maintnotifications.NewPoolHook(baseDialer, "tcp", nil, nil)
145145
defer processor.Shutdown(context.Background())
146146

147147
// Create hooks manager and add processor as hook
@@ -213,7 +213,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
213213
return nil, &net.OpError{Op: "dial", Err: &net.DNSError{Name: addr}}
214214
}
215215

216-
processor := hitless.NewPoolHook(failingDialer, "tcp", nil, nil)
216+
processor := maintnotifications.NewPoolHook(failingDialer, "tcp", nil, nil)
217217
defer processor.Shutdown(context.Background())
218218

219219
// Create hooks manager and add processor as hook
@@ -276,7 +276,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
276276
return &mockNetConn{addr: addr}, nil
277277
}
278278

279-
processor := hitless.NewPoolHook(slowDialer, "tcp", nil, nil)
279+
processor := maintnotifications.NewPoolHook(slowDialer, "tcp", nil, nil)
280280
defer processor.Shutdown(context.Background())
281281

282282
// Create hooks manager and add processor as hook

commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ func (c cmdable) ClientInfo(ctx context.Context) *ClientInfoCmd {
520520
return cmd
521521
}
522522

523-
// ClientMaintNotifications enables or disables maintenance notifications for hitless upgrades.
523+
// ClientMaintNotifications enables or disables maintenance notifications for maintenance upgrades.
524524
// When enabled, the client will receive push notifications about Redis maintenance events.
525525
func (c cmdable) ClientMaintNotifications(ctx context.Context, enabled bool, endpointType string) *StatusCmd {
526526
args := []interface{}{"client", "maint_notifications"}

example/pubsub/main.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"time"
1010

1111
"github.com/redis/go-redis/v9"
12-
"github.com/redis/go-redis/v9/hitless"
1312
"github.com/redis/go-redis/v9/logging"
13+
"github.com/redis/go-redis/v9/maintnotifications"
1414
)
1515

1616
var ctx = context.Background()
@@ -19,24 +19,28 @@ var cntSuccess atomic.Int64
1919
var startTime = time.Now()
2020

2121
// This example is not supposed to be run as is. It is just a test to see how pubsub behaves in relation to pool management.
22-
// It was used to find regressions in pool management in hitless mode.
22+
// It was used to find regressions in pool management in maintnotifications mode.
2323
// Please don't use it as a reference for how to use pubsub.
2424
func main() {
2525
startTime = time.Now()
2626
wg := &sync.WaitGroup{}
2727
rdb := redis.NewClient(&redis.Options{
2828
Addr: ":6379",
29-
HitlessUpgradeConfig: &redis.HitlessUpgradeConfig{
30-
Mode: hitless.MaintNotificationsEnabled,
29+
MaintNotificationsConfig: &maintnotifications.Config{
30+
Mode: maintnotifications.ModeEnabled,
31+
EndpointType: maintnotifications.EndpointTypeExternalIP,
32+
HandoffTimeout: 10 * time.Second,
33+
RelaxedTimeout: 10 * time.Second,
34+
PostHandoffRelaxedDuration: 10 * time.Second,
3135
},
3236
})
3337
_ = rdb.FlushDB(ctx).Err()
34-
hitlessManager := rdb.GetHitlessManager()
35-
if hitlessManager == nil {
36-
panic("hitless manager is nil")
38+
maintnotificationsManager := rdb.GetMaintNotificationsManager()
39+
if maintnotificationsManager == nil {
40+
panic("maintnotifications manager is nil")
3741
}
38-
loggingHook := hitless.NewLoggingHook(logging.LogLevelDebug)
39-
hitlessManager.AddNotificationHook(loggingHook)
42+
loggingHook := maintnotifications.NewLoggingHook(int(logging.LogLevelDebug))
43+
maintnotificationsManager.AddNotificationHook(loggingHook)
4044

4145
go func() {
4246
for {

hitless/errors.go

Lines changed: 0 additions & 105 deletions
This file was deleted.

internal/interfaces/interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Package interfaces provides shared interfaces used by both the main redis package
2-
// and the hitless upgrade package to avoid circular dependencies.
2+
// and the maintnotifications upgrade package to avoid circular dependencies.
33
package interfaces
44

55
import (
@@ -16,7 +16,7 @@ type NotificationProcessor interface {
1616
GetHandler(pushNotificationName string) interface{}
1717
}
1818

19-
// ClientInterface defines the interface that clients must implement for hitless upgrades.
19+
// ClientInterface defines the interface that clients must implement for maintnotifications upgrades.
2020
type ClientInterface interface {
2121
// GetOptions returns the client options.
2222
GetOptions() OptionsInterface

internal/log.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,49 @@ func NewDefaultLogger() Logging {
3131
// Logger calls Output to print to the stderr.
3232
// Arguments are handled in the manner of fmt.Print.
3333
var Logger Logging = NewDefaultLogger()
34+
35+
var LogLevel LogLevelT = LogLevelError
36+
37+
// LogLevelT represents the logging level
38+
type LogLevelT int
39+
40+
// Log level constants for the entire go-redis library
41+
const (
42+
LogLevelError LogLevelT = iota // 0 - errors only
43+
LogLevelWarn // 1 - warnings and errors
44+
LogLevelInfo // 2 - info, warnings, and errors
45+
LogLevelDebug // 3 - debug, info, warnings, and errors
46+
)
47+
48+
// String returns the string representation of the log level
49+
func (l LogLevelT) String() string {
50+
switch l {
51+
case LogLevelError:
52+
return "ERROR"
53+
case LogLevelWarn:
54+
return "WARN"
55+
case LogLevelInfo:
56+
return "INFO"
57+
case LogLevelDebug:
58+
return "DEBUG"
59+
default:
60+
return "UNKNOWN"
61+
}
62+
}
63+
64+
// IsValid returns true if the log level is valid
65+
func (l LogLevelT) IsValid() bool {
66+
return l >= LogLevelError && l <= LogLevelDebug
67+
}
68+
69+
func (l LogLevelT) WarnOrAbove() bool {
70+
return l >= LogLevelWarn
71+
}
72+
73+
func (l LogLevelT) InfoOrAbove() bool {
74+
return l >= LogLevelInfo
75+
}
76+
77+
func (l LogLevelT) DebugOrAbove() bool {
78+
return l >= LogLevelDebug
79+
}

0 commit comments

Comments
 (0)