From 95e9063bb8ef57edbb97eb060f320fb4e3251198 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 18 Dec 2024 18:03:35 +0000 Subject: [PATCH] Add envvar GOOGLE_CHRONICLE_INSTANCE_ID for tests (#12536) [upstream:0052688447f35fe46cecb1f418520295f9007b9c] Signed-off-by: Modular Magician --- .changelog/12536.txt | 3 +++ .teamcity/components/builds/build_parameters.kt | 10 ++++++++++ .teamcity/settings.kts | 7 +++++++ .teamcity/tests/test_utils.kt | 3 +++ google/envvar/envvar_utils.go | 12 ++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 .changelog/12536.txt diff --git a/.changelog/12536.txt b/.changelog/12536.txt new file mode 100644 index 00000000000..42b910df155 --- /dev/null +++ b/.changelog/12536.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` \ No newline at end of file diff --git a/.teamcity/components/builds/build_parameters.kt b/.teamcity/components/builds/build_parameters.kt index 8e9942934f3..8b1f9ac42d0 100644 --- a/.teamcity/components/builds/build_parameters.kt +++ b/.teamcity/components/builds/build_parameters.kt @@ -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 @@ -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, @@ -108,6 +114,7 @@ fun getGaAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigura allConfig.masterBillingAccountGa, allConfig.org, allConfig.org2Ga, + allConfig.chronicleInstanceIdGa, allConfig.orgDomain, allConfig.projectGa, allConfig.projectNumberGa, @@ -130,6 +137,7 @@ fun getBetaAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigu allConfig.masterBillingAccountBeta, allConfig.org, allConfig.org2Beta, + allConfig.chronicleInstanceIdBeta, allConfig.orgDomain, allConfig.projectBeta, allConfig.projectNumberBeta, @@ -152,6 +160,7 @@ fun getVcrAcceptanceTestConfig(allConfig: AllContextParameters): AccTestConfigur allConfig.masterBillingAccountVcr, allConfig.org, allConfig.org2Vcr, + allConfig.chronicleInstanceIdVcr, allConfig.orgDomain, allConfig.projectVcr, allConfig.projectNumberVcr, @@ -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") } diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index ac329c4bd6b..f9bab43f5ee 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -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 @@ -84,6 +88,9 @@ var allContextParams = AllContextParameters( org2Ga, org2Beta, org2Vcr, + chronicleInstanceIdGa, + chronicleInstanceIdBeta, + chronicleInstanceIdVcr, billingAccount, billingAccount2, custId, diff --git a/.teamcity/tests/test_utils.kt b/.teamcity/tests/test_utils.kt index a1d667790be..71ad0bcd4a2 100644 --- a/.teamcity/tests/test_utils.kt +++ b/.teamcity/tests/test_utils.kt @@ -41,6 +41,9 @@ fun testContextParameters(): AllContextParameters { "org2Ga", "org2Beta", "org2Vcr", + "chronicleInstanceIdGa", + "chronicleInstanceIdBeta", + "chronicleInstanceIdVcr", "billingAccount", "billingAccount2", "custId", diff --git a/google/envvar/envvar_utils.go b/google/envvar/envvar_utils.go index 7b4dff49fcc..d01f215b1dd 100644 --- a/google/envvar/envvar_utils.go +++ b/google/envvar/envvar_utils.go @@ -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", } @@ -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")