Documentation
¶
Index ¶
- Constants
- Variables
- func ExecSQL(t *testing.T, kubectlOpts *k8s.KubectlOptions, pod string, sql string) (string, error)
- func HelmChartPaths() (helmChartPath string, operatorChartPath string)
- func InstallCockroachDBOperator(t *testing.T, kubectlOptions *k8s.KubectlOptions, cloudRegion string)
- func InstallCockroachDBOperatorChart(t *testing.T, kubectlOptions *k8s.KubectlOptions, chart, version string, ...)
- func InstallCockroachDBOperatorScoped(t *testing.T, kubectlOptions *k8s.KubectlOptions, ...)
- func InstallCockroachDBOperatorScopedForMigration(t *testing.T, kubectlOptions *k8s.KubectlOptions, ...)
- func MustMarshalJSON(value interface{}) string
- func PatchHelmValues(inputValues map[string]string) map[string]string
- func TestOperatorHelmValues() map[string]string
- func UninstallCockroachDBOperator(t *testing.T, kubectlOptions *k8s.KubectlOptions)
- func UpgradeCockroachDBOperatorChart(t *testing.T, kubectlOptions *k8s.KubectlOptions, chart string, ...)
- func VerifyInitCommandInOperatorLogs(t *testing.T, kubectlOptions *k8s.KubectlOptions, expected string)
- type AdvancedInstallConfig
- type AdvancedValidationConfig
- type EncryptionAtRestValidation
- type PCRValidation
- type Region
- func (r *Region) AssignRandomNamespace(cluster string) string
- func (r *Region) AssignRandomNamespaceWithPrefix(cluster string, prefix string) string
- func (r *Region) AssignRandomNamespacesWithPrefix(prefix string)
- func (r *Region) BaseRegionConfig(cluster string, index int) map[string]interface{}
- func (r *Region) BuildEncryptionRegions(cluster string, index int, encryptionOverrides map[string]interface{}) []map[string]interface{}
- func (r *Region) CleanUpCACertificate(t *testing.T)
- func (r *Region) CleanupEncryptionInfra()
- func (r *Region) CleanupResources(t *testing.T)
- func (r *Region) CreateCACertificate(t *testing.T) error
- func (r *Region) CreateEncryptionKeySecret(t *testing.T, kubectlOptions *k8s.KubectlOptions, secretName string, ...) error
- func (r *Region) EncryptionAtRestConfig(secretName string, overrides map[string]interface{}) map[string]interface{}
- func (r *Region) EncryptionOverridesFromProvider() map[string]interface{}
- func (r *Region) EnsureKubeConfigPath() (string, error)
- func (r *Region) ExtendOperatorWatchNamespace(t *testing.T, cluster, operatorNamespace, newNamespace string)
- func (r *Region) GetCurrentContext(t *testing.T) (string, api.Config)
- func (r *Region) InstallCharts(t *testing.T, cluster string, index int)
- func (r *Region) InstallChartsWithAdvancedConfig(t *testing.T, cluster string, index int, config AdvancedInstallConfig)
- func (r *Region) OperatorRegions(index int, nodes int) []map[string]interface{}
- func (r *Region) RequireCACertificate(t *testing.T) func()
- func (r *Region) SetEncryptionProvider(p encryption.Provider)
- func (r *Region) SetupMultiClusterWithCA(t *testing.T) func()
- func (r *Region) SetupSingleClusterWithCA(t *testing.T, cluster string) func()
- func (r *Region) ValidateCRDB(t *testing.T, cluster string)
- func (r *Region) ValidateCRDBContainerResources(t *testing.T, kubectlOptions *k8s.KubectlOptions)
- func (r *Region) ValidateEncryptionAtRest(t *testing.T, cluster string, cfg *AdvancedValidationConfig)
- func (r *Region) ValidateMultiRegionSetup(t *testing.T)
- func (r *Region) ValidatePCR(t *testing.T, cfg *AdvancedValidationConfig)
- func (r *Region) ValidateWALFailover(t *testing.T, cluster string, cfg *AdvancedValidationConfig)
- func (r *Region) VerifyHelmUpgrade(t *testing.T, initialTimestamp time.Time, kubectlOptions *k8s.KubectlOptions) error
- type WALFailoverValidation
Constants ¶
const ( TestDBName = "testdb" Namespace = "cockroach-ns" LabelSelector = "app=cockroachdb" OperatorLabelSelector = "app=cockroach-operator" )
const ( DefaultEncryptionSecret = "cmek-key-secret" DefaultRotatedEncryptionSecret = "cmek-key-secret-new" )
Variables ¶
var ( Clusters = []string{"chart-testing-cluster-0", "chart-testing-cluster-1"} CustomDomains = map[int]string{ 0: "cluster1.local", 1: "cluster2.local", } ReleaseName = "cockroachdb" CockroachContainerName = "cockroachdb" )
Functions ¶
func ExecSQL ¶
func ExecSQL( t *testing.T, kubectlOpts *k8s.KubectlOptions, pod string, sql string, ) (string, error)
ExecSQL runs a SQL statement in the cockroachdb container using certs-dir authentication.
func HelmChartPaths ¶
func InstallCockroachDBOperator ¶
func InstallCockroachDBOperator( t *testing.T, kubectlOptions *k8s.KubectlOptions, cloudRegion string, )
func InstallCockroachDBOperatorScoped ¶
func InstallCockroachDBOperatorScoped( t *testing.T, kubectlOptions *k8s.KubectlOptions, watchNamespaces, cloudRegion string, )
func InstallCockroachDBOperatorScopedForMigration ¶
func InstallCockroachDBOperatorScopedForMigration( t *testing.T, kubectlOptions *k8s.KubectlOptions, watchNamespaces, cloudRegion string, )
func MustMarshalJSON ¶
func MustMarshalJSON(value interface{}) string
func PatchHelmValues ¶
PatchHelmValues adds and overrides few default values for the helm charts for testing purposes. It sets the persistent storage size to 1Gi, terminationGracePeriod to 30s and rolling restart delay to 30s.
func TestOperatorHelmValues ¶
func UninstallCockroachDBOperator ¶
func UninstallCockroachDBOperator(t *testing.T, kubectlOptions *k8s.KubectlOptions)
func VerifyInitCommandInOperatorLogs ¶
func VerifyInitCommandInOperatorLogs( t *testing.T, kubectlOptions *k8s.KubectlOptions, expected string, )
VerifyInitCommandInOperatorLogs verifies that the operator logs contain the expected init command.
Types ¶
type AdvancedInstallConfig ¶
type AdvancedInstallConfig struct {
// WAL Failover configuration
WALFailoverEnabled bool
WALFailoverSize string
EncryptionEnabled bool
// Virtual Cluster configuration (for PCR)
VirtualClusterMode string // "primary", "standby", or ""
// Custom helm values to merge
CustomValues map[string]string
// Custom regions configuration (for encryption)
CustomRegions []map[string]interface{}
// Skip operator installation (for second virtual cluster)
SkipOperatorInstall bool
}
AdvancedInstallConfig holds configuration for advanced feature installations.
type AdvancedValidationConfig ¶
type AdvancedValidationConfig struct {
WALFailover WALFailoverValidation
EncryptionAtRest EncryptionAtRestValidation
PCR PCRValidation
}
AdvancedValidationConfig aggregates validation knobs for advanced feature assertions.
func DefaultAdvancedValidationConfig ¶
func DefaultAdvancedValidationConfig() AdvancedValidationConfig
DefaultAdvancedValidationConfig returns default validation values used when a test does not override them.
type EncryptionAtRestValidation ¶
type EncryptionAtRestValidation struct {
SecretName string
// OldKeyExpected is the substring expected in the --enterprise-encryption old-key field.
// Defaults to "old-key=plain" (initial encryption setup). For key rotation use "old-key=/etc/cockroach-key/".
OldKeyExpected string
}
EncryptionAtRestValidation captures encryption validation expectations.
type PCRValidation ¶
type PCRValidation struct {
Cluster string
PrimaryNamespace string
StandbyNamespace string
// PrimaryClusterDomain overrides the cluster domain for the primary connection URI.
PrimaryClusterDomain string
}
PCRValidation captures virtual cluster replication validation inputs.
type Region ¶
type Region struct {
// IsCertManager is true if the cockroachdb cluster is using cert-manager.
IsCertManager bool
// NodeCount is the desired CockroachDB nodes in the region.
NodeCount int
// Namespace stores mapping between cluster name and namespace.
Namespace map[string]string
ReusingInfra bool
// Clients store the k8s client for each cluster
// needed for performing k8s operations on k8s objects.
Clients map[string]client.Client
Clusters []string
CorednsClusterOptions map[string]coredns.CoreDNSClusterOption
Provider string
RegionCodes []string
VirtualClusterModeStandby bool
IsOperatorInstalled bool
// OperatorNamespace tracks the namespace in which the operator was installed,
// keyed by cluster name.
OperatorNamespace map[string]string
// contains filtered or unexported fields
}
func (*Region) AssignRandomNamespace ¶
AssignRandomNamespace assigns a randomized namespace for the given cluster using the default prefix.
func (*Region) AssignRandomNamespaceWithPrefix ¶
AssignRandomNamespaceWithPrefix assigns a randomized namespace for the given cluster using the provided prefix.
func (*Region) AssignRandomNamespacesWithPrefix ¶
AssignRandomNamespacesWithPrefix assigns randomized namespaces for all tracked clusters.
func (*Region) BaseRegionConfig ¶
BaseRegionConfig returns a baseline region configuration map for the provided cluster and index.
func (*Region) BuildEncryptionRegions ¶
func (r *Region) BuildEncryptionRegions( cluster string, index int, encryptionOverrides map[string]interface{}, ) []map[string]interface{}
BuildEncryptionRegions creates a slice containing a single region entry with encryption settings applied.
func (*Region) CleanUpCACertificate ¶
func (*Region) CleanupEncryptionInfra ¶
func (r *Region) CleanupEncryptionInfra()
func (*Region) CleanupResources ¶
CleanupResources will clean the resources installed by Operator, CockroachDB charts and deletes the namespace. Any failure in doing so might cause issues in other tests as some of the cluster resources are tied to the namespace.
func (*Region) CreateCACertificate ¶
CreateCACertificate creates CA cert and key at the same path.
func (*Region) CreateEncryptionKeySecret ¶
func (*Region) EncryptionAtRestConfig ¶
func (r *Region) EncryptionAtRestConfig( secretName string, overrides map[string]interface{}, ) map[string]interface{}
EncryptionAtRestConfig returns a reusable encryption configuration map with optional overrides. When an override value is nil or empty string, the key is omitted from the config entirely. This matters because the operator uses *string with omitempty — a nil/absent keySecretName is interpreted as "plain" (unencrypted), while an empty string is not the same as nil.
func (*Region) EncryptionOverridesFromProvider ¶
func (*Region) EnsureKubeConfigPath ¶
EnsureKubeConfigPath ensures that the kubeconfig file exists and returns its path.
func (*Region) ExtendOperatorWatchNamespace ¶
func (r *Region) ExtendOperatorWatchNamespace( t *testing.T, cluster, operatorNamespace, newNamespace string, )
ExtendOperatorWatchNamespace patches the operator deployment in operatorNamespace to also watch newNamespace.
func (*Region) GetCurrentContext ¶
GetCurrentContext gets the current cluster context from KubeConfig.
func (*Region) InstallCharts ¶
InstallCharts Installs both Operator and CockroachDB charts by providing custom CA secret which is generated through cockroach binary, It also verifies whether relevant services are up and running.
func (*Region) InstallChartsWithAdvancedConfig ¶
func (r *Region) InstallChartsWithAdvancedConfig( t *testing.T, cluster string, index int, config AdvancedInstallConfig, )
InstallChartsWithAdvancedConfig installs CockroachDB with advanced features configuration
func (*Region) OperatorRegions ¶
OperatorRegions returns the regions config based on the index which is referring to cluster index.
func (*Region) RequireCACertificate ¶
RequireCACertificate creates a CA certificate for the current test and returns a cleanup closure. It cleans up any stale CA files from previous runs before creating new ones.
func (*Region) SetEncryptionProvider ¶
func (r *Region) SetEncryptionProvider(p encryption.Provider)
func (*Region) SetupMultiClusterWithCA ¶
SetupMultiClusterWithCA prepares all clusters for advanced tests and returns a cleanup closure.
func (*Region) SetupSingleClusterWithCA ¶
SetupSingleClusterWithCA prepares a single cluster for advanced tests and returns a cleanup closure.
func (*Region) ValidateCRDB ¶
ValidateCRDB validates the CockroachDB cluster by performing basic operations on db.
func (*Region) ValidateCRDBContainerResources ¶
func (r *Region) ValidateCRDBContainerResources(t *testing.T, kubectlOptions *k8s.KubectlOptions)
func (*Region) ValidateEncryptionAtRest ¶
func (r *Region) ValidateEncryptionAtRest( t *testing.T, cluster string, cfg *AdvancedValidationConfig, )
ValidateEncryptionAtRest verifies that encryption at rest is properly configured by checking flags and encryption status. Pass nil config to rely on defaults or provide overrides via AdvancedValidationConfig.EncryptionAtRest.
func (*Region) ValidateMultiRegionSetup ¶
ValidateMultiRegionSetup validates the multi-region setup.
func (*Region) ValidatePCR ¶
func (r *Region) ValidatePCR(t *testing.T, cfg *AdvancedValidationConfig)
ValidatePCR validates PCR by verifying virtual cluster configuration and testing failover/failback connections. Provide the cluster and namespaces through AdvancedValidationConfig.PCR.
func (*Region) ValidateWALFailover ¶
func (r *Region) ValidateWALFailover(t *testing.T, cluster string, cfg *AdvancedValidationConfig)
ValidateWALFailover verifies that WAL failover is properly configured by checking the --wal-failover flag and PVC. Pass nil config to rely on defaults or provide a pointer with overrides through AdvancedValidationConfig.WALFailover.
func (*Region) VerifyHelmUpgrade ¶
func (r *Region) VerifyHelmUpgrade( t *testing.T, initialTimestamp time.Time, kubectlOptions *k8s.KubectlOptions, ) error
VerifyHelmUpgrade waits till all the pods are restarted after the helm upgrade is completed, it verifies with initialTimestamp which is the timestamp of the pods before recreation and returns the pod name.
type WALFailoverValidation ¶
type WALFailoverValidation struct {
CustomPath string
}
WALFailoverValidation captures WAL failover expectations.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package infra provides AWS infrastructure provisioning and management for e2e operator tests.
|
Package infra provides AWS infrastructure provisioning and management for e2e operator tests. |