Skip to content

Commit

Permalink
Tooling: TeamCity cron based scheduling (#12549)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofallops authored Jul 13, 2021
1 parent 88d2264 commit bf0bcf3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
9 changes: 6 additions & 3 deletions .teamcity/components/build_components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@ fun ParametrizedWithType.hiddenPasswordVariable(name: String, value: String, des
password(name, value, "", description, ParameterDisplay.HIDDEN)
}

fun Triggers.RunNightly(nightlyTestsEnabled: Boolean, startHour: Int) {
fun Triggers.RunNightly(nightlyTestsEnabled: Boolean, startHour: Int, daysOfWeek: String, daysOfMonth: String) {
schedule{
enabled = nightlyTestsEnabled
branchFilter = "+:refs/heads/master"

schedulingPolicy = daily {
hour = startHour
schedulingPolicy = cron {
hours = startHour.toString()
timezone = "SERVER"

dayOfWeek = daysOfWeek
dayOfMonth = daysOfMonth
}
}
}
4 changes: 2 additions & 2 deletions .teamcity/components/build_config_service.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class serviceDetails(name: String, displayName: String, environment: String) {
val displayName = displayName
val environment = environment

fun buildConfiguration(providerName : String, nightlyTestsEnabled: Boolean, startHour: Int, parallelism: Int) : BuildType {
fun buildConfiguration(providerName : String, nightlyTestsEnabled: Boolean, startHour: Int, parallelism: Int, daysOfWeek: String, daysOfMonth: String) : BuildType {
return BuildType {
// TC needs a consistent ID for dynamically generated packages
id(uniqueID(providerName))
Expand Down Expand Up @@ -41,7 +41,7 @@ class serviceDetails(name: String, displayName: String, environment: String) {
}

triggers {
RunNightly(nightlyTestsEnabled, startHour)
RunNightly(nightlyTestsEnabled, startHour, daysOfWeek, daysOfMonth)
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions .teamcity/components/project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ fun buildConfigurationsForServices(services: Map<String, String>, providerName :

services.forEach { (serviceName, displayName) ->
// TODO: overriding locations
var defaultTestConfig = testConfiguration(defaultParallelism, defaultStartHour)
var defaultTestConfig = testConfiguration()
var testConfig = serviceTestConfigurationOverrides.getOrDefault(serviceName, defaultTestConfig)
var runNightly = runNightly.getOrDefault(environment, false)

var service = serviceDetails(serviceName, displayName, environment)
var buildConfig = service.buildConfiguration(providerName, runNightly, testConfig.startHour, testConfig.parallelism)
var buildConfig = service.buildConfiguration(providerName, runNightly, testConfig.startHour, testConfig.parallelism, testConfig.daysOfWeek, testConfig.daysOfMonth)

buildConfig.params.ConfigureAzureSpecificTestParameters(environment, config, locationsForEnv)

Expand All @@ -46,7 +46,9 @@ fun pullRequestBuildConfiguration(environment: String, configuration: ClientConf
return buildConfiguration
}

class testConfiguration(parallelism: Int, startHour: Int) {
class testConfiguration(parallelism: Int = defaultParallelism, startHour: Int = defaultStartHour, daysOfWeek: String = defaultDaysOfWeek, daysOfMonth: String = defaultDaysOfMonth) {
var parallelism = parallelism
var startHour = startHour
var daysOfWeek = daysOfWeek
var daysOfMonth = daysOfMonth
}
45 changes: 30 additions & 15 deletions .teamcity/components/settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ var defaultStartHour = 0
var defaultParallelism = 20

// specifies the default version of Terraform Core which should be used for testing
var defaultTerraformCoreVersion = "1.0.0"
var defaultTerraformCoreVersion = "1.0.1"

// This represents a cron view of days of the week, Monday - Friday.
const val defaultDaysOfWeek = "1,2,3,4,5"

// Cron value for any day of month
const val defaultDaysOfMonth = "*"

var locations = mapOf(
"public" to LocationConfiguration("westeurope", "eastus2", "francecentral", false),
Expand All @@ -20,40 +26,49 @@ var runNightly = mapOf(
// specifies a list of services which should be run with a custom test configuration
var serviceTestConfigurationOverrides = mapOf(
// these tests all conflict with one another
"authorization" to testConfiguration(1, defaultStartHour),
"authorization" to testConfiguration(parallelism = 1),

//Blueprints are constrained on the number of targets available - these execute quickly, so can be serialised
"blueprints" to testConfiguration(1, defaultStartHour),
"blueprints" to testConfiguration(parallelism = 1),

// "cognitive" is expensive - Monday, Wednesday, Friday
"cognitive" to testConfiguration(daysOfWeek = "1,3,5"),

// The AKS API has a low rate limit
"containers" to testConfiguration(5, defaultStartHour),
"containers" to testConfiguration(parallelism = 5),

// Data Lake has a low quota
"datalake" to testConfiguration(2, defaultStartHour),
"datalake" to testConfiguration(parallelism = 2),

// "hdinsight" is super expensive
"hdinsight" to testConfiguration(daysOfWeek = "1,3,5"),

// HPC Cache has a 4 instance per subscription quota as of early 2021
"hpccache" to testConfiguration(3, defaultStartHour),
"hpccache" to testConfiguration(parallelism = 3, daysOfWeek = "1,3,5"),

// HSM has low quota and potentially slow recycle time
"hsm" to testConfiguration(1, defaultStartHour),
// HSM has low quota and potentially slow recycle time, Only run on Mondays
"hsm" to testConfiguration(parallelism = 1, daysOfWeek = "1"),

// Log Analytics Clusters have a max deployments of 2 - parallelism set to 1 or `importTest` fails
"loganalytics" to testConfiguration(1, defaultStartHour),
"loganalytics" to testConfiguration(parallelism = 1),

// netapp has a max of 20 accounts per subscription so lets limit it to 10 to account for broken ones, run Monday, Wednesday, Friday
"netapp" to testConfiguration(parallelism = 10, daysOfWeek = "1,3,5"),

// netapp has a max of 20 accounts per subscription so lets limit it to 10 to account for broken ones
"netapp" to testConfiguration(10, defaultStartHour),
// redisenterprise is costly - Monday, Wednesday, Friday
"redisenterprise" to testConfiguration(daysOfWeek = "1,3,5"),

// servicebus quotas are limited and we experience failures if tests
// execute too quickly as we run out of namespaces in the sub
"servicebus" to testConfiguration(10, defaultStartHour),
"servicebus" to testConfiguration(parallelism = 10),

// SignalR only allows provisioning one "Free" instance at a time,
// which is used in multiple tests
"signalr" to testConfiguration(1, defaultStartHour),
"signalr" to testConfiguration(parallelism = 1),

// Spring Cloud only allows a max of 10 provisioned
"springcloud" to testConfiguration(5, defaultStartHour),
"springcloud" to testConfiguration(parallelism = 5),

// Currently have a quota of 10 nodes, 3 nodes required per test so lets limit it to 3
"vmware" to testConfiguration(3, defaultStartHour)
"vmware" to testConfiguration(parallelism = 3)
)

0 comments on commit bf0bcf3

Please sign in to comment.