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