Build API: Use the goma log options when available
Sets the goma log dir, and the stats and counterz file names when
passed through in an API call.
BUG=chromium:1031259
TEST=./run_tests
Change-Id: I571b93aa3a926d9816b694b38522ab0b7bbeee54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1958960
Commit-Queue: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
diff --git a/api/controller/controller_util.py b/api/controller/controller_util.py
index aa18bb7..9c6abaf 100644
--- a/api/controller/controller_util.py
+++ b/api/controller/controller_util.py
@@ -65,12 +65,20 @@
elif chroot_message.goma.goma_approach == common_pb2.GomaConfig.RBE_STAGING:
goma_approach = goma_util.GomaApproach('?staging',
'staging-goma.chromium.org', True)
+
+ log_dir = chroot_message.goma.log_dir.dir or None
+ stats_filename = chroot_message.goma.stats_file or None
+ counterz_filename = chroot_message.goma.counterz_file or None
+
goma = goma_util.Goma(chroot_message.goma.goma_dir,
chroot_message.goma.goma_client_json,
stage_name='BuildAPI',
chromeos_goma_dir=chromeos_goma_dir,
chroot_dir=path,
- goma_approach=goma_approach)
+ goma_approach=goma_approach,
+ log_dir=log_dir,
+ stats_filename=stats_filename,
+ counterz_filename=counterz_filename)
return Chroot(path=path, cache_dir=cache_dir, chrome_root=chrome_root,
env=env, goma=goma)
diff --git a/api/controller/controller_util_unittest.py b/api/controller/controller_util_unittest.py
index 99c717b..1dca932 100644
--- a/api/controller/controller_util_unittest.py
+++ b/api/controller/controller_util_unittest.py
@@ -42,7 +42,7 @@
self.assertEqual(expected, result)
-
+ # TODO(saklein): Rewrite this test.
def testChrootCallToGoma(self):
"""Test calls to goma."""
path = '/chroot/path'
@@ -53,6 +53,9 @@
goma_test_dir = '/goma/test/dir'
goma_test_json_string = 'goma_json'
chromeos_goma_test_dir = '/chromeos/goma/test/dir'
+ log_dir = '/log/dir'
+ stats_filename = 'stats_filename'
+ counterz_filename = 'counterz_filename'
# Patch goma constructor to avoid creating misc dirs.
patch = self.PatchObject(goma_util, 'Goma')
@@ -69,7 +72,9 @@
patch.assert_called_with(goma_test_dir, goma_test_json_string,
stage_name='BuildAPI', chromeos_goma_dir=None,
chroot_dir=path,
- goma_approach=None)
+ goma_approach=None,
+ log_dir=None, stats_filename=None,
+ counterz_filename=None)
goma_config.chromeos_goma_dir = chromeos_goma_test_dir
chroot_message = common_pb2.Chroot(path=path, cache_dir=cache_dir,
@@ -83,8 +88,11 @@
stage_name='BuildAPI',
chromeos_goma_dir=chromeos_goma_test_dir,
chroot_dir=path,
- goma_approach=None)
+ goma_approach=None,
+ log_dir=None, stats_filename=None,
+ counterz_filename=None)
+ # Test the goma approach options.
goma_config.goma_approach = common_pb2.GomaConfig.RBE_PROD
chroot_message = common_pb2.Chroot(path=path, cache_dir=cache_dir,
chrome_dir=chrome_root,
@@ -98,7 +106,9 @@
chromeos_goma_dir=chromeos_goma_test_dir,
chroot_dir=path,
goma_approach=goma_util.GomaApproach(
- '?prod', 'goma.chromium.org', True))
+ '?prod', 'goma.chromium.org', True),
+ log_dir=None, stats_filename=None,
+ counterz_filename=None)
goma_config.goma_approach = common_pb2.GomaConfig.RBE_STAGING
chroot_message = common_pb2.Chroot(path=path, cache_dir=cache_dir,
@@ -113,7 +123,28 @@
chromeos_goma_dir=chromeos_goma_test_dir,
chroot_dir=path,
goma_approach=goma_util.GomaApproach(
- '?staging', 'staging-goma.chromium.org', True))
+ '?staging', 'staging-goma.chromium.org', True),
+ log_dir=None, stats_filename=None,
+ counterz_filename=None)
+
+ # Test the goma log options.
+ goma_config = common_pb2.GomaConfig(goma_dir=goma_test_dir,
+ goma_client_json=goma_test_json_string,
+ log_dir={'dir': log_dir},
+ stats_file=stats_filename,
+ counterz_file=counterz_filename)
+ chroot_message = common_pb2.Chroot(path=path, cache_dir=cache_dir,
+ chrome_dir=chrome_root,
+ env={'use_flags': use_flags,
+ 'features': features},
+ goma=goma_config)
+
+ controller_util.ParseChroot(chroot_message)
+ patch.assert_called_with(goma_test_dir, goma_test_json_string,
+ stage_name='BuildAPI', chromeos_goma_dir=None,
+ chroot_dir=path, goma_approach=None,
+ log_dir=log_dir, stats_filename=stats_filename,
+ counterz_filename=counterz_filename)
def testWrongMessage(self):
"""Test invalid message type given."""