afdo: Adapt to AFDO bits moving outside of Chrome ebuild.
This patch deals with the reality that AFDO bits are no longer in
Chrome ebuild. We need to change the verification builder to:
(1) Update Chrome ebuild differently to use a created release profile;
(affects chrome-afdo-release-verify)
(2) Change the implementation we read profiles names from ebuild; now
we read the names from a file in Chromium;
(affects orderfile-generate-toolchain)
(3) Only upload a release profile to vetted bucket, i.e. we no longer
upload invidual benchmark and CWP profiles to bucket, because they are
not used (by Chrome ebuild) anymore.
(affects chrome-afdo-release-verify)
BUG=chromium:1001227
TEST=orderfile-generate-toolchain-tryjob https://ci.chromium.org/p/chromeos/builders/general/Try/b8900238346705646032
TEST=chrome-afdo-release-verify https://ci.chromium.org/p/chromeos/builders/general/Try/b8900497108143477904
Change-Id: I7cc72b29c1fd3cd9626b4226429a51e045553ff8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1828331
Tested-by: Tiancong Wang <tcwang@google.com>
Commit-Queue: Tiancong Wang <tcwang@google.com>
Reviewed-by: Alex Klein <saklein@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
diff --git a/api/controller/artifacts.py b/api/controller/artifacts.py
index 6183fc4..8974ec5 100644
--- a/api/controller/artifacts.py
+++ b/api/controller/artifacts.py
@@ -425,6 +425,7 @@
@validate.require('build_target.name', 'output_dir')
@validate.is_in('artifact_type', _VALID_ARTIFACT_TYPES)
@validate.exists('output_dir')
+@validate.exists('chroot.chrome_dir')
@validate.validation_complete
def BundleAFDOGenerationArtifacts(input_proto, output_proto, _config):
"""Generic function for creating tarballs of both AFDO and orerfile.
@@ -437,6 +438,9 @@
# Required args.
build_target = build_target_util.BuildTarget(input_proto.build_target.name)
+ chrome_root = input_proto.chroot.chrome_dir
+ if not chrome_root:
+ cros_build_lib.Die('chrome_root is not included in chroot')
output_dir = input_proto.output_dir
artifact_type = input_proto.artifact_type
@@ -445,7 +449,7 @@
try:
is_orderfile = bool(artifact_type is toolchain_pb2.ORDERFILE)
results = artifacts.BundleAFDOGenerationArtifacts(
- is_orderfile, chroot,
+ is_orderfile, chroot, chrome_root,
build_target, output_dir)
except artifacts.Error as e:
cros_build_lib.Die('Error %s raised in BundleSimpleChromeArtifacts: %s',
diff --git a/api/controller/artifacts_unittest.py b/api/controller/artifacts_unittest.py
index 38b2e2e..11ab472 100644
--- a/api/controller/artifacts_unittest.py
+++ b/api/controller/artifacts_unittest.py
@@ -751,6 +751,8 @@
osutils.SafeMakedirs(temp_dir)
self.output_dir = os.path.join(self.tempdir, 'output_dir')
osutils.SafeMakedirs(self.output_dir)
+ self.chrome_root = os.path.join(self.tempdir, 'chrome_root')
+ osutils.SafeMakedirs(self.chrome_root)
self.build_target = 'board'
self.valid_artifact_type = toolchain_pb2.ORDERFILE
self.invalid_artifact_type = toolchain_pb2.NONE_TYPE
@@ -759,19 +761,20 @@
self.response = artifacts_pb2.BundleResponse()
- def _GetRequest(self, chroot=None, build_target=None, output_dir=None,
- artifact_type=None):
+ def _GetRequest(self, chroot=None, build_target=None, chrome_root=None,
+ output_dir=None, artifact_type=None):
"""Helper to create a request message instance.
Args:
chroot (str): The chroot path.
build_target (str): The build target name.
+ chrome_root (str): The path to Chrome root.
output_dir (str): The output directory.
artifact_type (artifacts_pb2.AFDOArtifactType):
The type of the artifact.
"""
return artifacts_pb2.BundleChromeAFDORequest(
- chroot={'path': chroot},
+ chroot={'path': chroot, 'chrome_dir': chrome_root},
build_target={'name': build_target},
output_dir=output_dir,
artifact_type=artifact_type,
@@ -783,6 +786,7 @@
'BundleAFDOGenerationArtifacts')
request = self._GetRequest(chroot=self.chroot_dir,
build_target=self.build_target,
+ chrome_root=self.chrome_root,
output_dir=self.output_dir,
artifact_type=self.valid_artifact_type)
artifacts.BundleAFDOGenerationArtifacts(request, self.response,
@@ -792,6 +796,7 @@
def testNoBuildTarget(self):
"""Test no build target fails."""
request = self._GetRequest(chroot=self.chroot_dir,
+ chrome_root=self.chrome_root,
output_dir=self.output_dir,
artifact_type=self.valid_artifact_type)
with self.assertRaises(cros_build_lib.DieSystemExit) as context:
@@ -800,10 +805,23 @@
self.assertEqual('build_target.name is required.',
str(context.exception))
+ def testNoChromeRoot(self):
+ """Test no chrome root fails."""
+ request = self._GetRequest(chroot=self.chroot_dir,
+ build_target=self.build_target,
+ output_dir=self.output_dir,
+ artifact_type=self.valid_artifact_type)
+ with self.assertRaises(cros_build_lib.DieSystemExit) as context:
+ artifacts.BundleAFDOGenerationArtifacts(request, self.response,
+ self.api_config)
+ self.assertEqual('chroot.chrome_dir path does not exist: ',
+ str(context.exception))
+
def testNoOutputDir(self):
"""Test no output dir fails."""
request = self._GetRequest(chroot=self.chroot_dir,
build_target=self.build_target,
+ chrome_root=self.chrome_root,
artifact_type=self.valid_artifact_type)
with self.assertRaises(cros_build_lib.DieSystemExit) as context:
artifacts.BundleAFDOGenerationArtifacts(request, self.response,
@@ -815,6 +833,7 @@
"""Test output directory not existing fails."""
request = self._GetRequest(chroot=self.chroot_dir,
build_target=self.build_target,
+ chrome_root=self.chrome_root,
output_dir=self.does_not_exist,
artifact_type=self.valid_artifact_type)
with self.assertRaises(cros_build_lib.DieSystemExit) as context:
@@ -828,6 +847,7 @@
"""Test no artifact type."""
request = self._GetRequest(chroot=self.chroot_dir,
build_target=self.build_target,
+ chrome_root=self.chrome_root,
output_dir=self.output_dir)
with self.assertRaises(cros_build_lib.DieSystemExit) as context:
artifacts.BundleAFDOGenerationArtifacts(request, self.response,
@@ -839,6 +859,7 @@
"""Test passing wrong artifact type."""
request = self._GetRequest(chroot=self.chroot_dir,
build_target=self.build_target,
+ chrome_root=self.chrome_root,
output_dir=self.output_dir,
artifact_type=self.invalid_artifact_type)
with self.assertRaises(cros_build_lib.DieSystemExit) as context:
@@ -857,6 +878,7 @@
request = self._GetRequest(chroot=self.chroot_dir,
build_target=self.build_target,
+ chrome_root=self.chrome_root,
output_dir=self.output_dir,
artifact_type=artifact_type)