testlib

package
v3.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: BSD-3-Clause Imports: 45 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DNS_CONFIG_MARKER = "# BEGIN BASE CONFIG"
	COREDNS_NS        = "kube-system"
	COREDNS_CM        = "coredns"
	COREFILE_KEY      = "Corefile"
	DNS_SERVICE       = "dns-service"
)
View Source
const ADMIN_API_INGRESS_HOSTNAME = "api.nuodb.local"

FQDNs used for Ingress testing that point to minikube IP address; they must be aligned with the /etc/hosts entries in the `install_deps.sh` script

View Source
const ADMIN_HELM_CHART_PATH = "../../stable/admin"
View Source
const ADMIN_SQL_INGRESS_HOSTNAME = "sql.nuodb.local"
View Source
const ALWAYS_RUN_DIAGNOSTIC_TEARDOWNS = "ALWAYS_RUN_DIAGNOSTIC_TEARDOWNS"
View Source
const CA_CERT_FILE = "ca.cert"
View Source
const CA_CERT_FILE_NEW = "ca_new.cert"
View Source
const CA_CERT_SECRET = "nuodb-ca-cert"
View Source
const CERTIFICATES_BACKUP_PATH = "/tmp/keys_backup"
View Source
const CERTIFICATES_GENERATION_PATH = "/tmp/keys"
View Source
const CONTEXT_CLUSTER_KEY = CONTEXT_KEY("cluster")
View Source
const DATABASE_HELM_CHART_PATH = "../../stable/database"
View Source
const DATABASE_TE_INGRESS_HOSTNAME = "demo.nuodb.local"
View Source
const DEBUG_POD = `` /* 448-byte string literal not displayed */
View Source
const IMPORT_ARCHIVE_FILE = "../files/restore.bak.tz"
View Source
const IMPORT_SG0_BACKUP_FILE = "../files/backup-sg0.bak.tz"
View Source
const IMPORT_SG1_BACKUP_FILE = "../files/backup-sg1.bak.tz"
View Source
const INJECT_CLUSTERS_FILE = "../../clustersInject.yaml"
View Source
const INJECT_FILE = "../../versionInject.yaml"
View Source
const INJECT_VALUES_FILE = "../../valuesInject.yaml"
View Source
const K8S_EVENT_LOG_FILE = "kubernetes_event.log"
View Source
const KEYSTORE_FILE = "nuoadmin.p12"
View Source
const KEYSTORE_SECRET = "nuodb-keystore"
View Source
const MINIMAL_VIABLE_ENGINE_CPU = "500m"

suffix "m" for spec.containers[].resources.requests.cpu denotes "millicores", and 1 CPU is equivalent to 1000m

View Source
const MINIMAL_VIABLE_ENGINE_MEMORY = "500Mi"
View Source
const NAMESPACE_NAME_PREFIX = "test"
View Source
const NAMESPACE_RETENTION_PERIOD = 5 * time.Hour
View Source
const NGINX_DEPLOYMENT = "nginx"
View Source
const NUOCMD_FILE = "nuocmd.pem"
View Source
const NUOCMD_SECRET = "nuodb-client-pem"
View Source
const RESTORE_HELM_CHART_PATH = "../../stable/restore"
View Source
const RESULT_DIR = "../../results"
View Source
const SECRET_PASSWORD = "changeIt"
View Source
const SNAPSHOTABLE_STORAGE_CLASS = "csi-hostpath-sc"
View Source
const SNAPSHOT_TEMPLATE = `` /* 162-byte string literal not displayed */
View Source
const TEARDOWN_ADMIN = "admin"
View Source
const TEARDOWN_BACKUP = "backup"
View Source
const TEARDOWN_COLLECTOR = "nuocollector"
View Source
const TEARDOWN_CSIDRIVER_FS = "csidriver-fs"
View Source
const TEARDOWN_DATABASE = "database"
View Source
const TEARDOWN_HAPROXY = "haproxy"
View Source
const TEARDOWN_MULTICLUSTER = "multicluster"
View Source
const TEARDOWN_NGINX = "nginx"
View Source
const TEARDOWN_RESTORE = "restore"
View Source
const TEARDOWN_SECRETS = "secrets"
View Source
const TEARDOWN_VAULT = "vault"
View Source
const TEARDOWN_YCSB = "ycsb"
View Source
const THP_HELM_CHART_PATH = "../../stable/transparent-hugepage"
View Source
const TLS_GENERATOR_POD_TEMPLATE = `` /* 170-byte string literal not displayed */
View Source
const TLS_SECRET_NO_PASSWORD_YAML_TEMPLATE = `---
apiVersion: v1
kind: Secret
metadata:
  name: %s
  namespace: %s
apiVersion: v1
data:
  %s: %s
`
View Source
const TLS_SECRET_PASSWORD_YAML_TEMPLATE = `---
apiVersion: v1
kind: Secret
metadata:
  name: %s
  namespace: %s
apiVersion: v1
data:
  %s: %s
  password: %s
`
View Source
const TRUSTSTORE_FILE = "nuoadmin-truststore.p12"
View Source
const TRUSTSTORE_SECRET = "nuodb-truststore"
View Source
const UPGRADE_INJECT_FILE = "../../upgradeInject.yaml"
View Source
const UPGRADE_STRATEGY = `
spec:
  strategy:
    $retainKeys:
    - type
    type: Recreate
`
View Source
const VOLUME_SNAPSHOT_CLASS = "csi-hostpath-snapclass"
View Source
const YCSB_CONTROLLER_NAME = "ycsb-load"
View Source
const YCSB_HELM_CHART_PATH = "../../incubator/demo-ycsb"

Variables

View Source
var AlwaysRunDiagnosticTeardowns = strings.EqualFold(os.Getenv(ALWAYS_RUN_DIAGNOSTIC_TEARDOWNS), "true")

* Exported var - initialised from the EnvVar, but can be reset in code if desired

View Source
var MULTI_CLUSTER_1 = K8sCluster{
	Name:    "cluster-nuodb-1",
	Domain:  "cluster1.local",
	Context: "yin",
}
View Source
var MULTI_CLUSTER_2 = K8sCluster{
	Name:    "cluster-nuodb-2",
	Domain:  "cluster2.local",
	Context: "yang",
}
View Source
var NuoDBVersionRegex = regexp.MustCompile(`^([0-9]+\.[0-9]+(?:\.[0-9]+)?).*$`)

