Skip to content

[CC-35895] e2e/operator: add encryption provider interface and GCP advanced test infrastructure#627

Open
shreyaskm623 wants to merge 6 commits into
masterfrom
shreyaskm/gcp-operator-advanced-test-infra
Open

[CC-35895] e2e/operator: add encryption provider interface and GCP advanced test infrastructure#627
shreyaskm623 wants to merge 6 commits into
masterfrom
shreyaskm/gcp-operator-advanced-test-infra

Conversation

@shreyaskm623
Copy link
Copy Markdown
Contributor

@shreyaskm623 shreyaskm623 commented May 4, 2026

Introduces an encryption.Provider interface to abstract KMS and secret setup behind infra-level provider types, and adds GCP-specific test infrastructure support including version-gated PCR connection URI generation.

JIRA : https://cockroachlabs.atlassian.net/browse/CC-35895

@shreyaskm623 shreyaskm623 self-assigned this May 4, 2026
@shreyaskm623 shreyaskm623 force-pushed the nishanth/operator-advanced-tests branch 2 times, most recently from ef82b74 to 6df483d Compare May 8, 2026 09:02
@shreyaskm623 shreyaskm623 force-pushed the shreyaskm/gcp-operator-advanced-test-infra branch from 0326060 to 89e9a9c Compare May 8, 2026 09:49
@shreyaskm623 shreyaskm623 force-pushed the nishanth/operator-advanced-tests branch 4 times, most recently from e210753 to 6ab0067 Compare May 12, 2026 12:47
@shreyaskm623 shreyaskm623 force-pushed the shreyaskm/gcp-operator-advanced-test-infra branch 6 times, most recently from b1ddc9b to 90f3b64 Compare May 13, 2026 15:06
Base automatically changed from nishanth/operator-advanced-tests to master May 14, 2026 09:49
@shreyaskm623 shreyaskm623 force-pushed the shreyaskm/gcp-operator-advanced-test-infra branch 4 times, most recently from d8a51b1 to 1a6687c Compare May 18, 2026 09:16
@shreyaskm623 shreyaskm623 changed the title operator: Adds advanced tests support for the GCP environment e2e/operator: add encryption provider interface and GCP advanced test infrastructure May 18, 2026
@shreyaskm623 shreyaskm623 force-pushed the shreyaskm/gcp-operator-advanced-test-infra branch 4 times, most recently from 4d14a02 to 1a6687c Compare May 18, 2026 15:34
@shreyaskm623 shreyaskm623 marked this pull request as ready for review May 18, 2026 16:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the operator E2E test harness to abstract encryption-at-rest setup behind a provider interface (so tests don’t manually generate/store keys) and extends infrastructure support for GCP, including CRDB-version-gated PCR external connection URI generation.

Changes:

  • Centralize provider resolution (PROVIDER) and wire an encryption.Provider into the region/provider factory flow.
  • Move encryption key/secret setup into a dedicated tests/e2e/operator/encryption package and update advanced encryption tests to use provider-driven overrides/secret creation.
  • Add GCP KMS-backed encryption test infrastructure and gate PCR URI generation on the CRDB version (convert-url vs encode-uri).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/e2e/operator/singleRegion/cockroachdb_single_region_e2e_test.go Switch to centralized provider resolution; provider-scoped test runner cleanup.
tests/e2e/operator/singleRegion/cockroachdb_single_region_advanced_features_test.go Update encryption-at-rest flows (enable/disable/rotate) to use provider-driven overrides and secret creation; adjust PCR validation inputs.
tests/e2e/operator/region.go Add encryption provider plumbing and encryption secret setup during install; add PCR URI version gating and primary cluster-domain override.
tests/e2e/operator/multiRegion/cockroachdb_multi_region_e2e_test.go Switch to centralized provider resolution.
tests/e2e/operator/multiRegion/cockroachdb_multi_region_advanced_features_test.go Update multi-region encryption test to use provider-driven encryption region config.
tests/e2e/operator/infra/provider.go Add ResolveProvider and provider→region encryption provider wiring in the factory.
tests/e2e/operator/infra/local.go Implement encryption provider interface for local providers (file-based/UNKNOWN_KEY_TYPE).
tests/e2e/operator/infra/gcp.go Implement GCP KMS-backed encryption provider (keyring/key creation, encrypt, secret creation).
tests/e2e/operator/encryption/types.go Introduce provider interface + helpers for generating keys and creating secrets for file-based vs CMEK providers.
tests/e2e/migrate/helm_chart_to_cockroach_enterprise_operator_test.go Use centralized provider resolution for operator install region selection.
Comments suppressed due to low confidence (1)

