Files
go/maintnotifications/e2e/test_mode_test.go
T
b53f2b0c9d feat(sch): MaintNotifications for ClusterClient (#3643)
* [maintnotif] Cluster specific handlers (#3613)

* maint notification handlers for cluster messages

* unrelax all conns

* trigger ci on feature branches

* feat(maintnotif): lazy cluster topology reload (#3614)

* lazy cluster topology reload

* fix discrepancies between options structs

* Update osscluster_lazy_reload_test.go

Co-authored-by: Copilot <[email protected]>

* Update osscluster.go

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

* feat(e2e): mock maintnotif e2e tests (#3639)

* lazy cluster topology reload

* fix discrepancies between options structs

* Update osscluster_lazy_reload_test.go

Co-authored-by: Copilot <[email protected]>

* Update osscluster.go

Co-authored-by: Copilot <[email protected]>

* wip fault with mock proxy

* make lint happy

* fix linter issues

* faster tests with mocks

* linter once again

* add complex node test

* add ci e2e

* use correct redis container

* e2e fix

---------

Co-authored-by: Copilot <[email protected]>

* fix(retry): Add retry mechanism for NOREPLICAS error (#3647)

* fix(queuedNewConn): protect against nil context (#3649)

* fix(maintnotif): fix smigrated parser and add cluster state reload interval option (#3663)

* fix SMIGRATED parsing

* fix smigrated parser

* add ClusterStateReloadInterval to ClusterOptions

* fix tests

* set default cluster reload interval to 10s

* chore(lint): format

* feat(smigrated): new format & remember original host:port (#3697)

* lazy cluster topology reload

* fix discrepancies between options structs

* Update osscluster_lazy_reload_test.go

Co-authored-by: Copilot <[email protected]>

* Update osscluster.go

Co-authored-by: Copilot <[email protected]>

* wip fault with mock proxy

* make lint happy

* fix linter issues

* faster tests with mocks

* linter once again

* add complex node test

* add ci e2e

* use correct redis container

* e2e fix

* additional e2e tests

* fix data race

* fix random shard picker

* fix e2e tests

* fix for empty endpoint

* fix case when semaphore is full, but still need to check idle

* scenario tests

* create database from config

* wip

* feat(client): store original addrs for later use

* fix(notif): change smigrated notification

* fix(lint): fix linter

* fix(smigrated): use array

* fix(e2e): wip

* Update options.go

Co-authored-by: Copilot <[email protected]>

* Update redis.go

Co-authored-by: Copilot <[email protected]>

* fix(notif): if the conn has no original addr, trigger reload with first target

* chore(e2e): wip cluster e2e

* chore(e2e): fix nil pointer from e2e tests

* chore(e2e): fix tests and reports

* chore(e2e): proper logging in e2e

* chore(e2e): add pubsub in the tests as well

* chore(e2e): mockproxy fixes

* chore(e2e): mockproxy fixes

* chore(e2e): mockproxy fixes

* chore(e2e): mockproxy fixes v3

* stop background routines

* fix(e2e): tests

---------

Co-authored-by: Copilot <[email protected]>

* chore(docs): add example app (#3651)

* chore(lint): fmt

* chore(docs): improve docs

* chore(docs): update features.md

* chore(github): remove example

* chore(maintnotif): rename option and address pr comments

* fix(e2e): command runner should use client timeout

* chore(e2e): refactor tests

* fix(e2e): set default timeout to 90m

* fix(e2e): skip tests if proxy cannot be started

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: ofekshenawa <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
2026-02-13 13:25:07 +02:00

115 lines
3.6 KiB
Go

package e2e
import (
"os"
"time"
)
// TestMode represents the type of test environment
type TestMode int
const (
// TestModeProxyMock uses the local proxy mock for fast testing
TestModeProxyMock TestMode = iota
// TestModeRealFaultInjector uses the real fault injector with actual Redis Enterprise
TestModeRealFaultInjector
)
// TestModeConfig holds configuration for a specific test mode
type TestModeConfig struct {
Mode TestMode
// Timing configuration
NotificationDelay time.Duration // How long to wait after injecting a notification
ActionWaitTimeout time.Duration // How long to wait for fault injector actions
ActionPollInterval time.Duration // How often to poll for action status
DatabaseReadyDelay time.Duration // How long to wait for database to be ready
ConnectionEstablishDelay time.Duration // How long to wait for connections to establish
// Test behavior configuration
MaxClients int // Maximum number of clients to create (proxy mock should use 1)
SkipMultiClientTests bool // Whether to skip tests that require multiple clients
}
// GetTestMode detects the current test mode based on environment variables
func GetTestMode() TestMode {
// If REDIS_ENDPOINTS_CONFIG_PATH is set, we're using real fault injector
if os.Getenv("REDIS_ENDPOINTS_CONFIG_PATH") != "" {
return TestModeRealFaultInjector
}
// If FAULT_INJECTOR_URL is set, we're using real fault injector
if os.Getenv("FAULT_INJECTOR_URL") != "" {
return TestModeRealFaultInjector
}
// Otherwise, we're using proxy mock
return TestModeProxyMock
}
// GetTestModeConfig returns the configuration for the current test mode
func GetTestModeConfig() *TestModeConfig {
mode := GetTestMode()
switch mode {
case TestModeProxyMock:
return &TestModeConfig{
Mode: TestModeProxyMock,
NotificationDelay: 1 * time.Second,
ActionWaitTimeout: 10 * time.Second,
ActionPollInterval: 500 * time.Millisecond,
DatabaseReadyDelay: 1 * time.Second,
ConnectionEstablishDelay: 500 * time.Millisecond,
MaxClients: 1,
SkipMultiClientTests: true,
}
case TestModeRealFaultInjector:
return &TestModeConfig{
Mode: TestModeRealFaultInjector,
NotificationDelay: 30 * time.Second,
ActionWaitTimeout: 5 * time.Minute, // Real fault injector can take up to 5 minutes
ActionPollInterval: 500 * time.Millisecond,
DatabaseReadyDelay: 10 * time.Second,
ConnectionEstablishDelay: 2 * time.Second,
MaxClients: 3,
SkipMultiClientTests: false,
}
default:
// Default to proxy mock for safety
return &TestModeConfig{
Mode: TestModeProxyMock,
NotificationDelay: 1 * time.Second,
ActionWaitTimeout: 10 * time.Second,
ActionPollInterval: 500 * time.Millisecond,
DatabaseReadyDelay: 1 * time.Second,
ConnectionEstablishDelay: 500 * time.Millisecond,
MaxClients: 1,
SkipMultiClientTests: true,
}
}
}
// IsProxyMock returns true if running in proxy mock mode
func (c *TestModeConfig) IsProxyMock() bool {
return c.Mode == TestModeProxyMock
}
// IsRealFaultInjector returns true if running with real fault injector
func (c *TestModeConfig) IsRealFaultInjector() bool {
return c.Mode == TestModeRealFaultInjector
}
// String returns a human-readable name for the test mode
func (m TestMode) String() string {
switch m {
case TestModeProxyMock:
return "ProxyMock"
case TestModeRealFaultInjector:
return "RealFaultInjector"
default:
return "Unknown"
}
}