Functions

func AddDiagnosticTeardown

func AddDiagnosticTeardown(name string, condition interface{}, teardownFunc func())

*

  • add a diagnostic teardown func to be called before any other teardowns in the named list - to aid diagnostics/debugging.
  • This allows a diagnostic teardown to do such things as:
  • <ul>
  • <li>Generate logging and debug information immediately prior to resurce teardown
  • <li>call time.Sleep() to allow inspection and/or debugging of the exit state before teardown.
  • <ul> *
  • NOTE: it is generally undesirable to add multiple diagnostic teardowns that sleep - so it would usually be best to
  • add any Sleep() debug teardown to the innermost teardown list.
  • Nonetheless, there are use-cases where multiple Sleep() teardowns are useful - to allow inspecting different
  • intermediate states.

func AddGlobalDiagnosticTeardown added in v3.2.0

func AddGlobalDiagnosticTeardown(condition interface{}, teardownFunc func())

*

  • Adds a diagnostic teardown function to all named diagnostic teardown lists - for deferred execution. *
  • The teardown functions are called in reverse order of insertion, by a call to Teardown(name). *

func AddGlobalTeardown added in v3.2.0

func AddGlobalTeardown(teardownFunc func())

*

  • Adds a teardown function to all named teardown lists - for deferred execution. *
  • The teardown functions are called in reverse order of insertion, by a call to Teardown(name). *

func AddTeardown

func AddTeardown(name string, teardownFunc func())

*

  • add a teardown function to the named list - for deferred execution. *
  • The teardown functions are called in reverse order of insertion, by a call to Teardown(name). *
  • The typical idiom is:
  • <pre>
  • testlib.AddTeardown("DATABASE", func() { ...})
  • // possibly more testlib.AddTeardown("DATABASE", func() { ... })
  • defer testlib.Teardown("DATABASE")
  • <pre>

func AdjustPodTimeout added in v3.4.0

func AdjustPodTimeout(podName string, timeout time.Duration) time.Duration

func ApplyLicense added in v3.7.0

func ApplyLicense(t *testing.T, namespace string, adminPod string, licenseType LicenseType)

func ApplyNuoDBLicense deprecated added in v3.2.0

func ApplyNuoDBLicense(t *testing.T, namespace string, adminPod string)

Deprecated: The ApplyNuoDBLicense function is deprecated, When testing with NuoDB v6.0.0, use the ApplyLicense function instead

func ArgContains

func ArgContains(args []string, x string) bool

func AssertEnvContains added in v3.8.0

func AssertEnvContains(t *testing.T, envs []v1.EnvVar, key, expected string)

func AssertEnvNotContains added in v3.8.0

func AssertEnvNotContains(t *testing.T, envs []v1.EnvVar, key string)

func AssertResourceValue added in v3.5.0

func AssertResourceValue(t *testing.T, options *helm.Options, key string, actual *resource.Quantity)

func Await

func Await(t *testing.T, lmbd func() bool, timeout time.Duration)

func AwaitAdminFullyConnected

func AwaitAdminFullyConnected(t *testing.T, namespace string, podName string, numServers int)

func AwaitAdminKeystoreReload added in v3.7.0

func AwaitAdminKeystoreReload(t *testing.T, namespace string, podName string, adminPem string, timeout time.Duration)

func AwaitBalancerTerminated

func AwaitBalancerTerminated(t *testing.T, namespace string, expectedName string)

func AwaitDatabaseRestart

func AwaitDatabaseRestart(t *testing.T, namespace string, podName string, databaseName string, databaseOptions *helm.Options, restart func())

func AwaitDatabaseUp

func AwaitDatabaseUp(t *testing.T, namespace string, podName string, databaseName string, numProcesses int)

func AwaitDomainLeader added in v3.3.0

func AwaitDomainLeader(t *testing.T, namespace string, adminPod string, timeout time.Duration) (leader string)

func AwaitE added in v3.3.0

func AwaitE(t *testing.T, lmbd func() bool, timeout time.Duration) error

func AwaitJobSucceeded added in v3.1.0

func AwaitJobSucceeded(t *testing.T, namespace string, jobName string, timeout time.Duration)

func AwaitNoPods

func AwaitNoPods(t *testing.T, namespace string, expectedName string)

func AwaitNrLoadBalancerPolicies

func AwaitNrLoadBalancerPolicies(t *testing.T, namespace string, podName string, expectedNumber int)

func AwaitNrReplicasReady

func AwaitNrReplicasReady(t *testing.T, namespace string, expectedName string, nrReplicas int)

func AwaitNrReplicasScheduled

func AwaitNrReplicasScheduled(t *testing.T, namespace string, expectedName string, nrReplicas int)

func AwaitPodHasVersion

func AwaitPodHasVersion(t *testing.T, namespace string, podName string, expectedVersion string, timeout time.Duration)

func AwaitPodLog added in v3.2.0

func AwaitPodLog(t *testing.T, namespaceName string, podName string, fileNameSuffix string)

func AwaitPodObjectRecreated

func AwaitPodObjectRecreated(t *testing.T, namespace string, pod *corev1.Pod, timeout time.Duration)

func AwaitPodPhase

func AwaitPodPhase(t *testing.T, namespace string, podName string, phase corev1.PodPhase, timeout time.Duration)

func AwaitPodRestartCountGreaterThan

func AwaitPodRestartCountGreaterThan(t *testing.T, namespace string, podName string, expectedRestartCount int32,
	timeout time.Duration)

func AwaitPodStatus

func AwaitPodStatus(t *testing.T, namespace string, podName string, condition corev1.PodConditionType,
	status corev1.ConditionStatus, timeout time.Duration)

func AwaitPodTemplateHasVersion

func AwaitPodTemplateHasVersion(t *testing.T, namespace string, podNameTemplate string, expectedVersion string, timeout time.Duration)

func AwaitPodUp

func AwaitPodUp(t *testing.T, namespace string, adminPodName string, timeout time.Duration)

func AwaitPvDeleted added in v3.4.0