tests/e2e/operator/singleRegion/cockroachdb_single_region_e2e_test.go:63

  • The provider teardown only calls cloudProvider.TeardownInfra; it does not trigger any encryption-provider cleanup even though Region stores an encryptionCleanupFunc. To avoid leaking KMS/test resources, call providerRegion.CleanupEncryptionInfra() (or equivalent) as part of this cleanup block.
		// Use t.Cleanup for guaranteed cleanup even on test timeout/panic.
		t.Cleanup(func() {
			t.Logf("Starting infrastructure cleanup for provider: %s", provider)
			cloudProvider.TeardownInfra(t)
			t.Logf("Completed infrastructure cleanup for provider: %s", provider)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/e2e/operator/region.go
Comment thread tests/e2e/operator/region.go
Comment thread tests/e2e/operator/infra/gcp.go
Comment thread tests/e2e/operator/infra/gcp.go Outdated

out, err := exec.Command("kubectl", cmdArgs...).CombinedOutput()
if err != nil {
return fmt.Errorf("kubectl %s: %w\nOutput: %s", strings.Join(args[:2], " "), err, string(out))
Comment on lines +343 to +345
// oldCmekCredentialsSecretName is required for the operator to set OLD_CMEK_PLATFORM
// and OLD_GCP_SERVICE_ACCOUNT_KEY, which tells the init container to KMS-decrypt
// the old key instead of writing the raw ciphertext to old_store.key.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

tests/e2e/operator/singleRegion/cockroachdb_single_region_e2e_test.go:63

  • The provider-level cleanup only calls cloudProvider.TeardownInfra, but encryption infra cleanup closures captured via Region (CleanupEncryptionInfra) are never invoked. To avoid leaking KMS/IAM test resources (and to keep the cleanup API meaningful), call providerRegion.CleanupEncryptionInfra() in both the t.Cleanup block and the immediate failure cleanup path.
		// Use t.Cleanup for guaranteed cleanup even on test timeout/panic.
		t.Cleanup(func() {
			t.Logf("Starting infrastructure cleanup for provider: %s", provider)
			cloudProvider.TeardownInfra(t)
			t.Logf("Completed infrastructure cleanup for provider: %s", provider)

Comment thread tests/e2e/operator/region.go
Comment thread tests/e2e/operator/region.go Outdated

func (r *Region) EncryptionOverridesFromProvider() map[string]interface{} {
if r.encryptionProvider == nil {
return nil
Comment thread tests/e2e/operator/region.go Outdated

// Wait for crd to be installed.
// Wait for crdbclusters CRD to serve v1beta1 before proceeding.
_, _ = retry.DoWithRetryE(t, "wait-for-crd", 60, time.Second*5, func() (string, error) {
Comment thread tests/e2e/operator/infra/gcp.go
Comment thread tests/e2e/operator/encryption/types.go Outdated
Comment on lines +52 to +54
func SetupEncryptionSecrets(t *testing.T, provider Provider, kubectlOptions *k8s.KubectlOptions, clusterRegion string) error {
return SetupEncryptionSecretsWithName(t, provider, kubectlOptions, clusterRegion, "cmek-key-secret")
}
Comment thread tests/e2e/operator/encryption/types.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread tests/e2e/operator/region.go Outdated
require.NoError(t, err)
require.True(t, len(secretSize) > 0, "Secret StoreKeyData should be >0")
t.Logf("Created encryption secret %s with size: %d bytes", encryptionSecretName, len(secretSize))
err = encryption.SetupEncryptionSecretsWithName(t, r.encryptionProvider, kubectlOptions, cluster, DefaultEncryptionSecret)
@shreyaskm623 shreyaskm623 force-pushed the shreyaskm/gcp-operator-advanced-test-infra branch from 6e2b463 to c019669 Compare May 20, 2026 12:36
@shreyaskm623 shreyaskm623 changed the title e2e/operator: add encryption provider interface and GCP advanced test infrastructure [CC-35895] e2e/operator: add encryption provider interface and GCP advanced test infrastructure May 20, 2026
@shreyaskm623 shreyaskm623 force-pushed the shreyaskm/gcp-operator-advanced-test-infra branch from c019669 to 7c1ef66 Compare May 20, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants