Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 1 | # Copyright 2017 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 | """Module for task unittests.""" |
Xixuan Wu | 5ff0fac | 2019-01-07 10:06:35 -0800 | [diff] [blame] | 6 | # pylint: disable=g-missing-super-call |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 7 | |
| 8 | import re |
| 9 | import unittest |
| 10 | |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 11 | import build_lib |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 12 | import cloud_sql_client |
| 13 | import config_reader |
| 14 | import mock |
| 15 | import MySQLdb |
| 16 | import task |
| 17 | import tot_manager |
| 18 | |
| 19 | |
| 20 | class FakeTotMilestoneManager(tot_manager.TotMilestoneManager): |
| 21 | """Mock class for tot_manager.TotMilestoneManager.""" |
| 22 | |
| 23 | def __init__(self, is_sanity): |
| 24 | self.is_sanity = is_sanity |
| 25 | self.storage_client = None |
| 26 | self.tot = self._tot_milestone() |
| 27 | |
| 28 | |
| 29 | class FakeCIDBClient(object): |
| 30 | """Mock class for cloud_sql_client.CIDBClient.""" |
| 31 | |
| 32 | def __init__(self, success=True): |
| 33 | self.success = success |
| 34 | |
| 35 | def get_latest_passed_builds(self, build_config): |
| 36 | if not self.success: |
| 37 | raise MySQLdb.OperationalError('Failed to connect to db') |
| 38 | |
| 39 | return cloud_sql_client.BuildInfo(board=build_config.split('-')[0], |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 40 | model=None, |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 41 | milestone=TaskTestCase.MILESTONE, |
| 42 | platform=TaskTestCase.PLATFORM, |
| 43 | build_config=build_config) |
| 44 | |
| 45 | |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 46 | class FakeLabConfig(object): |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 47 | """Mock class for config_reader.LabConfig.""" |
| 48 | |
| 49 | def get_cros_model_map(self): |
| 50 | return {'coral': ['robo', 'nasher', 'lava']} |
| 51 | |
| 52 | |
| 53 | class FakeMigrationConfig(object): |
| 54 | """Mock class for config_reader.MigrationConfig.""" |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 55 | |
| 56 | def get_skylab_board_list(self): |
| 57 | return [] |
| 58 | |
| 59 | def get_skylab_suite_list(self): |
| 60 | return [] |
| 61 | |
Xixuan Wu | 5ff0fac | 2019-01-07 10:06:35 -0800 | [diff] [blame] | 62 | def get_skylab_model_map(self): |
| 63 | return {} |
| 64 | |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 65 | def get_cros_model_map(self): |
| 66 | return {'coral': ['robo', 'nasher', 'lava']} |
| 67 | |
| 68 | |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 69 | class TaskBaseTestCase(unittest.TestCase): |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 70 | |
| 71 | BOARD = 'fake_board' |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 72 | UNIBUILD_BOARD = 'coral' |
Po-Hsien Wang | 6d58973 | 2018-05-15 17:19:34 -0700 | [diff] [blame] | 73 | EXCLUDE_BOARD = 'exclude_fake_board' |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 74 | NAME = 'fake_name' |
| 75 | SUITE = 'fake_suite' |
| 76 | POOL = 'fake_pool' |
| 77 | PLATFORM = '6182.0.0-rc2' |
| 78 | MILESTONE = '30' |
| 79 | NUM = 1 |
| 80 | PRIORITY = 50 |
| 81 | TIMEOUT = 600 |
| 82 | |
| 83 | def setUp(self): |
| 84 | tot_patcher = mock.patch('tot_manager.TotMilestoneManager') |
| 85 | self._mock_tot = tot_patcher.start() |
| 86 | self.addCleanup(tot_patcher.stop) |
| 87 | # Can't pass in False since storage_client is not mocked. |
| 88 | self._mock_tot.return_value = FakeTotMilestoneManager(True) |
| 89 | self.task = task.Task(config_reader.TaskInfo( |
| 90 | name=self.NAME, |
| 91 | suite=self.SUITE, |
| 92 | branch_specs=[], |
| 93 | pool=self.POOL, |
| 94 | num=self.NUM, |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 95 | boards=','.join([self.BOARD, self.UNIBUILD_BOARD]), |
Po-Hsien Wang | 6d58973 | 2018-05-15 17:19:34 -0700 | [diff] [blame] | 96 | exclude_boards=self.EXCLUDE_BOARD, |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 97 | priority=self.PRIORITY, |
| 98 | timeout=self.TIMEOUT)) |
| 99 | |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 100 | self._empty_configs = config_reader.Configs( |
| 101 | lab_config=config_reader.LabConfig(None), |
| 102 | migration_config=config_reader.MigrationConfig(None)) |
| 103 | self._fake_configs = config_reader.Configs( |
| 104 | lab_config=FakeLabConfig(), |
| 105 | migration_config=FakeMigrationConfig()) |
| 106 | |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 107 | |
| 108 | class TaskTestCase(TaskBaseTestCase): |
| 109 | |
| 110 | def setUp(self): |
| 111 | super(TaskTestCase, self).setUp() |
| 112 | |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 113 | mock_push = mock.patch('task.Task._push_suite') |
| 114 | self._mock_push = mock_push.start() |
| 115 | self.addCleanup(mock_push.stop) |
| 116 | |
| 117 | def testSetSpecCompareInfoEqual(self): |
| 118 | """Test compare info setting for specs that equals to a milestone.""" |
| 119 | self.task.branch_specs = re.split(r'\s*,\s*', '==tot-2') |
| 120 | self.task._set_spec_compare_info() |
| 121 | self.assertTrue(self.task._version_equal_constraint) |
| 122 | self.assertFalse(self.task._version_gte_constraint) |
| 123 | self.assertFalse(self.task._version_lte_constraint) |
| 124 | self.assertEqual(self.task._bare_branches, []) |
| 125 | |
| 126 | def testSetSpecCompareInfoLess(self): |
| 127 | """Test compare info setting for specs that is less than a milestone.""" |
| 128 | self.task.branch_specs = re.split(r'\s*,\s*', '<=tot') |
| 129 | self.task._set_spec_compare_info() |
| 130 | self.assertFalse(self.task._version_equal_constraint) |
| 131 | self.assertFalse(self.task._version_gte_constraint) |
| 132 | self.assertTrue(self.task._version_lte_constraint) |
| 133 | self.assertEqual(self.task._bare_branches, []) |
| 134 | |
| 135 | def testSetSpecCompareInfoGreater(self): |
| 136 | """Test compare info setting for specs that is greater than a milestone.""" |
| 137 | self.task.branch_specs = re.split(r'\s*,\s*', '>=tot-2') |
| 138 | self.task._set_spec_compare_info() |
| 139 | self.assertFalse(self.task._version_equal_constraint) |
| 140 | self.assertTrue(self.task._version_gte_constraint) |
| 141 | self.assertFalse(self.task._version_lte_constraint) |
| 142 | self.assertEqual(self.task._bare_branches, []) |
| 143 | |
| 144 | def testFitsSpecEqual(self): |
| 145 | """Test milestone check for specs that equals to a milestone.""" |
| 146 | self.task.branch_specs = re.split(r'\s*,\s*', '==tot-1') |
| 147 | self.task._set_spec_compare_info() |
| 148 | self.assertFalse(self.task._fits_spec('40')) |
| 149 | self.assertTrue(self.task._fits_spec('39')) |
| 150 | self.assertFalse(self.task._fits_spec('38')) |
| 151 | |
| 152 | def testFitsSpecLess(self): |
| 153 | """Test milestone check for specs that is less than a milestone.""" |
| 154 | self.task.branch_specs = re.split(r'\s*,\s*', '<=tot-1') |
| 155 | self.task._set_spec_compare_info() |
| 156 | self.assertFalse(self.task._fits_spec('40')) |
| 157 | self.assertTrue(self.task._fits_spec('39')) |
| 158 | self.assertTrue(self.task._fits_spec('38')) |
| 159 | |
| 160 | def testFitsSpecGreater(self): |
| 161 | """Test milestone check for specs that is greater than a milestone.""" |
| 162 | self.task.branch_specs = re.split(r'\s*,\s*', '>=tot-2') |
| 163 | self.task._set_spec_compare_info() |
| 164 | self.assertTrue(self.task._fits_spec('39')) |
| 165 | self.assertTrue(self.task._fits_spec('38')) |
| 166 | self.assertFalse(self.task._fits_spec('37')) |
| 167 | |
| 168 | def testGetFirmwareFromLabConfig(self): |
| 169 | """Test get firmware from lab config successfully.""" |
| 170 | with mock.patch('config_reader.LabConfig.get_firmware_ro_build_list', |
| 171 | return_value='build1,build2'): |
| 172 | firmware = self.task._get_firmware_build( |
| 173 | 'released_ro_2', self.BOARD, config_reader.LabConfig(None), None) |
| 174 | self.assertEqual(firmware, 'build2') |
| 175 | |
| 176 | def testGetFirmwareFromLabConfigOutofIndex(self): |
| 177 | """Test get firmware from lab config when firmware index is invalid.""" |
| 178 | with mock.patch('config_reader.LabConfig.get_firmware_ro_build_list', |
| 179 | return_value='build1,build2'): |
| 180 | self.assertRaises(ValueError, |
| 181 | self.task._get_latest_firmware_build_from_lab_config, |
| 182 | 'released_ro_3', |
| 183 | self.BOARD, |
| 184 | config_reader.LabConfig(None)) |
| 185 | self.assertIsNone(self.task._get_firmware_build( |
| 186 | 'released_ro_3', self.BOARD, config_reader.LabConfig(None), None)) |
| 187 | |
| 188 | def testGetFirmwareFromDB(self): |
| 189 | """Test get firmware from DB successfully.""" |
| 190 | firmware = self.task._get_firmware_build( |
| 191 | 'firmware', self.BOARD, None, FakeCIDBClient()) |
| 192 | self.assertEqual( |
| 193 | firmware, |
| 194 | '%s-firmware/R%s-%s' % (self.BOARD, self.MILESTONE, self.PLATFORM)) |
| 195 | |
| 196 | def testGetFirmwareFromDBConnectionError(self): |
| 197 | """Test get firmware from DB when DB connection is failed.""" |
| 198 | self.assertIsNone(self.task._get_firmware_build( |
| 199 | 'firmware', self.BOARD, None, FakeCIDBClient(success=False))) |
| 200 | |
| 201 | def testScheduleCrosSuccessfully(self): |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 202 | """test schedule cros builds successfully.""" |
| 203 | branch_builds = {(self.BOARD, None, 'release', '56'): '0000.00.00'} |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 204 | self.task._schedule_cros_builds(branch_builds, |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 205 | self._empty_configs, |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 206 | FakeCIDBClient()) |
| 207 | self.assertEqual(self._mock_push.call_count, 1) |
| 208 | |
| 209 | def testScheduleCrosNonvalidBoard(self): |
| 210 | """Test schedule no cros builds due to non-allowed board.""" |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 211 | branch_builds = {('%s_2' % self.BOARD, None, 'release', '56'): '0000.00.00'} |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 212 | self.task._schedule_cros_builds(branch_builds, |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 213 | self._empty_configs, |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 214 | FakeCIDBClient()) |
| 215 | self.assertEqual(self._mock_push.call_count, 0) |
| 216 | |
Po-Hsien Wang | 6d58973 | 2018-05-15 17:19:34 -0700 | [diff] [blame] | 217 | def testScheduleCrosExcludeBoard(self): |
| 218 | """Test schedule no cros builds due to board is excluded.""" |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 219 | branch_builds = {(self.EXCLUDE_BOARD, None, 'release', '56'): '0000.00.00'} |
Po-Hsien Wang | 6d58973 | 2018-05-15 17:19:34 -0700 | [diff] [blame] | 220 | self.task._schedule_cros_builds(branch_builds, |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 221 | self._empty_configs, |
Po-Hsien Wang | 6d58973 | 2018-05-15 17:19:34 -0700 | [diff] [blame] | 222 | FakeCIDBClient()) |
| 223 | self.assertEqual(self._mock_push.call_count, 0) |
| 224 | |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 225 | def testScheduleCrosSuccessfullyWithSpecifiedModel(self): |
| 226 | """Test schedule unibuild with specific model.""" |
| 227 | self.task.board = self.UNIBUILD_BOARD |
| 228 | branch_builds = {(self.UNIBUILD_BOARD, 'robo', 'release', '56'): |
| 229 | '0000.00.00', |
| 230 | (self.UNIBUILD_BOARD, 'lava', 'release', '56'): |
| 231 | '0000.00.00'} |
| 232 | self.task._schedule_cros_builds(branch_builds, |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 233 | self._fake_configs, |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 234 | FakeCIDBClient()) |
| 235 | self.assertEqual(self._mock_push.call_count, 2) |
| 236 | |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 237 | def testScheduleCrosNonValidSpec(self): |
| 238 | """Test schedule no cros builds due to non-allowed branch milestone.""" |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 239 | branch_builds = {(self.BOARD, None, 'release', '56'): '0000.00.00'} |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 240 | # Only run tasks whose milestone = tot (R40) |
| 241 | self.task.branch_specs = re.split(r'\s*,\s*', '==tot') |
| 242 | self.task._set_spec_compare_info() |
| 243 | self.task._schedule_cros_builds(branch_builds, |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 244 | self._empty_configs, |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 245 | FakeCIDBClient()) |
| 246 | self.assertEqual(self._mock_push.call_count, 0) |
| 247 | |
| 248 | def testScheduleCrosSuccessfullyWithValidFirmware(self): |
| 249 | """Test schedule cros builds successfully with valid firmware.""" |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 250 | branch_builds = {(self.BOARD, None, 'release', '56'): '0000.00.00'} |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 251 | self.task.firmware_ro_build_spec = 'firmware' |
| 252 | self.task._schedule_cros_builds(branch_builds, |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 253 | self._empty_configs, |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 254 | FakeCIDBClient()) |
| 255 | self.assertEqual(self._mock_push.call_count, 1) |
| 256 | |
| 257 | def testScheduleCrosWithNonValidFirmware(self): |
| 258 | """Test schedule no cros builds due to non-existent firmware.""" |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 259 | branch_builds = {(self.BOARD, None, 'release', '56'): '0000.00.00'} |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 260 | self.task.firmware_ro_build_spec = 'firmware' |
| 261 | self.task._schedule_cros_builds(branch_builds, |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 262 | self._empty_configs, |
Xixuan Wu | 0c76d5b | 2017-08-30 16:40:17 -0700 | [diff] [blame] | 263 | FakeCIDBClient(success=False)) |
| 264 | self.assertEqual(self._mock_push.call_count, 0) |
| 265 | |
| 266 | def testScheduleLaunchControlWithFullBranches(self): |
| 267 | """Test schedule all launch control builds successfully.""" |
| 268 | lc_builds = {self.BOARD: ['git_nyc-mr2-release/shamu-userdebug/3844975', |
| 269 | 'git_nyc-mr1-release/shamu-userdebug/3783920']} |
| 270 | lc_branches = 'git_nyc-mr1-release,git_nyc-mr2-release' |
| 271 | self.task.launch_control_branches = [ |
| 272 | t.lstrip() for t in lc_branches.split(',')] |
| 273 | self.task._schedule_launch_control_builds(lc_builds) |
| 274 | self.assertEqual(self._mock_push.call_count, 2) |
| 275 | |
| 276 | def testScheduleLaunchControlWithPartlyBranches(self): |
| 277 | """Test schedule part of launch control builds due to branch check.""" |
| 278 | lc_builds = {self.BOARD: ['git_nyc-mr2-release/shamu-userdebug/3844975', |
| 279 | 'git_nyc-mr1-release/shamu-userdebug/3783920']} |
| 280 | lc_branches = 'git_nyc-mr1-release' |
| 281 | self.task.launch_control_branches = [ |
| 282 | t.lstrip() for t in lc_branches.split(',')] |
| 283 | self.task._schedule_launch_control_builds(lc_builds) |
| 284 | self.assertEqual(self._mock_push.call_count, 1) |
| 285 | |
| 286 | def testScheduleLaunchControlWithNoBranches(self): |
| 287 | """Test schedule none of launch control builds due to branch check.""" |
| 288 | lc_builds = {self.BOARD: ['git_nyc-mr2-release/shamu-userdebug/3844975', |
| 289 | 'git_nyc-mr1-release/shamu-userdebug/3783920']} |
| 290 | self.task.launch_control_branches = [] |
| 291 | self.task._schedule_launch_control_builds(lc_builds) |
| 292 | self.assertEqual(self._mock_push.call_count, 0) |
| 293 | |
| 294 | def testScheduleLaunchControlNonvalidBoard(self): |
| 295 | """Test schedule none of launch control builds due to board check.""" |
| 296 | lc_builds = {'%s_2' % self.BOARD: |
| 297 | ['git_nyc-mr2-release/shamu-userdebug/3844975', |
| 298 | 'git_nyc-mr1-release/shamu-userdebug/3783920']} |
| 299 | lc_branches = 'git_nyc-mr1-release,git_nyc-mr2-release' |
| 300 | self.task.launch_control_branches = [ |
| 301 | t.lstrip() for t in lc_branches.split(',')] |
| 302 | self.task._schedule_launch_control_builds(lc_builds) |
| 303 | self.assertEqual(self._mock_push.call_count, 0) |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 304 | |
Po-Hsien Wang | 6d58973 | 2018-05-15 17:19:34 -0700 | [diff] [blame] | 305 | def testScheduleLaunchControlExcludeBoard(self): |
| 306 | """Test schedule none of launch control builds due to board check.""" |
| 307 | lc_builds = {self.EXCLUDE_BOARD: |
| 308 | ['git_nyc-mr2-release/shamu-userdebug/3844975', |
| 309 | 'git_nyc-mr1-release/shamu-userdebug/3783920']} |
| 310 | lc_branches = 'git_nyc-mr1-release,git_nyc-mr2-release' |
| 311 | self.task.launch_control_branches = [ |
| 312 | t.lstrip() for t in lc_branches.split(',')] |
| 313 | self.task._schedule_launch_control_builds(lc_builds) |
| 314 | self.assertEqual(self._mock_push.call_count, 0) |
| 315 | |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 316 | |
| 317 | class TaskPushTestCase(TaskBaseTestCase): |
| 318 | |
| 319 | def setUp(self): |
| 320 | super(TaskPushTestCase, self).setUp() |
| 321 | mock_push = mock.patch('task_executor.push') |
| 322 | self._mock_push = mock_push.start() |
| 323 | self.addCleanup(mock_push.stop) |
| 324 | |
| 325 | def testScheduleCrOSIsPushSuccessfully(self): |
| 326 | """Test IS_PUSHED is changed if some CrOS suites are scheduled.""" |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 327 | branch_builds = {(self.BOARD, None, 'release', '56'): '0000.00.00'} |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 328 | self.task.os_type = build_lib.OS_TYPE_CROS |
| 329 | self.assertTrue(self.task.schedule( |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 330 | [], (branch_builds, []), self._empty_configs, |
Craig Bergstrom | 58263d3 | 2018-04-26 14:11:35 -0600 | [diff] [blame] | 331 | FakeCIDBClient())) |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 332 | |
| 333 | def testScheduleLaunchControlIsPushSuccessfully(self): |
| 334 | """Test IS_PUSHED is changed if some launch control suites are scheduled.""" |
| 335 | lc_builds = {self.BOARD: ['git_nyc-mr2-release/shamu-userdebug/3844975', |
| 336 | 'git_nyc-mr1-release/shamu-userdebug/3783920']} |
| 337 | lc_branches = 'git_nyc-mr1-release,git_nyc-mr2-release' |
| 338 | self.task.launch_control_branches = [ |
| 339 | t.lstrip() for t in lc_branches.split(',')] |
| 340 | self.task.os_type = build_lib.OS_TYPES_LAUNCH_CONTROL |
| 341 | self.assertTrue(self.task.schedule( |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 342 | lc_builds, ([], []), self._empty_configs, FakeCIDBClient())) |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 343 | |
| 344 | def testScheduleCrosIsPushInvalidBoard(self): |
| 345 | """Test schedule no cros builds due to non-allowed board.""" |
Craig Bergstrom | 58263d3 | 2018-04-26 14:11:35 -0600 | [diff] [blame] | 346 | branch_builds = ( |
Xixuan Wu | 8d2f286 | 2018-08-28 16:48:04 -0700 | [diff] [blame] | 347 | {('%s_2' % self.BOARD, None, 'release', '56'): '0000.00.00'}, {}, |
Craig Bergstrom | 58263d3 | 2018-04-26 14:11:35 -0600 | [diff] [blame] | 348 | ) |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 349 | self.task.os_type = build_lib.OS_TYPE_CROS |
| 350 | self.assertFalse(self.task.schedule( |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 351 | [], branch_builds, self._empty_configs, FakeCIDBClient())) |
Xixuan Wu | 5451a66 | 2017-10-17 10:57:40 -0700 | [diff] [blame] | 352 | |
| 353 | def testScheduleLaunchControlIsPushInvalidBoard(self): |
| 354 | """Test schedule none of launch control builds due to board check.""" |
| 355 | lc_builds = {'%s_2' % self.BOARD: |
| 356 | ['git_nyc-mr2-release/shamu-userdebug/3844975', |
| 357 | 'git_nyc-mr1-release/shamu-userdebug/3783920']} |
| 358 | lc_branches = 'git_nyc-mr1-release,git_nyc-mr2-release' |
| 359 | self.task.launch_control_branches = [ |
| 360 | t.lstrip() for t in lc_branches.split(',')] |
| 361 | self.task.os_type = build_lib.OS_TYPES_LAUNCH_CONTROL |
| 362 | self.task._schedule_launch_control_builds(lc_builds) |
| 363 | self.assertFalse(self.task.schedule( |
Xixuan Wu | f4a4c88 | 2019-03-15 14:48:26 -0700 | [diff] [blame] | 364 | lc_builds, ([], []), self._empty_configs, FakeCIDBClient())) |