Skip to content

Commit

Permalink
[Speed Infra] Handle single-shard shard maps
Browse files Browse the repository at this point in the history
For single shard runs, GTEST_SHARD_INDEX is not specified.

also, remove usage of GTEST_TOTAL_SHARDS since it isn't
needed.

Bug: 972844
Change-Id: Ia32b2ba839dc1ac7ddf736bfa74309322c629dd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1652649
Reviewed-by: John Chen <johnchen@chromium.org>
Commit-Queue: Caleb Rouleau <crouleau@chromium.org>
Auto-Submit: Caleb Rouleau <crouleau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668034}
  • Loading branch information
CalebRouleau authored and Commit Bot committed Jun 11, 2019
1 parent fdb3bb1 commit 1f6c506
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions testing/scripts/run_performance_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,9 @@ def main(sys_args):
elif options.test_shard_map_filename:
# First determine what shard we are running on to know how to
# index into the bot map to get list of telemetry benchmarks to run.
total_shards = None
shard_index = None
shard_map_path = os.path.join(SHARD_MAPS_DIRECTORY,
options.test_shard_map_filename)
env = os.environ.copy()
if 'GTEST_TOTAL_SHARDS' in env:
total_shards = env['GTEST_TOTAL_SHARDS']
if 'GTEST_SHARD_INDEX' in env:
shard_index = env['GTEST_SHARD_INDEX']
if not total_shards or not shard_index:
raise Exception(
'Sharded Telemetry perf tests must either specify --benchmarks '
'list or have shard indicator environment variables present.')
# Copy sharding map file to isolated_out_dir so that the merge script
# can collect it later.
# TODO(crouleau): Move this step over to merge script
Expand All @@ -501,6 +491,19 @@ def main(sys_args):
os.path.join(isolated_out_dir, 'benchmarks_shard_map.json'))
with open(shard_map_path) as f:
shard_map = json.load(f)
env = os.environ.copy()
if 'GTEST_SHARD_INDEX' in env:
shard_index = env['GTEST_SHARD_INDEX']
# TODO(crbug.com/972844): shard environment variables are not specified
# for single-shard shard runs.
if not shard_index:
shard_map_has_multiple_shards = bool(shard_map.get('1', False))
if not shard_map_has_multiple_shards:
shard_index = '0'
if not shard_index:
raise Exception(
'Sharded Telemetry perf tests must either specify --benchmarks '
'list or have GTEST_SHARD_INDEX environment variable present.')
benchmarks_and_stories = shard_map[shard_index]['benchmarks']

for benchmark, stories in benchmarks_and_stories.iteritems():
Expand Down

0 comments on commit 1f6c506

Please sign in to comment.