mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
autoninja: Use AUTONINJA_BUILD_ID for RBE_invocation_id as is.
To use build id/invocation id consistently, reclient_helper will set AUTONINJA_BUILD_ID as RBE_invocation_id as is. The host name information will be added as a metrics label. Bug: 355127782 Change-Id: I5609ef38d897b19029795adf1b288898986c7c70 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5737676 Auto-Submit: Junji Watanabe <jwata@google.com> Reviewed-by: Michael Savigny <msavigny@google.com> Commit-Queue: Michael Savigny <msavigny@google.com>
This commit is contained in:
@@ -139,19 +139,24 @@ def set_reproxy_metrics_flags(tool):
|
||||
RBE_metrics_project=chromium-reclient-metrics
|
||||
RBE_invocation_id=$AUTONINJA_BUILD_ID
|
||||
RBE_metrics_table=rbe_metrics.builds
|
||||
RBE_metrics_labels=source=developer,tool={tool}
|
||||
RBE_metrics_labels=\
|
||||
source=developer,\
|
||||
tool={tool},\
|
||||
creds_cache_status={auth_status},\
|
||||
creds_cache_mechanism={auth_mechanism},\
|
||||
host={host}
|
||||
RBE_metrics_prefix=go.chromium.org
|
||||
"""
|
||||
autoninja_id = os.environ.get("AUTONINJA_BUILD_ID")
|
||||
if autoninja_id is not None:
|
||||
os.environ.setdefault("RBE_invocation_id",
|
||||
"%s/%s" % (get_hostname(), autoninja_id))
|
||||
os.environ.setdefault("RBE_invocation_id", autoninja_id)
|
||||
os.environ.setdefault("RBE_metrics_project", "chromium-reclient-metrics")
|
||||
os.environ.setdefault("RBE_metrics_table", "rbe_metrics.builds")
|
||||
labels = "source=developer,tool=" + tool
|
||||
auth_status, auth_mechanism = auth_cache_status()
|
||||
labels += ",creds_cache_status=" + auth_status
|
||||
labels += ",creds_cache_mechanism=" + auth_mechanism
|
||||
labels += ",host=" + get_hostname()
|
||||
os.environ.setdefault("RBE_metrics_labels", labels)
|
||||
os.environ.setdefault("RBE_metrics_prefix", "go.chromium.org")
|
||||
|
||||
|
||||
@@ -134,6 +134,8 @@ class ReclientHelperTest(trial_dir.TestCase):
|
||||
|
||||
@unittest.mock.patch.dict(os.environ,
|
||||
{'AUTONINJA_BUILD_ID': "SOME_RANDOM_ID"})
|
||||
@unittest.mock.patch('reclient_helper.get_hostname',
|
||||
return_value='somehost')
|
||||
@unittest.mock.patch('subprocess.call', return_value=0)
|
||||
@unittest.mock.patch('ninja.main', return_value=0)
|
||||
def test_ninja_reclient_collect_metrics_cache_missing(self, *_):
|
||||
@@ -149,7 +151,7 @@ class ReclientHelperTest(trial_dir.TestCase):
|
||||
self.assertEqual(
|
||||
0, reclient_helper.run_ninja(argv, should_collect_logs=True))
|
||||
|
||||
self.assertIn("/SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
|
||||
self.assertIn("SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
|
||||
self.assertEqual(os.environ.get('RBE_metrics_project'),
|
||||
"chromium-reclient-metrics")
|
||||
self.assertEqual(os.environ.get('RBE_metrics_table'),
|
||||
@@ -157,13 +159,16 @@ class ReclientHelperTest(trial_dir.TestCase):
|
||||
self.assertEqual(
|
||||
os.environ.get('RBE_metrics_labels'),
|
||||
"source=developer,tool=ninja_reclient,"
|
||||
"creds_cache_status=missing,creds_cache_mechanism=UNSPECIFIED")
|
||||
"creds_cache_status=missing,creds_cache_mechanism=UNSPECIFIED,"
|
||||
"host=somehost")
|
||||
self.assertEqual(os.environ.get('RBE_metrics_prefix'),
|
||||
"go.chromium.org")
|
||||
|
||||
@unittest.mock.patch.dict(os.environ,
|
||||
{'AUTONINJA_BUILD_ID': "SOME_RANDOM_ID"},
|
||||
clear=True)
|
||||
@unittest.mock.patch('reclient_helper.get_hostname',
|
||||
return_value='somehost')
|
||||
@unittest.mock.patch('reclient_helper.datetime_now',
|
||||
return_value=datetime.datetime(2017, 3, 16, 20, 0, 41,
|
||||
0))
|
||||
@@ -194,7 +199,7 @@ expiry: {
|
||||
self.assertEqual(
|
||||
0, reclient_helper.run_ninja(argv, should_collect_logs=True))
|
||||
|
||||
self.assertIn("/SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
|
||||
self.assertIn("SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
|
||||
self.assertEqual(os.environ.get('RBE_metrics_project'),
|
||||
"chromium-reclient-metrics")
|
||||
self.assertEqual(os.environ.get('RBE_metrics_table'),
|
||||
@@ -202,13 +207,16 @@ expiry: {
|
||||
self.assertEqual(
|
||||
os.environ.get('RBE_metrics_labels'),
|
||||
"source=developer,tool=ninja_reclient,"
|
||||
"creds_cache_status=valid,creds_cache_mechanism=GCLOUD")
|
||||
"creds_cache_status=valid,creds_cache_mechanism=GCLOUD,"
|
||||
"host=somehost")
|
||||
self.assertEqual(os.environ.get('RBE_metrics_prefix'),
|
||||
"go.chromium.org")
|
||||
|
||||
@unittest.mock.patch.dict(os.environ,
|
||||
{'AUTONINJA_BUILD_ID': "SOME_RANDOM_ID"},
|
||||
clear=True)
|
||||
@unittest.mock.patch('reclient_helper.get_hostname',
|
||||
return_value='somehost')
|
||||
@unittest.mock.patch('subprocess.call', return_value=0)
|
||||
@unittest.mock.patch('ninja.main', return_value=0)
|
||||
def test_ninja_reclient_collect_metrics_cache_expired(self, *_):
|
||||
@@ -236,7 +244,7 @@ expiry: {
|
||||
self.assertEqual(
|
||||
0, reclient_helper.run_ninja(argv, should_collect_logs=True))
|
||||
|
||||
self.assertIn("/SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
|
||||
self.assertIn("SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
|
||||
self.assertEqual(os.environ.get('RBE_metrics_project'),
|
||||
"chromium-reclient-metrics")
|
||||
self.assertEqual(os.environ.get('RBE_metrics_table'),
|
||||
@@ -244,7 +252,8 @@ expiry: {
|
||||
self.assertEqual(
|
||||
os.environ.get('RBE_metrics_labels'),
|
||||
"source=developer,tool=ninja_reclient,"
|
||||
"creds_cache_status=expired,creds_cache_mechanism=GCLOUD")
|
||||
"creds_cache_status=expired,creds_cache_mechanism=GCLOUD,"
|
||||
"host=somehost")
|
||||
self.assertEqual(os.environ.get('RBE_metrics_prefix'),
|
||||
"go.chromium.org")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user