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