-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TeamCity: add Ephemeral-write-only subproject #12538
Merged
BBBmau
merged 8 commits into
GoogleCloudPlatform:main
from
BBBmau:add-ephemeral-write-only-tc
Dec 17, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
64fa030
add Ephemeral-write-only subproject into teamcity
BBBmau ea46802
fix teamcity config
BBBmau d909d01
use 1.11 alpha
BBBmau dadf0d3
rewrite to use getServices
BBBmau e800475
add getServices.kt
BBBmau cc29570
root_project add
BBBmau 18aa211
remove unneccessary transformation of paths in get_services.kt
BBBmau aba9b89
add startHour and support for custom testprefix in buildConfigurations
BBBmau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...orm/.teamcity/components/projects/feature_branches/FEATURE-BRANCH-ephemeral-write-only.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
// This file is maintained in the GoogleCloudPlatform/magic-modules repository and copied into the downstream provider repositories. Any changes to this file in the downstream will be overwritten. | ||
|
||
package projects.feature_branches | ||
|
||
import ProviderNameBeta | ||
import ProviderNameGa | ||
import SharedResourceNameBeta | ||
import SharedResourceNameGa | ||
import SharedResourceNameVcr | ||
import builds.* | ||
import generated.ServicesListBeta | ||
import generated.ServicesListGa | ||
import jetbrains.buildServer.configs.kotlin.Project | ||
import replaceCharsId | ||
import vcs_roots.HashiCorpVCSRootBeta | ||
import vcs_roots.HashiCorpVCSRootGa | ||
import vcs_roots.ModularMagicianVCSRootBeta | ||
import vcs_roots.ModularMagicianVCSRootGa | ||
import components.projects.feature_branches.getServicesList | ||
import DefaultStartHour | ||
|
||
const val featureBranchEphemeralWriteOnly = "FEATURE-BRANCH-ephemeral-write-only" | ||
const val EphemeralWriteOnlyTfCoreVersion = "1.11.0-alpha20241211" | ||
|
||
fun featureBranchEphemeralWriteOnlySubProject(allConfig: AllContextParameters): Project { | ||
|
||
val trigger = NightlyTriggerConfiguration( | ||
branch = "refs/heads/$featureBranchEphemeralWriteOnly", // triggered builds must test the feature branch | ||
startHour = DefaultStartHour + 6, | ||
) | ||
val vcrConfig = getVcrAcceptanceTestConfig(allConfig) // Reused below for both MM testing build configs | ||
|
||
// GA | ||
val gaConfig = getGaAcceptanceTestConfig(allConfig) | ||
// These are the packages that have resources that will use write-only attributes | ||
var ServicesListWriteOnlyGA = getServicesList(arrayOf("compute", "secretmanager", "sql", "bigquerydatatransfer"), "GA") | ||
|
||
val buildConfigsGa = BuildConfigurationsForPackages(ServicesListWriteOnlyGA, ProviderNameGa, "EphemeralWriteOnlyGa - HC", HashiCorpVCSRootGa, listOf(SharedResourceNameGa), gaConfig, "TestAcc.*Ephemeral") | ||
buildConfigsGa.forEach{ builds -> | ||
builds.addTrigger(trigger) | ||
} | ||
|
||
var ServicesListWriteOnlyGaMM = getServicesList(arrayOf("compute", "secretmanager", "sql", "bigquerydatatransfer"), "GA-MM") | ||
val buildConfigsMMGa = BuildConfigurationsForPackages(ServicesListWriteOnlyGaMM, ProviderNameGa, "EphemeralWriteOnlyGa - MM", ModularMagicianVCSRootGa, listOf(SharedResourceNameGa), vcrConfig, "TestAcc.*Ephemeral") | ||
|
||
// Beta | ||
val betaConfig = getBetaAcceptanceTestConfig(allConfig) | ||
var ServicesListWriteOnlyBeta = getServicesList(arrayOf("compute", "secretmanager", "sql", "bigquerydatatransfer"), "Beta") | ||
val buildConfigsBeta = BuildConfigurationsForPackages(ServicesListWriteOnlyBeta, ProviderNameBeta, "EphemeralWriteOnlyBeta - HC", HashiCorpVCSRootBeta, listOf(SharedResourceNameBeta), betaConfig, "TestAcc.*Ephemeral") | ||
buildConfigsBeta.forEach{ builds -> | ||
builds.addTrigger(trigger) | ||
} | ||
|
||
var ServicesListWriteOnlyBetaMM = getServicesList(arrayOf("compute", "secretmanager", "sql", "bigquerydatatransfer"), "Beta-MM") | ||
val buildConfigsMMBeta = BuildConfigurationsForPackages(ServicesListWriteOnlyBetaMM, ProviderNameBeta, "EphemeralWriteOnlyBeta - MM", ModularMagicianVCSRootBeta, listOf(SharedResourceNameBeta), vcrConfig, "TestAcc.*Ephemeral") | ||
|
||
// Make all builds use a 1.11.0-ish version of TF core | ||
val allBuildConfigs = buildConfigsGa + buildConfigsBeta + buildConfigsMMGa + buildConfigsMMBeta | ||
allBuildConfigs.forEach{ builds -> | ||
builds.overrideTerraformCoreVersion(EphemeralWriteOnlyTfCoreVersion) | ||
} | ||
|
||
// ------ | ||
|
||
return Project{ | ||
id("FEATURE_BRANCH_ephemeral_write_only") | ||
name = featureBranchEphemeralWriteOnly | ||
description = "Subproject for testing feature branch $featureBranchEphemeralWriteOnly" | ||
|
||
// Register all build configs in the project | ||
allBuildConfigs.forEach{ builds -> | ||
buildType(builds) | ||
} | ||
|
||
params { | ||
readOnlySettings() | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
mmv1/third_party/terraform/.teamcity/components/projects/feature_branches/get_services.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package components.projects.feature_branches | ||
|
||
import generated.ServicesListGa | ||
import generated.ServicesListBeta | ||
|
||
// This file is maintained in the GoogleCloudPlatform/magic-modules repository and copied into the downstream provider repositories. Any changes to this file in the downstream will be overwritten. | ||
|
||
// This function is used to get the services list for a given version. Typically used in feature branch builds for testing very specific services only. | ||
fun getServicesList(Services: Array<String>, version: String): Map<String,Map<String,String>> { | ||
if (Services.isEmpty()) { | ||
throw Exception("No services found for version $version") | ||
} | ||
|
||
var servicesList = mutableMapOf<String,Map<String,String>>() | ||
for (service in Services) { | ||
if (version == "GA" || version == "GA-MM") { | ||
servicesList[service] = ServicesListGa.getOrElse(service) { throw Exception("Service $service not found") } | ||
} else if (version == "Beta" || version == "Beta-MM") { | ||
servicesList[service] = ServicesListBeta.getOrElse(service) { throw Exception("Service $service not found") } | ||
} else { | ||
throw Exception("Invalid version $version") | ||
} | ||
} | ||
|
||
when (version) { | ||
"GA" -> servicesList | ||
"Beta" -> { | ||
servicesList.mapValues { (_, value) -> | ||
value + mapOf( | ||
"displayName" to "${value["displayName"]} - Beta" | ||
) | ||
}.toMutableMap() | ||
} | ||
"GA-MM" -> { | ||
servicesList.mapValues { (_, value) -> | ||
value + mapOf( | ||
"displayName" to "${value["displayName"]} - MM" | ||
) | ||
}.toMutableMap() | ||
} | ||
"Beta-MM" -> { | ||
servicesList.mapValues { (_, value) -> | ||
value + mapOf( | ||
"displayName" to "${value["displayName"]} - Beta - MM" | ||
) | ||
}.toMutableMap() | ||
} | ||
else -> throw Exception("Invalid version $version") | ||
}.also { servicesList = it as MutableMap<String, Map<String, String>> } | ||
|
||
return servicesList | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
mmv1/third_party/terraform/.teamcity/tests/FEATURE-BRANCH-ephemera-write-only.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
// This file is maintained in the GoogleCloudPlatform/magic-modules repository and copied into the downstream provider repositories. Any changes to this file in the downstream will be overwritten. | ||
|
||
package tests | ||
|
||
import jetbrains.buildServer.configs.kotlin.triggers.ScheduleTrigger | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import projects.feature_branches.featureBranchEphemeralWriteOnly | ||
import projects.googleCloudRootProject | ||
|
||
class FeatureBranchEphemeralWriteOnlySubProject { | ||
@Test | ||
fun buildsUsingHashiCorpReposAreOnSchedule() { | ||
val root = googleCloudRootProject(testContextParameters()) | ||
|
||
// Find feature branch project | ||
val project = getSubProject(root, featureBranchEphemeralWriteOnly ) | ||
|
||
// All builds using the HashiCorp owned GitHub repos | ||
val hashiBuilds = project.buildTypes.filter { bt -> | ||
bt.name.contains("HashiCorp downstream") | ||
} | ||
|
||
hashiBuilds.forEach{bt -> | ||
Assert.assertTrue( | ||
"Build configuration `${bt.name}` should contain at least one trigger", | ||
bt.triggers.items.isNotEmpty() | ||
) | ||
// Look for at least one CRON trigger | ||
var found = false | ||
lateinit var schedulingTrigger: ScheduleTrigger | ||
for (item in bt.triggers.items){ | ||
if (item.type == "schedulingTrigger") { | ||
schedulingTrigger = item as ScheduleTrigger | ||
found = true | ||
break | ||
} | ||
} | ||
|
||
Assert.assertTrue( | ||
"Build configuration `${bt.name}` should contain a CRON/'schedulingTrigger' trigger", | ||
found | ||
) | ||
|
||
// Check that triggered builds are being run on the feature branch | ||
val isCorrectBranch: Boolean = schedulingTrigger.branchFilter == "+:refs/heads/$featureBranchEphemeralWriteOnly" | ||
|
||
Assert.assertTrue( | ||
"Build configuration `${bt.name}` is using the $featureBranchEphemeralWriteOnly branch filter", | ||
isCorrectBranch | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun buildsUsingModularMagicianReposAreNotTriggered() { | ||
val root = googleCloudRootProject(testContextParameters()) | ||
|
||
// Find feature branch project | ||
val project = getSubProject(root, featureBranchEphemeralWriteOnly) | ||
|
||
// All builds using the HashiCorp owned GitHub repos | ||
val magicianBuilds = project.buildTypes.filter { bt -> | ||
bt.name.contains("MM upstream") | ||
} | ||
|
||
magicianBuilds.forEach{bt -> | ||
Assert.assertTrue( | ||
"Build configuration `${bt.name}` should not have any triggers", | ||
bt.triggers.items.isEmpty() | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to see that the new project will be limited to only the necessary services! 🙌🏻 Though the Compute build is one of our longest running builds... so running those tests in the feature branch testing project as well as the nightlies could cause some issues.
That's something to keep an eye on, at least. You could even add services to this list progressively over time, instead of adding them all now, to limit impact. Or you could change the trigger time (see other comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was also the idea of changing the test prefix within the write-only subproject to only run Tests with
TestAccEphemeral_
though we would miss out on making sure all other tests aren't affected.I could ensure that all other tests pass by manually triggering them to run the suite entirely, I'm leaning towards this in order to not have to make any TC updates in the future such as including it as part of the
getServices
list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good to me, as long as you're aware there's a potential problem and you've got options about how to navigate it then I'm good 👍🏻