redis

package
v1.3.0-main Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRedisClient

func GetRedisClient() (*redis.Client, func(), error)

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

func GetRedisPassword() (string, error)

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 IsRedisRunning

func IsRedisRunning() bool

IsRedisRunning returns whether Redis is running.

func RestartRedis

func RestartRedis() error

RestartRedis restarts Redis.

func StartRedis

func StartRedis() error

StartRedis starts Redis.

func StopRedis

func StopRedis() error

StopRedis stops Redis.

func TryConnectToRedis

func TryConnectToRedis(timeout time.Duration) error

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

func VerifyRedisRecovery(timeout time.Duration) bool

VerifyRedisRecovery verifies that Redis and services have recovered after restart.

func WaitForQueueAccessible

func WaitForQueueAccessible(timeout, polling time.Duration, msg string)

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

func WaitForRedisReady(timeout time.Duration) bool

WaitForRedisReady waits for Redis to be ready after restart/start.

func WaitForResourcesAccessible

func WaitForResourcesAccessible(timeout, polling time.Duration, checkFn func() bool, msg string)

WaitForResourcesAccessible waits for the check to succeed.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL