Commit d04140a5 authored by tapted@chromium.org's avatar tapted@chromium.org

Mod a hash of test names to determine a shard, rather than the test index.

This keeps tests on a particular shard, until their name changes.

Currently tests can move to a different waterfall bot between runs;
whenever a test is added or removed "before" it in the test suite. This
makes it very hard to track failure history of a particular test, since
it can "disappear" from prior builds on that bot.

Also, since the shards do not have synced cycles, a revision that breaks
test "A" might never be in a blamelist. E.g. Bad revision X breaks test
"A", good revision X+1 adds unrelated test "B". Blamelists
bot0:[X],[X+1] and bot1:[X, X+1]. Only bot0 will run test "A", and only
on its second run, but it will not blame revision "X". Note "X" could
even be the revision that adds test "A".

Hashing the name does not guarantee an even distribution of tests.
However, the duration of a test is not predictable, so the change to
load variance should balance out except in pathological cases or very
small test suites.

BUG=372461
TBR=phajdan.jr@chromium.org

Review URL: https://codereview.chromium.org/292973006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272920 0039d316-1c4b-4281-b951-d872f2087c98
parent b0e96230
......@@ -16,6 +16,7 @@
#include "base/files/file_path.h"
#include "base/files/scoped_file.h"
#include "base/format_macros.h"
#include "base/hash.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
......@@ -755,8 +756,6 @@ bool TestLauncher::Init() {
void TestLauncher::RunTests() {
testing::UnitTest* const unit_test = testing::UnitTest::GetInstance();
int num_runnable_tests = 0;
std::vector<std::string> test_names;
for (int i = 0; i < unit_test->total_test_case_count(); ++i) {
......@@ -804,8 +803,10 @@ void TestLauncher::RunTests() {
if (!launcher_delegate_->ShouldRunTest(test_case, test_info))
continue;
if (num_runnable_tests++ % total_shards_ != shard_index_)
if (base::Hash(test_name) % total_shards_ !=
static_cast<uint32>(shard_index_)) {
continue;
}
test_names.push_back(test_name);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment