Documentation ¶
Index ¶
- Constants
- func AwaitPodReadyOrDie(cs clientset.Interface, ns, name string, timeout time.Duration)
- func ExecuteSQL(cluster *v1alpha1.Cluster, member, sql string) (string, error)
- func ExpectNoError(err error, explain ...interface{})
- func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{})
- func Failf(format string, args ...interface{})
- func FailfWithOffset(offset int, format string, args ...interface{})
- func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
- func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
- func GetReadyPrimaryPodName(cs clientset.Interface, namespace, clusterName string) string
- func GetReadySecondaryPodName(cs clientset.Interface, namespace, clusterName string) string
- func IsPodAvailable(pod *v1.Pod, minReadySeconds int32, now metav1.Time) bool
- func IsPodReady(pod *v1.Pod) bool
- func IsPodReadyConditionTrue(status v1.PodStatus) bool
- func KubectlCmd(args ...string) *exec.Cmd
- func Logf(format string, args ...interface{})
- func NewKubectlCommand(args ...string) *kubectlBuilder
- func ReadSQLTest(cluster *v1alpha1.Cluster, member string) (string, error)
- func RegisterFlags()
- func RemoveCleanupAction(p CleanupActionHandle)
- func RunCleanupActions()
- func RunHostCmd(ns, name, container, cmd string) (string, error)
- func RunKubectl(args ...string) (string, error)
- func RunKubectlWithRetries(args ...string) (string, error)
- func WaitForPodCondition(c clientset.Interface, ns, podName, desc string, timeout time.Duration, ...) error
- func WriteSQLTest(cluster *v1alpha1.Cluster, member string) (string, error)
- type BackupTestJig
- func (j *BackupTestJig) CreateAndAwaitBackupOrFail(namespace, clusterName string, tweak func(backup *v1alpha1.Backup), ...) *v1alpha1.Backup
- func (j *BackupTestJig) CreateAndAwaitMySQLDumpBackupOrFail(namespace, clusterName string, databases []v1alpha1.Database, ...) *v1alpha1.Backup
- func (j *BackupTestJig) CreateBackupOrFail(namespace, clusterName string, tweak func(backup *v1alpha1.Backup)) *v1alpha1.Backup
- func (j *BackupTestJig) CreateS3AuthSecret(namespace, name string) (*corev1.Secret, error)
- func (j *BackupTestJig) WaitForbackupReadyOrFail(namespace, name string, timeout time.Duration) *v1alpha1.Backup
- type CleanupActionHandle
- type ClusterTestJig
- func (j *ClusterTestJig) CreateAndAwaitClusterOrFail(namespace string, members int32, tweak func(cluster *v1alpha1.Cluster), ...) *v1alpha1.Cluster
- func (j *ClusterTestJig) CreateClusterOrFail(namespace string, members int32, tweak func(cluster *v1alpha1.Cluster)) *v1alpha1.Cluster
- func (j *ClusterTestJig) SanityCheckCluster(cluster *v1alpha1.Cluster)
- func (j *ClusterTestJig) WaitForClusterReadyOrFail(namespace, name string, timeout time.Duration) *v1alpha1.Cluster
- func (j *ClusterTestJig) WaitForClusterUpgradedOrFail(namespace, name, version string, timeout time.Duration) *v1alpha1.Cluster
- func (j *ClusterTestJig) WaitForConditionOrFail(namespace, name string, timeout time.Duration, message string, ...) *v1alpha1.Cluster
- type Framework
- func (f *Framework) AfterEach()
- func (f *Framework) BeforeEach()
- func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*v1.Namespace, error)
- func (f *Framework) DeleteNamespace(namespace string, timeout time.Duration) error
- func (f *Framework) InstallOperator(namespace string) error
- type RestoreTestJig
- func (j *RestoreTestJig) CreateAndAwaitRestoreOrFail(namespace, clusterName, backupName string, ...) *v1alpha1.Restore
- func (j *RestoreTestJig) CreateRestoreOrFail(namespace, clusterName, backupName string, ...) *v1alpha1.Restore
- func (j *RestoreTestJig) CreateS3AuthSecret(namespace, name string) (*corev1.Secret, error)
- func (j *RestoreTestJig) WaitForRestoreCompleteOrFail(namespace, name string, timeout time.Duration) *v1alpha1.Restore
- type TestContextType
Constants ¶
const ( // Poll defines how regularly to poll kubernetes resources. Poll = 2 * time.Second // DefaultTimeout is how long we wait for long-running operations in the // test suite before giving up. DefaultTimeout = 10 * time.Minute )
const TestDBName = "testdb"
TestDBName is the name of database to use when executing test SQL queries.
Variables ¶
This section is empty.
Functions ¶
func AwaitPodReadyOrDie ¶
AwaitPodReadyOrDie polls the specified Pod until it is ready of a timeout
func ExecuteSQL ¶
ExecuteSQL executes the given SQL statement(s) on a specified Cluster member via kubectl exec.
func ExpectNoError ¶
func ExpectNoError(err error, explain ...interface{})
func ExpectNoErrorWithOffset ¶
ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f").
func FailfWithOffset ¶
FailfWithOffset calls "Fail" and logs the error at "offset" levels above its caller (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").
func GetPodCondition ¶
func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)
GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.
func GetPodReadyCondition ¶
func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition
Extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.
func GetReadyPrimaryPodName ¶
GetReadyPrimaryPodName returns the name of the first ready primary Pod it finds in the given cluster.
func GetReadySecondaryPodName ¶
GetReadySecondaryPodName returns the name of the first ready secondary pod it finds in the given cluster.
func IsPodAvailable ¶
IsPodAvailable returns true if a pod is available; false otherwise. Precondition for an available pod is that it must be ready. On top of that, there are two cases when a pod can be considered available: 1. minReadySeconds == 0, or 2. LastTransitionTime (is set) + minReadySeconds < current time
func IsPodReady ¶
IsPodReady returns true if a pod is ready; false otherwise.
func IsPodReadyConditionTrue ¶
IsPodReady returns true if a pod is ready; false otherwise.
func KubectlCmd ¶
KubectlCmd runs the kubectl executable through the wrapper script.
func NewKubectlCommand ¶
func NewKubectlCommand(args ...string) *kubectlBuilder
func ReadSQLTest ¶
ReadSQLTest SELECTs v from testdb.foo where k=foo.
func RegisterFlags ¶
func RegisterFlags()
RegisterFlags registers the test framework flags and populates TestContext.
func RemoveCleanupAction ¶
func RemoveCleanupAction(p CleanupActionHandle)
RemoveCleanupAction removes a function that was installed by AddCleanupAction.
func RunCleanupActions ¶
func RunCleanupActions()
RunCleanupActions runs all functions installed by AddCleanupAction. It does not remove them (see RemoveCleanupAction) but it does run unlocked, so they may remove themselves.
func RunHostCmd ¶
RunHostCmd runs the given cmd in the context of the given pod using `kubectl exec` inside of a shell.
func RunKubectl ¶
RunKubectl is a convenience wrapper over kubectlBuilder
func RunKubectlWithRetries ¶
RunKubectlWithRetries runs a kubectl command with 3 retries.
Types ¶
type BackupTestJig ¶
type BackupTestJig struct { ID string Name string Labels map[string]string MySQLClient mysqlclientset.Interface KubeClient clientset.Interface }
BackupTestJig is a jig to help Backup testing.
func NewBackupTestJig ¶
func NewBackupTestJig(mysqlClient mysqlclientset.Interface, kubeClient clientset.Interface, name string) *BackupTestJig
NewBackupTestJig allocates and inits a new BackupTestJig.
func (*BackupTestJig) CreateAndAwaitBackupOrFail ¶
func (j *BackupTestJig) CreateAndAwaitBackupOrFail(namespace, clusterName string, tweak func(backup *v1alpha1.Backup), timeout time.Duration) *v1alpha1.Backup
CreateAndAwaitBackupOrFail creates a new Backup based on the jig's defaults, waits for it to become ready. Callers can provide a function to tweak the Backup object before it is created.
func (*BackupTestJig) CreateAndAwaitMySQLDumpBackupOrFail ¶
func (j *BackupTestJig) CreateAndAwaitMySQLDumpBackupOrFail(namespace, clusterName string, databases []v1alpha1.Database, tweak func(backup *v1alpha1.Backup), timeout time.Duration) *v1alpha1.Backup
CreateAndAwaitMySQLDumpBackupOrFail creates a new Backup based on the jig's defaults, waits for it to become ready. Callers can provide a function to tweak the Backup object before it is created.
func (*BackupTestJig) CreateBackupOrFail ¶
func (j *BackupTestJig) CreateBackupOrFail(namespace, clusterName string, tweak func(backup *v1alpha1.Backup)) *v1alpha1.Backup
CreateBackupOrFail creates a new Backup based on the jig's defaults. Callers can provide a function to tweak the Backup object before it is created.
func (*BackupTestJig) CreateS3AuthSecret ¶
func (j *BackupTestJig) CreateS3AuthSecret(namespace, name string) (*corev1.Secret, error)
CreateS3AuthSecret creates a secret containing the S3 (compat.) credentials for storing backups.
func (*BackupTestJig) WaitForbackupReadyOrFail ¶
func (j *BackupTestJig) WaitForbackupReadyOrFail(namespace, name string, timeout time.Duration) *v1alpha1.Backup
WaitForbackupReadyOrFail waits up to a given timeout for a backup to be in the running phase.
type CleanupActionHandle ¶
type CleanupActionHandle *int
func AddCleanupAction ¶
func AddCleanupAction(fn func()) CleanupActionHandle
AddCleanupAction installs a function that will be called in the event of the whole test being terminated. This allows arbitrary pieces of the overall test to hook into SynchronizedAfterSuite().
type ClusterTestJig ¶
type ClusterTestJig struct { ID string Name string Labels map[string]string MySQLClient mysqlclientset.Interface KubeClient clientset.Interface }
ClusterTestJig is a jig to help Cluster testing.
func NewClusterTestJig ¶
func NewClusterTestJig(mysqlClient mysqlclientset.Interface, kubeClient clientset.Interface, name string) *ClusterTestJig
NewClusterTestJig allocates and inits a new ClusterTestJig.
func (*ClusterTestJig) CreateAndAwaitClusterOrFail ¶
func (j *ClusterTestJig) CreateAndAwaitClusterOrFail(namespace string, members int32, tweak func(cluster *v1alpha1.Cluster), timeout time.Duration) *v1alpha1.Cluster
CreateAndAwaitClusterOrFail creates a new Cluster based on the jig's defaults, waits for it to become ready, and then sanity checks it and its dependant resources. Callers can provide a function to tweak the Cluster object before it is created.
func (*ClusterTestJig) CreateClusterOrFail ¶
func (j *ClusterTestJig) CreateClusterOrFail(namespace string, members int32, tweak func(cluster *v1alpha1.Cluster)) *v1alpha1.Cluster
CreateClusterOrFail creates a new Cluster based on the jig's defaults. Callers can provide a function to tweak the Cluster object before it is created.
func (*ClusterTestJig) SanityCheckCluster ¶
func (j *ClusterTestJig) SanityCheckCluster(cluster *v1alpha1.Cluster)
SanityCheckCluster checks basic properties of a given Cluster match our expectations.
func (*ClusterTestJig) WaitForClusterReadyOrFail ¶
func (j *ClusterTestJig) WaitForClusterReadyOrFail(namespace, name string, timeout time.Duration) *v1alpha1.Cluster
WaitForClusterReadyOrFail waits up to a given timeout for a cluster to be in the running phase.
func (*ClusterTestJig) WaitForClusterUpgradedOrFail ¶
func (j *ClusterTestJig) WaitForClusterUpgradedOrFail(namespace, name, version string, timeout time.Duration) *v1alpha1.Cluster
WaitForClusterUpgradedOrFail waits for a MySQL cluster to be upgraded to the given version or fails.
type Framework ¶
type Framework struct { BaseName string OperatorInstalled bool ClientSet clientset.Interface MySQLClientSet mysqlclientset.Interface Namespace *v1.Namespace // Every test has at least one namespace unless creation is skipped // contains filtered or unexported fields }
Framework is used in the execution of e2e tests.
func NewDefaultFramework ¶
NewDefaultFramework constructs a new e2e test Framework with default options.
func NewFramework ¶
NewFramework constructs a new e2e test Framework.
func (*Framework) BeforeEach ¶
func (f *Framework) BeforeEach()
BeforeEach gets a client and makes a namespace.
func (*Framework) CreateNamespace ¶
func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (*v1.Namespace, error)
CreateNamespace creates a e2e test namespace.
func (*Framework) DeleteNamespace ¶
DeleteNamespace deletes a given namespace and waits until its contents are deleted.
func (*Framework) InstallOperator ¶
InstallOperator installs the MySQL operator into the given namespace via helm. NOTE: Requires that the MySQL operator CRDs have already been installed.
type RestoreTestJig ¶
type RestoreTestJig struct { ID string Name string Labels map[string]string MySQLClient mysqlclientset.Interface KubeClient clientset.Interface }
RestoreTestJig is a jig to help Restore testing.
func NewRestoreTestJig ¶
func NewRestoreTestJig(mysqlClient mysqlclientset.Interface, kubeClient clientset.Interface, name string) *RestoreTestJig
NewRestoreTestJig allocates and inits a new RestoreTestJig.
func (*RestoreTestJig) CreateAndAwaitRestoreOrFail ¶
func (j *RestoreTestJig) CreateAndAwaitRestoreOrFail(namespace, clusterName, backupName string, tweak func(restore *v1alpha1.Restore), timeout time.Duration) *v1alpha1.Restore
CreateAndAwaitRestoreOrFail creates a new Restore based on the jig's defaults, waits for it to become ready. Callers can provide a function to tweak the Restore object before it is created.
func (*RestoreTestJig) CreateRestoreOrFail ¶
func (j *RestoreTestJig) CreateRestoreOrFail(namespace, clusterName, backupName string, tweak func(restore *v1alpha1.Restore)) *v1alpha1.Restore
CreateRestoreOrFail creates a new Restore based on the jig's defaults. Callers can provide a function to tweak the Restore object before it is created.
func (*RestoreTestJig) CreateS3AuthSecret ¶
func (j *RestoreTestJig) CreateS3AuthSecret(namespace, name string) (*corev1.Secret, error)
CreateS3AuthSecret creates a secret containing the S3 (compat.) credentials for storing backups.
func (*RestoreTestJig) WaitForRestoreCompleteOrFail ¶
func (j *RestoreTestJig) WaitForRestoreCompleteOrFail(namespace, name string, timeout time.Duration) *v1alpha1.Restore
WaitForRestoreCompleteOrFail waits up to a given timeout for a Restore to enter the complete phase.
type TestContextType ¶
type TestContextType struct { // OperatorVersion is the version of the MySQL operator under test. OperatorVersion string // RepoRoot is the root directory of the repository. RepoRoot string // KubeConfig is the path to the kubeconfig file. KubeConfig string // Namespace (if provided) is the namespace of an existing namespace to // use for test execution rather than creating a new namespace. Namespace string // DeleteNamespace controls whether or not to delete test namespaces DeleteNamespace bool // DeleteNamespaceOnFailure controls whether or not to delete test // namespaces when the test fails. DeleteNamespaceOnFailure bool // S3AccessKey is the S3 (compat.) access key for the bucket used in // backup / restore tests. S3AccessKey string // S3AccessKey is the S3 (compat.) secret key for the bucket used in // backup / restore tests. S3SecretKey string }
TestContextType represents the co
var TestContext TestContextType
TestContext holds the context of the the test run.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string.
|
Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic with structured data instead of a constant string. |