func AwaitPvDeleted(t *testing.T, name string, timeout time.Duration)

func AwaitServerState added in v3.3.0

func AwaitServerState(t *testing.T, namespace string, adminPod string,
	serverId string, expectedState string, timeout time.Duration)

func AwaitTillerUp

func AwaitTillerUp(t *testing.T)

func BackupCerificateFilesOnTestFailure

func BackupCerificateFilesOnTestFailure(t *testing.T, namespaceName string, srcDirectory string)

func BackupDatabase added in v3.1.0

func BackupDatabase(
	t *testing.T,
	namespaceName string,
	podName string,
	databaseName string,
	backupType string,
	backupGroup string,
) string

func BackupDatabaseE added in v3.6.0

func BackupDatabaseE(
	t *testing.T,
	namespaceName string,
	podName string,
	databaseName string,
	backupType string,
	backupGroup string,
) error

func ChangeCluster added in v3.2.0

func ChangeCluster(t *testing.T, cluster K8sCluster) (func(), func())

*

  • Change kubectl current context *
  • A change and revert functions are returned so that
  • the caller can use them. *

func CheckArchives added in v3.1.0

func CheckArchives(t *testing.T, namespaceName string, adminPod string, dbName string, numExpected int, numExpectedRemoved int) (archives []NuoDBArchive, removedArchives []NuoDBArchive)

func CheckRestoreRequests added in v3.2.0

func CheckRestoreRequests(t *testing.T, namespaceName string, podName string, databaseName string,
	expectedValue string, expectedLegacyValue string) (string, string)

func CopyCertificatesToControlHost

func CopyCertificatesToControlHost(t *testing.T, podName string, namespaceName string) string

func CopyMap added in v3.2.0

func CopyMap(m map[string]string) map[string]string

func CreateNamespace

func CreateNamespace(t *testing.T, namespaceName string)

func CreateNginxDeployment added in v3.2.0

func CreateNginxDeployment(t *testing.T, namespaceName string)

func CreateQuickstartSchema added in v3.2.0

func CreateQuickstartSchema(t *testing.T, namespaceName string, adminPod string)

func CreateSecret

func CreateSecret(t *testing.T, namespaceName string, certName string, secretName string, keyDir string)

func CreateSecretWithPassword

func CreateSecretWithPassword(t *testing.T, namespaceName string, certName string, secretName string, password string, keyDir string)

func CreateSecretsInVault added in v3.2.0

func CreateSecretsInVault(t *testing.T, namespaceName string, vaultName string)

func CreateVault added in v3.2.0

func CreateVault(t *testing.T, namespaceName string, vaultName string)

func DeleteDatabase

func DeleteDatabase(t *testing.T, namespace string, dbName string, podName string)

func DeleteJobPods added in v3.5.0

func DeleteJobPods(t *testing.T, namespace string, jobName string)

func DeletePVC added in v3.3.0

func DeletePVC(t *testing.T, namespaceName string, name string)

func DeletePod

func DeletePod(t *testing.T, namespace string, podName string)

func DeleteStatefulSet added in v3.3.0

func DeleteStatefulSet(t *testing.T, namespaceName string, name string)

func DeployWithContext added in v3.2.0

func DeployWithContext(t *testing.T, context context.Context, deployFunc func(context *ClusterDeploymentContext, options *helm.Options))

*

  • Deploy NuoDB Helm charts using deployment context *
  • This function is typically used when performing a multi-cluster deployment. *
  • The typical idiom is:
  • <pre>
  • testlib.DeployWithContext(t,
  • deploymentContext,
  • func(context *testlib.ClusterDeploymentContext, options *helm.Options) {
  • testlib.CreateNamespace(t, namespaceName)
  • testlib.StartAdminCustomRelease(t, options, 1, namespaceName, adminReleaseName)
  • admin0 := fmt.Sprintf("%s-nuodb-%s-0", adminReleaseName, context.ThisCluster.Name)
  • databaseReleaseName := testlib.StartDatabase(t, namespaceName, admin0, options)
  • // Store deployment details in the context
  • context.AdminReleaseName = adminReleaseName
  • context.DatabaseReleaseName = databaseReleaseName
  • context.Namespace = namespaceName
  • },
  • )
  • <pre>

func DescribePods added in v3.2.0

func DescribePods(t *testing.T, namespace string, expectedName string)

func EnableVaultKubernetesIntegration added in v3.2.0

func EnableVaultKubernetesIntegration(t *testing.T, namespaceName string, vaultName string)

func EnsureDatabaseNotRunning

func EnsureDatabaseNotRunning(t *testing.T, adminPod string, opt ExtractedOptions, kubectlOptions *k8s.KubectlOptions)

func EnvContains

func EnvContains(envs []v1.EnvVar, key string, expected string) bool

func EnvContainsValueFrom

func EnvContainsValueFrom(envs []v1.EnvVar, key string, valueFrom *v1.EnvVarSource) bool

func EnvFromSourceContains

func EnvFromSourceContains(envs []v1.EnvFromSource, value string) bool

func EnvGet added in v3.8.0

func EnvGet(envs []v1.EnvVar, key string) (string, bool)

func ExecuteCommandsInPod

func ExecuteCommandsInPod(t *testing.T, namespaceName string, podName string, commands []string)

func ExecuteInAllClusters added in v3.2.0

func ExecuteInAllClusters(t *testing.T, actionFunc func(context *ClusterDeploymentContext))

*

  • Execute arbitrary actions on all known cluster deployments *
  • The cluster deployment is stored in clusterDeployments variable when
  • a deployment context for it is created. *

func FindAllPodsInSchema added in v3.5.0

func FindAllPodsInSchema(t *testing.T, namespace string) []corev1.Pod

func FindPod added in v3.6.0

func FindPod(t *testing.T, namespace string, expectedName string) (*corev1.Pod, error)

func GenerateAndSetTLSKeys

func GenerateAndSetTLSKeys(t *testing.T, options *helm.Options, namespaceName string) (string, string)

func GenerateCustomCertificates

func GenerateCustomCertificates(t *testing.T, podName string, namespaceName string, commands []string)

func GenerateTLSConfiguration

func GenerateTLSConfiguration(t *testing.T, namespaceName string, commands []string) (string, string)

func GetAdminEventLog

func GetAdminEventLog(t *testing.T, namespace string, podName string)

func GetAppLog

func GetAppLog(t *testing.T, namespace string, podName string, fileNameSuffix string, podLogOptions *corev1.PodLogOptions) string

func GetArchives added in v3.6.0

func GetArchives(t *testing.T, namespaceName string, adminPod string, dbName string) (archives []NuoDBArchive, removedArchives []NuoDBArchive)

func GetDaemonSet

func GetDaemonSet(t *testing.T, namespace string, daemonSetName string) *v1.DaemonSet

func GetDiagnoseOnTestFailure

func GetDiagnoseOnTestFailure(t *testing.T, namespace string, podName string)

func GetDomainLeaderE added in v3.3.0

func GetDomainLeaderE(t *testing.T, namespace string, adminPod string) (string, error)

func GetDomainServersE added in v3.3.0

func GetDomainServersE(t *testing.T, namespace string, adminPod string) (map[string]NuoDBServer, error)

func GetEvents added in v3.5.0

func GetEvents(t *testing.T, namespace string, filter metav1.ListOptions) []corev1.Event

func GetK8sEventLog

func GetK8sEventLog(t *testing.T, namespace string)

func GetLatestBackup added in v3.1.0

func GetLatestBackup(t *testing.T, namespaceName string, podName string,
	databaseName string, backupGroup string) string

func GetLatestBackupGroup added in v3.7.0

func GetLatestBackupGroup(t *testing.T, namespaceName string, podName string, databaseName string) string

func GetLoadBalancerPoliciesE

func GetLoadBalancerPoliciesE(t *testing.T, namespaceName string, adminPod string) (map[string]NuoDBLoadBalancerPolicy, error)

func GetMount added in v3.1.0

func GetMount(mounts []v1.VolumeMount, expectedName string) (*v1.VolumeMount, bool)

func GetNamespaces added in v3.3.0

func GetNamespaces(t *testing.T) []corev1.Namespace

func GetNodesInternalAddresses added in v3.4.0

func GetNodesInternalAddresses(t *testing.T) map[string]string

func GetNuoDBVersion added in v3.3.0

func GetNuoDBVersion(t *testing.T, namespaceName string, options *helm.Options) string

func GetPod

func GetPod(t *testing.T, namespace string, podName string) *corev1.Pod

func GetPodName

func GetPodName(t *testing.T, namespaceName string, expectedName string) string

func GetPodNames added in v3.3.0

func GetPodNames(t *testing.T, namespaceName string, expectedName string) []string

func GetPodRestartCount

func GetPodRestartCount(t *testing.T, namespace string, podName string) int32

func GetPvc added in v3.4.0

func GetPvc(t *testing.T, namespace string, pvcName string) *corev1.PersistentVolumeClaim

func GetRegexOccurrenceInLog

func GetRegexOccurrenceInLog(t *testing.T, namespace string, podName string, expectedLogLine string, podLogOptions *corev1.PodLogOptions) int

func GetReplicationController

func GetReplicationController(t *testing.T, namespace string, replicationControllerName string) *corev1.ReplicationController

func GetSecret

func GetSecret(t *testing.T, namespace string, secretName string) *corev1.Secret

func GetService

func GetService(t *testing.T, namespaceName string, serviceName string) *corev1.Service

func GetStatefulSet added in v3.5.0

func GetStatefulSet(t *testing.T, namespaceName, name string) *v1.StatefulSet

func GetStatefulSets added in v3.3.0

func GetStatefulSets(t *testing.T, namespaceName string) *v1.StatefulSetList

func GetStringOccurrenceInLog

func GetStringOccurrenceInLog(t *testing.T, namespace string, podName string, expectedLogLine string, podLogOptions *corev1.PodLogOptions) int

func GetUpgradedReleaseVersion

func GetUpgradedReleaseVersion(t *testing.T, options *helm.Options) string

func GetVolume added in v3.1.0

func GetVolume(volumes []v1.Volume, expectedName string) (*v1.Volume, bool)

func GetVolumeClaim added in v3.3.0

func GetVolumeClaim(vcp []v1.PersistentVolumeClaim, expectedName string) (*v1.PersistentVolumeClaim, bool)

func HasDirectory added in v3.7.0

func HasDirectory(t *testing.T, namespace string, podName string, filename string) bool

func HasFile added in v3.7.0

func HasFile(t *testing.T, namespace string, podName string, filename string) bool

func InferVersionFromTemplate

func InferVersionFromTemplate(t *testing.T, options *helm.Options)

func InjectOpenShiftOverrides

func InjectOpenShiftOverrides(t *testing.T, options *helm.Options)

func InjectTestValues

func InjectTestValues(t *testing.T, options *helm.Options)

func InjectTestValuesFile

func InjectTestValuesFile(t *testing.T, options *helm.Options)

func InjectTestVersion

func InjectTestVersion(t *testing.T, options *helm.Options)

func InstallAdmin added in v3.5.0

func InstallAdmin(t *testing.T, options *helm.Options, helmChartReleaseName string)

func InstallDatabase added in v3.1.0

func InstallDatabase(t *testing.T, options *helm.Options, helmChartReleaseName string)

func InvokeBackupHook added in v3.8.0

func InvokeBackupHook(t *testing.T, namespaceName, smPod, resourcePath string, payload ...string)

func IsDaemonSetHotCopyEnabled

func IsDaemonSetHotCopyEnabled(ss *appsv1.DaemonSet) bool

func IsOpenShiftEnvironment

func IsOpenShiftEnvironment(t *testing.T) bool

func IsRestoreRequestSupported added in v3.2.0

func IsRestoreRequestSupported(t *testing.T, namespaceName string, podName string) bool

func IsStatefulSetHotCopyEnabled

func IsStatefulSetHotCopyEnabled(ss *appsv1.StatefulSet) bool

func KillAdminPod

func KillAdminPod(t *testing.T, namespace string, podName string)

func KillProcess

func KillProcess(t *testing.T, namespace string, podName string)

func LabelNodes

func LabelNodes(t *testing.T, namespaceName string, labelName string, labelValue string)

func LabelNodesIfMissing added in v3.9.0

