Documentation
¶
Overview ¶
Package utils contains helper functions/methods for e2e
Index ¶
- Constants
- Variables
- func AllClusterPodsHaveAnnotations(env *TestingEnvironment, namespace, clusterName string, ...) (bool, error)
- func AllClusterPodsHaveLabels(env *TestingEnvironment, namespace, clusterName string, ...) (bool, error)
- func AreSameLsn(lsnList []string) bool
- func AssertBackupConditionInClusterStatus(env *TestingEnvironment, namespace, clusterName string)
- func AssertQueryRecord(logEntries []map[string]interface{}, errorTestQuery string, message string, ...) bool
- func BumpPostgresImageMajorVersion(postgresImage string) (string, error)
- func CheckOptionsForBarmanCommand(logEntries []map[string]interface{}, message, backupName, podName string, ...) (bool, error)
- func CheckRecordForQuery(entry map[string]interface{}, errorTestQuery, user, database, message string) bool
- func CheckWebhookReady(env *TestingEnvironment, namespace string) error
- func ClusterHasAnnotations(cluster *apiv1.Cluster, annotations map[string]string) bool
- func ClusterHasLabels(cluster *apiv1.Cluster, labels map[string]string) bool
- func ComposeAzBlobListAzuriteCmd(clusterName, path string) string
- func ComposeAzBlobListCmd(configuration AzureConfiguration, clusterName, path string) string
- func CountFilesOnAzureBlobStorage(configuration AzureConfiguration, clusterName, path string) (int, error)
- func CountFilesOnAzuriteBlobStorage(namespace, clusterName, path string) (int, error)
- func CountReplicas(env *TestingEnvironment, pod *corev1.Pod) (int, error)
- func CreateBackup(targetBackup apiv1.Backup, env *TestingEnvironment) (*apiv1.Backup, error)
- func CreateCertificateSecretsOnAzurite(namespace, clusterName, azuriteCaSecName, azuriteTLSSecName string, ...) error
- func CreateClientCertificatesViaKubectlPlugin(cluster apiv1.Cluster, certName string, userName string, ...) error
- func CreateClusterFromBackupUsingPITR(namespace, clusterName, backupFilePath, targetTime string, ...) (*apiv1.Cluster, error)
- func CreateClusterFromExternalClusterBackupWithPITROnAzure(namespace, externalClusterName, sourceClusterName, targetTime, ... string, ...) (*v1.Cluster, error)
- func CreateClusterFromExternalClusterBackupWithPITROnAzurite(namespace, externalClusterName, sourceClusterName, targetTime string, ...) (*v1.Cluster, error)
- func CreateClusterFromExternalClusterBackupWithPITROnMinio(namespace, externalClusterName, sourceClusterName, targetTime string, ...) (*apiv1.Cluster, error)
- func CreateDSN(host, user, dbname, password string, sslmode SSLMode, port int) string
- func CreateObject(env *TestingEnvironment, object client.Object, opts ...client.CreateOption) (client.Object, error)
- func CreateObjectStorageSecret(namespace string, secretName string, id string, key string, ...) (*corev1.Secret, error)
- func CreateOnDemandBackup(namespace, clusterName, backupName string, target apiv1.BackupTarget, ...) (*apiv1.Backup, error)
- func CreateOnDemandBackupViaKubectlPlugin(namespace, clusterName, backupName string, target apiv1.BackupTarget, ...) error
- func CreateOperatorConfigurationMap(pgOperatorNamespace, configName string, isOnline bool, env *TestingEnvironment)
- func CreateSASTokenCredentials(namespace string, id string, key string, env *TestingEnvironment) error
- func CreateSecretCA(namespace string, clusterName string, caSecName string, ...) (*apiv1.Cluster, *certs.KeyPair, error)
- func CreateServiceFQDN(namespace, serviceName string) string
- func CreateStorageCredentialsOnAzurite(namespace string, env *TestingEnvironment) error
- func CreateSubscription(env *TestingEnvironment, channel string) error
- func DefaultWebapp(namespace string, name string, rootCASecretName string, tlsSecretName string) corev1.Pod
- func DeleteCSV(env *TestingEnvironment) error
- func DeleteObject(env *TestingEnvironment, object client.Object, opts ...client.DeleteOption) error
- func DeleteOperatorCRDs(env *TestingEnvironment) error
- func DeleteSubscription(env *TestingEnvironment) error
- func DeploymentIsReady(deployment appsv1.Deployment) bool
- func DeploymentWaitForReady(env *TestingEnvironment, deployment *appsv1.Deployment, timeoutSeconds uint) error
- func Envsubst(vars map[string]string, data []byte) ([]byte, error)
- func ExecuteBackup(namespace, backupFile string, onlyTargetStandbys bool, timeoutSeconds int, ...) *apiv1.Backup
- func FencingOff(env *TestingEnvironment, serverName, namespace, clusterName string, ...) error
- func FencingOn(env *TestingEnvironment, serverName, namespace, clusterName string, ...) error
- func FirstEndpointIP(endpoint *corev1.Endpoints) string
- func ForgeArchiveWalOnMinio(namespace, clusterName, miniClientPodName, existingWALName, newWALName string) error
- func GetAvailableReleases(releasesPath string) ([]*semver.Version, error)
- func GetCNPGsMutatingWebhookByName(env *TestingEnvironment, name string) (*admissionregistrationv1.MutatingWebhookConfiguration, int, error)
- func GetCNPGsValidatingWebhookByName(env *TestingEnvironment, name string) (*admissionregistrationv1.ValidatingWebhookConfiguration, int, error)
- func GetCNPGsValidatingWebhookConf(env *TestingEnvironment) (*admissionregistrationv1.ValidatingWebhookConfiguration, error)
- func GetConditionsInClusterStatus(namespace, clusterName string, env *TestingEnvironment, ...) (*metav1.Condition, error)
- func GetCredentials(clusterName, namespace string, secretSuffix string, env *TestingEnvironment) (string, string, error)
- func GetCurrentTimestamp(namespace, clusterName string, env *TestingEnvironment) (string, error)
- func GetExpectedHAReplicationSlotsOnPod(namespace, clusterName, podName string, env *TestingEnvironment) ([]string, error)
- func GetHostName(namespace, clusterName string, env *TestingEnvironment) (string, error)
- func GetLeaderInfoFromLease(operatorNamespace string, env *TestingEnvironment) (string, error)
- func GetManagerVersion(namespace, podName string) (string, error)
- func GetMostRecentReleaseTag(releasesPath string) (string, error)
- func GetObject(env *TestingEnvironment, objectKey client.ObjectKey, object client.Object) error
- func GetObjectList(env *TestingEnvironment, objectList client.ObjectList, ...) error
- func GetOpenshiftVersion(env *TestingEnvironment) (semver.Version, error)
- func GetOperatorArchitectures(operatorPod *corev1.Pod) ([]string, error)
- func GetOperatorPodName(env *TestingEnvironment) (string, error)
- func GetOperatorVersion(namespace, podName string) (string, error)
- func GetReadWriteServiceName(clusterName string) string
- func GetReplicationSlotLsnsOnPod(namespace, clusterName string, pod corev1.Pod, env *TestingEnvironment) ([]string, error)
- func GetReplicationSlotsOnPod(namespace, podName string, env *TestingEnvironment) ([]string, error)
- func GetRwServiceObject(namespace, clusterName string, env *TestingEnvironment) (*corev1.Service, error)
- func GetService(namespace, name string, env *TestingEnvironment) (*corev1.Service, error)
- func GetStorageAllowExpansion(defaultStorageClass string, env *TestingEnvironment) (*bool, error)
- func GetSubscription(env *TestingEnvironment) (*unstructured.Unstructured, error)
- func GetSubscriptionVersion(env *TestingEnvironment) (string, error)
- func HasLogger(logEntries []map[string]interface{}, logger string) bool
- func HasOperatorBeenUpgraded(env *TestingEnvironment) bool
- func HibernateOff(env *TestingEnvironment, namespace, clusterName string, ...) error
- func HibernateOn(env *TestingEnvironment, namespace, clusterName string, ...) error
- func ImportDatabaseMicroservice(...) (*apiv1.Cluster, error)
- func ImportDatabasesMonolith(namespace, sourceClusterName, importedClusterName, imageName string, ...) (*apiv1.Cluster, error)
- func InstallAzCli(namespace string, env *TestingEnvironment) error
- func InstallAzurite(namespace string, env *TestingEnvironment) error
- func InstallLatestCNPGOperator(releaseTag string, env *TestingEnvironment)
- func IsWalStorageEnabled(namespace, clusterName string, env *TestingEnvironment) (bool, error)
- func IsWellFormedLogForLogger(item map[string]interface{}, loggerField string) bool
- func ObjectHasAnnotations(object client.Object, annotations []string) bool
- func ObjectMatchesAnnotations(object client.Object, annotations map[string]string) bool
- func OperatorPodRenamed(operatorPod corev1.Pod, expectedOperatorPodName string) bool
- func OperatorPodRestarted(operatorPod corev1.Pod) bool
- func ParseJSONLogs(namespace string, podName string, env *TestingEnvironment) ([]map[string]interface{}, error)
- func ParseObjectsFromYAML(data []byte, namespace string) ([]client.Object, error)
- func PatchStatusCondition(namespace, clusterName string, env *TestingEnvironment) error
- func PodCreateAndWaitForReady(env *TestingEnvironment, pod *corev1.Pod, timeoutSeconds uint) error
- func PodHasAnnotations(pod corev1.Pod, annotations map[string]string) bool
- func PodHasCondition(pod *corev1.Pod, conditionType corev1.PodConditionType, ...) bool
- func PodHasLabels(pod corev1.Pod, labels map[string]string) bool
- func PodWaitForReady(env *TestingEnvironment, pod *corev1.Pod, timeoutSeconds uint) error
- func PrintClusterResources(namespace, clusterName string, env *TestingEnvironment) string
- func PrintReplicationSlots(namespace, clusterName string, env *TestingEnvironment) string
- func PvcHasLabels(pvc corev1.PersistentVolumeClaim, labels map[string]string) bool
- func ReloadOperatorDeployment(env *TestingEnvironment, timeoutSeconds uint) error
- func RetrieveMetricsFromInstance(env *TestingEnvironment, pod corev1.Pod, tlsEnabled bool) (string, error)
- func RetrieveMetricsFromPgBouncer(env *TestingEnvironment, pod corev1.Pod) (string, error)
- func RetrievePgStatusFromInstance(env *TestingEnvironment, pod corev1.Pod, tlsEnabled bool) (string, error)
- func Run(command string) (stdout string, stderr string, err error)
- func RunExecOverForward(env *TestingEnvironment, ...) (sql.Result, error)
- func RunQueryRowOverForward(env *TestingEnvironment, ...) (*sql.Row, error)
- func RunRetry(command string) (stdout string, stderr string, err error)
- func RunUnchecked(command string) (stdout string, stderr string, err error)
- func RunUncheckedRetry(command string) (stdout string, stderr string, err error)
- func SetSnapshotNameAsEnv(snapshotList *volumesnapshot.VolumeSnapshotList, backup *apiv1.Backup, ...) error
- func TestDirectoryEmpty(namespace, podName, directoryPath string) bool
- func TestFileExist(namespace, podName, directoryPath, fileName string) bool
- func Timeouts() (map[Timeout]int, error)
- func ToggleHAReplicationSlots(namespace, clusterName string, enable bool, env *TestingEnvironment) error
- func ToggleSynchronizeReplicationSlots(namespace, clusterName string, enable bool, env *TestingEnvironment) error
- func UpdateCNPGsMutatingWebhookConf(env *TestingEnvironment, ...) error
- func UpdateCNPGsValidatingWebhookConf(env *TestingEnvironment, ...) error
- func UpgradeSubscription(env *TestingEnvironment, channel string) error
- type AzureConfiguration
- type ContainerLocator
- type DatabaseName
- type EnvProfile
- type EnvVarsForSnapshots
- type FencingMethod
- type HibernationMethod
- type PSQLForwardConnection
- func ForwardPSQLConnection(env *TestingEnvironment, namespace, clusterName, dbname, secretSuffix string) (*PSQLForwardConnection, *sql.DB, error)
- func ForwardPSQLConnectionWithCreds(env *TestingEnvironment, ...) (*PSQLForwardConnection, *sql.DB, error)
- func ForwardPSQLServiceConnection(env *TestingEnvironment, ...) (*PSQLForwardConnection, *sql.DB, error)
- type PodLocator
- type SSLMode
- type TestEnvVendor
- type TestingEnvironment
- func (env TestingEnvironment) CleanupNamespace(namespace string, testName string, testFailed bool) error
- func (env TestingEnvironment) CreateNamespace(name string, opts ...client.CreateOption) error
- func (env TestingEnvironment) CreateTestNamespace(name string, opts ...client.CreateOption) error
- func (env TestingEnvironment) CreateUniqueTestNamespace(namespacePrefix string, opts ...client.CreateOption) (string, error)
- func (env TestingEnvironment) DeleteNamespace(name string, opts ...client.DeleteOption) error
- func (env TestingEnvironment) DeleteNamespaceAndWait(name string, timeoutSeconds int) error
- func (env TestingEnvironment) DeletePod(namespace string, name string, opts ...client.DeleteOption) error
- func (env TestingEnvironment) DescribeKubernetesNodes() (string, error)
- func (env TestingEnvironment) DumpNamespaceObjects(namespace string, filename string)
- func (env TestingEnvironment) DumpOperator(namespace string, filename string)
- func (env TestingEnvironment) EnsureNamespace(namespace string) error
- func (env TestingEnvironment) EventuallyExecCommand(ctx context.Context, pod corev1.Pod, containerName string, ...) (string, string, error)
- func (env TestingEnvironment) EventuallyExecQueryInInstancePod(podLocator PodLocator, dbname DatabaseName, query string, retryTimeout int, ...) (string, string, error)
- func (env TestingEnvironment) ExecCommand(ctx context.Context, pod corev1.Pod, containerName string, ...) (string, string, error)
- func (env TestingEnvironment) ExecCommandInContainer(container ContainerLocator, timeout *time.Duration, command ...string) (string, string, error)
- func (env TestingEnvironment) ExecCommandInInstancePod(podLocator PodLocator, timeout *time.Duration, command ...string) (string, string, error)
- func (env TestingEnvironment) ExecQueryInInstancePod(podLocator PodLocator, dbname DatabaseName, query string) (string, string, error)
- func (env TestingEnvironment) GetBackupList(namespace string) (*apiv1.BackupList, error)
- func (env TestingEnvironment) GetCNPGsMutatingWebhookConf() (*admissionregistrationv1.MutatingWebhookConfiguration, error)
- func (env TestingEnvironment) GetCluster(namespace string, name string) (*apiv1.Cluster, error)
- func (env TestingEnvironment) GetClusterPodList(namespace string, clusterName string) (*corev1.PodList, error)
- func (env TestingEnvironment) GetClusterPrimary(namespace string, clusterName string) (*corev1.Pod, error)
- func (env TestingEnvironment) GetClusterReplicas(namespace string, clusterName string) (*corev1.PodList, error)
- func (env TestingEnvironment) GetEventList(namespace string) (*eventsv1.EventList, error)
- func (env TestingEnvironment) GetJob(namespace, jobName string) (*batchv1.Job, error)
- func (env TestingEnvironment) GetJobList(namespace string) (*batchv1.JobList, error)
- func (env TestingEnvironment) GetNodeList() (*corev1.NodeList, error)
- func (env TestingEnvironment) GetOperatorDeployment() (appsv1.Deployment, error)
- func (env TestingEnvironment) GetOperatorLogs(buf *bytes.Buffer) error
- func (env TestingEnvironment) GetOperatorNamespaceName() (string, error)
- func (env TestingEnvironment) GetOperatorPod() (corev1.Pod, error)
- func (env TestingEnvironment) GetPVCList(namespace string) (*corev1.PersistentVolumeClaimList, error)
- func (env TestingEnvironment) GetPod(namespace, podName string) (*corev1.Pod, error)
- func (env TestingEnvironment) GetPodList(namespace string) (*corev1.PodList, error)
- func (env TestingEnvironment) GetPodLogs(namespace string, podName string) (string, error)
- func (env TestingEnvironment) GetPodMonitor(namespace string, name string) (*monitoringv1.PodMonitor, error)
- func (env TestingEnvironment) GetResourceNameFromYAML(path string) (string, error)
- func (env TestingEnvironment) GetResourceNamespacedNameFromYAML(path string) (types.NamespacedName, error)
- func (env TestingEnvironment) GetScheduledBackupList(namespace string) (*apiv1.ScheduledBackupList, error)
- func (env TestingEnvironment) GetServiceAccountList(namespace string) (*corev1.ServiceAccountList, error)
- func (env TestingEnvironment) GetSnapshotList(namespace string) (*storagesnapshotv1.VolumeSnapshotList, error)
- func (env TestingEnvironment) GetVolumeSnapshot(namespace, name string) (*volumesnapshot.VolumeSnapshot, error)
- func (env *TestingEnvironment) IsOperatorDeploymentReady() (bool, error)
- func (env TestingEnvironment) IsOperatorReady() (bool, error)
- func (env TestingEnvironment) ScaleClusterSize(namespace, clusterName string, newClusterSize int) error
- func (env *TestingEnvironment) ScaleOperatorDeployment(replicas int32) error
- type Timeout
Constants ¶
const ( // RetryTimeout retry timeout (in seconds) when a client api call or kubectl cli request get failed RetryTimeout = 60 // RetryAttempts maximum number of attempts when it fails in `retry`. Mainly used in `RunUncheckedRetry` RetryAttempts = 5 // PollingTime polling interval (in seconds) between retries PollingTime = 5 )
const ( // PGLocalSocketDir is the directory containing the PostgreSQL local socket PGLocalSocketDir = "/controller/run" // AppUser for app user AppUser = "app" // PostgresUser for postgres user PostgresUser = "postgres" // AppDBName database name app AppDBName = "app" // PostgresDBName database name postgres PostgresDBName = "postgres" // TablespaceDefaultName is the default tablespace location TablespaceDefaultName = "pg_default" )
const TestTimeoutsEnvVar = "TEST_TIMEOUTS"
TestTimeoutsEnvVar is the environment variable where specific timeouts can be set for the E2E test suite
Variables ¶
var AKS = TestEnvVendor("aks")
AKS azure cloud cluster
var DefaultTestTimeouts = map[Timeout]int{ Failover: 240, NamespaceCreation: 30, ClusterIsReady: 600, ClusterIsReadyQuick: 300, ClusterIsReadySlow: 800, NewPrimaryAfterSwitchover: 45, NewPrimaryAfterFailover: 30, NewTargetOnFailover: 120, PodRollout: 180, OperatorIsReady: 120, LargeObject: 300, WalsInMinio: 60, MinioInstallation: 300, BackupIsReady: 180, DrainNode: 900, VolumeSnapshotIsReady: 300, Short: 5, ManagedServices: 30, }
DefaultTestTimeouts contains the default timeout in seconds for various events
var EKS = TestEnvVendor("eks")
EKS amazon elastic cloud cluster
var ErrEnvVarNotFound = errors.New("could not find environment variable")
ErrEnvVarNotFound is thrown when a SHELL-FORMAT var in a file does not have a matching env variable
var GKE = TestEnvVendor("gke")
GKE google cloud cluster
var LOCAL = TestEnvVendor("local")
LOCAL kind or k3d cluster running locally
var OCP = TestEnvVendor("ocp")
OCP openshift cloud cluster
Functions ¶
func AllClusterPodsHaveAnnotations ¶
func AllClusterPodsHaveAnnotations( env *TestingEnvironment, namespace, clusterName string, annotations map[string]string, ) (bool, error)
AllClusterPodsHaveAnnotations verifies if the annotations defined in a map are included in all the pods of a cluster
func AllClusterPodsHaveLabels ¶
func AllClusterPodsHaveLabels( env *TestingEnvironment, namespace, clusterName string, labels map[string]string, ) (bool, error)
AllClusterPodsHaveLabels verifies if the labels defined in a map are included in all the pods of a cluster
func AreSameLsn ¶ added in v1.18.0
AreSameLsn returns true if all the LSN values inside a given list are the same
func AssertBackupConditionInClusterStatus ¶ added in v1.23.6
func AssertBackupConditionInClusterStatus(env *TestingEnvironment, namespace, clusterName string)
AssertBackupConditionInClusterStatus check that the backup condition in the Cluster's Status eventually returns true
func AssertQueryRecord ¶
func AssertQueryRecord(logEntries []map[string]interface{}, errorTestQuery string, message string, logger string) bool
AssertQueryRecord verifies if any of the message record field of each JSON row contains the expectedResult string, then applies the assertions related to the log format
func BumpPostgresImageMajorVersion ¶ added in v1.16.0
BumpPostgresImageMajorVersion returns a postgresImage incrementing the major version of the argument (if available)
func CheckOptionsForBarmanCommand ¶ added in v1.21.4
func CheckOptionsForBarmanCommand( logEntries []map[string]interface{}, message, backupName, podName string, optionsExpected []string, ) (bool, error)
CheckOptionsForBarmanCommand checks if the expected options are used from the barman command execution log
func CheckRecordForQuery ¶
func CheckRecordForQuery(entry map[string]interface{}, errorTestQuery, user, database, message string) bool
CheckRecordForQuery applies some assertions related to the format of the JSON log fields keys and values
func CheckWebhookReady ¶
func CheckWebhookReady(env *TestingEnvironment, namespace string) error
CheckWebhookReady ensures that the operator has finished the webhook setup.
func ClusterHasAnnotations ¶
ClusterHasAnnotations verifies that the annotations of a cluster contain a specified annotations map
func ClusterHasLabels ¶
ClusterHasLabels verifies that the labels of a cluster contain a specified labels map
func ComposeAzBlobListAzuriteCmd ¶
ComposeAzBlobListAzuriteCmd builds the Azure storage blob list command for Azurite
func ComposeAzBlobListCmd ¶
func ComposeAzBlobListCmd( configuration AzureConfiguration, clusterName, path string, ) string
ComposeAzBlobListCmd builds the Azure storage blob list command
func CountFilesOnAzureBlobStorage ¶
func CountFilesOnAzureBlobStorage( configuration AzureConfiguration, clusterName, path string, ) (int, error)
CountFilesOnAzureBlobStorage counts files on Azure Blob storage
func CountFilesOnAzuriteBlobStorage ¶
CountFilesOnAzuriteBlobStorage counts files on Azure Blob storage. using Azurite
func CountReplicas ¶
func CountReplicas(env *TestingEnvironment, pod *corev1.Pod) (int, error)
CountReplicas counts the number of replicas attached to an instance
func CreateBackup ¶ added in v1.21.1
CreateBackup creates a Backup resource for a given cluster name
func CreateCertificateSecretsOnAzurite ¶ added in v1.15.3
func CreateCertificateSecretsOnAzurite( namespace, clusterName, azuriteCaSecName, azuriteTLSSecName string, env *TestingEnvironment, ) error
CreateCertificateSecretsOnAzurite will create secrets for Azurite deployment
func CreateClientCertificatesViaKubectlPlugin ¶
func CreateClientCertificatesViaKubectlPlugin( cluster apiv1.Cluster, certName string, userName string, env *TestingEnvironment, ) error
CreateClientCertificatesViaKubectlPlugin creates a certificate for a given user on a given cluster
func CreateClusterFromBackupUsingPITR ¶
func CreateClusterFromBackupUsingPITR( namespace, clusterName, backupFilePath, targetTime string, env *TestingEnvironment, ) (*apiv1.Cluster, error)
CreateClusterFromBackupUsingPITR creates a cluster from backup, using the PITR
func CreateClusterFromExternalClusterBackupWithPITROnAzure ¶
func CreateClusterFromExternalClusterBackupWithPITROnAzure( namespace, externalClusterName, sourceClusterName, targetTime, storageCredentialsSecretName, azStorageAccount, azBlobContainer string, env *TestingEnvironment, ) (*v1.Cluster, error)
CreateClusterFromExternalClusterBackupWithPITROnAzure creates a cluster on Azure, starting from an external cluster backup with PITR
func CreateClusterFromExternalClusterBackupWithPITROnAzurite ¶
func CreateClusterFromExternalClusterBackupWithPITROnAzurite( namespace, externalClusterName, sourceClusterName, targetTime string, env *TestingEnvironment, ) (*v1.Cluster, error)
CreateClusterFromExternalClusterBackupWithPITROnAzurite creates a cluster with Azurite, starting from an external cluster backup with PITR
func CreateClusterFromExternalClusterBackupWithPITROnMinio ¶
func CreateClusterFromExternalClusterBackupWithPITROnMinio( namespace, externalClusterName, sourceClusterName, targetTime string, env *TestingEnvironment, ) (*apiv1.Cluster, error)
CreateClusterFromExternalClusterBackupWithPITROnMinio creates a cluster on Minio, starting from an external cluster backup with PITR
func CreateObject ¶
func CreateObject(env *TestingEnvironment, object client.Object, opts ...client.CreateOption) (client.Object, error)
CreateObject create object in the Kubernetes cluster
func CreateObjectStorageSecret ¶ added in v1.23.6
func CreateObjectStorageSecret( namespace string, secretName string, id string, key string, env *TestingEnvironment, ) (*corev1.Secret, error)
CreateObjectStorageSecret generates an Opaque Secret with a given ID and Key
func CreateOnDemandBackup ¶ added in v1.21.0
func CreateOnDemandBackup( namespace, clusterName, backupName string, target apiv1.BackupTarget, method apiv1.BackupMethod, env *TestingEnvironment, ) (*apiv1.Backup, error)
CreateOnDemandBackup creates a Backup resource for a given cluster name Deprecated: Use CreateBackup. TODO: eradicate
func CreateOnDemandBackupViaKubectlPlugin ¶ added in v1.21.0
func CreateOnDemandBackupViaKubectlPlugin( namespace, clusterName, backupName string, target apiv1.BackupTarget, method apiv1.BackupMethod, ) error
CreateOnDemandBackupViaKubectlPlugin uses the kubectl plugin to create a backup
func CreateOperatorConfigurationMap ¶ added in v1.20.6
func CreateOperatorConfigurationMap(pgOperatorNamespace, configName string, isOnline bool, env *TestingEnvironment)
CreateOperatorConfigurationMap creates the operator namespace and enables/disable the online upgrade for the instance manager
func CreateSASTokenCredentials ¶ added in v1.23.6
func CreateSASTokenCredentials(namespace string, id string, key string, env *TestingEnvironment) error
CreateSASTokenCredentials generates Secrets for the Azure Blob Storage
func CreateSecretCA ¶
func CreateSecretCA( namespace string, clusterName string, caSecName string, includeCAPrivateKey bool, env *TestingEnvironment) ( *apiv1.Cluster, *certs.KeyPair, error, )
CreateSecretCA generates a CA for the cluster and return the cluster and the key pair
func CreateServiceFQDN ¶ added in v1.18.1
CreateServiceFQDN create service name with full dns
func CreateStorageCredentialsOnAzurite ¶ added in v1.15.3
func CreateStorageCredentialsOnAzurite(namespace string, env *TestingEnvironment) error
CreateStorageCredentialsOnAzurite will create credentials for Azurite
func CreateSubscription ¶ added in v1.21.3
func CreateSubscription(env *TestingEnvironment, channel string) error
CreateSubscription creates a subscription object inside openshift with a fixed name
func DefaultWebapp ¶
func DefaultWebapp(namespace string, name string, rootCASecretName string, tlsSecretName string) corev1.Pod
DefaultWebapp returns a struct representing a
func DeleteCSV ¶ added in v1.21.3
func DeleteCSV(env *TestingEnvironment) error
DeleteCSV will delete all operator's CSVs
func DeleteObject ¶
func DeleteObject(env *TestingEnvironment, object client.Object, opts ...client.DeleteOption) error
DeleteObject delete object in the Kubernetes cluster
func DeleteOperatorCRDs ¶ added in v1.21.3
func DeleteOperatorCRDs(env *TestingEnvironment) error
DeleteOperatorCRDs deletes the CRDs associated with the operator
func DeleteSubscription ¶ added in v1.21.3
func DeleteSubscription(env *TestingEnvironment) error
DeleteSubscription deletes the operator's subscription object
func DeploymentIsReady ¶
func DeploymentIsReady(deployment appsv1.Deployment) bool
DeploymentIsReady checks if a Deployment is ready
func DeploymentWaitForReady ¶
func DeploymentWaitForReady(env *TestingEnvironment, deployment *appsv1.Deployment, timeoutSeconds uint) error
DeploymentWaitForReady waits for a Deployment to be ready
func Envsubst ¶ added in v1.15.4
Envsubst substitutes any SHELL-FORMAT variables embedded in a file by the value of the corresponding environment variable, provided in `vars`
SHELL-FORMAT is, `${foo}` BUT NOT `$foo`, for simplicity of implementation
NOTE: If a variable embedded in the file is not provided in the `vars` argument, this function will error out. This is different from the behavior of the `envsubst` shell command: in testing we should avoid silent failures
func ExecuteBackup ¶
func ExecuteBackup( namespace, backupFile string, onlyTargetStandbys bool, timeoutSeconds int, env *TestingEnvironment, ) *apiv1.Backup
ExecuteBackup performs a backup and checks the backup status
func FencingOff ¶
func FencingOff( env *TestingEnvironment, serverName, namespace, clusterName string, fencingMethod FencingMethod, ) error
FencingOff marks an instance in a cluster as not fenced
func FencingOn ¶
func FencingOn( env *TestingEnvironment, serverName, namespace, clusterName string, fencingMethod FencingMethod, ) error
FencingOn marks an instance in a cluster as fenced
func FirstEndpointIP ¶
FirstEndpointIP returns the IP of first Address in the Endpoint
func ForgeArchiveWalOnMinio ¶
func ForgeArchiveWalOnMinio(namespace, clusterName, miniClientPodName, existingWALName, newWALName string) error
ForgeArchiveWalOnMinio instead of using `switchWalCmd` to generate a real WAL archive, directly forges a WAL archive file on Minio by copying and renaming an existing WAL archive file for the sake of more control of testing. To make sure the forged one won't be a real WAL archive, we let the sequence in newWALName to be big enough so that it can't be a real WAL archive name in an idle postgresql.
func GetAvailableReleases ¶ added in v1.15.1
GetAvailableReleases retrieves all the available releases from the list of YAML files in the top-level `releases/` directory.
func GetCNPGsMutatingWebhookByName ¶
func GetCNPGsMutatingWebhookByName(env *TestingEnvironment, name string) ( *admissionregistrationv1.MutatingWebhookConfiguration, int, error, )
GetCNPGsMutatingWebhookByName get the MutatingWebhook filtered by the name of one of the webhooks
func GetCNPGsValidatingWebhookByName ¶
func GetCNPGsValidatingWebhookByName(env *TestingEnvironment, name string) ( *admissionregistrationv1.ValidatingWebhookConfiguration, int, error, )
GetCNPGsValidatingWebhookByName get ValidatingWebhook by the name of one of the webhooks
func GetCNPGsValidatingWebhookConf ¶
func GetCNPGsValidatingWebhookConf(env *TestingEnvironment) ( *admissionregistrationv1.ValidatingWebhookConfiguration, error, )
GetCNPGsValidatingWebhookConf get the ValidatingWebhook linked to the operator
func GetConditionsInClusterStatus ¶
func GetConditionsInClusterStatus( namespace, clusterName string, env *TestingEnvironment, conditionType apiv1.ClusterConditionType, ) (*metav1.Condition, error)
GetConditionsInClusterStatus get conditions values as given type from cluster object status
func GetCredentials ¶ added in v1.18.1
func GetCredentials( clusterName, namespace string, secretSuffix string, env *TestingEnvironment) ( string, string, error, )
GetCredentials retrieve username and password from secrets and return it as per user suffix
func GetCurrentTimestamp ¶
func GetCurrentTimestamp(namespace, clusterName string, env *TestingEnvironment) (string, error)
GetCurrentTimestamp getting current time stamp from postgres server
func GetExpectedHAReplicationSlotsOnPod ¶ added in v1.23.0
func GetExpectedHAReplicationSlotsOnPod( namespace, clusterName, podName string, env *TestingEnvironment, ) ([]string, error)
GetExpectedHAReplicationSlotsOnPod returns a slice of replication slot names which should be present in a given pod
func GetHostName ¶ added in v1.18.1
func GetHostName(namespace, clusterName string, env *TestingEnvironment) (string, error)
GetHostName return fully qualified domain name for read write service
func GetLeaderInfoFromLease ¶ added in v1.15.1
func GetLeaderInfoFromLease(operatorNamespace string, env *TestingEnvironment) (string, error)
GetLeaderInfoFromLease gathers leader holderIdentity from the lease
func GetManagerVersion ¶ added in v1.21.3
GetManagerVersion returns the current manager version of a given pod
func GetMostRecentReleaseTag ¶
GetMostRecentReleaseTag retrieves the most recent release tag from the list of YAML files in the top-level `releases/` directory. Used for testing upgrades, so: if we're in a release branch, the MostRecent should be the next-to-last release
func GetObject ¶
GetObject retrieves an objects for the given object key from the Kubernetes Cluster
func GetObjectList ¶
func GetObjectList(env *TestingEnvironment, objectList client.ObjectList, opts ...client.ListOption) error
GetObjectList retrieves list of objects for a given namespace and list options
func GetOpenshiftVersion ¶ added in v1.21.3
func GetOpenshiftVersion(env *TestingEnvironment) (semver.Version, error)
GetOpenshiftVersion returns the current openshift version
func GetOperatorArchitectures ¶ added in v1.21.4
GetOperatorArchitectures returns all the supported operator architectures
func GetOperatorPodName ¶ added in v1.21.3
func GetOperatorPodName(env *TestingEnvironment) (string, error)
GetOperatorPodName returns the name of the current operator pod NOTE: will return an error if the pod is being deleted
func GetOperatorVersion ¶ added in v1.21.3
GetOperatorVersion returns the current operator version
func GetReadWriteServiceName ¶ added in v1.18.1
GetReadWriteServiceName read write service name
func GetReplicationSlotLsnsOnPod ¶ added in v1.18.0
func GetReplicationSlotLsnsOnPod( namespace, clusterName string, pod corev1.Pod, env *TestingEnvironment, ) ([]string, error)
GetReplicationSlotLsnsOnPod returns a slice containing the current restart_lsn values of each replication slot present in a given pod
func GetReplicationSlotsOnPod ¶ added in v1.18.0
func GetReplicationSlotsOnPod(namespace, podName string, env *TestingEnvironment) ([]string, error)
GetReplicationSlotsOnPod returns a slice containing the names of the current replication slots present in a given pod
func GetRwServiceObject ¶ added in v1.18.1
func GetRwServiceObject(namespace, clusterName string, env *TestingEnvironment) (*corev1.Service, error)
GetRwServiceObject return read write service object
func GetService ¶ added in v1.23.6
func GetService(namespace, name string, env *TestingEnvironment) (*corev1.Service, error)
GetService gets a service given name and namespace
func GetStorageAllowExpansion ¶
func GetStorageAllowExpansion(defaultStorageClass string, env *TestingEnvironment) (*bool, error)
GetStorageAllowExpansion returns the boolean value of the 'AllowVolumeExpansion' value of the storage class
func GetSubscription ¶ added in v1.21.3
func GetSubscription(env *TestingEnvironment) (*unstructured.Unstructured, error)
GetSubscription returns an unstructured subscription object
func GetSubscriptionVersion ¶ added in v1.21.3
func GetSubscriptionVersion(env *TestingEnvironment) (string, error)
GetSubscriptionVersion retrieves the current ClusterServiceVersion version of the operator
func HasOperatorBeenUpgraded ¶ added in v1.21.3
func HasOperatorBeenUpgraded(env *TestingEnvironment) bool
HasOperatorBeenUpgraded determines if the operator has been upgraded by checking if there is a deletion timestamp. If there isn't, it returns true
func HibernateOff ¶ added in v1.22.0
func HibernateOff( env *TestingEnvironment, namespace, clusterName string, method HibernationMethod, ) error
HibernateOff hibernate off a cluster
func HibernateOn ¶ added in v1.22.0
func HibernateOn( env *TestingEnvironment, namespace, clusterName string, method HibernationMethod, ) error
HibernateOn hibernate on a cluster
func ImportDatabaseMicroservice ¶ added in v1.16.0
func ImportDatabaseMicroservice( namespace, sourceClusterName, importedClusterName, imageName, databaseName string, env *TestingEnvironment, ) (*apiv1.Cluster, error)
ImportDatabaseMicroservice creates a cluster, starting from an external cluster using microservice approach NOTE: the application user on the source Cluster needs to be granted with REPLICATION permissions, which are not set by default
func ImportDatabasesMonolith ¶ added in v1.18.4
func ImportDatabasesMonolith( namespace, sourceClusterName, importedClusterName, imageName string, databaseNames []string, roles []string, env *TestingEnvironment, ) (*apiv1.Cluster, error)
ImportDatabasesMonolith creates a new cluster spec importing from a sourceCluster using the Monolith approach. Imports all the specified `databaseNames` and `roles` from the source cluster NOTE: enableSuperuserAccess needs to be enabled
func InstallAzCli ¶ added in v1.15.3
func InstallAzCli(namespace string, env *TestingEnvironment) error
InstallAzCli will install Az cli
func InstallAzurite ¶ added in v1.15.3
func InstallAzurite(namespace string, env *TestingEnvironment) error
InstallAzurite will set up Azurite in defined namespace and creates service
func InstallLatestCNPGOperator ¶
func InstallLatestCNPGOperator(releaseTag string, env *TestingEnvironment)
InstallLatestCNPGOperator installs an operator version with the most recent release tag
func IsWalStorageEnabled ¶ added in v1.17.0
func IsWalStorageEnabled(namespace, clusterName string, env *TestingEnvironment) (bool, error)
IsWalStorageEnabled returns true if 'WalStorage' is being used
func IsWellFormedLogForLogger ¶
IsWellFormedLogForLogger verifies if the message record field of the given map contains the expectedResult string. If the message field matches the expectedResult, then the related record is returned. Otherwise return nil.
func ObjectHasAnnotations ¶ added in v1.18.0
ObjectHasAnnotations returns true if the object has the passed annotations
func ObjectMatchesAnnotations ¶ added in v1.18.0
ObjectMatchesAnnotations returns true if the object has the passed annotations key/value
func OperatorPodRenamed ¶
OperatorPodRenamed checks if the operator pod was renamed
func OperatorPodRestarted ¶
OperatorPodRestarted checks if the operator pod was restarted
func ParseJSONLogs ¶
func ParseJSONLogs(namespace string, podName string, env *TestingEnvironment) ([]map[string]interface{}, error)
ParseJSONLogs returns the pod's logs of a given pod name, in the form of a list of JSON entries
func ParseObjectsFromYAML ¶ added in v1.15.4
ParseObjectsFromYAML parses a series of kubernetes objects defined in a YAML payload, into the specified namespace.
func PatchStatusCondition ¶ added in v1.21.3
func PatchStatusCondition(namespace, clusterName string, env *TestingEnvironment) error
PatchStatusCondition removes status conditions on a given Cluster
func PodCreateAndWaitForReady ¶
func PodCreateAndWaitForReady(env *TestingEnvironment, pod *corev1.Pod, timeoutSeconds uint) error
PodCreateAndWaitForReady creates a given pod object and wait for it to be ready
func PodHasAnnotations ¶
PodHasAnnotations verifies that the annotations of a pod contain a specified annotations map
func PodHasCondition ¶ added in v1.24.0
func PodHasCondition(pod *corev1.Pod, conditionType corev1.PodConditionType, status corev1.ConditionStatus) bool
PodHasCondition verifies that a pod has a specified condition
func PodHasLabels ¶
PodHasLabels verifies that the labels of a pod contain a specified labels map
func PodWaitForReady ¶
func PodWaitForReady(env *TestingEnvironment, pod *corev1.Pod, timeoutSeconds uint) error
PodWaitForReady waits for a pod to be ready
func PrintClusterResources ¶ added in v1.18.0
func PrintClusterResources(namespace, clusterName string, env *TestingEnvironment) string
PrintClusterResources prints a summary of the cluster pods, jobs, pvcs etc.
func PrintReplicationSlots ¶ added in v1.18.0
func PrintReplicationSlots( namespace, clusterName string, env *TestingEnvironment, ) string
PrintReplicationSlots prints replications slots with their restart_lsn
func PvcHasLabels ¶ added in v1.17.0
func PvcHasLabels( pvc corev1.PersistentVolumeClaim, labels map[string]string, ) bool
PvcHasLabels returns true if a PVC contains a given map of labels
func ReloadOperatorDeployment ¶
func ReloadOperatorDeployment(env *TestingEnvironment, timeoutSeconds uint) error
ReloadOperatorDeployment finds and deletes the operator pod. Returns error if the new pod is not ready within a defined timeout
func RetrieveMetricsFromInstance ¶ added in v1.22.5
func RetrieveMetricsFromInstance( env *TestingEnvironment, pod corev1.Pod, tlsEnabled bool, ) (string, error)
RetrieveMetricsFromInstance aims to retrieve the metrics from a PostgreSQL instance pod using a GET request on the pod interface proxy
func RetrieveMetricsFromPgBouncer ¶ added in v1.22.5
func RetrieveMetricsFromPgBouncer( env *TestingEnvironment, pod corev1.Pod, ) (string, error)
RetrieveMetricsFromPgBouncer aims to retrieve the metrics from a PgBouncer pod using a GET request on the pod interface proxy
func RetrievePgStatusFromInstance ¶ added in v1.23.5
func RetrievePgStatusFromInstance( env *TestingEnvironment, pod corev1.Pod, tlsEnabled bool, ) (string, error)
RetrievePgStatusFromInstance aims to retrieve the pgStatus from a PostgreSQL instance pod using a GET request on the pod interface proxy
func RunExecOverForward ¶ added in v1.23.6
func RunExecOverForward( env *TestingEnvironment, namespace, clusterName, dbname, secretSuffix, query string, ) (sql.Result, error)
RunExecOverForward runs Exec with a given query, returning the Result of the SQL command
func RunQueryRowOverForward ¶ added in v1.23.5
func RunQueryRowOverForward( env *TestingEnvironment, namespace, clusterName, dbname, secretSuffix, query string, ) (*sql.Row, error)
RunQueryRowOverForward runs QueryRow with a given query, returning the Row of the SQL command
func RunRetry ¶
RunRetry executes a command with retry and prints the output when terminates with an error
func RunUnchecked ¶
RunUnchecked executes a command and process the information
func RunUncheckedRetry ¶
RunUncheckedRetry executes a command and process the information with retry
func SetSnapshotNameAsEnv ¶ added in v1.21.0
func SetSnapshotNameAsEnv( snapshotList *volumesnapshot.VolumeSnapshotList, backup *apiv1.Backup, envVars EnvVarsForSnapshots, ) error
SetSnapshotNameAsEnv sets the names of a PG_DATA, a PG_WAL and a list of PG_TABLESPACE snapshots from a given snapshotList as env variables
func TestDirectoryEmpty ¶
TestDirectoryEmpty tests if a directory `directoryPath` exists on pod `podName` in namespace `namespace`
func TestFileExist ¶
TestFileExist tests if a file specified with `fileName` exist under directory `directoryPath`, on pod `podName` in namespace `namespace`
func Timeouts ¶ added in v1.18.5
Timeouts returns the map of timeouts, where each event gets the timeout specified in the `TEST_TIMEOUTS` environment variable, or if not specified, takes the default value
func ToggleHAReplicationSlots ¶ added in v1.23.0
func ToggleHAReplicationSlots(namespace, clusterName string, enable bool, env *TestingEnvironment) error
ToggleHAReplicationSlots sets the HA Replication Slot feature on/off depending on `enable`
func ToggleSynchronizeReplicationSlots ¶ added in v1.23.0
func ToggleSynchronizeReplicationSlots(namespace, clusterName string, enable bool, env *TestingEnvironment) error
ToggleSynchronizeReplicationSlots sets the Synchronize Replication Slot feature on/off depending on `enable`
func UpdateCNPGsMutatingWebhookConf ¶
func UpdateCNPGsMutatingWebhookConf(env *TestingEnvironment, wh *admissionregistrationv1.MutatingWebhookConfiguration, ) error
UpdateCNPGsMutatingWebhookConf update MutatingWebhookConfiguration object
func UpdateCNPGsValidatingWebhookConf ¶
func UpdateCNPGsValidatingWebhookConf(env *TestingEnvironment, wh *admissionregistrationv1.ValidatingWebhookConfiguration, ) error
UpdateCNPGsValidatingWebhookConf update the ValidatingWebhook object
func UpgradeSubscription ¶ added in v1.21.3
func UpgradeSubscription(env *TestingEnvironment, channel string) error
UpgradeSubscription patch an unstructured subscription object with target channel
Types ¶
type AzureConfiguration ¶ added in v1.20.5
AzureConfiguration contains the variables needed to run the azure test environment correctly
type ContainerLocator ¶ added in v1.18.5
ContainerLocator contains the necessary data to find a container on a pod
type DatabaseName ¶ added in v1.18.5
type DatabaseName string
DatabaseName is a special type for the database argument in an Exec call
type EnvProfile ¶ added in v1.22.5
type EnvProfile interface {
CanMovePVCAcrossNodes() bool
IsLeaderElectionEnabled() bool
CanRunAppArmor() bool
UsesNodeDiskSpace() bool
}
EnvProfile represents the capabilities of different cloud environments for testing
func GetEnvProfile ¶ added in v1.22.5
func GetEnvProfile(te TestEnvVendor) EnvProfile
GetEnvProfile returns a cloud environment's capabilities envProfile
type EnvVarsForSnapshots ¶ added in v1.22.0
type EnvVarsForSnapshots struct {
DataSnapshot string
WalSnapshot string
TablespaceSnapshotPrefix string
}
EnvVarsForSnapshots represents the environment variables to use to track snapshots and apply them in test fixture templates
type FencingMethod ¶
type FencingMethod string
FencingMethod will be one of the supported ways to trigger an instance fencing
const ( // UsingAnnotation it is a keyword to use while fencing on/off the instances using annotation method UsingAnnotation FencingMethod = "annotation" // UsingPlugin it is a keyword to use while fencing on/off the instances using plugin method UsingPlugin FencingMethod = "plugin" )
type HibernationMethod ¶ added in v1.22.0
type HibernationMethod string
HibernationMethod will be one of the supported ways to trigger an instance fencing
const ( // HibernateDeclaratively it is a keyword to use while fencing on/off the instances using annotation method HibernateDeclaratively HibernationMethod = "annotation" // HibernateImperatively it is a keyword to use while fencing on/off the instances using plugin method HibernateImperatively HibernationMethod = "plugin" )
type PSQLForwardConnection ¶ added in v1.23.5
type PSQLForwardConnection struct {
// contains filtered or unexported fields
}
PSQLForwardConnection manages the creation of a port-forwarding to open a new database connection
func ForwardPSQLConnection ¶ added in v1.23.5
func ForwardPSQLConnection( env *TestingEnvironment, namespace, clusterName, dbname, secretSuffix string, ) (*PSQLForwardConnection, *sql.DB, error)
ForwardPSQLConnection simplifies the creation of forwarded connection to PostgreSQL cluster
func ForwardPSQLConnectionWithCreds ¶ added in v1.23.5
func ForwardPSQLConnectionWithCreds( env *TestingEnvironment, namespace, clusterName, dbname, userApp, passApp string, ) (*PSQLForwardConnection, *sql.DB, error)
ForwardPSQLConnectionWithCreds creates a forwarded connection to a PostgreSQL cluster using the given credentials
func ForwardPSQLServiceConnection ¶ added in v1.23.6
func ForwardPSQLServiceConnection( env *TestingEnvironment, namespace, serviceName, dbname, userApp, passApp string, ) (*PSQLForwardConnection, *sql.DB, error)
ForwardPSQLServiceConnection creates a forwarded connection to a PostgreSQL service using the given credentials
func (*PSQLForwardConnection) Close ¶ added in v1.23.5
func (psqlc *PSQLForwardConnection) Close()
Close will stop the port-forwarding and exit
func (*PSQLForwardConnection) GetPooler ¶ added in v1.23.5
func (psqlc *PSQLForwardConnection) GetPooler() pool.Pooler
GetPooler returns the connection Pooler
type PodLocator ¶ added in v1.18.5
PodLocator contains the necessary data to find a pod
type SSLMode ¶ added in v1.18.1
type SSLMode string
SSLMode while using psql connection with `sslmode`
type TestEnvVendor ¶ added in v1.18.5
type TestEnvVendor string
TestEnvVendor is the type of cloud vendor the e2e test is running on
func TestCloudVendor ¶ added in v1.18.5
func TestCloudVendor() (*TestEnvVendor, error)
TestCloudVendor creates the environment for testing
type TestingEnvironment ¶
type TestingEnvironment struct {
RestClientConfig *rest.Config
Client client.Client
Interface kubernetes.Interface
APIExtensionClient apiextensionsclientset.Interface
Ctx context.Context
Scheme *runtime.Scheme
PreserveNamespaces []string
Log logr.Logger
PostgresVersion uint64
AzureConfiguration AzureConfiguration
SternLogDir 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) CleanupNamespace ¶ added in v1.23.5
func (env TestingEnvironment) CleanupNamespace( namespace string, testName string, testFailed bool, ) error
CleanupNamespace does cleanup duty related to the tear-down of a namespace, and is intended to be called in a DeferCleanup clause
func (TestingEnvironment) CreateNamespace ¶
func (env TestingEnvironment) CreateNamespace(name string, opts ...client.CreateOption) error
CreateNamespace creates a namespace.
func (TestingEnvironment) CreateTestNamespace ¶ added in v1.23.5
func (env TestingEnvironment) CreateTestNamespace( name string, opts ...client.CreateOption, ) error
CreateTestNamespace creates a namespace creates a namespace. Prefer CreateUniqueTestNamespace instead, unless you need a specific namespace name. If so, make sure there is no collision potential. The namespace is automatically cleaned up at the end of the test.
func (TestingEnvironment) CreateUniqueTestNamespace ¶ added in v1.23.5
func (env TestingEnvironment) CreateUniqueTestNamespace( 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) DeleteNamespace ¶
func (env TestingEnvironment) DeleteNamespace(name string, opts ...client.DeleteOption) error
DeleteNamespace deletes a namespace if existent
func (TestingEnvironment) DeleteNamespaceAndWait ¶
func (env TestingEnvironment) DeleteNamespaceAndWait(name string, timeoutSeconds int) error
DeleteNamespaceAndWait deletes a namespace if existent and returns when deletion is completed
func (TestingEnvironment) DeletePod ¶
func (env TestingEnvironment) DeletePod(namespace string, name string, opts ...client.DeleteOption) error
DeletePod deletes a pod if existent
func (TestingEnvironment) DescribeKubernetesNodes ¶ added in v1.18.0
func (env TestingEnvironment) DescribeKubernetesNodes() (string, error)
DescribeKubernetesNodes prints the `describe node` for each node in the kubernetes cluster
func (TestingEnvironment) DumpNamespaceObjects ¶ added in v1.15.2
func (env TestingEnvironment) DumpNamespaceObjects(namespace string, filename string)
DumpNamespaceObjects logs the clusters, pods, pvcs etc. found in a namespace as JSON sections
func (TestingEnvironment) DumpOperator ¶
func (env TestingEnvironment) DumpOperator(namespace string, filename string)
DumpOperator logs the JSON for the deployment in an operator namespace, its pods and endpoints
func (TestingEnvironment) EnsureNamespace ¶ added in v1.20.6
func (env TestingEnvironment) EnsureNamespace(namespace string) error
EnsureNamespace checks for the presence of a namespace, and if it does not exist, creates it
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) EventuallyExecQueryInInstancePod ¶ added in v1.23.6
func (env TestingEnvironment) EventuallyExecQueryInInstancePod( podLocator PodLocator, dbname DatabaseName, query string, retryTimeout int, pollingTime int, ) (string, string, error)
EventuallyExecQueryInInstancePod wraps ExecQueryInInstancePod with an Eventually clause
func (TestingEnvironment) ExecCommand ¶
func (env TestingEnvironment) ExecCommand( ctx context.Context, pod corev1.Pod, containerName string, timeout *time.Duration, command ...string, ) (string, string, error)
ExecCommand wraps the utils.ExecCommand pre-setting values constant during tests
func (TestingEnvironment) ExecCommandInContainer ¶ added in v1.18.5
func (env TestingEnvironment) ExecCommandInContainer( container ContainerLocator, timeout *time.Duration, command ...string, ) (string, string, error)
ExecCommandInContainer executes commands in a given instance pod, in the postgres container
func (TestingEnvironment) ExecCommandInInstancePod ¶ added in v1.18.5
func (env TestingEnvironment) ExecCommandInInstancePod( podLocator PodLocator, timeout *time.Duration, command ...string, ) (string, string, error)
ExecCommandInInstancePod executes commands in a given instance pod, in the postgres container
func (TestingEnvironment) ExecQueryInInstancePod ¶ added in v1.18.5
func (env TestingEnvironment) ExecQueryInInstancePod( podLocator PodLocator, dbname DatabaseName, query string, ) (string, string, error)
ExecQueryInInstancePod executes a query in an instance pod, by connecting to the pod and the postgres container, and using a local connection with the postgres user
func (TestingEnvironment) GetBackupList ¶ added in v1.15.3
func (env TestingEnvironment) GetBackupList(namespace string) (*apiv1.BackupList, error)
GetBackupList gathers the current list of backup in namespace
func (TestingEnvironment) GetCNPGsMutatingWebhookConf ¶
func (env TestingEnvironment) GetCNPGsMutatingWebhookConf() ( *admissionregistrationv1.MutatingWebhookConfiguration, error, )
GetCNPGsMutatingWebhookConf get the MutatingWebhook linked to the operator
func (TestingEnvironment) GetCluster ¶
GetCluster gets a cluster given name and namespace
func (TestingEnvironment) GetClusterPodList ¶
func (env TestingEnvironment) GetClusterPodList(namespace string, clusterName string) (*corev1.PodList, error)
GetClusterPodList gathers the current list of instance pods for a cluster in a namespace
func (TestingEnvironment) GetClusterPrimary ¶
func (env TestingEnvironment) GetClusterPrimary(namespace string, clusterName string) (*corev1.Pod, error)
GetClusterPrimary gets the primary pod of a cluster
func (TestingEnvironment) GetClusterReplicas ¶ added in v1.15.5
func (env TestingEnvironment) GetClusterReplicas(namespace string, clusterName string) (*corev1.PodList, error)
GetClusterReplicas gets a slice containing all the replica pods of a cluster
func (TestingEnvironment) GetEventList ¶
func (env TestingEnvironment) GetEventList(namespace string) (*eventsv1.EventList, error)
GetEventList gathers the current list of events in a namespace
func (TestingEnvironment) GetJob ¶ added in v1.21.0
func (env TestingEnvironment) GetJob(namespace, jobName string) (*batchv1.Job, error)
GetJob gets a Job by namespace and name
func (TestingEnvironment) GetJobList ¶
func (env TestingEnvironment) GetJobList(namespace string) (*batchv1.JobList, error)
GetJobList gathers the current list of jobs in a namespace
func (TestingEnvironment) GetNodeList ¶
func (env TestingEnvironment) GetNodeList() (*corev1.NodeList, error)
GetNodeList gathers the current list of Nodes
func (TestingEnvironment) GetOperatorDeployment ¶
func (env TestingEnvironment) GetOperatorDeployment() (appsv1.Deployment, error)
GetOperatorDeployment returns the operator Deployment if there is a single one running, error otherwise
func (TestingEnvironment) GetOperatorLogs ¶ added in v1.23.5
func (env TestingEnvironment) GetOperatorLogs(buf *bytes.Buffer) error
GetOperatorLogs collects the operator logs
func (TestingEnvironment) GetOperatorNamespaceName ¶
func (env TestingEnvironment) GetOperatorNamespaceName() (string, error)
GetOperatorNamespaceName returns the namespace the operator Deployment is running in
func (TestingEnvironment) GetOperatorPod ¶
func (env TestingEnvironment) GetOperatorPod() (corev1.Pod, error)
GetOperatorPod returns the operator pod if there is a single one running, error otherwise
func (TestingEnvironment) GetPVCList ¶
func (env TestingEnvironment) GetPVCList(namespace string) (*corev1.PersistentVolumeClaimList, error)
GetPVCList gathers the current list of PVCs in a namespace
func (TestingEnvironment) GetPod ¶ added in v1.18.5
func (env TestingEnvironment) GetPod(namespace, podName string) (*corev1.Pod, error)
GetPod gets a pod by namespace and name
func (TestingEnvironment) GetPodList ¶
func (env TestingEnvironment) GetPodList(namespace string) (*corev1.PodList, error)
GetPodList gathers the current list of pods in a namespace
func (TestingEnvironment) GetPodLogs ¶
func (env TestingEnvironment) GetPodLogs(namespace string, podName string) (string, error)
GetPodLogs gathers pod logs
func (TestingEnvironment) GetPodMonitor ¶ added in v1.23.1
func (env TestingEnvironment) GetPodMonitor(namespace string, name string) (*monitoringv1.PodMonitor, error)
GetPodMonitor gathers the current PodMonitor in a namespace
func (TestingEnvironment) GetResourceNameFromYAML ¶
func (env TestingEnvironment) GetResourceNameFromYAML(path string) (string, error)
GetResourceNameFromYAML returns the name of a resource in a YAML file
func (TestingEnvironment) GetResourceNamespacedNameFromYAML ¶
func (env TestingEnvironment) GetResourceNamespacedNameFromYAML(path string) (types.NamespacedName, error)
GetResourceNamespacedNameFromYAML returns the NamespacedName representing a resource in a YAML file
func (TestingEnvironment) GetScheduledBackupList ¶ added in v1.15.3
func (env TestingEnvironment) GetScheduledBackupList(namespace string) (*apiv1.ScheduledBackupList, error)
GetScheduledBackupList gathers the current list of scheduledBackup in namespace
func (TestingEnvironment) GetServiceAccountList ¶
func (env TestingEnvironment) GetServiceAccountList(namespace string) (*corev1.ServiceAccountList, error)
GetServiceAccountList gathers the current list of jobs in a namespace
func (TestingEnvironment) GetSnapshotList ¶ added in v1.20.3
func (env TestingEnvironment) GetSnapshotList(namespace string) (*storagesnapshotv1.VolumeSnapshotList, error)
GetSnapshotList gathers the current list of VolumeSnapshots in a namespace
func (TestingEnvironment) GetVolumeSnapshot ¶ added in v1.21.0
func (env TestingEnvironment) GetVolumeSnapshot( namespace, name string, ) (*volumesnapshot.VolumeSnapshot, error)
GetVolumeSnapshot gets a VolumeSnapshot given name and namespace
func (*TestingEnvironment) IsOperatorDeploymentReady ¶ added in v1.21.6
func (env *TestingEnvironment) IsOperatorDeploymentReady() (bool, error)
IsOperatorDeploymentReady returns true if the operator deployment has the expected number of ready pods. It returns an error if there was a problem getting the operator deployment
func (TestingEnvironment) IsOperatorReady ¶
func (env TestingEnvironment) IsOperatorReady() (bool, error)
IsOperatorReady ensures that the operator will be ready.
func (TestingEnvironment) ScaleClusterSize ¶ added in v1.15.5
func (env TestingEnvironment) ScaleClusterSize(namespace, clusterName string, newClusterSize int) error
ScaleClusterSize scales a cluster to the requested size
func (*TestingEnvironment) ScaleOperatorDeployment ¶ added in v1.21.6
func (env *TestingEnvironment) ScaleOperatorDeployment(replicas int32) error
ScaleOperatorDeployment will scale the operator to n replicas and return error in case of failure
type Timeout ¶ added in v1.18.5
type Timeout string
Timeout represents an event whose time we want to limit in the test suite
const ( Failover Timeout = "failover" NamespaceCreation Timeout = "namespaceCreation" ClusterIsReady Timeout = "clusterIsReady" ClusterIsReadyQuick Timeout = "clusterIsReadyQuick" ClusterIsReadySlow Timeout = "clusterIsReadySlow" NewPrimaryAfterSwitchover Timeout = "newPrimaryAfterSwitchover" NewPrimaryAfterFailover Timeout = "newPrimaryAfterFailover" NewTargetOnFailover Timeout = "newTargetOnFailover" PodRollout Timeout = "podRollout" OperatorIsReady Timeout = "operatorIsReady" LargeObject Timeout = "largeObject" WalsInMinio Timeout = "walsInMinio" MinioInstallation Timeout = "minioInstallation" BackupIsReady Timeout = "backupIsReady" DrainNode Timeout = "drainNode" VolumeSnapshotIsReady Timeout = "volumeSnapshotIsReady" Short Timeout = "short" ManagedServices Timeout = "managedServices" )
the events we're setting timeouts for NOTE: the text representation will be used as the fields in the JSON representation of the timeout object passed to the ginkgo command as an environment variable
Source Files
¶
- azurite.go
- backup.go
- certificates.go
- cloud_vendor.go
- cluster.go
- commons.go
- deployment.go
- endpoints.go
- environment.go
- envsubst.go
- fence.go
- hibernate.go
- import_db.go
- job.go
- lease.go
- logs.go
- monitoring.go
- namespace.go
- openshift.go
- operator.go
- pod.go
- postgres.go
- proxy.go
- psql_connection.go
- release.go
- replication_slots.go
- run.go
- secrets.go
- service.go
- storage.go
- time.go
- timeouts.go
- upgrade.go
- version.go
- webapp.go
- webhooks.go
- yaml.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package forwardconnection provides an easy interface to create a port forward from the local test to a service or pod inside the testing k8s cluster
|
Package forwardconnection provides an easy interface to create a port forward from the local test to a service or pod inside the testing k8s cluster |
|
Package minio contains all the require functions to setup a MinIO deployment and query this MinIO deployment using the MinIO API
|
Package minio contains all the require functions to setup a MinIO deployment and query this MinIO deployment using the MinIO API |
|
Package nodes contains the helper methods/functions for nodes
|
Package nodes contains the helper methods/functions for nodes |
|
Package sternmultitailer handle the logs of every pod in the tests saving them in a structured way within a directory.
|
Package sternmultitailer handle the logs of every pod in the tests saving them in a structured way within a directory. |