Documentation
¶
Overview ¶
Package redis provides Redis and queue helpers for e2e tests using infra providers. It uses the default providers (setup.GetDefaultProviders()) so tests do not pass context/namespace.
Index ¶
- func GetRedisClient() (*redis.Client, func(), error)
- func GetRedisPassword() (string, error)
- func IsQueueAccessible() bool
- func IsQueueInitialized() bool
- func IsRedisRunning() bool
- func RestartRedis() error
- func StartRedis() error
- func StopRedis() error
- func TryConnectToRedis(timeout time.Duration) error
- func TryQueueAccessible() error
- func VerifyRedisRecovery(timeout time.Duration) bool
- func WaitForQueueAccessible(timeout, polling time.Duration, msg string)
- func WaitForQueueInitializedAfterRestart(timeout, polling time.Duration, createResourceFn func() error, ...)
- func WaitForRedisReady(timeout time.Duration) bool
- func WaitForResourcesAccessible(timeout, polling time.Duration, checkFn func() bool, msg string)
- type QueueState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRedisClient ¶
GetRedisClient returns a Redis client and a cleanup function. Caller must call cleanup when done. For K8s this port-forwards to Redis; for Quadlet uses direct host from provider.
func GetRedisPassword ¶
GetRedisPassword returns the Redis password from the infra Secrets provider (K8s secret or Podman secret via flightctl-kv container). Returns an error if the provider is unavailable or the secret cannot be read (no fallback).
func IsQueueAccessible ¶
func IsQueueAccessible() bool
IsQueueAccessible returns whether the Redis queue is accessible.
func IsQueueInitialized ¶
func IsQueueInitialized() bool
IsQueueInitialized returns whether the queue is ready (accessible and consumer group exists).
func TryConnectToRedis ¶
TryConnectToRedis attempts to connect to Redis with retries until timeout and returns the last error if all fail. Each retry invalidates the expose cache and creates a new port-forward so we connect to the current Redis instance.
func TryQueueAccessible ¶
func TryQueueAccessible() error
TryQueueAccessible attempts to connect to Redis and ping it; returns an error describing the failure.
func VerifyRedisRecovery ¶
VerifyRedisRecovery verifies that Redis and services have recovered after restart.
func WaitForQueueAccessible ¶
WaitForQueueAccessible waits for the Redis queue to become accessible.
func WaitForQueueInitializedAfterRestart ¶
func WaitForQueueInitializedAfterRestart( timeout, polling time.Duration, createResourceFn func() error, verifyResourceFn func() bool, )
WaitForQueueInitializedAfterRestart creates a resource and verifies queue initialization after restart.
func WaitForRedisReady ¶
WaitForRedisReady waits for Redis to be ready after restart/start.
Types ¶
type QueueState ¶
type QueueState struct {
Accessible bool
TaskQueueExists bool
HasConsumerGroup bool
InFlightTasks int
FailedMessages int
QueueLength int64
}
QueueState represents the state of Redis queues.
func AssertQueueState ¶
func AssertQueueState() (state QueueState, errors []string)
AssertQueueState returns the queue state and any validation errors.
func CheckQueueState ¶
func CheckQueueState() QueueState
CheckQueueState returns the current Redis queue state.
func HasQueueActivity ¶
func HasQueueActivity() (state QueueState, hasActivity bool)
HasQueueActivity returns whether the queue has in-flight tasks or pending items.
func VerifyQueueHealthy ¶
func VerifyQueueHealthy() (QueueState, error)
VerifyQueueHealthy returns queue state and error if not healthy.