api: artifacts: Cleanup legacy code paths
Cleanup some legacy input handling code paths that haven't been
relevant since at least April 2020.
BUG=b:223433932
TEST=CQ
Change-Id: Ib8de7880e2fbc06234671a90c3432376eb28a10a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3684159
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Lizzy Presland <zland@google.com>
Commit-Queue: Lizzy Presland <zland@google.com>
Auto-Submit: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/artifacts_unittest.py b/api/controller/artifacts_unittest.py
index 4641ba7..5c5255c 100644
--- a/api/controller/artifacts_unittest.py
+++ b/api/controller/artifacts_unittest.py
@@ -199,40 +199,20 @@
def testValidateOnly(self):
"""Quick check that a validate only call does not execute any logic."""
patch = self.PatchObject(artifacts_svc, 'BundleAutotestFiles')
- artifacts.BundleAutotestFiles(self.target_request, self.response,
+ artifacts.BundleAutotestFiles(self.sysroot_request, self.response,
self.validate_only_config)
patch.assert_not_called()
def testMockCall(self):
"""Test that a mock call does not execute logic, returns mocked value."""
patch = self.PatchObject(artifacts_svc, 'BundleAutotestFiles')
- artifacts.BundleAutotestFiles(self.target_request, self.response,
+ artifacts.BundleAutotestFiles(self.sysroot_request, self.response,
self.mock_call_config)
patch.assert_not_called()
self.assertEqual(len(self.response.artifacts), 1)
self.assertEqual(self.response.artifacts[0].path,
os.path.join(self.output_dir, 'autotest-a.tar.gz'))
- def testBundleAutotestFilesLegacy(self):
- """BundleAutotestFiles calls service correctly with legacy args."""
- files = {
- artifacts_svc.ARCHIVE_CONTROL_FILES: '/tmp/artifacts/autotest-a.tar.gz',
- artifacts_svc.ARCHIVE_PACKAGES: '/tmp/artifacts/autotest-b.tar.gz',
- }
- patch = self.PatchObject(artifacts_svc, 'BundleAutotestFiles',
- return_value=files)
-
- artifacts.BundleAutotestFiles(self.target_request, self.response,
- self.api_config)
-
- # Verify the arguments are being passed through.
- patch.assert_called_with(mock.ANY, self.sysroot, self.output_dir)
-
- # Verify the output proto is being populated correctly.
- self.assertTrue(self.response.artifacts)
- paths = [artifact.path for artifact in self.response.artifacts]
- self.assertCountEqual(list(files.values()), paths)
-
def testBundleAutotestFiles(self):
"""BundleAutotestFiles calls service correctly."""
files = {
@@ -275,8 +255,8 @@
sysroot='/does/not/exist',
output_dir=self.output_dir)
- with self.assertRaises(cros_build_lib.DieSystemExit):
- artifacts.BundleAutotestFiles(request, self.response, self.api_config)
+ artifacts.BundleAutotestFiles(request, self.response, self.api_config)
+ self.assertFalse(self.response.artifacts)
class BundleTastFilesTest(BundleTestCase):
@@ -285,14 +265,14 @@
def testValidateOnly(self):
"""Quick check that a validate only call does not execute any logic."""
patch = self.PatchObject(artifacts_svc, 'BundleTastFiles')
- artifacts.BundleTastFiles(self.target_request, self.response,
+ artifacts.BundleTastFiles(self.sysroot_request, self.response,
self.validate_only_config)
patch.assert_not_called()
def testMockCall(self):
"""Test that a mock call does not execute logic, returns mocked value."""
patch = self.PatchObject(artifacts_svc, 'BundleTastFiles')
- artifacts.BundleTastFiles(self.target_request, self.response,
+ artifacts.BundleTastFiles(self.sysroot_request, self.response,
self.mock_call_config)
patch.assert_not_called()
self.assertEqual(len(self.response.artifacts), 1)
@@ -303,35 +283,9 @@
"""BundleTasteFiles succeeds when no tast files found."""
self.PatchObject(commands, 'BuildTastBundleTarball',
return_value=None)
- artifacts.BundleTastFiles(self.target_request, self.response,
+ artifacts.BundleTastFiles(self.sysroot_request, self.response,
self.api_config)
- self.assertEqual(list(self.response.artifacts), [])
-
- def testBundleTastFilesLegacy(self):
- """BundleTastFiles handles legacy args correctly."""
- buildroot = self.tempdir
- chroot_dir = os.path.join(buildroot, 'chroot')
- sysroot_path = os.path.join(chroot_dir, 'build', 'board')
- output_dir = os.path.join(self.tempdir, 'results')
- osutils.SafeMakedirs(sysroot_path)
- osutils.SafeMakedirs(output_dir)
-
- chroot = chroot_lib.Chroot(chroot_dir)
- sysroot = sysroot_lib.Sysroot('/build/board')
-
- expected_archive = os.path.join(output_dir, artifacts_svc.TAST_BUNDLE_NAME)
- # Patch the service being called.
- bundle_patch = self.PatchObject(artifacts_svc, 'BundleTastFiles',
- return_value=expected_archive)
- self.PatchObject(constants, 'SOURCE_ROOT', new=buildroot)
-
- request = artifacts_pb2.BundleRequest(build_target={'name': 'board'},
- output_dir=output_dir)
- artifacts.BundleTastFiles(request, self.response, self.api_config)
- self.assertEqual(
- [artifact.path for artifact in self.response.artifacts],
- [expected_archive])
- bundle_patch.assert_called_once_with(chroot, sysroot, output_dir)
+ self.assertFalse(self.response.artifacts)
def testBundleTastFiles(self):
"""BundleTastFiles calls service correctly."""
@@ -442,14 +396,14 @@
def testValidateOnly(self):
"""Quick check that a validate only call does not execute any logic."""
patch = self.PatchObject(commands, 'BuildEbuildLogsTarball')
- artifacts.BundleEbuildLogs(self.target_request, self.response,
+ artifacts.BundleEbuildLogs(self.sysroot_request, self.response,
self.validate_only_config)
patch.assert_not_called()
def testMockCall(self):
"""Test that a mock call does not execute logic, returns mocked value."""
patch = self.PatchObject(commands, 'BuildEbuildLogsTarball')
- artifacts.BundleEbuildLogs(self.target_request, self.response,
+ artifacts.BundleEbuildLogs(self.sysroot_request, self.response,
self.mock_call_config)
patch.assert_not_called()
self.assertEqual(len(self.response.artifacts), 1)
@@ -470,24 +424,13 @@
bundle_ebuild_logs_tarball.call_args_list,
[mock.call(mock.ANY, self.sysroot, self.output_dir)])
- def testBundleEBuildLogsOldProto(self):
- bundle_ebuild_logs_tarball = self.PatchObject(
- artifacts_svc, 'BundleEBuildLogsTarball',
- return_value='ebuild-logs.tar.gz')
-
- artifacts.BundleEbuildLogs(self.target_request, self.response,
- self.api_config)
-
- self.assertEqual(
- bundle_ebuild_logs_tarball.call_args_list,
- [mock.call(mock.ANY, self.sysroot, self.output_dir)])
-
def testBundleEbuildLogsNoLogs(self):
"""BundleEbuildLogs dies when no logs found."""
self.PatchObject(commands, 'BuildEbuildLogsTarball', return_value=None)
- with self.assertRaises(cros_build_lib.DieSystemExit):
- artifacts.BundleEbuildLogs(self.sysroot_request, self.response,
- self.api_config)
+ artifacts.BundleEbuildLogs(self.sysroot_request, self.response,
+ self.api_config)
+
+ self.assertFalse(self.response.artifacts)
class BundleChromeOSConfigTest(BundleTestCase):
@@ -861,22 +804,15 @@
-class ExportCpeReportTest(cros_test_lib.MockTempDirTestCase,
- api_config.ApiConfigMixin):
+class ExportCpeReportTest(BundleTestCase):
"""ExportCpeReport tests."""
- def setUp(self):
- self.response = artifacts_pb2.BundleResponse()
-
def testValidateOnly(self):
"""Quick check validate only calls don't execute."""
patch = self.PatchObject(artifacts_svc, 'GenerateCpeReport')
- request = artifacts_pb2.BundleRequest()
- request.build_target.name = 'board'
- request.output_dir = str(self.tempdir)
-
- artifacts.ExportCpeReport(request, self.response, self.validate_only_config)
+ artifacts.ExportCpeReport(self.sysroot_request, self.response,
+ self.validate_only_config)
patch.assert_not_called()
@@ -884,25 +820,15 @@
"""Test that a mock call does not execute logic, returns mocked value."""
patch = self.PatchObject(artifacts_svc, 'GenerateCpeReport')
- request = artifacts_pb2.BundleRequest()
- request.build_target.name = 'board'
- request.output_dir = str(self.tempdir)
-
- artifacts.ExportCpeReport(request, self.response, self.mock_call_config)
+ artifacts.ExportCpeReport(self.sysroot_request, self.response,
+ self.mock_call_config)
patch.assert_not_called()
self.assertEqual(len(self.response.artifacts), 2)
self.assertEqual(self.response.artifacts[0].path,
- os.path.join(self.tempdir, 'cpe_report.txt'))
+ os.path.join(self.output_dir, 'cpe_report.txt'))
self.assertEqual(self.response.artifacts[1].path,
- os.path.join(self.tempdir, 'cpe_warnings.txt'))
-
- def testNoBuildTarget(self):
- request = artifacts_pb2.BundleRequest()
- request.output_dir = str(self.tempdir)
-
- with self.assertRaises(cros_build_lib.DieSystemExit):
- artifacts.ExportCpeReport(request, self.response, self.api_config)
+ os.path.join(self.output_dir, 'cpe_warnings.txt'))
def testSuccess(self):
"""Test success case."""
@@ -910,11 +836,8 @@
report='/output/report.json', warnings='/output/warnings.json')
self.PatchObject(artifacts_svc, 'GenerateCpeReport', return_value=expected)
- request = artifacts_pb2.BundleRequest()
- request.build_target.name = 'board'
- request.output_dir = str(self.tempdir)
-
- artifacts.ExportCpeReport(request, self.response, self.api_config)
+ artifacts.ExportCpeReport(self.sysroot_request, self.response,
+ self.api_config)
for artifact in self.response.artifacts:
self.assertIn(artifact.path, [expected.report, expected.warnings])