testutil

package
v0.0.0-...-fa5fe1c Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SelfSignedIssuerName = "cockroachdb-selfsigned"
	SelfSignedCertName   = "cockroachdb-ca"
	CAIssuerName         = "cockroachdb"
	CASecretName         = "cockroachdb-ca-secret"
	CAConfigMapName      = "cockroachdb-ca"
	CertManagerNamespace = "cert-manager"
)
View Source
const (
	TestDBName = "test_db"
)

Variables

This section is empty.

Functions

func CreateBundle

func CreateBundle(t *testing.T, kubectlOptions *k8s.KubectlOptions, caSecretName, caConfigMapName string)

CreateBundle creates a bundle which transfers the CA certificate from secret to configmap in the target namespace.

func CreateCAIssuer

func CreateCAIssuer(t *testing.T, kubectlOptions *k8s.KubectlOptions, issuerNamespace string)

CreateCAIssuer creates a CA issuer using the CA certificate stored in a secret. The CA issuer is used to sign the certificates for the cockroachdb cluster.

func CreateSelfSignedCertificate

func CreateSelfSignedCertificate(t *testing.T, kubectlOptions *k8s.KubectlOptions, issuerNamespace string)

CreateSelfSignedCertificate creates a self-signed certificate which is stored in a secret.

func CreateSelfSignedIssuer

func CreateSelfSignedIssuer(t *testing.T, kubectlOptions *k8s.KubectlOptions, issuerNamespace string)

CreateSelfSignedIssuer creates a self-signed issuer which is used to sign the self signed CA certificate.

func DeleteBundle

func DeleteBundle(t *testing.T, kubectlOptions *k8s.KubectlOptions)

DeleteBundle deletes the bundle.

func DeleteCAIssuer

func DeleteCAIssuer(t *testing.T, kubectlOptions *k8s.KubectlOptions, issuerNamespace string)

func DeleteCertManager

func DeleteCertManager(t *testing.T, kubectlOptions *k8s.KubectlOptions)

DeleteCertManager deletes the cert-manager release.

func DeleteSelfSignedCertificate

func DeleteSelfSignedCertificate(t *testing.T, kubectlOptions *k8s.KubectlOptions, issuerNamespace string)

func DeleteSelfSignedIssuer

func DeleteSelfSignedIssuer(t *testing.T, kubectlOptions *k8s.KubectlOptions, issuerNamespace string)

DeleteSelfSignedIssuer deletes the self-signed issuer.

func DeleteTrustManager

func DeleteTrustManager(t *testing.T, kubectlOptions *k8s.KubectlOptions)

DeleteTrustManager deletes the trust-manager release.

func GetGitRoot

func GetGitRoot() string

func InstallCertManager

func InstallCertManager(t *testing.T, kubectlOptions *k8s.KubectlOptions)

InstallCertManager installs the cert-manager in cert-manager namespace with helm: https://cert-manager.io/docs/installation/helm/

func InstallIngressAndMetalLB

func InstallIngressAndMetalLB(t *testing.T)

func InstallTrustManager

func InstallTrustManager(t *testing.T, kubectlOptions *k8s.KubectlOptions, trustNamespace string)

InstallTrustManager installs the trust-manager in cert-manager namespace with helm: https://cert-manager.io/docs/trust/trust-manager/installation/

func LoadCertificate

func LoadCertificate(t *testing.T, certSecret *corev1.Secret, key string) *x509.Certificate

func PatchHelmValues

func PatchHelmValues(inputValues map[string]string) map[string]string

func PrintDebugLogs

func PrintDebugLogs(t *testing.T, options *k8s.KubectlOptions)

PrintDebugLogs adds the verbose logging of the cluster at the runtime.

func RequireCRDBClusterToBeReadyEventuallyTimeout

func RequireCRDBClusterToBeReadyEventuallyTimeout(t *testing.T, opts *k8s.KubectlOptions, crdbCluster CockroachCluster, timeout time.Duration)

RequireCRDBClusterToBeReadyEventuallyTimeout waits for all the CockroachDB pods to come into running state.

func RequireCRDBClusterToFunction

func RequireCRDBClusterToFunction(t *testing.T, crdbCluster CockroachCluster, rotate bool, podName string)

func RequireCRDBDatabaseToFunction

func RequireCRDBDatabaseToFunction(t *testing.T, crdbCluster CockroachCluster, dbName string, podName string)

RequireCRDBDatabaseToFunction creates a database, a table and insert two rows.

func RequireCRDBToFunction

func RequireCRDBToFunction(t *testing.T, crdbCluster CockroachCluster, validateExistingData bool)

RequireCRDBToFunction creates a database, a table and insert two rows if it is a fresh installation of the cluster. If validateExistingData is true, this will check that existing two rows are present.

func RequireCertRotateJobToBeCompleted

func RequireCertRotateJobToBeCompleted(t *testing.T, jobName string, crdbCluster CockroachCluster, timeout time.Duration)

RequireCertRotateJobToBeCompleted waits for the certificate rotation job to complete.

func RequireCertificatesToBeValid

func RequireCertificatesToBeValid(t *testing.T, crdbCluster CockroachCluster)

RequireCertificatesToBeValid will check the CA certificate and client certificate validity from their respective secrets. Also, it verifies that node certificates are signed by the CA certificates used in the cluster.

func RequireClusterToBeReadyEventuallyTimeout

func RequireClusterToBeReadyEventuallyTimeout(t *testing.T, crdbCluster CockroachCluster, timeout time.Duration)

RequireClusterToBeReadyEventuallyTimeout waits for all the CRDB pods to come into running state.

func RequirePodToBeCreatedAndReady

func RequirePodToBeCreatedAndReady(t *testing.T, opts *k8s.KubectlOptions, podName string, timeout time.Duration)

func RequireToRunRotateJob

func RequireToRunRotateJob(t *testing.T, crdbCluster CockroachCluster, values map[string]string,
	scheduleToTriggerRotation string, caRotate bool,
)

RequireToRunRotateJob triggers the client/node or CA certificate rotation job based on next cron schedule.

func TestIngressRoutingDirect

func TestIngressRoutingDirect(t *testing.T, hostName string)

func UninstallIngressAndMetalLB

func UninstallIngressAndMetalLB(t *testing.T)

func WaitUntilPodDeleted

func WaitUntilPodDeleted(
	t *testing.T,
	options *k8s.KubectlOptions,
	podName string,
	retries int,
	sleepBetweenRetries time.Duration,
)

WaitUntilPodDeleted waits until the pod is deleted, retrying the check for the specified amount of times, sleeping for the provided duration between each try.

Types

type CockroachCluster

type CockroachCluster struct {
	Cfg                        *rest.Config
	K8sClient                  client.Client
	StatefulSetName, Namespace string
	ClientSecret, NodeSecret   string
	CaSecret                   string
	IsCaUserProvided           bool
	DesiredNodes               int
	Context                    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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