func LabelNodesIfMissing(t *testing.T, labelName string, defaultValue string) map[string]string

LabelNodesIfMissing checks if all Nodes in the cluster have a labelName label. Any that do not, have that label set to defaultValue. It returns the list of all current values encountered.

func ListCronJobs added in v3.5.0

func ListCronJobs(t *testing.T, namespace string) []batchv1beta1.CronJob

func MapContains added in v3.5.0

func MapContains(actual map[string]string, expected map[string]string) (string, bool)

func MountContains

func MountContains(mounts []v1.VolumeMount, expectedName string) bool

func NewClusterDeploymentContext added in v3.2.0

func NewClusterDeploymentContext(parent context.Context, options *helm.Options, thisCluster K8sCluster, entrypointCluster K8sCluster) context.Context

*

  • Creates cluster deployment context *
  • New cluster deployment context will be created and attached to
  • provided parent context. The new context will be stored in
  • clusterDeployments global map so that it can be used later if needed. *
  • The typical idiom is:
  • <pre>
  • defer testlib.Teardown(testlib.TEARDOWN_MULTICLUSTER) *
  • context := context.Background()
  • deploymentContext := testlib.NewClusterDeploymentContext(context,
  • &helm.Options{},
  • testlib.MULTI_CLUSTER_1,
  • testlib.MULTI_CLUSTER_1)
  • <pre>

func OverrideReadinessProbesTimeout added in v3.4.0

func OverrideReadinessProbesTimeout(t *testing.T, options *helm.Options, timeoutSec string)

func OverrideUpgradeContainerImage added in v3.2.0

func OverrideUpgradeContainerImage(t *testing.T, options *helm.Options)

func PingService

func PingService(t *testing.T, namespace string, serviceName string, podName string)

func PurgeDatabaseArchives added in v3.3.0

func PurgeDatabaseArchives(t *testing.T, namespaceName string, adminPod string, dbName string)

func ReadAll

func ReadAll(path string) ([]byte, error)

func RecoverCoresFromEngine

func RecoverCoresFromEngine(t *testing.T, namespaceName string, engineType string, pvcName string)

func RemoveEmptyLines

func RemoveEmptyLines(s string) string

func RemoveOrphanNamespaces added in v3.3.0

func RemoveOrphanNamespaces(t *testing.T)

func RestartDatabasePods added in v3.5.0

func RestartDatabasePods(t *testing.T, namespaceName string, helmChartReleaseName string, options *helm.Options)

func RestoreDatabase added in v3.1.0

func RestoreDatabase(t *testing.T, namespaceName string, podName string, databaseOptions *helm.Options)

func Retry added in v3.5.0

func Retry(t *testing.T, fn func() error, attempts int, interval time.Duration) error

func RotateTLSCertificates

func RotateTLSCertificates(t *testing.T, options *helm.Options, namespaceName string,
	adminReleaseName string, databaseReleaseName string, tlsKeysLocation string, helmUpgrade bool)

func RunOnNuoDBVersion added in v3.3.0

func RunOnNuoDBVersion(t *testing.T, versionCheckFunc func(*semver.Version) bool, actionFunc func(*semver.Version))

func RunOnNuoDBVersionCondition added in v3.3.0

func RunOnNuoDBVersionCondition(t *testing.T, condition string, actionFunc func(*semver.Version))

func RunOnNuoDBVersionFromOptionCondition added in v3.7.0

func RunOnNuoDBVersionFromOptionCondition(t *testing.T, options *helm.Options, condition string, actionFunc func(*semver.Version))

func RunOnNuoDBVersionFromOptions added in v3.7.0

func RunOnNuoDBVersionFromOptions(t *testing.T, options *helm.Options, versionCheckFunc func(*semver.Version) bool, actionFunc func(*semver.Version))

func RunSQL

func RunSQL(t *testing.T, namespace string, podName string, databaseName string, sql string) (result string, err error)

func ScaleDeployment added in v3.6.0

func ScaleDeployment(t *testing.T, namespaceName string, name string, replicas int)

func ScaleStatefulSet added in v3.3.0

func ScaleStatefulSet(t *testing.T, namespaceName string, name string, replicas int)

func ScaleYCSB added in v3.6.0

func ScaleYCSB(t *testing.T, namespaceName string, replicas int)

func ServeFileViaHTTP added in v3.5.0

func ServeFileViaHTTP(t *testing.T, namespaceName string, localFilePath string) string

func ServePodFileViaHTTP added in v3.2.0

func ServePodFileViaHTTP(t *testing.T, namespaceName string, srcPodName string, filePath string) string

func SetDeploymentUpgradeStrategyToRecreate

func SetDeploymentUpgradeStrategyToRecreate(t *testing.T, namespaceName string, deploymentName string)

func SkipTestOnNuoDBVersion added in v3.3.0

func SkipTestOnNuoDBVersion(t *testing.T, versionCheckFunc func(*semver.Version) bool)

func SkipTestOnNuoDBVersionCondition added in v3.3.0

func SkipTestOnNuoDBVersionCondition(t *testing.T, condition string)

*

func SnapshotSm added in v3.8.0

func SnapshotSm(t *testing.T, namespaceName, smPod, backupId, snapshotNameTemplate string, journalVolume bool)

func SnapshotVolume added in v3.8.0

func SnapshotVolume(t *testing.T, namespaceName string, pvcName string, snapName string)

Create a snapshot of a pvc and wait for it to become ready

func SplitAndRender added in v3.8.0

func SplitAndRender[T any](t *testing.T, output string, expectedNrObjects int, kind string) []T

func SplitAndRenderClusterClusterRoleBinding added in v3.9.0

func SplitAndRenderClusterClusterRoleBinding(t *testing.T, output string, expectedNrObjects int) []rbacv1.ClusterRoleBinding

func SplitAndRenderClusterRole added in v3.9.0

func SplitAndRenderClusterRole(t *testing.T, output string, expectedNrObjects int) []rbacv1.ClusterRole

func SplitAndRenderConfigMap

func SplitAndRenderConfigMap(t *testing.T, output string, expectedNrObjects int) []v1.ConfigMap

func SplitAndRenderCronJob added in v3.1.0

