environment

package
v1.26.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package environment contains functions to handle the TestingEnvironment struct

Index

Constants

View Source
const (
	// RetryTimeout retry timeout (in seconds) when a client api call or kubectl cli request get failed
	RetryTimeout = 60

	// StandardTrixieSuffix is the suffix for standard Trixie images
	StandardTrixieSuffix = "standard-trixie"

	// MinimalTrixieSuffix is the suffix for minimal Trixie images
	MinimalTrixieSuffix = "minimal-trixie"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type TestingEnvironment

type TestingEnvironment struct {
	RestClientConfig        *rest.Config
	Client                  client.Client
	Interface               kubernetes.Interface
	APIExtensionClient      apiextensionsclientset.Interface
	Ctx                     context.Context
	Scheme                  *runtime.Scheme
	Log                     logr.Logger
	PostgresImageName       string
	PostgresImageTag        string
	PostgresVersion         uint64
	PostgresImageRepository string
	PostGISImageRepository  string
	// contains filtered or unexported fields
}

TestingEnvironment struct for operator testing

func NewTestingEnvironment

func NewTestingEnvironment() (*TestingEnvironment, error)

NewTestingEnvironment creates the environment for testing

func (TestingEnvironment) CreateUniqueTestNamespace

func (env TestingEnvironment) CreateUniqueTestNamespace(
	ctx context.Context,
	crudClient client.Client,
	namespacePrefix string,
	opts ...client.CreateOption,
) (string, error)

CreateUniqueTestNamespace creates a namespace by using the passed prefix. Return the namespace name and any errors encountered. The namespace is automatically cleaned up at the end of the test.

func (TestingEnvironment) EventuallyExecCommand

func (env TestingEnvironment) EventuallyExecCommand(
	ctx context.Context,
	pod corev1.Pod,
	containerName string,
	timeout *time.Duration,
	command ...string,
) (string, string, error)

EventuallyExecCommand wraps the utils.ExecCommand pre-setting values constant during tests, wrapping it with an Eventually clause

func (*TestingEnvironment) ImageNameWithSuffix added in v1.25.4

func (env *TestingEnvironment) ImageNameWithSuffix(tag, suffix string) string

ImageNameWithSuffix constructs a full image name by appending a suffix to the tag. It uses the PostgresImageName from the environment and formats it as: name:tag-suffix

func (*TestingEnvironment) MinimalImageName added in v1.25.4

func (env *TestingEnvironment) MinimalImageName(tag string) string

MinimalImageName returns the full image name for a minimal Postgres image. Example: ghcr.io/cloudnative-pg/postgresql:17-minimal-trixie

func (*TestingEnvironment) OfficialMinimalImageName added in v1.25.4

func (env *TestingEnvironment) OfficialMinimalImageName(tag string) string

OfficialMinimalImageName returns the full image name for the official minimal Postgres image. This is used for major upgrade tests where source images must come from the official registry. Example: ghcr.io/cloudnative-pg/postgresql:16-minimal-trixie

func (*TestingEnvironment) OfficialPostGISImageName added in v1.25.4

func (env *TestingEnvironment) OfficialPostGISImageName(tag string) string

OfficialPostGISImageName returns the full image name for the official CloudNativePG PostGIS image. This is used for major upgrade tests where source images must come from the official registry. Example: ghcr.io/cloudnative-pg/postgis:16-3-standard-trixie

func (*TestingEnvironment) OfficialPostgresImageName added in v1.25.4

func (env *TestingEnvironment) OfficialPostgresImageName(tag string) string

OfficialPostgresImageName returns the full image name for the official CloudNativePG Postgres image. Example: ghcr.io/cloudnative-pg/postgresql:17

func (*TestingEnvironment) OfficialStandardImageName added in v1.25.4

func (env *TestingEnvironment) OfficialStandardImageName(tag string) string

OfficialStandardImageName returns the full image name for the official standard Postgres image. This is used for major upgrade tests where source images must come from the official registry. Example: ghcr.io/cloudnative-pg/postgresql:16-standard-trixie

func (*TestingEnvironment) PostGISImageName added in v1.25.4

func (env *TestingEnvironment) PostGISImageName(tag string) string

PostGISImageName returns the full image name for a PostGIS image. Example: ghcr.io/cloudnative-pg/postgis:17-3-standard-trixie

func (*TestingEnvironment) StandardImageName added in v1.25.4

func (env *TestingEnvironment) StandardImageName(tag string) string

StandardImageName returns the full image name for a standard Postgres image. Example: ghcr.io/cloudnative-pg/postgresql:17-standard-trixie

Jump to

Keyboard shortcuts

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