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 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 10 | import contextlib |
Alex Klein | fa6ebdc | 2019-05-10 10:57:31 -0600 | [diff] [blame] | 11 | import mock |
| 12 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 13 | from chromite.api import api_config |
Alex Klein | 8cb365a | 2019-05-15 16:24:53 -0600 | [diff] [blame] | 14 | from chromite.api import controller |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 15 | from chromite.api.controller import test as test_controller |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 16 | from chromite.api.gen.chromiumos import common_pb2 |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 17 | from chromite.api.gen.chromite.api import test_pb2 |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 18 | from chromite.lib import chroot_lib |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 19 | from chromite.lib import cros_build_lib |
| 20 | from chromite.lib import cros_test_lib |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 21 | from chromite.lib import image_lib |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 22 | from chromite.lib import osutils |
| 23 | from chromite.lib import portage_util |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 24 | from chromite.scripts import cros_set_lsb_release |
| 25 | from chromite.service import test as test_service |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 26 | |
| 27 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 28 | class BuildTargetUnitTestTest(cros_test_lib.MockTempDirTestCase, |
| 29 | api_config.ApiConfigMixin): |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 30 | """Tests for the UnitTest function.""" |
| 31 | |
| 32 | def _GetInput(self, board=None, result_path=None, chroot_path=None, |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 33 | cache_dir=None, empty_sysroot=None, blacklist=None): |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 34 | """Helper to build an input message instance.""" |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 35 | formatted_blacklist = [] |
| 36 | for pkg in blacklist or []: |
| 37 | formatted_blacklist.append({'category': pkg.category, |
| 38 | 'package_name': pkg.package}) |
| 39 | |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 40 | return test_pb2.BuildTargetUnitTestRequest( |
| 41 | build_target={'name': board}, result_path=result_path, |
Alex Klein | fa6ebdc | 2019-05-10 10:57:31 -0600 | [diff] [blame] | 42 | chroot={'path': chroot_path, 'cache_dir': cache_dir}, |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 43 | flags={'empty_sysroot': empty_sysroot}, |
| 44 | package_blacklist=formatted_blacklist, |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 45 | ) |
| 46 | |
| 47 | def _GetOutput(self): |
| 48 | """Helper to get an empty output message instance.""" |
| 49 | return test_pb2.BuildTargetUnitTestResponse() |
| 50 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 51 | def testValidateOnly(self): |
| 52 | """Sanity check that a validate only call does not execute any logic.""" |
| 53 | patch = self.PatchObject(test_service, 'BuildTargetUnitTest') |
| 54 | |
| 55 | input_msg = self._GetInput(board='board', result_path=self.tempdir) |
| 56 | test_controller.BuildTargetUnitTest(input_msg, self._GetOutput(), |
| 57 | self.validate_only_config) |
| 58 | patch.assert_not_called() |
| 59 | |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 60 | def testNoArgumentFails(self): |
| 61 | """Test no arguments fails.""" |
| 62 | input_msg = self._GetInput() |
| 63 | output_msg = self._GetOutput() |
| 64 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 65 | test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 66 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 67 | |
| 68 | def testNoBuildTargetFails(self): |
| 69 | """Test missing build target name fails.""" |
| 70 | input_msg = self._GetInput(result_path=self.tempdir) |
| 71 | output_msg = self._GetOutput() |
| 72 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 73 | test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 74 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 75 | |
| 76 | def testNoResultPathFails(self): |
| 77 | """Test missing result path fails.""" |
| 78 | # Missing result_path. |
| 79 | input_msg = self._GetInput(board='board') |
| 80 | output_msg = self._GetOutput() |
| 81 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 82 | test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 83 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 84 | |
| 85 | def testPackageBuildFailure(self): |
| 86 | """Test handling of raised BuildPackageFailure.""" |
| 87 | tempdir = osutils.TempDir(base_dir=self.tempdir) |
| 88 | self.PatchObject(osutils, 'TempDir', return_value=tempdir) |
| 89 | |
| 90 | pkgs = ['cat/pkg', 'foo/bar'] |
| 91 | expected = [('cat', 'pkg'), ('foo', 'bar')] |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 92 | |
Alex Klein | 38c7d9e | 2019-05-08 09:31:19 -0600 | [diff] [blame] | 93 | result = test_service.BuildTargetUnitTestResult(1, None) |
| 94 | result.failed_cpvs = [portage_util.SplitCPV(p, strict=False) for p in pkgs] |
| 95 | self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 96 | |
| 97 | input_msg = self._GetInput(board='board', result_path=self.tempdir) |
| 98 | output_msg = self._GetOutput() |
| 99 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 100 | rc = test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 101 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 102 | |
Alex Klein | 8cb365a | 2019-05-15 16:24:53 -0600 | [diff] [blame] | 103 | self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 104 | self.assertTrue(output_msg.failed_packages) |
| 105 | failed = [] |
| 106 | for pi in output_msg.failed_packages: |
| 107 | failed.append((pi.category, pi.package_name)) |
| 108 | self.assertItemsEqual(expected, failed) |
| 109 | |
| 110 | def testOtherBuildScriptFailure(self): |
| 111 | """Test build script failure due to non-package emerge error.""" |
| 112 | tempdir = osutils.TempDir(base_dir=self.tempdir) |
| 113 | self.PatchObject(osutils, 'TempDir', return_value=tempdir) |
| 114 | |
Alex Klein | 38c7d9e | 2019-05-08 09:31:19 -0600 | [diff] [blame] | 115 | result = test_service.BuildTargetUnitTestResult(1, None) |
| 116 | self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 117 | |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 118 | pkgs = ['foo/bar', 'cat/pkg'] |
| 119 | blacklist = [portage_util.SplitCPV(p, strict=False) for p in pkgs] |
Alex Klein | fa6ebdc | 2019-05-10 10:57:31 -0600 | [diff] [blame] | 120 | input_msg = self._GetInput(board='board', result_path=self.tempdir, |
Alex Klein | f267446 | 2019-05-16 16:47:24 -0600 | [diff] [blame] | 121 | empty_sysroot=True, blacklist=blacklist) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 122 | output_msg = self._GetOutput() |
| 123 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 124 | rc = test_controller.BuildTargetUnitTest(input_msg, output_msg, |
| 125 | self.api_config) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 126 | |
Alex Klein | 8cb365a | 2019-05-15 16:24:53 -0600 | [diff] [blame] | 127 | self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc) |
Alex Klein | a2e42c4 | 2019-04-17 16:13:19 -0600 | [diff] [blame] | 128 | self.assertFalse(output_msg.failed_packages) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 129 | |
| 130 | |
Alex Klein | 4bc8f4f | 2019-08-16 14:53:30 -0600 | [diff] [blame] | 131 | class CrosSigningTestTest(cros_test_lib.RunCommandTestCase, |
| 132 | api_config.ApiConfigMixin): |
| 133 | """CrosSigningTest tests.""" |
| 134 | |
| 135 | def testValidateOnly(self): |
| 136 | """Sanity check that a validate only call does not execute any logic.""" |
| 137 | test_controller.CrosSigningTest(None, None, self.validate_only_config) |
| 138 | self.assertFalse(self.rc.call_count) |
| 139 | |
| 140 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 141 | class VmTestTest(cros_test_lib.RunCommandTestCase, api_config.ApiConfigMixin): |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 142 | """Test the VmTest endpoint.""" |
| 143 | |
| 144 | def _GetInput(self, **kwargs): |
| 145 | values = dict( |
| 146 | build_target=common_pb2.BuildTarget(name='target'), |
Alex Klein | 311b802 | 2019-06-05 16:00:07 -0600 | [diff] [blame] | 147 | vm_path=common_pb2.Path(path='/path/to/image.bin', |
| 148 | location=common_pb2.Path.INSIDE), |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 149 | test_harness=test_pb2.VmTestRequest.TAST, |
| 150 | vm_tests=[test_pb2.VmTestRequest.VmTest(pattern='suite')], |
| 151 | ssh_options=test_pb2.VmTestRequest.SshOptions( |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 152 | port=1234, private_key_path={'path': '/path/to/id_rsa', |
Alex Klein | aa70541 | 2019-06-04 15:00:30 -0600 | [diff] [blame] | 153 | 'location': common_pb2.Path.INSIDE}), |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 154 | ) |
| 155 | values.update(kwargs) |
| 156 | return test_pb2.VmTestRequest(**values) |
| 157 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 158 | def testValidateOnly(self): |
| 159 | """Sanity check that a validate only call does not execute any logic.""" |
| 160 | test_controller.VmTest(self._GetInput(), None, self.validate_only_config) |
| 161 | self.assertEqual(0, self.rc.call_count) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 162 | |
| 163 | def testTastAllOptions(self): |
| 164 | """Test VmTest for Tast with all options set.""" |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 165 | test_controller.VmTest(self._GetInput(), None, self.api_config) |
| 166 | self.assertCommandContains([ |
Achuith Bhandarkar | a9e9c3d | 2019-05-22 13:56:11 -0700 | [diff] [blame] | 167 | 'cros_run_test', '--debug', '--no-display', '--copy-on-write', |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 168 | '--board', 'target', |
| 169 | '--image-path', '/path/to/image.bin', |
| 170 | '--tast', 'suite', |
| 171 | '--ssh-port', '1234', |
| 172 | '--private-key', '/path/to/id_rsa', |
| 173 | ]) |
| 174 | |
| 175 | def testAutotestAllOptions(self): |
| 176 | """Test VmTest for Autotest with all options set.""" |
| 177 | input_proto = self._GetInput(test_harness=test_pb2.VmTestRequest.AUTOTEST) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 178 | test_controller.VmTest(input_proto, None, self.api_config) |
| 179 | self.assertCommandContains([ |
Achuith Bhandarkar | a9e9c3d | 2019-05-22 13:56:11 -0700 | [diff] [blame] | 180 | 'cros_run_test', '--debug', '--no-display', '--copy-on-write', |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 181 | '--board', 'target', |
| 182 | '--image-path', '/path/to/image.bin', |
| 183 | '--autotest', 'suite', |
| 184 | '--ssh-port', '1234', |
| 185 | '--private-key', '/path/to/id_rsa', |
| 186 | '--test_that-args=--whitelist-chrome-crashes', |
| 187 | ]) |
| 188 | |
| 189 | def testMissingBuildTarget(self): |
| 190 | """Test VmTest dies when build_target not set.""" |
| 191 | input_proto = self._GetInput(build_target=None) |
| 192 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 193 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 194 | |
| 195 | def testMissingVmImage(self): |
| 196 | """Test VmTest dies when vm_image not set.""" |
Alex Klein | 311b802 | 2019-06-05 16:00:07 -0600 | [diff] [blame] | 197 | input_proto = self._GetInput(vm_path=None) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 198 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 199 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 200 | |
| 201 | def testMissingTestHarness(self): |
| 202 | """Test VmTest dies when test_harness not specified.""" |
| 203 | input_proto = self._GetInput( |
| 204 | test_harness=test_pb2.VmTestRequest.UNSPECIFIED) |
| 205 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 206 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | 4e388a5 | 2019-05-01 12:16:33 -0600 | [diff] [blame] | 207 | |
| 208 | def testMissingVmTests(self): |
| 209 | """Test VmTest dies when vm_tests not set.""" |
| 210 | input_proto = self._GetInput(vm_tests=[]) |
| 211 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 212 | test_controller.VmTest(input_proto, None, self.api_config) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 213 | |
| 214 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 215 | class MoblabVmTestTest(cros_test_lib.MockTestCase, api_config.ApiConfigMixin): |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 216 | """Test the MoblabVmTest endpoint.""" |
| 217 | |
| 218 | @staticmethod |
| 219 | def _Payload(path): |
| 220 | return test_pb2.MoblabVmTestRequest.Payload( |
| 221 | path=common_pb2.Path(path=path)) |
| 222 | |
| 223 | @staticmethod |
| 224 | def _Output(): |
| 225 | return test_pb2.MoblabVmTestResponse() |
| 226 | |
| 227 | def _Input(self): |
| 228 | return test_pb2.MoblabVmTestRequest( |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 229 | chroot=common_pb2.Chroot(path=self.chroot_dir), |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 230 | image_payload=self._Payload(self.image_payload_dir), |
| 231 | cache_payloads=[self._Payload(self.autotest_payload_dir)]) |
| 232 | |
| 233 | def setUp(self): |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 234 | self.chroot_dir = '/chroot' |
| 235 | self.chroot_tmp_dir = '/chroot/tmp' |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 236 | self.image_payload_dir = '/payloads/image' |
| 237 | self.autotest_payload_dir = '/payloads/autotest' |
| 238 | self.builder = 'moblab-generic-vm/R12-3.4.5-67.890' |
| 239 | self.image_cache_dir = '/mnt/moblab/cache' |
| 240 | self.image_mount_dir = '/mnt/image' |
| 241 | |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 242 | self.PatchObject(chroot_lib.Chroot, 'tempdir', osutils.TempDir) |
Evan Hernandez | 655e804 | 2019-06-13 12:50:44 -0600 | [diff] [blame] | 243 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 244 | self.mock_create_moblab_vms = self.PatchObject( |
| 245 | test_service, 'CreateMoblabVm') |
| 246 | self.mock_prepare_moblab_vm_image_cache = self.PatchObject( |
| 247 | test_service, 'PrepareMoblabVmImageCache', |
| 248 | return_value=self.image_cache_dir) |
| 249 | self.mock_run_moblab_vm_tests = self.PatchObject( |
| 250 | test_service, 'RunMoblabVmTest') |
| 251 | self.mock_validate_moblab_vm_tests = self.PatchObject( |
| 252 | test_service, 'ValidateMoblabVmTest') |
| 253 | |
| 254 | @contextlib.contextmanager |
Alex Klein | 38c7d9e | 2019-05-08 09:31:19 -0600 | [diff] [blame] | 255 | def MockLoopbackPartitions(*_args, **_kwargs): |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 256 | mount = mock.MagicMock() |
Evan Hernandez | 40ee745 | 2019-06-13 12:51:43 -0600 | [diff] [blame] | 257 | mount.Mount.return_value = [self.image_mount_dir] |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 258 | yield mount |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 259 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 260 | self.PatchObject(image_lib, 'LoopbackPartitions', MockLoopbackPartitions) |
| 261 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 262 | def testValidateOnly(self): |
| 263 | """Sanity check that a validate only call does not execute any logic.""" |
| 264 | test_controller.MoblabVmTest(self._Input(), self._Output(), |
| 265 | self.validate_only_config) |
| 266 | self.mock_create_moblab_vms.assert_not_called() |
| 267 | |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 268 | def testImageContainsBuilder(self): |
| 269 | """MoblabVmTest calls service with correct args.""" |
| 270 | request = self._Input() |
| 271 | response = self._Output() |
| 272 | |
| 273 | self.PatchObject( |
| 274 | cros_build_lib, 'LoadKeyValueFile', |
| 275 | return_value={cros_set_lsb_release.LSB_KEY_BUILDER_PATH: self.builder}) |
| 276 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 277 | test_controller.MoblabVmTest(request, response, self.api_config) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 278 | |
| 279 | self.assertEqual( |
| 280 | self.mock_create_moblab_vms.call_args_list, |
Evan Hernandez | e1e05d3 | 2019-07-19 12:32:18 -0600 | [diff] [blame] | 281 | [mock.call(mock.ANY, self.chroot_dir, self.image_payload_dir)]) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 282 | self.assertEqual( |
| 283 | self.mock_prepare_moblab_vm_image_cache.call_args_list, |
| 284 | [mock.call(mock.ANY, self.builder, [self.autotest_payload_dir])]) |
| 285 | self.assertEqual( |
| 286 | self.mock_run_moblab_vm_tests.call_args_list, |
Evan Hernandez | 655e804 | 2019-06-13 12:50:44 -0600 | [diff] [blame] | 287 | [mock.call(mock.ANY, mock.ANY, self.builder, self.image_cache_dir, |
| 288 | mock.ANY)]) |
Evan Hernandez | dc3f0bb | 2019-06-06 12:46:52 -0600 | [diff] [blame] | 289 | self.assertEqual( |
| 290 | self.mock_validate_moblab_vm_tests.call_args_list, |
| 291 | [mock.call(mock.ANY)]) |
| 292 | |
| 293 | def testImageMissingBuilder(self): |
| 294 | """MoblabVmTest dies when builder path not found in lsb-release.""" |
| 295 | request = self._Input() |
| 296 | response = self._Output() |
| 297 | |
| 298 | self.PatchObject(cros_build_lib, 'LoadKeyValueFile', return_value={}) |
| 299 | |
| 300 | with self.assertRaises(cros_build_lib.DieSystemExit): |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 301 | test_controller.MoblabVmTest(request, response, self.api_config) |