Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 1 | # Copyright 2019 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 | """The test controller tests.""" |
| 6 | |
Alex Klein | 9f91578 | 2020-02-14 23:15:09 +0000 | [diff] [blame] | 7 | import contextlib |
Mike Frysinger | ef94e4c | 2020-02-10 23:59:54 -0500 | [diff] [blame] | 8 | import os |
Mike Frysinger | ef94e4c | 2020-02-10 23:59:54 -0500 | [diff] [blame] | 9 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 10 | from chromite.api import api_config |
Alex Klein | 8cb365a | 2019-05-15 16:24:53 -0600 | [diff] [blame] | 11 | from chromite.api import controller |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 12 | from chromite.api.controller import test as test_controller |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 13 | from chromite.api.gen.chromiumos import common_pb2 |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 14 | from chromite.api.gen.chromite.api import test_pb2 |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 15 | from chromite.lib import chroot_lib |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 16 | from chromite.lib import cros_build_lib |
| 17 | from chromite.lib import cros_test_lib |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 18 | from chromite.lib import image_lib |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 19 | from chromite.lib import osutils |
Alex Klein | 18a60af | 2020-06-11 12:08:47 -0600 | [diff] [blame] | 20 | from chromite.lib.parser import package_info |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 21 | from chromite.scripts import cros_set_lsb_release |
| 22 | from chromite.service import test as test_service |
Mike Frysinger | 40ffb53 | 2021-02-12 07:36:08 -0500 | [diff] [blame] | 23 | from chromite.third_party import mock |
Mike Frysinger | e652ba1 | 2019-09-08 00:57:43 -0400 | [diff] [blame] | 24 | from chromite.utils import key_value_store |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 25 | |
| 26 | |
Michael Mortensen | 8ca4d3b | 2019-11-27 09:35:22 -0700 | [diff] [blame] | 27 | class DebugInfoTestTest(cros_test_lib.MockTempDirTestCase, |
| 28 | api_config.ApiConfigMixin): |
| 29 | """Tests for the DebugInfoTest function.""" |
| 30 | |
| 31 | def setUp(self): |
| 32 | self.board = 'board' |
| 33 | self.chroot_path = os.path.join(self.tempdir, 'chroot') |
| 34 | self.sysroot_path = '/build/board' |
| 35 | self.full_sysroot_path = os.path.join(self.chroot_path, |
| 36 | self.sysroot_path.lstrip(os.sep)) |
| 37 | osutils.SafeMakedirs(self.full_sysroot_path) |
| 38 | |
| 39 | def _GetInput(self, sysroot_path=None, build_target=None): |
| 40 | """Helper to build an input message instance.""" |
| 41 | proto = test_pb2.DebugInfoTestRequest() |
| 42 | if sysroot_path: |
| 43 | proto.sysroot.path = sysroot_path |
| 44 | if build_target: |
| 45 | proto.sysroot.build_target.name = build_target |
| 46 | return proto |
| 47 | |
| 48 | def _GetOutput(self): |
| 49 | """Helper to get an empty output message instance.""" |
| 50 | return test_pb2.DebugInfoTestResponse() |
| 51 | |
| 52 | def testValidateOnly(self): |
| 53 | """Sanity check that a validate only call does not execute any logic.""" |
| 54 | patch = self.PatchObject(test_service, 'DebugInfoTest') |
| 55 | input_msg = self._GetInput(sysroot_path=self.full_sysroot_path) |
| 56 | test_controller.DebugInfoTest(input_msg, self._GetOutput(), |
| 57 | self.validate_only_config) |
| 58 | patch.assert_not_called() |
| 59 | |
Michael Mortensen | 85d3840 | 2019-12-12 09:50:29 -0700 | [diff] [blame] | 60 | def testMockError(self): |
| 61 | """Test mock error call does not execute any logic, returns error.""" |
| 62 | patch = self.PatchObject(test_service, 'DebugInfoTest') |
| 63 | |
| 64 | input_msg = self._GetInput(sysroot_path=self.full_sysroot_path) |
| 65 | rc = test_controller.DebugInfoTest(input_msg, self._GetOutput(), |
| 66 | self.mock_error_config) |
| 67 | patch.assert_not_called() |
| 68 | self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc) |
| 69 | |
| 70 | def testMockCall(self): |
| 71 | """Test mock call does not execute any logic, returns success.""" |
| 72 | patch = self.PatchObject(test_service, 'DebugInfoTest') |
| 73 | |
| 74 | input_msg = self._GetInput(sysroot_path=self.full_sysroot_path) |
| 75 | rc = test_controller.DebugInfoTest(input_msg, self._GetOutput(), |
| 76 | self.mock_call_config) |
| 77 | patch.assert_not_called() |
| 78 | self.assertEqual(controller.RETURN_CODE_SUCCESS, rc) |
| 79 | |
Michael Mortensen | 8ca4d3b | 2019-11-27 09:35:22 -0700 | [diff] [blame] | 80 | def testNoBuildTargetNoSysrootFails(self): |
| 81 | """Test missing build target name and sysroot path fails.""" |
| 82 | input_msg = self._GetInput() |
| 83 | output_msg = self._GetOutput() |
| 84 | with self.assertRaises(cros_build_lib.DieSystemExit): |
| 85 | test_controller.DebugInfoTest(input_msg, output_msg, self.api_config) |
| 86 | |
| 87 | def testDebugInfoTest(self): |
| 88 | """Call DebugInfoTest with valid sysroot_path.""" |
| 89 | request = self._GetInput(sysroot_path=self.full_sysroot_path) |
| 90 | |
| 91 | test_controller.DebugInfoTest(request, self._GetOutput(), self.api_config) |
| 92 | |
| 93 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 94 | class BuildTargetUnitTestTest(cros_test_lib.MockTempDirTestCase, |
| 95 | api_config.ApiConfigMixin): |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 96 | """Tests for the UnitTest function.""" |
| 97 | |
Navil Perez | c0b29a8 | 2020-07-07 14:17:48 +0000 | [diff] [blame] | 98 | def _GetInput(self, |
| 99 | board=None, |
| 100 | result_path=None, |
| 101 | chroot_path=None, |
| 102 | cache_dir=None, |
| 103 | empty_sysroot=None, |
| 104 | packages=None, |
Alex Klein | b64e5f8 | 2020-09-23 10:55:31 -0600 | [diff] [blame] | 105 | blocklist=None): |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 106 | """Helper to build an input message instance.""" |
Navil Perez | c0b29a8 | 2020-07-07 14:17:48 +0000 | [diff] [blame] | 107 | formatted_packages = [] |
| 108 | for pkg in packages or []: |
| 109 | formatted_packages.append({ |
| 110 | 'category': pkg.category, |
| 111 | 'package_name': pkg.package |
| 112 | }) |
Alex Klein | b64e5f8 | 2020-09-23 10:55:31 -0600 | [diff] [blame] | 113 | formatted_blocklist = [] |
| 114 | for pkg in blocklist or []: |
| 115 | formatted_blocklist.append({'category': pkg.category, |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 116 | 'package_name': pkg.package}) |
| 117 | |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 118 | return test_pb2.BuildTargetUnitTestRequest( |
| 119 | build_target={'name': board}, result_path=result_path, |
Alex Klein | fa6ebdc | 2019-05-10 10:57:31 -0600 | [diff] [blame] | 120 | chroot={'path': chroot_path, 'cache_dir': cache_dir}, |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 121 | flags={'empty_sysroot': empty_sysroot}, |
Alex Klein | 64ac34c | 2020-09-23 10:21:33 -0600 | [diff] [blame] | 122 | packages=formatted_packages, |
Alex Klein | b64e5f8 | 2020-09-23 10:55:31 -0600 | [diff] [blame] | 123 | package_blacklist=formatted_blocklist, |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 124 | ) |
| 125 | |
| 126 | def _GetOutput(self): |
| 127 | """Helper to get an empty output message instance.""" |
| 128 | return test_pb2.BuildTargetUnitTestResponse() |
| 129 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 130 | def testValidateOnly(self): |
| 131 | """Sanity check that a validate only call does not execute any logic.""" |
| 132 | patch = self.PatchObject(test_service, 'BuildTargetUnitTest') |
| 133 | |
| 134 | input_msg = self._GetInput(board='board', result_path=self.tempdir) |
| 135 | test_controller.BuildTargetUnitTest(input_msg, self._GetOutput(), |
| 136 | self.validate_only_config) |
| 137 | patch.assert_not_called() |
| 138 | |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 139 | def testMockCall(self): |
| 140 | """Test that a mock call does not execute logic, returns mocked value.""" |
| 141 | patch = self.PatchObject(test_service, 'BuildTargetUnitTest') |
| 142 | |
| 143 | input_msg = self._GetInput(board='board', result_path=self.tempdir) |
| 144 | response = self._GetOutput() |
| 145 | test_controller.BuildTargetUnitTest(input_msg, response, |
| 146 | self.mock_call_config) |
| 147 | patch.assert_not_called() |
| 148 | self.assertEqual(response.tarball_path, |
| 149 | os.path.join(input_msg.result_path, 'unit_tests.tar')) |
| 150 | |
| 151 | def testMockError(self): |
Michael Mortensen | 85d3840 | 2019-12-12 09:50:29 -0700 | [diff] [blame] | 152 | """Test that a mock error does not execute logic, returns error.""" |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 153 | patch = self.PatchObject(test_service, 'BuildTargetUnitTest') |
| 154 | |
| 155 | input_msg = self._GetInput(board='board', result_path=self.tempdir) |
| 156 | response = self._GetOutput() |
| 157 | rc = test_controller.BuildTargetUnitTest(input_msg, response, |
| 158 | self.mock_error_config) |
| 159 | patch.assert_not_called() |
| 160 | self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc) |
| 161 | self.assertTrue(response.failed_packages) |
| 162 | self.assertEqual(response.failed_packages[0].category, 'foo') |
| 163 | self.assertEqual(response.failed_packages[0].package_name, 'bar') |
| 164 | self.assertEqual(response.failed_packages[1].category, 'cat') |
| 165 | self.assertEqual(response.failed_packages[1].package_name, 'pkg') |
| 166 | |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 167 | def testNoArgumentFails(self): |
| 168 | """Test no arguments fails.""" |
| 169 | input_msg = self._GetInput() |
| 170 | output_msg = self._GetOutput() |
| 171 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 172 | test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 173 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 174 | |
| 175 | def testNoBuildTargetFails(self): |
| 176 | """Test missing build target name fails.""" |
| 177 | input_msg = self._GetInput(result_path=self.tempdir) |
| 178 | output_msg = self._GetOutput() |
| 179 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 180 | test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 181 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 182 | |
| 183 | def testNoResultPathFails(self): |
| 184 | """Test missing result path fails.""" |
| 185 | # Missing result_path. |
| 186 | input_msg = self._GetInput(board='board') |
| 187 | output_msg = self._GetOutput() |
| 188 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 189 | test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 190 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 191 | |
Alex Klein | 64ac34c | 2020-09-23 10:21:33 -0600 | [diff] [blame] | 192 | def testInvalidPackageFails(self): |
| 193 | """Test missing result path fails.""" |
| 194 | # Missing result_path. |
| 195 | pkg = package_info.PackageInfo(package='bar') |
| 196 | input_msg = self._GetInput(board='board', result_path=self.tempdir, |
| 197 | packages=[pkg]) |
| 198 | output_msg = self._GetOutput() |
| 199 | with self.assertRaises(cros_build_lib.DieSystemExit): |
| 200 | test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 201 | self.api_config) |
| 202 | |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 203 | def testPackageBuildFailure(self): |
| 204 | """Test handling of raised BuildPackageFailure.""" |
| 205 | tempdir = osutils.TempDir(base_dir=self.tempdir) |
| 206 | self.PatchObject(osutils, 'TempDir', return_value=tempdir) |
| 207 | |
| 208 | pkgs = ['cat/pkg', 'foo/bar'] |
| 209 | expected = [('cat', 'pkg'), ('foo', 'bar')] |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 210 | |
Alex Klein | 38c7d9e | 2019-05-08 09:31:19 -0600 | [diff] [blame] | 211 | result = test_service.BuildTargetUnitTestResult(1, None) |
Alex Klein | 18a60af | 2020-06-11 12:08:47 -0600 | [diff] [blame] | 212 | result.failed_cpvs = [package_info.SplitCPV(p, strict=False) for p in pkgs] |
Alex Klein | 38c7d9e | 2019-05-08 09:31:19 -0600 | [diff] [blame] | 213 | self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 214 | |
| 215 | input_msg = self._GetInput(board='board', result_path=self.tempdir) |
| 216 | output_msg = self._GetOutput() |
| 217 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 218 | rc = test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 219 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 220 | |
Alex Klein | 8cb365a | 2019-05-15 16:24:53 -0600 | [diff] [blame] | 221 | self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 222 | self.assertTrue(output_msg.failed_packages) |
| 223 | failed = [] |
| 224 | for pi in output_msg.failed_packages: |
| 225 | failed.append((pi.category, pi.package_name)) |
Mike Frysinger | 678735c | 2019-09-28 18:23:28 -0400 | [diff] [blame] | 226 | self.assertCountEqual(expected, failed) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 227 | |
| 228 | def testOtherBuildScriptFailure(self): |
| 229 | """Test build script failure due to non-package emerge error.""" |
| 230 | tempdir = osutils.TempDir(base_dir=self.tempdir) |
| 231 | self.PatchObject(osutils, 'TempDir', return_value=tempdir) |
| 232 | |
Alex Klein | 38c7d9e | 2019-05-08 09:31:19 -0600 | [diff] [blame] | 233 | result = test_service.BuildTargetUnitTestResult(1, None) |
| 234 | self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 235 | |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 236 | pkgs = ['foo/bar', 'cat/pkg'] |
Alex Klein | b64e5f8 | 2020-09-23 10:55:31 -0600 | [diff] [blame] | 237 | blocklist = [package_info.SplitCPV(p, strict=False) for p in pkgs] |
Alex Klein | fa6ebdc | 2019-05-10 10:57:31 -0600 | [diff] [blame] | 238 | input_msg = self._GetInput(board='board', result_path=self.tempdir, |
Alex Klein | b64e5f8 | 2020-09-23 10:55:31 -0600 | [diff] [blame] | 239 | empty_sysroot=True, blocklist=blocklist) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 240 | output_msg = self._GetOutput() |
| 241 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 242 | rc = test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 243 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 244 | |
Alex Klein | 8cb365a | 2019-05-15 16:24:53 -0600 | [diff] [blame] | 245 | self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 246 | self.assertFalse(output_msg.failed_packages) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 247 | |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 248 | def testBuildTargetUnitTest(self): |
| 249 | """Test BuildTargetUnitTest successful call.""" |
Navil Perez | c0b29a8 | 2020-07-07 14:17:48 +0000 | [diff] [blame] | 250 | pkgs = ['foo/bar', 'cat/pkg'] |
Alex Klein | 18a60af | 2020-06-11 12:08:47 -0600 | [diff] [blame] | 251 | packages = [package_info.SplitCPV(p, strict=False) for p in pkgs] |
Navil Perez | c0b29a8 | 2020-07-07 14:17:48 +0000 | [diff] [blame] | 252 | input_msg = self._GetInput( |
| 253 | board='board', result_path=self.tempdir, packages=packages) |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 254 | |
| 255 | result = test_service.BuildTargetUnitTestResult(0, None) |
| 256 | self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result) |
| 257 | |
| 258 | tarball_result = os.path.join(input_msg.result_path, 'unit_tests.tar') |
| 259 | self.PatchObject(test_service, 'BuildTargetUnitTestTarball', |
| 260 | return_value=tarball_result) |
| 261 | |
| 262 | response = self._GetOutput() |
| 263 | test_controller.BuildTargetUnitTest(input_msg, response, |
| 264 | self.api_config) |
| 265 | self.assertEqual(response.tarball_path, |
| 266 | os.path.join(input_msg.result_path, 'unit_tests.tar')) |
| 267 | |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 268 | |
Michael Mortensen | 8ca4d3b | 2019-11-27 09:35:22 -0700 | [diff] [blame] | 269 | class ChromiteUnitTestTest(cros_test_lib.MockTestCase, |
| 270 | api_config.ApiConfigMixin): |
| 271 | """Tests for the ChromiteInfoTest function.""" |
| 272 | |
| 273 | def setUp(self): |
| 274 | self.board = 'board' |
| 275 | self.chroot_path = '/path/to/chroot' |
| 276 | |
| 277 | def _GetInput(self, chroot_path=None): |
| 278 | """Helper to build an input message instance.""" |
| 279 | proto = test_pb2.ChromiteUnitTestRequest( |
| 280 | chroot={'path': chroot_path}, |
| 281 | ) |
| 282 | return proto |
| 283 | |
| 284 | def _GetOutput(self): |
| 285 | """Helper to get an empty output message instance.""" |
| 286 | return test_pb2.ChromiteUnitTestResponse() |
| 287 | |
| 288 | def testValidateOnly(self): |
| 289 | """Sanity check that a validate only call does not execute any logic.""" |
| 290 | patch = self.PatchObject(cros_build_lib, 'run') |
| 291 | |
| 292 | input_msg = self._GetInput(chroot_path=self.chroot_path) |
| 293 | test_controller.ChromiteUnitTest(input_msg, self._GetOutput(), |
| 294 | self.validate_only_config) |
| 295 | patch.assert_not_called() |
| 296 | |
Michael Mortensen | 7a860eb | 2019-12-03 20:25:15 -0700 | [diff] [blame] | 297 | def testMockError(self): |
| 298 | """Test mock error call does not execute any logic, returns error.""" |
| 299 | patch = self.PatchObject(cros_build_lib, 'run') |
| 300 | |
| 301 | input_msg = self._GetInput(chroot_path=self.chroot_path) |
| 302 | rc = test_controller.ChromiteUnitTest(input_msg, self._GetOutput(), |
| 303 | self.mock_error_config) |
| 304 | patch.assert_not_called() |
| 305 | self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc) |
| 306 | |
| 307 | def testMockCall(self): |
| 308 | """Test mock call does not execute any logic, returns success.""" |
| 309 | patch = self.PatchObject(cros_build_lib, 'run') |
| 310 | |
| 311 | input_msg = self._GetInput(chroot_path=self.chroot_path) |
| 312 | rc = test_controller.ChromiteUnitTest(input_msg, self._GetOutput(), |
| 313 | self.mock_call_config) |
| 314 | patch.assert_not_called() |
| 315 | self.assertEqual(controller.RETURN_CODE_SUCCESS, rc) |
| 316 | |
Michael Mortensen | 8ca4d3b | 2019-11-27 09:35:22 -0700 | [diff] [blame] | 317 | def testChromiteUnitTest(self): |
| 318 | """Call ChromiteUnitTest with mocked cros_build_lib.run.""" |
| 319 | request = self._GetInput(chroot_path=self.chroot_path) |
| 320 | patch = self.PatchObject( |
| 321 | cros_build_lib, 'run', |
| 322 | return_value=cros_build_lib.CommandResult(returncode=0)) |
| 323 | |
| 324 | test_controller.ChromiteUnitTest(request, self._GetOutput(), |
| 325 | self.api_config) |
| 326 | patch.assert_called_once() |
| 327 | |
| 328 | |
Alex Klein | 4bc8f4f | 2019-08-16 14:53:30 -0600 | [diff] [blame] | 329 | class CrosSigningTestTest(cros_test_lib.RunCommandTestCase, |
| 330 | api_config.ApiConfigMixin): |
| 331 | """CrosSigningTest tests.""" |
| 332 | |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 333 | def setUp(self): |
| 334 | self.chroot_path = '/path/to/chroot' |
| 335 | |
| 336 | def _GetInput(self, chroot_path=None): |
| 337 | """Helper to build an input message instance.""" |
| 338 | proto = test_pb2.CrosSigningTestRequest( |
| 339 | chroot={'path': chroot_path}, |
| 340 | ) |
| 341 | return proto |
| 342 | |
| 343 | def _GetOutput(self): |
| 344 | """Helper to get an empty output message instance.""" |
| 345 | return test_pb2.CrosSigningTestResponse() |
| 346 | |
Alex Klein | 4bc8f4f | 2019-08-16 14:53:30 -0600 | [diff] [blame] | 347 | def testValidateOnly(self): |
| 348 | """Sanity check that a validate only call does not execute any logic.""" |
| 349 | test_controller.CrosSigningTest(None, None, self.validate_only_config) |
| 350 | self.assertFalse(self.rc.call_count) |
| 351 | |
Michael Mortensen | 7a7646d | 2019-12-12 15:36:14 -0700 | [diff] [blame] | 352 | def testMockCall(self): |
| 353 | """Test mock call does not execute any logic, returns success.""" |
| 354 | rc = test_controller.CrosSigningTest(None, None, self.mock_call_config) |
| 355 | self.assertFalse(self.rc.call_count) |
| 356 | self.assertEqual(controller.RETURN_CODE_SUCCESS, rc) |
| 357 | |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 358 | def testCrosSigningTest(self): |
| 359 | """Call CrosSigningTest with mocked cros_build_lib.run.""" |
| 360 | request = self._GetInput(chroot_path=self.chroot_path) |
| 361 | patch = self.PatchObject( |
| 362 | cros_build_lib, 'run', |
| 363 | return_value=cros_build_lib.CommandResult(returncode=0)) |
| 364 | |
| 365 | test_controller.CrosSigningTest(request, self._GetOutput(), |
| 366 | self.api_config) |
| 367 | patch.assert_called_once() |
| 368 | |
Alex Klein | 4bc8f4f | 2019-08-16 14:53:30 -0600 | [diff] [blame] | 369 | |
Michael Mortensen | c28d6f1 | 2019-10-03 13:34:51 -0600 | [diff] [blame] | 370 | class SimpleChromeWorkflowTestTest(cros_test_lib.MockTestCase, |
| 371 | api_config.ApiConfigMixin): |
| 372 | """Test the SimpleChromeWorkflowTest endpoint.""" |
| 373 | |
| 374 | @staticmethod |
| 375 | def _Output(): |
| 376 | return test_pb2.SimpleChromeWorkflowTestResponse() |
| 377 | |
| 378 | def _Input(self, sysroot_path=None, build_target=None, chrome_root=None, |
| 379 | goma_config=None): |
| 380 | proto = test_pb2.SimpleChromeWorkflowTestRequest() |
| 381 | if sysroot_path: |
| 382 | proto.sysroot.path = sysroot_path |
| 383 | if build_target: |
| 384 | proto.sysroot.build_target.name = build_target |
| 385 | if chrome_root: |
| 386 | proto.chrome_root = chrome_root |
| 387 | if goma_config: |
| 388 | proto.goma_config = goma_config |
| 389 | return proto |
| 390 | |
| 391 | def setUp(self): |
| 392 | self.chrome_path = 'path/to/chrome' |
| 393 | self.sysroot_dir = 'build/board' |
| 394 | self.build_target = 'amd64' |
| 395 | self.mock_simple_chrome_workflow_test = self.PatchObject( |
| 396 | test_service, 'SimpleChromeWorkflowTest') |
| 397 | |
| 398 | def testMissingBuildTarget(self): |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 399 | """Test SimpleChromeWorkflowTest dies when build_target not set.""" |
Michael Mortensen | c28d6f1 | 2019-10-03 13:34:51 -0600 | [diff] [blame] | 400 | input_proto = self._Input(build_target=None, sysroot_path='/sysroot/dir', |
| 401 | chrome_root='/chrome/path') |
| 402 | with self.assertRaises(cros_build_lib.DieSystemExit): |
| 403 | test_controller.SimpleChromeWorkflowTest(input_proto, None, |
| 404 | self.api_config) |
| 405 | |
| 406 | def testMissingSysrootPath(self): |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 407 | """Test SimpleChromeWorkflowTest dies when build_target not set.""" |
Michael Mortensen | c28d6f1 | 2019-10-03 13:34:51 -0600 | [diff] [blame] | 408 | input_proto = self._Input(build_target='board', sysroot_path=None, |
| 409 | chrome_root='/chrome/path') |
| 410 | with self.assertRaises(cros_build_lib.DieSystemExit): |
| 411 | test_controller.SimpleChromeWorkflowTest(input_proto, None, |
| 412 | self.api_config) |
| 413 | |
| 414 | def testMissingChromeRoot(self): |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 415 | """Test SimpleChromeWorkflowTest dies when build_target not set.""" |
Michael Mortensen | c28d6f1 | 2019-10-03 13:34:51 -0600 | [diff] [blame] | 416 | input_proto = self._Input(build_target='board', sysroot_path='/sysroot/dir', |
| 417 | chrome_root=None) |
| 418 | with self.assertRaises(cros_build_lib.DieSystemExit): |
| 419 | test_controller.SimpleChromeWorkflowTest(input_proto, None, |
| 420 | self.api_config) |
| 421 | |
| 422 | def testSimpleChromeWorkflowTest(self): |
| 423 | """Call SimpleChromeWorkflowTest with valid args and temp dir.""" |
| 424 | request = self._Input(sysroot_path='sysroot_path', build_target='board', |
| 425 | chrome_root='/path/to/chrome') |
| 426 | response = self._Output() |
| 427 | |
| 428 | test_controller.SimpleChromeWorkflowTest(request, response, self.api_config) |
| 429 | self.mock_simple_chrome_workflow_test.assert_called() |
| 430 | |
| 431 | def testValidateOnly(self): |
| 432 | request = self._Input(sysroot_path='sysroot_path', build_target='board', |
| 433 | chrome_root='/path/to/chrome') |
| 434 | test_controller.SimpleChromeWorkflowTest(request, self._Output(), |
| 435 | self.validate_only_config) |
| 436 | self.mock_simple_chrome_workflow_test.assert_not_called() |
| 437 | |
Michael Mortensen | 7a7646d | 2019-12-12 15:36:14 -0700 | [diff] [blame] | 438 | def testMockCall(self): |
| 439 | """Test mock call does not execute any logic, returns success.""" |
| 440 | patch = self.mock_simple_chrome_workflow_test = self.PatchObject( |
| 441 | test_service, 'SimpleChromeWorkflowTest') |
| 442 | |
| 443 | request = self._Input(sysroot_path='sysroot_path', build_target='board', |
| 444 | chrome_root='/path/to/chrome') |
| 445 | rc = test_controller.SimpleChromeWorkflowTest(request, self._Output(), |
| 446 | self.mock_call_config) |
| 447 | patch.assert_not_called() |
| 448 | self.assertEqual(controller.RETURN_CODE_SUCCESS, rc) |
| 449 | |
Michael Mortensen | c28d6f1 | 2019-10-03 13:34:51 -0600 | [diff] [blame] | 450 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 451 | class VmTestTest(cros_test_lib.RunCommandTestCase, api_config.ApiConfigMixin): |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 452 | """Test the VmTest endpoint.""" |
| 453 | |
| 454 | def _GetInput(self, **kwargs): |
| 455 | values = dict( |
| 456 | build_target=common_pb2.BuildTarget(name='target'), |
Alex Klein | 311b802 | 2019-06-05 16:00:07 -0600 | [diff] [blame] | 457 | vm_path=common_pb2.Path(path='/path/to/image.bin', |
| 458 | location=common_pb2.Path.INSIDE), |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 459 | test_harness=test_pb2.VmTestRequest.TAST, |
| 460 | vm_tests=[test_pb2.VmTestRequest.VmTest(pattern='suite')], |
| 461 | ssh_options=test_pb2.VmTestRequest.SshOptions( |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 462 | port=1234, private_key_path={'path': '/path/to/id_rsa', |
Alex Klein | aa70541 | 2019-06-04 15:00:30 -0600 | [diff] [blame] | 463 | 'location': common_pb2.Path.INSIDE}), |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 464 | ) |
| 465 | values.update(kwargs) |
| 466 | return test_pb2.VmTestRequest(**values) |
| 467 | |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 468 | def _Output(self): |
| 469 | return test_pb2.VmTestResponse() |
| 470 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 471 | def testValidateOnly(self): |
| 472 | """Sanity check that a validate only call does not execute any logic.""" |
| 473 | test_controller.VmTest(self._GetInput(), None, self.validate_only_config) |
| 474 | self.assertEqual(0, self.rc.call_count) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 475 | |
Michael Mortensen | 7a7646d | 2019-12-12 15:36:14 -0700 | [diff] [blame] | 476 | def testMockCall(self): |
| 477 | """Test mock call does not execute any logic.""" |
| 478 | patch = self.PatchObject(cros_build_lib, 'run') |
| 479 | |
| 480 | request = self._GetInput() |
| 481 | response = self._Output() |
| 482 | # VmTest does not return a value, checking mocked value is flagged by lint. |
| 483 | test_controller.VmTest(request, response, self.mock_call_config) |
| 484 | patch.assert_not_called() |
| 485 | |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 486 | def testTastAllOptions(self): |
| 487 | """Test VmTest for Tast with all options set.""" |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 488 | test_controller.VmTest(self._GetInput(), None, self.api_config) |
| 489 | self.assertCommandContains([ |
Achuith Bhandarkar | a9e9c3d | 2019-05-22 13:56:11 -0700 | [diff] [blame] | 490 | 'cros_run_test', '--debug', '--no-display', '--copy-on-write', |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 491 | '--board', 'target', |
| 492 | '--image-path', '/path/to/image.bin', |
| 493 | '--tast', 'suite', |
| 494 | '--ssh-port', '1234', |
| 495 | '--private-key', '/path/to/id_rsa', |
| 496 | ]) |
| 497 | |
| 498 | def testAutotestAllOptions(self): |
| 499 | """Test VmTest for Autotest with all options set.""" |
| 500 | input_proto = self._GetInput(test_harness=test_pb2.VmTestRequest.AUTOTEST) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 501 | test_controller.VmTest(input_proto, None, self.api_config) |
| 502 | self.assertCommandContains([ |
Achuith Bhandarkar | a9e9c3d | 2019-05-22 13:56:11 -0700 | [diff] [blame] | 503 | 'cros_run_test', '--debug', '--no-display', '--copy-on-write', |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 504 | '--board', 'target', |
| 505 | '--image-path', '/path/to/image.bin', |
| 506 | '--autotest', 'suite', |
| 507 | '--ssh-port', '1234', |
| 508 | '--private-key', '/path/to/id_rsa', |
Greg Edelston | dcb0e91 | 2020-08-31 11:09:40 -0600 | [diff] [blame] | 509 | '--test_that-args=--allow-chrome-crashes', |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 510 | ]) |
| 511 | |
| 512 | def testMissingBuildTarget(self): |
| 513 | """Test VmTest dies when build_target not set.""" |
| 514 | input_proto = self._GetInput(build_target=None) |
| 515 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 516 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 517 | |
| 518 | def testMissingVmImage(self): |
| 519 | """Test VmTest dies when vm_image not set.""" |
Alex Klein | 311b802 | 2019-06-05 16:00:07 -0600 | [diff] [blame] | 520 | input_proto = self._GetInput(vm_path=None) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 521 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 522 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 523 | |
| 524 | def testMissingTestHarness(self): |
| 525 | """Test VmTest dies when test_harness not specified.""" |
| 526 | input_proto = self._GetInput( |
| 527 | test_harness=test_pb2.VmTestRequest.UNSPECIFIED) |
| 528 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 529 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 530 | |
| 531 | def testMissingVmTests(self): |
| 532 | """Test VmTest dies when vm_tests not set.""" |
| 533 | input_proto = self._GetInput(vm_tests=[]) |
| 534 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 535 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 536 | |
Michael Mortensen | 82cd62d | 2019-12-01 14:58:54 -0700 | [diff] [blame] | 537 | def testVmTest(self): |
| 538 | """Call VmTest with valid args and temp dir.""" |
| 539 | request = self._GetInput() |
| 540 | response = self._Output() |
| 541 | patch = self.PatchObject( |
| 542 | cros_build_lib, 'run', |
| 543 | return_value=cros_build_lib.CommandResult(returncode=0)) |
| 544 | |
| 545 | test_controller.VmTest(request, response, self.api_config) |
| 546 | patch.assert_called() |
| 547 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 548 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 549 | class MoblabVmTestTest(cros_test_lib.MockTestCase, api_config.ApiConfigMixin): |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 550 | """Test the MoblabVmTest endpoint.""" |
| 551 | |
| 552 | @staticmethod |
| 553 | def _Payload(path): |
| 554 | return test_pb2.MoblabVmTestRequest.Payload( |
| 555 | path=common_pb2.Path(path=path)) |
| 556 | |
| 557 | @staticmethod |
| 558 | def _Output(): |
| 559 | return test_pb2.MoblabVmTestResponse() |
| 560 | |
| 561 | def _Input(self): |
| 562 | return test_pb2.MoblabVmTestRequest( |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 563 | chroot=common_pb2.Chroot(path=self.chroot_dir), |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 564 | image_payload=self._Payload(self.image_payload_dir), |
| 565 | cache_payloads=[self._Payload(self.autotest_payload_dir)]) |
| 566 | |
| 567 | def setUp(self): |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 568 | self.chroot_dir = '/chroot' |
| 569 | self.chroot_tmp_dir = '/chroot/tmp' |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 570 | self.image_payload_dir = '/payloads/image' |
| 571 | self.autotest_payload_dir = '/payloads/autotest' |
| 572 | self.builder = 'moblab-generic-vm/R12-3.4.5-67.890' |
| 573 | self.image_cache_dir = '/mnt/moblab/cache' |
| 574 | self.image_mount_dir = '/mnt/image' |
| 575 | |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 576 | self.PatchObject(chroot_lib.Chroot, 'tempdir', osutils.TempDir) |
Evan Hernandez | 655e804 | 2019-06-13 12:50:44 -0600 | [diff] [blame] | 577 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 578 | self.mock_create_moblab_vms = self.PatchObject( |
| 579 | test_service, 'CreateMoblabVm') |
| 580 | self.mock_prepare_moblab_vm_image_cache = self.PatchObject( |
| 581 | test_service, 'PrepareMoblabVmImageCache', |
| 582 | return_value=self.image_cache_dir) |
| 583 | self.mock_run_moblab_vm_tests = self.PatchObject( |
| 584 | test_service, 'RunMoblabVmTest') |
| 585 | self.mock_validate_moblab_vm_tests = self.PatchObject( |
| 586 | test_service, 'ValidateMoblabVmTest') |
| 587 | |
| 588 | @contextlib.contextmanager |
Alex Klein | 38c7d9e | 2019-05-08 09:31:19 -0600 | [diff] [blame] | 589 | def MockLoopbackPartitions(*_args, **_kwargs): |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 590 | mount = mock.MagicMock() |
Evan Hernandez | 40ee745 | 2019-06-13 12:51:43 -0600 | [diff] [blame] | 591 | mount.Mount.return_value = [self.image_mount_dir] |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 592 | yield mount |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 593 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 594 | self.PatchObject(image_lib, 'LoopbackPartitions', MockLoopbackPartitions) |
| 595 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 596 | def testValidateOnly(self): |
| 597 | """Sanity check that a validate only call does not execute any logic.""" |
| 598 | test_controller.MoblabVmTest(self._Input(), self._Output(), |
| 599 | self.validate_only_config) |
| 600 | self.mock_create_moblab_vms.assert_not_called() |
| 601 | |
Michael Mortensen | 7a7646d | 2019-12-12 15:36:14 -0700 | [diff] [blame] | 602 | def testMockCall(self): |
| 603 | """Test mock call does not execute any logic.""" |
| 604 | patch = self.PatchObject(key_value_store, 'LoadFile') |
| 605 | |
| 606 | # MoblabVmTest does not return a value, checking mocked value is flagged by |
| 607 | # lint. |
| 608 | test_controller.MoblabVmTest(self._Input(), self._Output(), |
| 609 | self.mock_call_config) |
| 610 | patch.assert_not_called() |
| 611 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 612 | def testImageContainsBuilder(self): |
| 613 | """MoblabVmTest calls service with correct args.""" |
| 614 | request = self._Input() |
| 615 | response = self._Output() |
| 616 | |
| 617 | self.PatchObject( |
Mike Frysinger | e652ba1 | 2019-09-08 00:57:43 -0400 | [diff] [blame] | 618 | key_value_store, 'LoadFile', |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 619 | return_value={cros_set_lsb_release.LSB_KEY_BUILDER_PATH: self.builder}) |
| 620 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 621 | test_controller.MoblabVmTest(request, response, self.api_config) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 622 | |
| 623 | self.assertEqual( |
| 624 | self.mock_create_moblab_vms.call_args_list, |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 625 | [mock.call(mock.ANY, self.chroot_dir, self.image_payload_dir)]) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 626 | self.assertEqual( |
| 627 | self.mock_prepare_moblab_vm_image_cache.call_args_list, |
| 628 | [mock.call(mock.ANY, self.builder, [self.autotest_payload_dir])]) |
| 629 | self.assertEqual( |
| 630 | self.mock_run_moblab_vm_tests.call_args_list, |
Evan Hernandez | 655e804 | 2019-06-13 12:50:44 -0600 | [diff] [blame] | 631 | [mock.call(mock.ANY, mock.ANY, self.builder, self.image_cache_dir, |
| 632 | mock.ANY)]) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 633 | self.assertEqual( |
| 634 | self.mock_validate_moblab_vm_tests.call_args_list, |
| 635 | [mock.call(mock.ANY)]) |
| 636 | |
| 637 | def testImageMissingBuilder(self): |
| 638 | """MoblabVmTest dies when builder path not found in lsb-release.""" |
| 639 | request = self._Input() |
| 640 | response = self._Output() |
| 641 | |
Mike Frysinger | e652ba1 | 2019-09-08 00:57:43 -0400 | [diff] [blame] | 642 | self.PatchObject(key_value_store, 'LoadFile', return_value={}) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 643 | |
| 644 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 645 | test_controller.MoblabVmTest(request, response, self.api_config) |