func SplitAndRenderCronJob(t *testing.T, output string, expectedNrObjects int) []v1beta1.CronJob

func SplitAndRenderDaemonSet

func SplitAndRenderDaemonSet(t *testing.T, output string, expectedNrObjects int) []appsv1.DaemonSet

func SplitAndRenderDeployment

func SplitAndRenderDeployment(t *testing.T, output string, expectedNrObjects int) []appsv1.Deployment

func SplitAndRenderIngress added in v3.5.0

func SplitAndRenderIngress(t *testing.T, output string, expectedNrObjects int) []networkingv1.Ingress

func SplitAndRenderJob added in v3.1.0

func SplitAndRenderJob(t *testing.T, output string, expectedNrObjects int) []batchv1.Job

func SplitAndRenderPersistentVolumeClaim added in v3.8.0

func SplitAndRenderPersistentVolumeClaim(t *testing.T, output string, expectedNrObjects int) []v1.PersistentVolumeClaim

func SplitAndRenderReplicationController

func SplitAndRenderReplicationController(t *testing.T, output string, expectedNrObjects int) []v1.ReplicationController

func SplitAndRenderRole

func SplitAndRenderRole(t *testing.T, output string, expectedNrObjects int) []rbacv1.Role

func SplitAndRenderSecret

func SplitAndRenderSecret(t *testing.T, output string, expectedNrObjects int) []v1.Secret

func SplitAndRenderService

func SplitAndRenderService(t *testing.T, output string, expectedNrObjects int) []v1.Service

func SplitAndRenderServiceAccount added in v3.5.0

func SplitAndRenderServiceAccount(t *testing.T, output string, expectedNrObjects int) []v1.ServiceAccount

func SplitAndRenderStatefulSet

func SplitAndRenderStatefulSet(t *testing.T, output string, expectedNrObjects int) []appsv1.StatefulSet

func SplitAndRenderStorageClass

func SplitAndRenderStorageClass(t *testing.T, output string, expectedNrObjects int) []storagev1.StorageClass

func StartAdmin

func StartAdmin(t *testing.T, options *helm.Options, replicaCount int, namespace string) (string, string)

func StartAdminCustomRelease added in v3.2.0

func StartAdminCustomRelease(t *testing.T, options *helm.Options, replicaCount int, namespace string, releaseName string) (string, string)

func StartAdminNoWait added in v3.5.0

func StartAdminNoWait(t *testing.T, options *helm.Options, replicaCount int, namespace string) (string, string)

func StartAdminTemplate

func StartAdminTemplate(t *testing.T, options *helm.Options, replicaCount int, namespace string, releaseName string, installStep AdminInstallationStep, awaitRunning bool) (helmChartReleaseName string, namespaceName string)

func StartDatabase

func StartDatabase(t *testing.T, namespace string, adminPod string, options *helm.Options) string

func StartDatabaseNoWait added in v3.1.0

func StartDatabaseNoWait(t *testing.T, namespace string, adminPod string, options *helm.Options) string

func StartDatabaseTemplate

func StartDatabaseTemplate(t *testing.T, namespaceName string, adminPod string, options *helm.Options, installationStep DatabaseInstallationStep, awaitDatabase bool) (helmChartReleaseName string)

func StartHAProxyIngress added in v3.5.0

func StartHAProxyIngress(t *testing.T, options *helm.Options, namespaceName string) string

func StartVault added in v3.2.0

func StartVault(t *testing.T, options *helm.Options, namespaceName string) string

func StartYCSBWorkload

func StartYCSBWorkload(t *testing.T, namespaceName string, options *helm.Options) (helmChartReleaseName string)

func SuspendDatabaseBackupJobs added in v3.5.0

func SuspendDatabaseBackupJobs(t *testing.T, namespaceName string, domain, dbName string, backupGroup string)

func Teardown

func Teardown(name string)

*

  • Call the stored teardown functions in the named list, in the correct order (last-in-first-out) *
  • NOTE: Any DIAGNOSTIC teardowns - those added with AddDiagnosticTeardown() for this name - are called BEFORE any other teardowns for this name. *
  • The typical use of Teardown is with a deferred call:
  • defer testlib.Teardown("SOME NAME")
  • See: testlib.AddTeardown(); testlib.AddDiagnosticTeardown()

func UnmarshalClusters added in v3.2.0

func UnmarshalClusters(s string) (err error, clusters map[string]K8sCluster)

func UnmarshalDomainServers added in v3.3.0

func UnmarshalDomainServers(s string) (err error, servers map[string]NuoDBServer)

func UnmarshalJSONObject

func UnmarshalJSONObject(t *testing.T, stringJSON string) map[string]interface{}

func UnmarshalLoadBalancerPolicies

func UnmarshalLoadBalancerPolicies(s string) (err error, policies map[string]NuoDBLoadBalancerPolicy)

func UpdateDnsConfig added in v3.8.0

func UpdateDnsConfig(t *testing.T, fromCtx context.Context, toCtx context.Context)

UpdateDnsConfig adds the DNS server from one cluster as an upstream resolver for the other, replacing any stale IP addresses that may currently be appear in the CoreDNS configuration.

func UpgradeDatabase added in v3.3.0

func UpgradeDatabase(t *testing.T, namespaceName string, helmChartReleaseName string, adminPod string, options *helm.Options, upgradeOptions *UpgradeOptions)

func VerifyAdminKvSetAndGet

func VerifyAdminKvSetAndGet(t *testing.T, podName string, namespaceName string)

func VerifyAdminLabels added in v3.9.0

func VerifyAdminLabels(t *testing.T, namespace string, adminPod string, expectedLabelValues map[string]string)

VerifyAdminLabels checks if adminPod in namespace has all the label values in expectedLabelValues

func VerifyAdminState

func VerifyAdminState(t *testing.T, namespace string, podName string)

func VerifyCertificateInLog

func VerifyCertificateInLog(t *testing.T, namespace string, podName string, expectedLogLine string)

func VerifyLicense added in v3.7.0

func VerifyLicense(t *testing.T, namespace string, podName string, expected LicenseType)

func VerifyLicenseE added in v3.7.0

func VerifyLicenseE(t *testing.T, namespace string, podName string, expected LicenseType) error

