operator

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: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestDBName            = "testdb"
	Namespace             = "cockroach-ns"
	LabelSelector         = "app=cockroachdb"
	OperatorLabelSelector = "app=cockroach-operator"
)

Variables

View Source
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 HelmChartPaths

func HelmChartPaths() (helmChartPath string, operatorChartPath string)

func InstallCockroachDBEnterpriseOperator

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

func MustMarshalJSON

func MustMarshalJSON(value interface{}) string

func PatchHelmValues

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

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 UninstallCockroachDBEnterpriseOperator

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

Types

type OperatorUseCases

type OperatorUseCases interface {
	TestHelmInstall(t *testing.T)
	TestHelmUpgrade(t *testing.T)
	TestClusterScaleUp(t *testing.T)
	TestClusterRollingRestart(t *testing.T)
	TestKillingCockroachNode(t *testing.T)
	TestInstallWithCertManager(t *testing.T)
}

OperatorUseCases defines use cases for the CockroachDB cluster.

type Region

type Region struct {
	// IsCertManager is true if the cockroachdb cluster is using cert-manager.
	IsCertManager bool
	// IsMultiRegion is true if the region is multi-region.
	IsMultiRegion 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
}

func (*Region) CleanUpCACertificate

func (r *Region) CleanUpCACertificate(t *testing.T)

func (*Region) CleanupResources

func (r *Region) CleanupResources(t *testing.T)

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

func (r *Region) CreateCACertificate(t *testing.T) error

CreateCACertificate creates CA cert and key at the same path.

func (*Region) EnsureKubeConfigPath

func (r *Region) EnsureKubeConfigPath() (string, error)

EnsureKubeConfigPath ensures that the kubeconfig file exists and returns its path.

func (*Region) GetCurrentContext

func (r *Region) GetCurrentContext(t *testing.T) (string, api.Config)

GetCurrentContext gets the current cluster context from KubeConfig.

func (*Region) InstallCharts

func (r *Region) InstallCharts(t *testing.T, cluster string, index int)

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) OperatorRegions

func (r *Region) OperatorRegions(index int, nodes int) []map[string]interface{}

OperatorRegions returns the regions config based on the index which is referring to cluster index.

func (*Region) ValidateCRDB

func (r *Region) ValidateCRDB(t *testing.T, cluster string)

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) ValidateMultiRegionSetup

func (r *Region) ValidateMultiRegionSetup(t *testing.T)

ValidateMultiRegionSetup validates the multi-region setup.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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