Skip to content

Commit

Permalink
Add envvar GOOGLE_CHRONICLE_INSTANCE_ID for tests (#12536)
Browse files Browse the repository at this point in the history
[upstream:0052688447f35fe46cecb1f418520295f9007b9c]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Dec 18, 2024
1 parent b3cd6a6 commit 95e9063
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/12536.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
10 changes: 10 additions & 0 deletions .teamcity/components/builds/build_parameters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class AllContextParameters(
val org2Beta: String,
val org2Vcr: String,

// GOOGLE_CHRONICLE_INSTANCE_ID
val chronicleInstanceIdGa: String,
val chronicleInstanceIdBeta: String,
val chronicleInstanceIdVcr: 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 @@ -83,6 +88,7 @@ class AccTestConfiguration(
val masterBillingAccount: String,
val org: String,
val org2: String,
val chronicleInstanceId: String,
val orgDomain: String,
val project: String,
val projectNumber: String,
Expand All @@ -108,6 +114,7 @@ fun getGaAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigura
allConfig.masterBillingAccountGa,
allConfig.org,
allConfig.org2Ga,
allConfig.chronicleInstanceIdGa,
allConfig.orgDomain,
allConfig.projectGa,
allConfig.projectNumberGa,
Expand All @@ -130,6 +137,7 @@ fun getBetaAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigu
allConfig.masterBillingAccountBeta,
allConfig.org,
allConfig.org2Beta,
allConfig.chronicleInstanceIdBeta,
allConfig.orgDomain,
allConfig.projectBeta,
allConfig.projectNumberBeta,
Expand All @@ -152,6 +160,7 @@ fun getVcrAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigur
allConfig.masterBillingAccountVcr,
allConfig.org,
allConfig.org2Vcr,
allConfig.chronicleInstanceIdVcr,
allConfig.orgDomain,
allConfig.projectVcr,
allConfig.projectNumberVcr,
Expand Down Expand Up @@ -180,6 +189,7 @@ fun ParametrizedWithType.configureGoogleSpecificTestParameters(config: AccTestCo
hiddenVariable("env.GOOGLE_SERVICE_ACCOUNT", config.serviceAccount, "The service account")
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")
hiddenPasswordVariable("env.GOOGLE_CREDENTIALS", config.credentials, "The Google credentials for this test runner")
}

Expand Down
7 changes: 7 additions & 0 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ val masterBillingAccountVcr = DslContext.getParameter("masterBillingAccountVcr"
val org2Ga = DslContext.getParameter("org2Ga", "")
val org2Beta = DslContext.getParameter("org2Beta", "")
val org2Vcr = DslContext.getParameter("org2Vcr", "")
// GOOGLE_CHRONICLE_INSTANCE_ID
val chronicleInstanceIdGa = DslContext.getParameter("chronicleInstanceIdGa", "")
val chronicleInstanceIdBeta = DslContext.getParameter("chronicleInstanceIdBeta", "")
val chronicleInstanceIdVcr = DslContext.getParameter("chronicleInstanceIdVcr", "")

// Values that are the same across GA, Beta, and VCR testing environments
val billingAccount = DslContext.getParameter("billingAccount", "") // GOOGLE_BILLING_ACCOUNT
Expand Down Expand Up @@ -84,6 +88,9 @@ var allContextParams = AllContextParameters(
org2Ga,
org2Beta,
org2Vcr,
chronicleInstanceIdGa,
chronicleInstanceIdBeta,
chronicleInstanceIdVcr,
billingAccount,
billingAccount2,
custId,
Expand Down
3 changes: 3 additions & 0 deletions .teamcity/tests/test_utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ fun testContextParameters(): AllContextParameters {
"org2Ga",
"org2Beta",
"org2Vcr",
"chronicleInstanceIdGa",
"chronicleInstanceIdBeta",
"chronicleInstanceIdVcr",
"billingAccount",
"billingAccount2",
"custId",
Expand Down
12 changes: 12 additions & 0 deletions google/envvar/envvar_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ var PapDescriptionEnvVars = []string{
"GOOGLE_PUBLIC_AVERTISED_PREFIX_DESCRIPTION",
}

// This value is the instance id of a pre-configured Chronicle instance, for the purpose of
// integration tests. It is needed because the instance is 1-to-1 with a test project, and it
// cannot be created within the test org.
var ChronicleInstanceIdEnvVars = []string{
"GOOGLE_CHRONICLE_INSTANCE_ID",
}

var ImpersonateServiceAccountEnvVars = []string{
"GOOGLE_IMPERSONATE_SERVICE_ACCOUNT",
}
Expand Down Expand Up @@ -205,6 +212,11 @@ func GetTestPublicAdvertisedPrefixDescriptionFromEnv(t *testing.T) string {
return transport_tpg.MultiEnvSearch(PapDescriptionEnvVars)
}

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

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 95e9063

Please sign in to comment.