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