Documentation
¶
Overview ¶
Package features provides test feature implementations for integration testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupAssertFunc ¶
type BackupAssertFunc func(ctx context.Context, t *testing.T, cfg *envconf.Config, backup *cnpgv1.Backup)
BackupAssertFunc is a function that performs assertions after a backup completes.
type BackupFeature ¶
type BackupFeature struct {
// contains filtered or unexported fields
}
BackupFeature defines a feature for testing backups in the CloudNativePG operator.
func NewBackupFeature ¶
func NewBackupFeature(config BackupFeatureConfig) *BackupFeature
NewBackupFeature creates a new BackupFeature with the given configuration and default timeouts.
func (*BackupFeature) Name ¶
func (f *BackupFeature) Name() string
Name returns the name of the backup feature.
func (*BackupFeature) Run ¶
func (f *BackupFeature) Run() types.StepFunc
Run executes the backup feature test, creating a backup and waiting for it to complete.
func (*BackupFeature) Setup ¶
func (f *BackupFeature) Setup() types.StepFunc
Setup initializes the backup feature test, setting up the necessary resources.
func (*BackupFeature) Teardown ¶
func (f *BackupFeature) Teardown() types.StepFunc
Teardown cleans up resources after the test is run.
type BackupFeatureConfig ¶
type BackupFeatureConfig struct {
// Name of the backup feature test.
Name string
// Setup function to initialize test resources.
Setup types.StepFunc
// Teardown function to clean up test resources.
Teardown types.StepFunc
// Backup resource to be created and tested.
Backup *cnpgv1.Backup
// BackupTimeout is the timeout for backup (defaults to 1 minute).
BackupTimeout time.Duration
// BackupCheckInterval is the interval for checking backup status (defaults to 10 seconds).
BackupCheckInterval time.Duration
// PostBackupAssert is an optional function to run assertions after backup completes.
PostBackupAssert BackupAssertFunc
}
BackupFeatureConfig holds the configuration for creating a backup feature test.
type Feature ¶
type Feature interface {
Name() string
Setup() types.StepFunc
Run() types.StepFunc
Teardown() types.StepFunc
}
Feature defines the interface for a feature in the test environment.
type PitrFeature ¶
type PitrFeature struct {
*RecoveryFeature
}
PitrFeature defines a feature for testing the PITR of a backup in the CloudNativePG operator.
func NewPitrFeature ¶
func NewPitrFeature(config RecoveryFeatureConfig) *PitrFeature
NewPitrFeature creates a new PitrFeature with the given configuration and default timeouts.
func (*PitrFeature) Run ¶
func (f *PitrFeature) Run() types.StepFunc
Run executes the PITR feature test, defining a recovery targetTime, recovering a Cluster from a backup defining and waiting for it to complete.
type RecoveryClusterMutateFunc ¶
type RecoveryClusterMutateFunc func(ctx context.Context, recoveryCluster *cnpgv1.Cluster, r *resources.Resources) error
RecoveryClusterMutateFunc is a function that mutates a recovery Cluster object.
type RecoveryFeature ¶
type RecoveryFeature struct {
// contains filtered or unexported fields
}
RecoveryFeature defines a feature for testing recovery of a backup in the CloudNativePG operator.
func NewRecoveryFeature ¶
func NewRecoveryFeature(config RecoveryFeatureConfig) *RecoveryFeature
NewRecoveryFeature creates a new RecoveryFeature with the given configuration and default timeouts.
func (*RecoveryFeature) Name ¶
func (f *RecoveryFeature) Name() string
Name returns the name of the recovery feature.
func (*RecoveryFeature) Run ¶
func (f *RecoveryFeature) Run() types.StepFunc
Run executes the recovery feature test, creating a Cluster from a backup and waiting for it to complete.
func (*RecoveryFeature) Setup ¶
func (f *RecoveryFeature) Setup() types.StepFunc
Setup initializes the recovery feature test, setting up the necessary resources.
func (*RecoveryFeature) Teardown ¶
func (f *RecoveryFeature) Teardown() types.StepFunc
Teardown cleans up resources after the test is run.
type RecoveryFeatureConfig ¶
type RecoveryFeatureConfig struct {
// Name of the recovery feature test
Name string
// Setup function to initialize test resources.
Setup types.StepFunc
// Teardown function to clean up test resources.
Teardown types.StepFunc
// SourcePrimaryPod is the current primary of the Cluster to be backed up and recovered.
// The cluster must be running before the feature Run() starts.
SourcePrimaryPod *corev1.Pod
// Backup resource to be created during the test.
Backup *cnpgv1.Backup
// RecoveryCluster to be created from the backup.
RecoveryCluster *cnpgv1.Cluster
// MutateRecoveryCluster can be used to inject exposed runtime fields into the recovery cluster.
MutateRecoveryCluster []RecoveryClusterMutateFunc
// BackupTimeout is the timeout for backup operations (defaults to 1 minute).
BackupTimeout time.Duration
// BackupCheckInterval is the interval for checking backup status for completion (defaults to 10 seconds).
BackupCheckInterval time.Duration
// RecoveryTimeout is the timeout for recovery operations (defaults to 2 minutes)
RecoveryTimeout time.Duration
// RecoveryCheckInterval is the interval for checking recovery status for completion (defaults to 10 seconds).
RecoveryCheckInterval time.Duration
}
RecoveryFeatureConfig holds the configuration for creating a recovery feature test.
type ReplicaClusterFeature ¶
type ReplicaClusterFeature struct {
*RecoveryFeature
}
ReplicaClusterFeature defines a feature for testing the replication between a source Cluster and a Replica Cluster in the CloudNativePG operator, recovering the WAL files from the archive.
func NewReplicaClusterFeature ¶
func NewReplicaClusterFeature(config RecoveryFeatureConfig) *ReplicaClusterFeature
NewReplicaClusterFeature creates a new ReplicaClusterFeature with the given configuration and default timeouts.
func (*ReplicaClusterFeature) Run ¶
func (f *ReplicaClusterFeature) Run() types.StepFunc
Run executes the Replica Cluster feature test: 1. Recovers a Cluster from a backup 2. Applies changes in the source Cluster 3. Waits for the changes to be correctly applied in the replica Cluster.
type TablespaceRecoveryFeature ¶
type TablespaceRecoveryFeature struct {
*RecoveryFeature
// contains filtered or unexported fields
}
TablespaceRecoveryFeature defines a feature for testing recovery of a backup in the CloudNativePG operator.
func NewTablespaceRecoveryFeature ¶
func NewTablespaceRecoveryFeature( config TablespaceRecoveryFeatureConfig, ) *TablespaceRecoveryFeature
NewTablespaceRecoveryFeature creates a new TablespaceRecoveryFeature with the given configuration and default timeouts.
func (*TablespaceRecoveryFeature) Name ¶
func (f *TablespaceRecoveryFeature) Name() string
Name returns the name of the recovery feature.
func (*TablespaceRecoveryFeature) Run ¶
func (f *TablespaceRecoveryFeature) Run() types.StepFunc
Run executes the recovery feature test, creating a Cluster from a backup and waiting for it to complete.
func (*TablespaceRecoveryFeature) Setup ¶
func (f *TablespaceRecoveryFeature) Setup() types.StepFunc
Setup initializes the recovery feature test, setting up the necessary resources.
func (*TablespaceRecoveryFeature) Teardown ¶
func (f *TablespaceRecoveryFeature) Teardown() types.StepFunc
Teardown cleans up resources after the test is run.
type TablespaceRecoveryFeatureConfig ¶
type TablespaceRecoveryFeatureConfig struct {
*RecoveryFeatureConfig
// SourceTablespaceConfig is the tablespaces list created in the source Cluster.
SourceTablespaceConfig *[]cnpgv1.TablespaceConfiguration
}
TablespaceRecoveryFeatureConfig holds the configuration for creating a recovery feature test.