v8/tools/testrunner/testproc/shard.py
Michal Majewski d53c4aa065 [test] Implement shard processor
Bug: v8:6917
Change-Id: I5b77e7445ca3a8eb5692659e94d3b8266479b415
Cq-Include-Trybots: luci.v8.try:v8_linux64_fyi_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/866866
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50615}
2018-01-16 11:33:03 +00:00

31 lines
872 B
Python

# Copyright 2018 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from . import base
class ShardProc(base.TestProcFilter):
"""Processor distributing tests between shards.
It simply passes every n-th test. To be deterministic it has to be placed
before all processors that generate tests dynamically.
"""
def __init__(self, myid, shards_count):
"""
Args:
myid: id of the shard within [0; shards_count - 1]
shards_count: number of shards
"""
super(ShardProc, self).__init__()
assert myid >= 0 and myid < shards_count
self._myid = myid
self._shards_count = shards_count
self._last = 0
def _filter(self, test):
res = self._last != self._myid
self._last = (self._last + 1) % self._shards_count
return res