Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 1 | # Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Test gen_luci_scheduler.""" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 6 | |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 7 | from chromite.config import chromeos_config |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 8 | from chromite.lib import config_lib |
| 9 | from chromite.lib import config_lib_unittest |
Mike Frysinger | 807d828 | 2022-04-28 22:45:17 -0400 | [diff] [blame] | 10 | from chromite.lib import cros_test_lib |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 11 | from chromite.scripts import gen_luci_scheduler |
| 12 | |
Mike Frysinger | 74a6cc8 | 2020-02-14 14:16:22 -0500 | [diff] [blame] | 13 | |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 14 | # It's reasonable for unittests to look at internals. |
| 15 | # pylint: disable=protected-access |
| 16 | |
| 17 | |
| 18 | class GenLuciSchedulerTest(cros_test_lib.MockTestCase): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 19 | """Tests for cbuildbot_launch script.""" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 20 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 21 | def testSanityAgainstProd(self): |
| 22 | """Test we can generate a luci scheduler config with live data.""" |
| 23 | # If it runs without crashing, we pass. |
| 24 | gen_luci_scheduler.genLuciSchedulerConfig( |
| 25 | config_lib.GetConfig(), chromeos_config.BranchScheduleConfig() |
| 26 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 27 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 28 | def testGenSchedulerJob(self): |
| 29 | """Test the job creation helper.""" |
| 30 | build_config = config_lib_unittest.MockBuildConfig().apply( |
| 31 | schedule="funky schedule" |
| 32 | ) |
| 33 | |
| 34 | expected = """ |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 35 | job { |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 36 | id: "amd64-generic-release" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 37 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 38 | acl_sets: "default" |
| 39 | schedule: "funky schedule" |
| 40 | buildbucket: { |
| 41 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 42 | bucket: "general" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 43 | builder: "LegacyRelease" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 44 | tags: "cbb_branch:main" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 45 | tags: "cbb_config:amd64-generic-release" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 46 | tags: "cbb_display_label:MockLabel" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 47 | properties: "cbb_branch:main" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 48 | properties: "cbb_config:amd64-generic-release" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 49 | properties: "cbb_display_label:MockLabel" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 50 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 51 | } |
| 52 | } |
Mike Frysinger | 80de501 | 2019-08-01 14:10:53 -0400 | [diff] [blame] | 53 | """ |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 54 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 55 | result = gen_luci_scheduler.genSchedulerJob(build_config) |
| 56 | self.assertEqual(result, expected) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 57 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 58 | def testGenSchedulerTriggerSimple(self): |
| 59 | """Test the trigger creation helper.""" |
| 60 | trigger_name = "simple" |
| 61 | repo = "url://repo" |
| 62 | refs = ["refs/path"] |
| 63 | path_regexps = ["path/regexps"] |
| 64 | builds = ["test_build"] |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 65 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 66 | expected = """ |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 67 | trigger { |
| 68 | id: "simple" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 69 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 70 | acl_sets: "default" |
| 71 | schedule: "with 5m interval" |
| 72 | gitiles: { |
| 73 | repo: "url://repo" |
| 74 | refs: "refs/path" |
David Burger | cba0d27 | 2020-06-24 16:21:26 -0600 | [diff] [blame] | 75 | path_regexps: "path/regexps" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 76 | } |
| 77 | triggers: "test_build" |
| 78 | } |
Mike Frysinger | 80de501 | 2019-08-01 14:10:53 -0400 | [diff] [blame] | 79 | """ |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 80 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 81 | result = gen_luci_scheduler.genSchedulerTrigger( |
| 82 | trigger_name, repo, refs, path_regexps, builds |
| 83 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 84 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 85 | self.assertEqual(result, expected) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 86 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 87 | def testGenSchedulerTriggerComplex(self): |
| 88 | """Test the trigger creation helper.""" |
| 89 | trigger_name = "complex" |
| 90 | repo = "url://repo" |
| 91 | refs = ["refs/path", "refs/other_path"] |
| 92 | builds = ["test_build_a", "test_build_b"] |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 93 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 94 | expected = """ |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 95 | trigger { |
| 96 | id: "complex" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 97 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 98 | acl_sets: "default" |
| 99 | schedule: "with 5m interval" |
| 100 | gitiles: { |
| 101 | repo: "url://repo" |
| 102 | refs: "refs/path" |
| 103 | refs: "refs/other_path" |
| 104 | } |
| 105 | triggers: "test_build_a" |
| 106 | triggers: "test_build_b" |
| 107 | } |
Mike Frysinger | 80de501 | 2019-08-01 14:10:53 -0400 | [diff] [blame] | 108 | """ |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 109 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 110 | result = gen_luci_scheduler.genSchedulerTrigger( |
| 111 | trigger_name, repo, refs, None, builds |
| 112 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 113 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 114 | self.assertEqual(result, expected) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 115 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 116 | def testGenSchedulerBranched(self): |
| 117 | """Test the job creation helper.""" |
| 118 | build_config = config_lib_unittest.MockBuildConfig().apply( |
| 119 | schedule_branch="mock_branch", |
| 120 | schedule="funky schedule", |
| 121 | ) |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 122 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 123 | expected = """ |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 124 | job { |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 125 | id: "mock_branch-amd64-generic-release" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 126 | realm: "cbb-jobs" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 127 | acl_sets: "default" |
| 128 | schedule: "funky schedule" |
| 129 | buildbucket: { |
| 130 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 131 | bucket: "general" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 132 | builder: "LegacyRelease" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 133 | tags: "cbb_branch:mock_branch" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 134 | tags: "cbb_config:amd64-generic-release" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 135 | tags: "cbb_display_label:MockLabel" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 136 | properties: "cbb_branch:mock_branch" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 137 | properties: "cbb_config:amd64-generic-release" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 138 | properties: "cbb_display_label:MockLabel" |
| 139 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 140 | } |
| 141 | } |
Mike Frysinger | 80de501 | 2019-08-01 14:10:53 -0400 | [diff] [blame] | 142 | """ |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 143 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 144 | result = gen_luci_scheduler.genSchedulerJob(build_config) |
| 145 | self.assertEqual(result, expected) |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 146 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 147 | def testGenSchedulerWorkspaceBranch(self): |
| 148 | """Test the job creation helper.""" |
| 149 | build_config = config_lib_unittest.MockBuildConfig().apply( |
| 150 | workspace_branch="work_branch", |
| 151 | schedule="funky schedule", |
| 152 | ) |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 153 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 154 | expected = """ |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 155 | job { |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 156 | id: "amd64-generic-release" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 157 | realm: "cbb-jobs" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 158 | acl_sets: "default" |
| 159 | schedule: "funky schedule" |
| 160 | buildbucket: { |
| 161 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 162 | bucket: "general" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 163 | builder: "LegacyRelease" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 164 | tags: "cbb_branch:main" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 165 | tags: "cbb_config:amd64-generic-release" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 166 | tags: "cbb_display_label:MockLabel" |
| 167 | tags: "cbb_workspace_branch:work_branch" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 168 | properties: "cbb_branch:main" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 169 | properties: "cbb_config:amd64-generic-release" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 170 | properties: "cbb_display_label:MockLabel" |
| 171 | properties: "cbb_workspace_branch:work_branch" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 172 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 173 | } |
| 174 | } |
Mike Frysinger | 80de501 | 2019-08-01 14:10:53 -0400 | [diff] [blame] | 175 | """ |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 176 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 177 | result = gen_luci_scheduler.genSchedulerJob(build_config) |
| 178 | self.assertEqual(result, expected) |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 179 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 180 | def testGenSchedulerGomaClientType(self): |
| 181 | """Test the job creation helper.""" |
| 182 | build_config = config_lib_unittest.MockBuildConfig().apply( |
| 183 | goma_client_type="client_type", |
| 184 | schedule="funky schedule", |
| 185 | ) |
Yoshisato Yanagisawa | 16285b4 | 2018-09-19 14:00:58 +0900 | [diff] [blame] | 186 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 187 | expected = """ |
Yoshisato Yanagisawa | 16285b4 | 2018-09-19 14:00:58 +0900 | [diff] [blame] | 188 | job { |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 189 | id: "amd64-generic-release" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 190 | realm: "cbb-jobs" |
Yoshisato Yanagisawa | 16285b4 | 2018-09-19 14:00:58 +0900 | [diff] [blame] | 191 | acl_sets: "default" |
| 192 | schedule: "funky schedule" |
| 193 | buildbucket: { |
| 194 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 195 | bucket: "general" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 196 | builder: "LegacyRelease" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 197 | tags: "cbb_branch:main" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 198 | tags: "cbb_config:amd64-generic-release" |
Yoshisato Yanagisawa | 16285b4 | 2018-09-19 14:00:58 +0900 | [diff] [blame] | 199 | tags: "cbb_display_label:MockLabel" |
| 200 | tags: "cbb_goma_client_type:client_type" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 201 | properties: "cbb_branch:main" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 202 | properties: "cbb_config:amd64-generic-release" |
Yoshisato Yanagisawa | 16285b4 | 2018-09-19 14:00:58 +0900 | [diff] [blame] | 203 | properties: "cbb_display_label:MockLabel" |
| 204 | properties: "cbb_goma_client_type:client_type" |
| 205 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 206 | } |
| 207 | } |
Mike Frysinger | 80de501 | 2019-08-01 14:10:53 -0400 | [diff] [blame] | 208 | """ |
Yoshisato Yanagisawa | 16285b4 | 2018-09-19 14:00:58 +0900 | [diff] [blame] | 209 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 210 | result = gen_luci_scheduler.genSchedulerJob(build_config) |
| 211 | self.assertEqual(result, expected) |
Yoshisato Yanagisawa | 16285b4 | 2018-09-19 14:00:58 +0900 | [diff] [blame] | 212 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 213 | def testGenLuciSchedulerConfig(self): |
| 214 | """Test a full LUCI Scheduler config file.""" |
| 215 | site_config = config_lib.SiteConfig() |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 216 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 217 | site_config.Add( |
| 218 | "not_scheduled", |
| 219 | luci_builder="ReleaseBuilder", |
| 220 | display_label="MockLabel", |
| 221 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 222 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 223 | site_config.Add( |
| 224 | "build_prod", |
| 225 | luci_builder="ReleaseBuilder", |
| 226 | display_label="MockLabel", |
| 227 | schedule="run once in a while", |
| 228 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 229 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 230 | site_config.Add( |
| 231 | "build_tester", |
| 232 | luci_builder="TestBuilder", |
| 233 | display_label="TestLabel", |
| 234 | schedule="run daily", |
| 235 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 236 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 237 | site_config.Add( |
| 238 | "build_triggered_a", |
| 239 | luci_builder="ReleaseBuilder", |
| 240 | display_label="MockLabel", |
| 241 | schedule="triggered", |
| 242 | triggered_gitiles=[ |
| 243 | [ |
| 244 | "gitiles_url_a", |
| 245 | ["ref_a", "ref_b"], |
| 246 | ], |
| 247 | [ |
| 248 | "gitiles_url_b", |
| 249 | ["ref_c"], |
| 250 | ], |
| 251 | ], |
| 252 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 253 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 254 | site_config.Add( |
| 255 | "build_triggered_b", |
| 256 | luci_builder="ProdBuilder", |
| 257 | display_label="MockLabel", |
| 258 | schedule="triggered", |
| 259 | triggered_gitiles=[ |
| 260 | [ |
| 261 | "gitiles_url_b", |
| 262 | ["ref_c"], |
| 263 | ] |
| 264 | ], |
| 265 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 266 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 267 | default_config = config_lib.GetConfig().GetDefault() |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 268 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 269 | branch_configs = [ |
| 270 | default_config.derive( |
| 271 | name="branch_tester", |
| 272 | luci_builder="TestBuilder", |
| 273 | display_label="TestLabel", |
| 274 | schedule="run daily", |
| 275 | schedule_branch="test-branch", |
| 276 | ), |
| 277 | default_config.derive( |
| 278 | name="branch_tester_triggered", |
| 279 | luci_builder="TestBuilder", |
| 280 | display_label="TestLabel", |
| 281 | schedule="run daily", |
| 282 | schedule_branch="test-branch", |
| 283 | triggered_gitiles=[ |
| 284 | [ |
| 285 | "gitiles_url_a", |
| 286 | ["ref_a", "ref_b"], |
| 287 | ] |
| 288 | ], |
| 289 | ), |
| 290 | ] |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 291 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 292 | expected = """# Defines buckets on luci-scheduler.appspot.com. |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 293 | # |
| 294 | # For schema of this file and documentation see ProjectConfig message in |
Mike Frysinger | 92dc649 | 2021-02-17 16:01:09 -0500 | [diff] [blame] | 295 | # https://github.com/luci/luci-go/blob/HEAD/scheduler/appengine/messages/config.proto |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 296 | |
| 297 | # Generated with chromite/scripts/gen_luci_scheduler |
| 298 | |
Don Garrett | ff45f4b | 2018-10-04 09:08:01 -0700 | [diff] [blame] | 299 | # Autodeployed with: |
Mike Nichols | b575c61 | 2021-04-09 10:04:43 -0600 | [diff] [blame] | 300 | # https://data.corp.google.com/sites/chromeos_ci_cros_ci_builds/utility/?f=board_name:in:luci-scheduler-updater |
Don Garrett | ff45f4b | 2018-10-04 09:08:01 -0700 | [diff] [blame] | 301 | |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 302 | acl_sets { |
| 303 | name: "default" |
| 304 | acls { |
| 305 | role: READER |
| 306 | granted_to: "group:googlers" |
| 307 | } |
| 308 | acls { |
| 309 | role: OWNER |
| 310 | granted_to: "group:project-chromeos-admins" |
| 311 | } |
Jason D. Clinton | a9e374a | 2018-10-18 18:41:00 -0600 | [diff] [blame] | 312 | acls { |
| 313 | role: TRIGGERER |
| 314 | granted_to: "group:mdb/chromeos-build-access" |
LaMont Jones | 48ddfd9 | 2020-09-16 13:46:41 -0600 | [diff] [blame] | 315 | } |
| 316 | acls { |
| 317 | role: TRIGGERER |
LaMont Jones | d1bb000 | 2020-09-16 09:35:10 -0600 | [diff] [blame] | 318 | granted_to: "group:project-chromeos-buildbucket-schedulers" |
Jason D. Clinton | a9e374a | 2018-10-18 18:41:00 -0600 | [diff] [blame] | 319 | } |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | trigger { |
| 323 | id: "trigger_0" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 324 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 325 | acl_sets: "default" |
| 326 | schedule: "with 5m interval" |
| 327 | gitiles: { |
| 328 | repo: "gitiles_url_a" |
| 329 | refs: "ref_a" |
| 330 | refs: "ref_b" |
| 331 | } |
| 332 | triggers: "build_triggered_a" |
Don Garrett | 9a0d90c | 2018-10-30 12:47:14 -0700 | [diff] [blame] | 333 | triggers: "test-branch-branch_tester_triggered" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | trigger { |
| 337 | id: "trigger_1" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 338 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 339 | acl_sets: "default" |
| 340 | schedule: "with 5m interval" |
| 341 | gitiles: { |
| 342 | repo: "gitiles_url_b" |
| 343 | refs: "ref_c" |
| 344 | } |
| 345 | triggers: "build_triggered_a" |
| 346 | triggers: "build_triggered_b" |
| 347 | } |
| 348 | |
| 349 | job { |
| 350 | id: "build_prod" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 351 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 352 | acl_sets: "default" |
| 353 | schedule: "run once in a while" |
| 354 | buildbucket: { |
| 355 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 356 | bucket: "general" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 357 | builder: "ReleaseBuilder" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 358 | tags: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 359 | tags: "cbb_config:build_prod" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 360 | tags: "cbb_display_label:MockLabel" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 361 | properties: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 362 | properties: "cbb_config:build_prod" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 363 | properties: "cbb_display_label:MockLabel" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 364 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | job { |
| 369 | id: "build_tester" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 370 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 371 | acl_sets: "default" |
| 372 | schedule: "run daily" |
| 373 | buildbucket: { |
| 374 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 375 | bucket: "general" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 376 | builder: "TestBuilder" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 377 | tags: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 378 | tags: "cbb_config:build_tester" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 379 | tags: "cbb_display_label:TestLabel" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 380 | properties: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 381 | properties: "cbb_config:build_tester" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 382 | properties: "cbb_display_label:TestLabel" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 383 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | job { |
| 388 | id: "build_triggered_a" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 389 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 390 | acl_sets: "default" |
| 391 | schedule: "triggered" |
| 392 | buildbucket: { |
| 393 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 394 | bucket: "general" |
Mike Nichols | 9e47e84 | 2020-08-11 15:23:56 -0600 | [diff] [blame] | 395 | builder: "ReleaseBuilder" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 396 | tags: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 397 | tags: "cbb_config:build_triggered_a" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 398 | tags: "cbb_display_label:MockLabel" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 399 | properties: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 400 | properties: "cbb_config:build_triggered_a" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 401 | properties: "cbb_display_label:MockLabel" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 402 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | job { |
| 407 | id: "build_triggered_b" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 408 | realm: "cbb-jobs" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 409 | acl_sets: "default" |
| 410 | schedule: "triggered" |
| 411 | buildbucket: { |
| 412 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 413 | bucket: "general" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 414 | builder: "ProdBuilder" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 415 | tags: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 416 | tags: "cbb_config:build_triggered_b" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 417 | tags: "cbb_display_label:MockLabel" |
Mike Frysinger | 62a0245 | 2021-03-16 03:48:34 -0400 | [diff] [blame] | 418 | properties: "cbb_branch:main" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 419 | properties: "cbb_config:build_triggered_b" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 420 | properties: "cbb_display_label:MockLabel" |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 421 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 422 | } |
| 423 | } |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 424 | |
| 425 | job { |
| 426 | id: "test-branch-branch_tester" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 427 | realm: "cbb-jobs" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 428 | acl_sets: "default" |
| 429 | schedule: "run daily" |
| 430 | buildbucket: { |
| 431 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 432 | bucket: "general" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 433 | builder: "TestBuilder" |
| 434 | tags: "cbb_branch:test-branch" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 435 | tags: "cbb_config:branch_tester" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 436 | tags: "cbb_display_label:TestLabel" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 437 | properties: "cbb_branch:test-branch" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 438 | properties: "cbb_config:branch_tester" |
Don Garrett | 73148e5 | 2018-08-17 16:54:46 -0700 | [diff] [blame] | 439 | properties: "cbb_display_label:TestLabel" |
Don Garrett | 8dace27 | 2018-07-19 14:07:42 -0700 | [diff] [blame] | 440 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 441 | } |
| 442 | } |
Don Garrett | 9a0d90c | 2018-10-30 12:47:14 -0700 | [diff] [blame] | 443 | |
| 444 | job { |
| 445 | id: "test-branch-branch_tester_triggered" |
Vadim Shtayura | 6398e00 | 2021-01-11 12:02:11 -0800 | [diff] [blame] | 446 | realm: "cbb-jobs" |
Don Garrett | 9a0d90c | 2018-10-30 12:47:14 -0700 | [diff] [blame] | 447 | acl_sets: "default" |
| 448 | schedule: "run daily" |
| 449 | buildbucket: { |
| 450 | server: "cr-buildbucket.appspot.com" |
Vadim Shtayura | 959cb0f | 2022-02-03 12:45:58 -0800 | [diff] [blame] | 451 | bucket: "general" |
Don Garrett | 9a0d90c | 2018-10-30 12:47:14 -0700 | [diff] [blame] | 452 | builder: "TestBuilder" |
| 453 | tags: "cbb_branch:test-branch" |
| 454 | tags: "cbb_config:branch_tester_triggered" |
| 455 | tags: "cbb_display_label:TestLabel" |
| 456 | properties: "cbb_branch:test-branch" |
| 457 | properties: "cbb_config:branch_tester_triggered" |
| 458 | properties: "cbb_display_label:TestLabel" |
| 459 | properties: "cbb_extra_args:[\\"--buildbot\\"]" |
| 460 | } |
| 461 | } |
Mike Frysinger | 80de501 | 2019-08-01 14:10:53 -0400 | [diff] [blame] | 462 | """ |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 463 | result = gen_luci_scheduler.genLuciSchedulerConfig( |
| 464 | site_config, branch_configs |
| 465 | ) |
Don Garrett | be3608b | 2018-06-05 17:10:09 -0700 | [diff] [blame] | 466 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 467 | self.assertEqual(result, expected) |