Skip to content

Commit

Permalink
Add GOOGLE_VMWAREENGINE_PROJECT env var for vmwareengine tests (#12707)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuyama1 authored Jan 8, 2025
1 parent c13527d commit 415b35b
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 47 deletions.
4 changes: 3 additions & 1 deletion .ci/gcb-pr-downstream-generation-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ steps:
- name: 'gcr.io/graphite-docker-images/go-plus'
id: gcb-tpg-vcr-test
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
secretEnv: ["GITHUB_TOKEN_DOWNSTREAMS", "GITHUB_TOKEN_MAGIC_MODULES", "GOOGLE_BILLING_ACCOUNT", "GOOGLE_CHRONICLE_INSTANCE_ID", "GOOGLE_CUST_ID", "GOOGLE_IDENTITY_USER", "GOOGLE_MASTER_BILLING_ACCOUNT", "GOOGLE_ORG", "GOOGLE_ORG_2", "GOOGLE_ORG_DOMAIN", "GOOGLE_PROJECT", "GOOGLE_PROJECT_NUMBER", "GOOGLE_SERVICE_ACCOUNT", "SA_KEY", "GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION"]
secretEnv: ["GITHUB_TOKEN_DOWNSTREAMS", "GITHUB_TOKEN_MAGIC_MODULES", "GOOGLE_BILLING_ACCOUNT", "GOOGLE_CHRONICLE_INSTANCE_ID", "GOOGLE_CUST_ID", "GOOGLE_IDENTITY_USER", "GOOGLE_MASTER_BILLING_ACCOUNT", "GOOGLE_ORG", "GOOGLE_ORG_2", "GOOGLE_ORG_DOMAIN", "GOOGLE_PROJECT", "GOOGLE_PROJECT_NUMBER", "GOOGLE_SERVICE_ACCOUNT", "SA_KEY", "GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION", "GOOGLE_VMWAREENGINE_PROJECT"]
waitFor: ["diff"]
env:
- BASE_BRANCH=$_BASE_BRANCH
Expand Down Expand Up @@ -314,3 +314,5 @@ availableSecrets:
env: SA_KEY
- versionName: projects/673497134629/secrets/ci-test-public-advertised-prefix-description/versions/latest
env: GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION
- versionName: projects/673497134629/secrets/ci-test-vmwareengine-project/versions/latest
env: GOOGLE_VMWAREENGINE_PROJECT
3 changes: 3 additions & 0 deletions .ci/gcb-push-downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ steps:
- "GOOGLE_SERVICE_ACCOUNT"
- "SA_KEY"
- "GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION"
- "GOOGLE_VMWAREENGINE_PROJECT"
env:
- "COMMIT_SHA=$COMMIT_SHA"
- "GOOGLE_REGION=us-central1"
Expand Down Expand Up @@ -249,3 +250,5 @@ availableSecrets:
env: SA_KEY
- versionName: projects/673497134629/secrets/ci-test-public-advertised-prefix-description/versions/latest
env: GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION
- versionName: projects/673497134629/secrets/ci-test-vmwareengine-project/versions/latest
env: GOOGLE_VMWAREENGINE_PROJECT
4 changes: 3 additions & 1 deletion .ci/gcb-vcr-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ steps:
- name: 'gcr.io/graphite-docker-images/go-plus'
id: gcb-vcr-nightly
entrypoint: '/workspace/.ci/scripts/go-plus/magician/exec.sh'
secretEnv: ["GOOGLE_BILLING_ACCOUNT", "GOOGLE_CHRONICLE_INSTANCE_ID", "GOOGLE_CUST_ID", "GOOGLE_IDENTITY_USER", "GOOGLE_MASTER_BILLING_ACCOUNT", "GOOGLE_ORG", "GOOGLE_ORG_2", "GOOGLE_ORG_DOMAIN", "GOOGLE_PROJECT", "GOOGLE_PROJECT_NUMBER", "GOOGLE_SERVICE_ACCOUNT", "SA_KEY", "GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION", "GITHUB_TOKEN_CLASSIC"]
secretEnv: ["GOOGLE_BILLING_ACCOUNT", "GOOGLE_CHRONICLE_INSTANCE_ID", "GOOGLE_CUST_ID", "GOOGLE_IDENTITY_USER", "GOOGLE_MASTER_BILLING_ACCOUNT", "GOOGLE_ORG", "GOOGLE_ORG_2", "GOOGLE_ORG_DOMAIN", "GOOGLE_PROJECT", "GOOGLE_PROJECT_NUMBER", "GOOGLE_SERVICE_ACCOUNT", "SA_KEY", "GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION", "GITHUB_TOKEN_CLASSIC", "GOOGLE_VMWAREENGINE_PROJECT"]
env:
- "GOOGLE_REGION=us-central1"
- "GOOGLE_ZONE=us-central1-a"
Expand Down Expand Up @@ -48,3 +48,5 @@ availableSecrets:
env: GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION
- versionName: projects/673497134629/secrets/github-classic--repo-workflow/versions/latest
env: GITHUB_TOKEN_CLASSIC
- versionName: projects/673497134629/secrets/ci-test-vmwareengine-project/versions/latest
env: GOOGLE_VMWAREENGINE_PROJECT
1 change: 1 addition & 0 deletions .ci/magician/cmd/check_cassettes.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var ccRequiredEnvironmentVariables = [...]string{

var ccOptionalEnvironmentVariables = [...]string{
"GOOGLE_CHRONICLE_INSTANCE_ID",
"GOOGLE_VMWAREENGINE_PROJECT",
}

var checkCassettesCmd = &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions .ci/magician/cmd/test_eap_vcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var tevOptionalEnvironmentVariables = [...]string{
"GOOGLE_ORG_2",
"GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION",
"GOOGLE_SERVICE_ACCOUNT",
"GOOGLE_VMWAREENGINE_PROJECT",
}

var testEAPVCRCmd = &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions .ci/magician/cmd/test_terraform_vcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var ttvRequiredEnvironmentVariables = [...]string{

var ttvOptionalEnvironmentVariables = [...]string{
"GOOGLE_CHRONICLE_INSTANCE_ID",
"GOOGLE_VMWAREENGINE_PROJECT",
}

type analytics struct {
Expand Down
1 change: 1 addition & 0 deletions .ci/magician/cmd/vcr_cassette_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var vcuRequiredEnvironmentVariables = [...]string{

var vcuOptionalEnvironmentVariables = [...]string{
"GOOGLE_CHRONICLE_INSTANCE_ID",
"GOOGLE_VMWAREENGINE_PROJECT",
}

var (
Expand Down
1 change: 1 addition & 0 deletions .ci/magician/vcr/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var safeToLog = map[string]bool{
"GOOGLE_REGION": true,
"GOOGLE_SERVICE_ACCOUNT": true,
"GOOGLE_TEST_DIRECTORY": true,
"GOOGLE_VMWAREENGINE_PROJECT": true,
"GOOGLE_ZONE": true,
"GOPATH": true,
"HOME": true,
Expand Down
28 changes: 15 additions & 13 deletions mmv1/api/resource/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Examples struct {
// - :CUST_ID
// - :IDENTITY_USER
// - :CHRONICLE_ID
// - :VMWAREENGINE_PROJECT
// This list corresponds to the `get*FromEnv` methods in provider_test.go.
TestEnvVars map[string]string `yaml:"test_env_vars,omitempty"`

Expand Down Expand Up @@ -215,19 +216,20 @@ func (e *Examples) SetHCLText() {
originalTestEnvVars := e.TestEnvVars
docTestEnvVars := make(map[string]string)
docs_defaults := map[string]string{
"PROJECT_NAME": "my-project-name",
"CREDENTIALS": "my/credentials/filename.json",
"REGION": "us-west1",
"ORG_ID": "123456789",
"ORG_DOMAIN": "example.com",
"ORG_TARGET": "123456789",
"BILLING_ACCT": "000000-0000000-0000000-000000",
"MASTER_BILLING_ACCT": "000000-0000000-0000000-000000",
"SERVICE_ACCT": "[email protected]",
"CUST_ID": "A01b123xz",
"IDENTITY_USER": "cloud_identity_user",
"PAP_DESCRIPTION": "description",
"CHRONICLE_ID": "00000000-0000-0000-0000-000000000000",
"PROJECT_NAME": "my-project-name",
"CREDENTIALS": "my/credentials/filename.json",
"REGION": "us-west1",
"ORG_ID": "123456789",
"ORG_DOMAIN": "example.com",
"ORG_TARGET": "123456789",
"BILLING_ACCT": "000000-0000000-0000000-000000",
"MASTER_BILLING_ACCT": "000000-0000000-0000000-000000",
"SERVICE_ACCT": "[email protected]",
"CUST_ID": "A01b123xz",
"IDENTITY_USER": "cloud_identity_user",
"PAP_DESCRIPTION": "description",
"CHRONICLE_ID": "00000000-0000-0000-0000-000000000000",
"VMWAREENGINE_PROJECT": "my-vmwareengine-project",
}

// Apply doc defaults to test_env_vars from YAML
Expand Down
66 changes: 34 additions & 32 deletions mmv1/provider/template_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,23 @@ func (td *TemplateData) GenerateTestFile(filePath string, resource api.Resource)
templatePath,
}
tmplInput := TestInput{
Res: resource,
ImportPath: td.ImportPath(),
PROJECT_NAME: "my-project-name",
CREDENTIALS: "my/credentials/filename.json",
REGION: "us-west1",
ORG_ID: "123456789",
ORG_DOMAIN: "example.com",
ORG_TARGET: "123456789",
PROJECT_NUMBER: "1111111111111",
BILLING_ACCT: "000000-0000000-0000000-000000",
MASTER_BILLING_ACCT: "000000-0000000-0000000-000000",
SERVICE_ACCT: "[email protected]",
CUST_ID: "A01b123xz",
IDENTITY_USER: "cloud_identity_user",
PAP_DESCRIPTION: "description",
CHRONICLE_ID: "00000000-0000-0000-0000-000000000000",
Res: resource,
ImportPath: td.ImportPath(),
PROJECT_NAME: "my-project-name",
CREDENTIALS: "my/credentials/filename.json",
REGION: "us-west1",
ORG_ID: "123456789",
ORG_DOMAIN: "example.com",
ORG_TARGET: "123456789",
PROJECT_NUMBER: "1111111111111",
BILLING_ACCT: "000000-0000000-0000000-000000",
MASTER_BILLING_ACCT: "000000-0000000-0000000-000000",
SERVICE_ACCT: "[email protected]",
CUST_ID: "A01b123xz",
IDENTITY_USER: "cloud_identity_user",
PAP_DESCRIPTION: "description",
CHRONICLE_ID: "00000000-0000-0000-0000-000000000000",
VMWAREENGINE_PROJECT: "my-vmwareengine-project",
}

td.GenerateFile(filePath, templatePath, tmplInput, true, templates...)
Expand Down Expand Up @@ -283,20 +284,21 @@ func FixImports(outputPath string, dumpDiffs bool) {
}

type TestInput struct {
Res api.Resource
ImportPath string
PROJECT_NAME string
CREDENTIALS string
REGION string
ORG_ID string
ORG_DOMAIN string
ORG_TARGET string
PROJECT_NUMBER string
BILLING_ACCT string
MASTER_BILLING_ACCT string
SERVICE_ACCT string
CUST_ID string
IDENTITY_USER string
PAP_DESCRIPTION string
CHRONICLE_ID string
Res api.Resource
ImportPath string
PROJECT_NAME string
CREDENTIALS string
REGION string
ORG_ID string
ORG_DOMAIN string
ORG_TARGET string
PROJECT_NUMBER string
BILLING_ACCT string
MASTER_BILLING_ACCT string
SERVICE_ACCT string
CUST_ID string
IDENTITY_USER string
PAP_DESCRIPTION string
CHRONICLE_ID string
VMWAREENGINE_PROJECT string
}
2 changes: 2 additions & 0 deletions mmv1/templates/terraform/env_var_context.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"{{$varKey}}": envvar.GetTestPublicAdvertisedPrefixDescriptionFromEnv(t),
{{- else if eq $varVal "CHRONICLE_ID" }}
"{{$varKey}}": envvar.GetTestChronicleInstanceIdFromEnv(t),
{{- else if eq $varVal "VMWAREENGINE_PROJECT" }}
"{{$varKey}}": envvar.GetTestVmwareengineProjectFromEnv(t),
{{- else if eq $varVal "ZONE" }}
"{{$varKey}}": envvar.GetTestZoneFromEnv(),
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class AllContextParameters(
val chronicleInstanceIdBeta: String,
val chronicleInstanceIdVcr: String,

// GOOGLE_VMWAREENGINE_PROJECT
val vmwareengineProjectGa: String,
val vmwareengineProjectBeta: String,
val vmwareengineProjectVcr: String,

// Values that are the same across GA, Beta, and VCR testing environments
val billingAccount: String, // GOOGLE_BILLING_ACCOUNT
val billingAccount2: String, // GOOGLE_BILLING_ACCOUNT_2
Expand Down Expand Up @@ -94,6 +99,7 @@ class AccTestConfiguration(
val projectNumber: String,
val region: String,
val serviceAccount: String,
val vmwareengineProject: String,
val zone: String,

// VCR specific
Expand All @@ -120,6 +126,7 @@ fun getGaAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigura
allConfig.projectNumberGa,
allConfig.region,
allConfig.serviceAccountGa,
allConfig.vmwareengineProjectGa,
allConfig.zone,
allConfig.infraProject,
allConfig.vcrBucketName,
Expand All @@ -143,6 +150,7 @@ fun getBetaAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigu
allConfig.projectNumberBeta,
allConfig.region,
allConfig.serviceAccountBeta,
allConfig.vmwareengineProjectBeta,
allConfig.zone,
allConfig.infraProject,
allConfig.vcrBucketName,
Expand All @@ -166,6 +174,7 @@ fun getVcrAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigur
allConfig.projectNumberVcr,
allConfig.region,
allConfig.serviceAccountVcr,
allConfig.vmwareengineProjectVcr,
allConfig.zone,
allConfig.infraProject,
allConfig.vcrBucketName,
Expand All @@ -190,6 +199,7 @@ fun ParametrizedWithType.configureGoogleSpecificTestParameters(config: AccTestCo
hiddenVariable("env.GOOGLE_ZONE", config.zone, "The google zone to use")
hiddenVariable("env.GOOGLE_IDENTITY_USER", config.identityUser, "The user for the identity platform")
hiddenVariable("env.GOOGLE_CHRONICLE_INSTANCE_ID", config.chronicleInstanceId, "The id of the Chronicle instance")
hiddenVariable("env.GOOGLE_VMWAREENGINE_PROJECT", config.vmwareengineProject, "The project used for vmwareengine tests")
hiddenPasswordVariable("env.GOOGLE_CREDENTIALS", config.credentials, "The Google credentials for this test runner")
}

Expand Down
7 changes: 7 additions & 0 deletions mmv1/third_party/terraform/.teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ val org2Vcr = DslContext.getParameter("org2Vcr", "")
val chronicleInstanceIdGa = DslContext.getParameter("chronicleInstanceIdGa", "")
val chronicleInstanceIdBeta = DslContext.getParameter("chronicleInstanceIdBeta", "")
val chronicleInstanceIdVcr = DslContext.getParameter("chronicleInstanceIdVcr", "")
// GOOGLE_VMWAREENGINE_PROJECT
val vmwareengineProjectGa = DslContext.getParameter("vmwareengineProjectGa", "")
val vmwareengineProjectBeta = DslContext.getParameter("vmwareengineProjectBeta", "")
val vmwareengineProjectVcr = DslContext.getParameter("vmwareengineProjectVcr", "")

// Values that are the same across GA, Beta, and VCR testing environments
val billingAccount = DslContext.getParameter("billingAccount", "") // GOOGLE_BILLING_ACCOUNT
Expand Down Expand Up @@ -91,6 +95,9 @@ var allContextParams = AllContextParameters(
chronicleInstanceIdGa,
chronicleInstanceIdBeta,
chronicleInstanceIdVcr,
vmwareengineProjectGa,
vmwareengineProjectBeta,
vmwareengineProjectVcr,
billingAccount,
billingAccount2,
custId,
Expand Down
3 changes: 3 additions & 0 deletions mmv1/third_party/terraform/.teamcity/tests/test_utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ fun testContextParameters(): AllContextParameters {
"chronicleInstanceIdGa",
"chronicleInstanceIdBeta",
"chronicleInstanceIdVcr",
"vmwareengineProjectGa",
"vmwareengineProjectBeta",
"vmwareengineProjectVcr",
"billingAccount",
"billingAccount2",
"custId",
Expand Down
11 changes: 11 additions & 0 deletions mmv1/third_party/terraform/envvar/envvar_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ var ImpersonateServiceAccountEnvVars = []string{
"GOOGLE_IMPERSONATE_SERVICE_ACCOUNT",
}

// This value is the project used for vmwareengine tests. A separate project is needed
// due to the limited quota allocated to each testing project
var vmwareengineProjectEnvVars = []string{
"GOOGLE_VMWAREENGINE_PROJECT",
}

// AccTestPreCheck ensures at least one of the project env variables is set.
func GetTestProjectNumberFromEnv() string {
return transport_tpg.MultiEnvSearch(ProjectNumberEnvVars)
Expand Down Expand Up @@ -215,6 +221,11 @@ func GetTestChronicleInstanceIdFromEnv(t *testing.T) string {
return transport_tpg.MultiEnvSearch(ChronicleInstanceIdEnvVars)
}

func GetTestVmwareengineProjectFromEnv(t *testing.T) string {
SkipIfEnvNotSet(t, vmwareengineProjectEnvVars...)
return transport_tpg.MultiEnvSearch(vmwareengineProjectEnvVars)
}

func SkipIfEnvNotSet(t *testing.T, envs ...string) {
if t == nil {
log.Printf("[DEBUG] Not running inside of test - skip skipping")
Expand Down

0 comments on commit 415b35b

Please sign in to comment.