func VerifyLicenseFile

func VerifyLicenseFile(t *testing.T, namespace string, podName string, expectedLicense string)

func VerifyLicenseIsCommunity deprecated

func VerifyLicenseIsCommunity(t *testing.T, namespace string, podName string)

Deprecated: The VerifyLicenseIsCommunity function has been deprecated. When testing with NuoDB v6.0.0, use the VerifyLicense function instead.

func VerifyLicensingErrorsInLog

func VerifyLicensingErrorsInLog(t *testing.T, namespace string, podName string, expectError bool)

func VerifyPolicyInstalled

func VerifyPolicyInstalled(t *testing.T, namespace string, podName string)

func VerifyTeardown

func VerifyTeardown(t *testing.T)

* * Verify all teardownLists have been executed already; and throw an require if not. * Can be used to verify correct coding of a test that uses teardown - and to ensure eventual release of resources. * * NOTE: while the funcs are called in the correct order for each list, * there can be NO guarantee that the lists are iterated in the correct order. * * This function MUST NOT be used as a replacement for calling teardown() at the correct point in the code.

func VolumesContains

func VolumesContains(mounts []v1.Volume, expectedName string) bool

func WithClusterDeployment added in v3.2.0

func WithClusterDeployment(t *testing.T, context *ClusterDeploymentContext, actionsFunc func(context *ClusterDeploymentContext))

*

  • Execute arbitrary actions in context of a cluster deployment *
  • The deployment context will be passed in the custom function as parameter
  • which can be used to obtain information about the deployment. *

Types

type AdminInstallationStep

type AdminInstallationStep func(t *testing.T, options *helm.Options, helmChartReleaseName string)

type BackupHookResponse added in v3.8.0

type BackupHookResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

func GetBackupHookResponse added in v3.8.0

func GetBackupHookResponse(t *testing.T, namespaceName, smPod, resourcePath string, payload ...string) *BackupHookResponse

type CONTEXT_KEY added in v3.2.0

type CONTEXT_KEY string

type ClusterDeploymentContext added in v3.2.0

type ClusterDeploymentContext struct {
	Options             *helm.Options
	ThisCluster         K8sCluster
	EntrypointCluster   K8sCluster
	AdminReleaseName    string
	DatabaseReleaseName string
	Namespace           string
}

func GetClusterDeploymentContext added in v3.8.0

func GetClusterDeploymentContext(t *testing.T, context context.Context) *ClusterDeploymentContext

type ContainersNotStarted added in v3.5.0

type ContainersNotStarted struct {
	Name string
}

func (*ContainersNotStarted) Error added in v3.5.0

func (e *ContainersNotStarted) Error() string

type DBVersion

type DBVersion struct {
	Major int `json:"major"`
	Minor int `json:"minor"`
}

func GetDatabaseIncarnation

func GetDatabaseIncarnation(t *testing.T, namespace string, podName string, databaseName string) *DBVersion

type DatabaseInstallationStep

type DatabaseInstallationStep func(t *testing.T, options *helm.Options, helmChartReleaseName string)

type ExtractedOptions

type ExtractedOptions struct {
	NrTePods              int
	NrSmHotCopyPods       int
	NrSmNoHotCopyPods     int
	NrSmPods              int
	DbName                string
	ClusterName           string
	EntrypointClusterName string
	DbPrimaryRelease      bool
	DomainName            string
}

func GetExtractedOptions

func GetExtractedOptions(options *helm.Options) (opt ExtractedOptions)

type K8sCluster added in v3.2.0

type K8sCluster struct {
	Name    string `json:"name"`
	Domain  string `json:"domain"`
	Context string `json:"context"`
}

func InjectClusters added in v3.2.0

func InjectClusters(t *testing.T, cluster K8sCluster) K8sCluster

*

  • Injects user-defined Kubernetes cluster information *
  • The information is expected to be in stored in
  • clustersInject.yaml file in JSON format as a list.
  • See all cluster names in MULTI_CLUSTER_* constants. *

type LicenseType added in v3.7.0

type LicenseType string
const (
	UNLICENSED LicenseType = "UNLICENSED"
	LIMITED    LicenseType = "LIMITED"
	ENTERPRISE LicenseType = "ENTERPRISE"
)

type NuoDBArchive

type NuoDBArchive struct {
	Id          int    `json:"id"`
	DbName      string `json:"dbName"`
	Path        string `json:"path"`
	State       string `json:"state"`
	JournalPath string `json:"journalPath"`
}

func UnmarshalArchives

func UnmarshalArchives(s string) (err error, archives []NuoDBArchive)

type NuoDBCertInfo added in v3.7.0

type NuoDBCertInfo struct {
	CAPathLength     int    `json:"caPathLength"`
	CertificatePem   string `json:"certificatePem"`
	ExpiresTimestamp string `json:"expiresTimestamp"`
	IssuerName       string `json:"issuerName"`
	SubjectName      string `json:"subjectName"`
}

type NuoDBCertificateInfo added in v3.7.0

type NuoDBCertificateInfo struct {
	ServerCertificates  map[string]NuoDBCertInfo `json:"serverCertificates"`
	ProcessCertificates map[string]NuoDBCertInfo `json:"processCertificates"`
	TrustedCertificates map[string]NuoDBCertInfo `json:"trustedCertificates"`
}

func UnmarshalCertificateInfo added in v3.7.0

func UnmarshalCertificateInfo(s string) (err error, info NuoDBCertificateInfo)

type NuoDBDatabase

type NuoDBDatabase struct {
	Incarnation DBVersion `json:"incarnation"`
	Name        string    `json:"name"`
	Processes   string    `json:"processes"`
	State       string    `json:"state"`
}

func GetDatabaseE added in v3.6.0

func GetDatabaseE(t *testing.T, namespace string, podName string, databaseName string) (*NuoDBDatabase, error)

func UnmarshalDatabase

func UnmarshalDatabase(s string) (err error, databases []NuoDBDatabase)

type NuoDBKubeConfig

type NuoDBKubeConfig struct {
	Pods         map[string]corev1.Pod     `json:"pods"`
	Deployments  map[string]v1.Deployment  `json:"deployments"`
	StatefulSets map[string]v1.StatefulSet `json:"statefulsets"`
	Volumes      map[string]corev1.Volume  `json:"volumes"`
	DaemonSets   map[string]v1.DaemonSet   `json:"daemonSets"`
}

func GetNuoDBK8sConfigDump

func GetNuoDBK8sConfigDump(t *testing.T, namespace string, podName string) NuoDBKubeConfig

func UnmarshalNuoDBKubeConfig

func UnmarshalNuoDBKubeConfig(s string) (err error, kubeConfigs []NuoDBKubeConfig)

type NuoDBLoadBalancerConfig

type NuoDBLoadBalancerConfig struct {
	DbName         string `json:"dbName"`
	DefaultLbQuery string `json:"defaultLbQuery"`
	Prefilter      string `json:"prefilter"`
	IsGlobal       bool   `json:"isGlobal"`
}

func GetDatabaseLoadBalancerConfigE added in v3.3.0

func GetDatabaseLoadBalancerConfigE(t *testing.T, dbName string, loadBalancerConfigs []NuoDBLoadBalancerConfig) (*NuoDBLoadBalancerConfig, error)

func GetGlobalLoadBalancerConfigE added in v3.3.0

func GetGlobalLoadBalancerConfigE(t *testing.T, loadBalancerConfigs []NuoDBLoadBalancerConfig) (*NuoDBLoadBalancerConfig, error)

func GetLoadBalancerConfigE

func GetLoadBalancerConfigE(t *testing.T, namespaceName string, adminPod string) ([]NuoDBLoadBalancerConfig, error)

func UnmarshalLoadBalancerConfigs

func UnmarshalLoadBalancerConfigs(s string) (err error, lbConfigs []NuoDBLoadBalancerConfig)

type NuoDBLoadBalancerPolicy

type NuoDBLoadBalancerPolicy struct {
	LbQuery    string `json:"lbQuery"`
	PolicyName string `json:"policyName"`
}

type NuoDBProcess

type NuoDBProcess struct {
	Address   string            `json:"address"`
	DbName    string            `json:"dbName"`
	Type      string            `json:"type"`
	Host      string            `json:"host"`
	Hostname  string            `json:"hostname"`
	Labels    map[string]string `json:"labels"`
	IpAddress string            `json:"ipAddress"`
	Options   map[string]string `json:"options"`
	NodeId    int32             `json:"nodeId"`
	StartId   string            `json:"startId"`
	State     string            `json:"state"`
	DState    string            `json:"durableState"`
}

func GetDatabaseProcessesE added in v3.3.0

func GetDatabaseProcessesE(t *testing.T, namespaceName string, adminPod string, dbName string) (processes []NuoDBProcess, err error)

func Unmarshal

func Unmarshal(s string) (err error, processes []NuoDBProcess)

type NuoDBServer added in v3.3.0

type NuoDBServer struct {
	Address         string              `json:"address"`
	ConnectedState  NuoDBServerState    `json:"connectedState"`
	Id              string              `json:"id"`
	IsEvicted       bool                `json:"isEvicted"`
	IsLocal         bool                `json:"isLocal"`
	LocalRoleInfo   NuoDBServerRoleInfo `json:"localRoleInfo"`
	PeerMemberState string              `json:"peerMemberState"`
	PeerState       string              `json:"peerState"`
	Version         string              `json:"version"`
	Labels          map[string]string   `json:"labels"`
}

type NuoDBServerRoleInfo added in v3.3.0

type NuoDBServerRoleInfo struct {
	LeaderServerId         string                   `json:"leaderServerId"`
	LocalPeerTermIndexInfo NuoDBServerTermIndexInfo `json:"localPeerTermIndexInfo"`
	Role                   string                   `json:"role"`
}

type NuoDBServerState added in v3.3.0

type NuoDBServerState struct {
	State              string `json:"state"`
	Latency            int64  `json:"latency"`
	LastAckDeltaMillis int64  `json:"lastAckDeltaMillis"`
}

type NuoDBServerTermIndexInfo added in v3.3.0

type NuoDBServerTermIndexInfo struct {
	CommitIndex  int64 `json:"commitIndex"`
	CurrentTerm  int64 `json:"currentTerm"`
	LogLastIndex int64 `json:"logLastIndex"`
	LogLastTerm  int64 `json:"logLastTerm"`
	Valid        bool  `json:"valid"`
}

type NuoDBStatefulSets added in v3.3.0

type NuoDBStatefulSets struct {
	AdminSet   v1.StatefulSet
	SmNonHCSet v1.StatefulSet
	SmHCSet    v1.StatefulSet
}

func FindAllStatefulSets added in v3.3.0

func FindAllStatefulSets(t *testing.T, namespaceName string) NuoDBStatefulSets

type NuoDBStorageGroup added in v3.6.0

type NuoDBStorageGroup struct {
	Id               int               `json:"sgId"`
	Name             string            `json:"sgName"`
	DbName           string            `json:"dbName"`
	State            string            `json:"state"`
	ArchiveStates    map[string]string `json:"archiveStates"`
	ProcessStates    map[string]string `json:"processStates"`
	LeaderCandidates []string          `json:"leaderCandidates"`
}

func AwaitStorageGroup added in v3.6.0

func AwaitStorageGroup(t *testing.T, namespaceName, adminPod, dbName, sgName string, timeout time.Duration) *NuoDBStorageGroup

func GetStorageGroup added in v3.6.0

func GetStorageGroup(t *testing.T, namespaceName, adminPod, dbName, sgName string) *NuoDBStorageGroup

func UnmarshalStorageGroups added in v3.6.0

func UnmarshalStorageGroups(s string) (err error, sgs []NuoDBStorageGroup)

type Registry

type Registry struct {
	Nuodb struct {
		Image struct {
			Registry   string
			Repository string
			Tag        string
		}
	}
}

func UnmarshalImageYAML

func UnmarshalImageYAML(s string) (err error, registry Registry)

UnmarshalImageYAML is used to unmarshal into map[string]string

type UpgradeOptions added in v3.3.0

type UpgradeOptions struct {
	AdminPodShouldGetRecreated bool
	TePodShouldGetRecreated    bool
	SmPodShouldGetRecreated    bool
}

Jump to

Keyboard shortcuts

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