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 AssertQueryRecord(logEntries []map[string]interface{}, errorTestQuery string, message string, ...) bool
- func BumpPostgresImageMajorVersion(postgresImage string) (string, 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 string, path string) string
- func ComposeAzBlobListCmd(azStorageAccount, azStorageKey, clusterName string, path string) string
- func CountFilesOnAzureBlobStorage(azStorageAccount string, azStorageKey string, clusterName string, path string) (int, error)
- func CountFilesOnAzuriteBlobStorage(namespace, clusterName string, path string) (int, error)
- func CountFilesOnMinio(namespace string, minioClientName string, path string) (value int, err error)
- func CountReplicas(env *TestingEnvironment, pod *corev1.Pod) (int, 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, ...) error
- func CreateClusterFromExternalClusterBackupWithPITROnAzure(namespace, externalClusterName, sourceClusterName, targetTime, ... string, ...) error
- func CreateClusterFromExternalClusterBackupWithPITROnAzurite(namespace, externalClusterName, sourceClusterName, targetTime string, ...) error
- func CreateClusterFromExternalClusterBackupWithPITROnMinio(namespace, externalClusterName, sourceClusterName, targetTime string, ...) error
- func CreateObject(env *TestingEnvironment, object client.Object, opts ...client.CreateOption) error
- func CreateSecretCA(namespace string, clusterName string, caSecName string, ...) (*apiv1.Cluster, *certs.KeyPair, error)
- func CreateStorageCredentialsOnAzurite(namespace string, env *TestingEnvironment) error
- func CurlClient(namespace string) corev1.Pod
- func CurlGetMetrics(namespace, curlPodName, podIP string, port int) (string, error)
- func DefaultWebapp(namespace string, name string, rootCASecretName string, tlsSecretName string) corev1.Pod
- func DeleteObject(env *TestingEnvironment, object client.Object, opts ...client.DeleteOption) error
- func DeploymentIsReady(deployment appsv1.Deployment) bool
- func DeploymentWaitForReady(env *TestingEnvironment, deployment *appsv1.Deployment, timeoutSeconds uint) error
- func EnableOnlineUpgradeForInstanceManager(pgOperatorNamespace, configName string, env *TestingEnvironment)
- func Envsubst(vars map[string]string, data []byte) ([]byte, error)
- func ExecuteBackup(namespace string, backupFile string, env *TestingEnvironment)
- 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 GetCurrentTimestamp(namespace, clusterName string, env *TestingEnvironment) (string, error)
- func GetLeaderInfoFromLease(operatorNamespace string, env *TestingEnvironment) (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 GetPassword(clusterName, namespace, userPrefix string, env *TestingEnvironment) (string, error)
- func GetStorageAllowExpansion(defaultStorageClass string, env *TestingEnvironment) (*bool, error)
- func HasLogger(logEntries []map[string]interface{}, logger string) bool
- func ImportDatabaseMicroservice(namespace, importedClusterName, sourceClusterName, databaseName string, ...) error
- func InstallAzCli(namespace string, env *TestingEnvironment) error
- func InstallAzurite(namespace string, env *TestingEnvironment) error
- func InstallLatestCNPGOperator(releaseTag string, env *TestingEnvironment)
- func InstallMinio(env *TestingEnvironment, minioSetup MinioSetup, timeoutSeconds uint) error
- func IsWellFormedLogForLogger(item map[string]interface{}, loggerField string) bool
- func MinioDefaultClient(namespace string) corev1.Pod
- func MinioDefaultDeployment(namespace string, minioPVC corev1.PersistentVolumeClaim) appsv1.Deployment
- func MinioDefaultPVC(namespace string) (corev1.PersistentVolumeClaim, error)
- func MinioDefaultSVC(namespace string) corev1.Service
- func MinioSSLClient(namespace string) corev1.Pod
- func MinioTestConnectivityUsingBarmanCloudWalArchive(namespace, clusterName, podName, id, key string) (bool, error)
- 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 PodCreateAndWaitForReady(env *TestingEnvironment, pod *corev1.Pod, timeoutSeconds uint) error
- func PodHasAnnotations(pod corev1.Pod, annotations map[string]string) bool
- func PodHasLabels(pod corev1.Pod, labels map[string]string) bool
- func PodWaitForReady(env *TestingEnvironment, pod *corev1.Pod, timeoutSeconds uint) error
- func ReloadOperatorDeployment(env *TestingEnvironment, timeoutSeconds uint) error
- func Run(command string) (stdout string, stderr string, err error)
- func RunQueryFromPod(connectingPod *corev1.Pod, host string, dbname string, user string, ...) (string, string, 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 TestDirectoryEmpty(namespace, podName, directoryPath string) bool
- func TestFileExist(namespace, podName, directoryPath, fileName string) bool
- func UpdateCNPGsMutatingWebhookConf(env *TestingEnvironment, ...) error
- func UpdateCNPGsValidatingWebhookConf(env *TestingEnvironment, ...) error
- type ClusterResourcePrinter
- type FencingMethod
- type MinioSetup
- type TagSet
- type TestingEnvironment
- func (env TestingEnvironment) CreateNamespace(name string, opts ...client.CreateOption) 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) DumpNamespaceObjects(namespace string, filename string)
- func (env TestingEnvironment) DumpOperator(namespace string, filename string)
- func (env TestingEnvironment) DumpOperatorLogs(getPrevious bool, requestedLineLength int) ([]string, error)
- func (env TestingEnvironment) DumpPoolerResourcesInfo(namespace, currentTestName string)
- func (env TestingEnvironment) EventuallyExecCommand(ctx context.Context, pod corev1.Pod, containerName string, ...) (string, string, error)
- func (env TestingEnvironment) ExecCommand(ctx context.Context, pod corev1.Pod, containerName 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) GetJobList(namespace string) (*batchv1.JobList, error)
- func (env TestingEnvironment) GetNodeList() (*corev1.NodeList, error)
- func (env TestingEnvironment) GetOperatorDeployment() (appsv1.Deployment, 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) GetPodList(namespace string) (*corev1.PodList, error)
- func (env TestingEnvironment) GetPodLogs(namespace string, podName string) (string, error)
- func (env TestingEnvironment) GetPoolerList(namespace string) (*apiv1.PoolerList, error)
- func (env TestingEnvironment) GetResourceNameFromYAML(path string) (string, error)
- func (env TestingEnvironment) GetResourceNamespaceFromYAML(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) IsAKS() (bool, error)
- func (env TestingEnvironment) IsEKS() (bool, error)
- func (env TestingEnvironment) IsGKE() (bool, error)
- func (env TestingEnvironment) IsIBM() bool
- func (env TestingEnvironment) IsOperatorReady() (bool, error)
- func (env TestingEnvironment) ScaleClusterSize(namespace, clusterName string, newClusterSize int) error
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 = "/controller/run"
PGLocalSocketDir is the directory containing the PostgreSQL local socket
Variables ¶
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
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 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 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 ¶
ComposeAzBlobListCmd builds the Azure storage blob list command
func CountFilesOnAzureBlobStorage ¶
func CountFilesOnAzureBlobStorage( azStorageAccount string, azStorageKey string, clusterName string, path string, ) (int, error)
CountFilesOnAzureBlobStorage counts files on Azure Blob storage
func CountFilesOnAzuriteBlobStorage ¶
CountFilesOnAzuriteBlobStorage counts files on Azure Blob storage. using Azurite
func CountFilesOnMinio ¶
func CountFilesOnMinio(namespace string, minioClientName string, path string) (value int, err error)
CountFilesOnMinio uses the minioClient in the given `namespace` to count the amount of files matching the given `path`
func CountReplicas ¶
func CountReplicas(env *TestingEnvironment, pod *corev1.Pod) (int, error)
CountReplicas counts the number of replicas attached to an instance
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, ) error
CreateClusterFromBackupUsingPITR creates a cluster from backup, using the PITR
func CreateClusterFromExternalClusterBackupWithPITROnAzure ¶
func CreateClusterFromExternalClusterBackupWithPITROnAzure( namespace, externalClusterName, sourceClusterName, targetTime, storageCredentialsSecretName, azStorageAccount string, env *TestingEnvironment, ) 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, ) 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, ) 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) error
CreateObject create object in the Kubernetes cluster
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 CreateStorageCredentialsOnAzurite ¶ added in v1.15.3
func CreateStorageCredentialsOnAzurite(namespace string, env *TestingEnvironment) error
CreateStorageCredentialsOnAzurite will create credentials for Azurite
func CurlClient ¶
CurlClient returns the Pod definition for a curl client
func CurlGetMetrics ¶
CurlGetMetrics returns true if test connection is successful else false
func DefaultWebapp ¶
func DefaultWebapp(namespace string, name string, rootCASecretName string, tlsSecretName string) corev1.Pod
DefaultWebapp returns a struct representing a
func DeleteObject ¶
func DeleteObject(env *TestingEnvironment, object client.Object, opts ...client.DeleteOption) error
DeleteObject delete object in the Kubernetes cluster
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 EnableOnlineUpgradeForInstanceManager ¶
func EnableOnlineUpgradeForInstanceManager(pgOperatorNamespace, configName string, env *TestingEnvironment)
EnableOnlineUpgradeForInstanceManager creates the operator namespace and enables tho online upgrade for the instance manager
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 string, backupFile string, env *TestingEnvironment)
ExecuteBackup performs a backup and check 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 GetCurrentTimestamp ¶
func GetCurrentTimestamp(namespace, clusterName string, env *TestingEnvironment) (string, error)
GetCurrentTimestamp getting current time stamp from postgres server
func GetLeaderInfoFromLease ¶ added in v1.15.1
func GetLeaderInfoFromLease(operatorNamespace string, env *TestingEnvironment) (string, error)
GetLeaderInfoFromLease gathers leader holderIdentity from the lease
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 GetPassword ¶ added in v1.16.0
func GetPassword(clusterName, namespace, userPrefix string, env *TestingEnvironment) (string, error)
GetPassword generates password and return it as per user prefix
func GetStorageAllowExpansion ¶
func GetStorageAllowExpansion(defaultStorageClass string, env *TestingEnvironment) (*bool, error)
GetStorageAllowExpansion returns the boolean value of the 'AllowVolumeExpansion' value of the storage class
func ImportDatabaseMicroservice ¶ added in v1.16.0
func ImportDatabaseMicroservice(namespace, importedClusterName, sourceClusterName, databaseName string, env *TestingEnvironment, imageName string, ) error
ImportDatabaseMicroservice creates a cluster, starting from an external cluster using microservice approach
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 InstallMinio ¶
func InstallMinio( env *TestingEnvironment, minioSetup MinioSetup, timeoutSeconds uint, ) error
InstallMinio installs minio in a given namespace
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 MinioDefaultClient ¶
MinioDefaultClient returns the default Pod definition for a minio client
func MinioDefaultDeployment ¶
func MinioDefaultDeployment(namespace string, minioPVC corev1.PersistentVolumeClaim) appsv1.Deployment
MinioDefaultDeployment returns a default Deployment for minio
func MinioDefaultPVC ¶
func MinioDefaultPVC(namespace string) (corev1.PersistentVolumeClaim, error)
MinioDefaultPVC returns a default PVC for minio
func MinioDefaultSVC ¶
MinioDefaultSVC returns a default Service for minio
func MinioSSLClient ¶
MinioSSLClient returns the Pod definition for a minio client using SSL
func MinioTestConnectivityUsingBarmanCloudWalArchive ¶
func MinioTestConnectivityUsingBarmanCloudWalArchive(namespace, clusterName, podName, id, key string) (bool, error)
MinioTestConnectivityUsingBarmanCloudWalArchive returns true if test connection is successful else false
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 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 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 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 RunQueryFromPod ¶
func RunQueryFromPod( connectingPod *corev1.Pod, host string, dbname string, user string, password string, query string, env *TestingEnvironment, ) (string, string, error)
RunQueryFromPod executes a query from a pod to a host
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 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 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
Types ¶
type ClusterResourcePrinter ¶ added in v1.15.5
type ClusterResourcePrinter = func() string
ClusterResourcePrinter is a function that returns a string containing a summary of the cluster resources
func NewClusterResourcePrinter ¶ added in v1.15.5
func NewClusterResourcePrinter(namespace, clusterName string, env *TestingEnvironment) ClusterResourcePrinter
NewClusterResourcePrinter returns a function that fetches and then prints a summary of the cluster resources
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 MinioSetup ¶
type MinioSetup struct {
PersistentVolumeClaim corev1.PersistentVolumeClaim
Deployment appsv1.Deployment
Service corev1.Service
}
MinioSetup contains the resources needed for a working minio server deployment: a PersistentVolumeClaim, a Deployment and a Service
func MinioDefaultSetup ¶
func MinioDefaultSetup(namespace string) (MinioSetup, error)
MinioDefaultSetup returns the definition for the default minio setup
func MinioSSLSetup ¶
func MinioSSLSetup(namespace string) (MinioSetup, error)
MinioSSLSetup returns the definition for a minio setup using SSL
type TagSet ¶
TagSet will contain the `tagset` section of the minio output command
func GetFileTagsOnMinio ¶
GetFileTagsOnMinio will use the minioClient to retrieve the tags in a specified path
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
}
TestingEnvironment struct for operator testing
func NewTestingEnvironment ¶
func NewTestingEnvironment() (*TestingEnvironment, error)
NewTestingEnvironment creates the environment for testing
func (TestingEnvironment) CreateNamespace ¶
func (env TestingEnvironment) CreateNamespace(name string, opts ...client.CreateOption) error
CreateNamespace creates a namespace
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) 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) DumpOperatorLogs ¶ added in v1.15.5
func (env TestingEnvironment) DumpOperatorLogs(getPrevious bool, requestedLineLength int) ([]string, error)
DumpOperatorLogs dumps the operator logs to a file, and returns the log lines as a slice.
func (TestingEnvironment) DumpPoolerResourcesInfo ¶
func (env TestingEnvironment) DumpPoolerResourcesInfo(namespace, currentTestName string)
DumpPoolerResourcesInfo logs the JSON for the pooler resources in a namespace, its pods, Deployment, services and endpoints
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) 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) 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 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) 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) 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) 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) GetPoolerList ¶
func (env TestingEnvironment) GetPoolerList(namespace string) (*apiv1.PoolerList, error)
GetPoolerList gathers the current list of poolers 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) GetResourceNamespaceFromYAML ¶
func (env TestingEnvironment) GetResourceNamespaceFromYAML(path string) (string, error)
GetResourceNamespaceFromYAML returns the namespace 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) IsAKS ¶
func (env TestingEnvironment) IsAKS() (bool, error)
IsAKS returns true if we run on Azure Kubernetes Service. We check that by verifying if all the node names start with "aks-"
func (TestingEnvironment) IsEKS ¶ added in v1.15.2
func (env TestingEnvironment) IsEKS() (bool, error)
IsEKS returns true if we run on amazon EKS Service. We check that by verifying if all the node names start with "ip-"
func (TestingEnvironment) IsGKE ¶
func (env TestingEnvironment) IsGKE() (bool, error)
IsGKE returns true if we run on Google Kubernetes Engine. We check that by verifying if all the node names start with "gke-"
func (TestingEnvironment) IsIBM ¶
func (env TestingEnvironment) IsIBM() bool
IsIBM returns true if we are running on IBM architecture. We check that by verifying if IBM_ARCH env is equals to "true"
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