Bug 1305877 - Make HashChunker stable; r=jgraham

The built-in hash() function uses the backing memory address for
hashing. This is essentially random. Switch to md5 so input is
consistently hashed across processes.

MozReview-Commit-ID: D52uzttE5hc

--HG--
extra : rebase_source : b7f15e519ec0ba05d0a310fe0470d82893a0a07c
extra : source : 4c8e1c96a27df961c1dd2e984745d06757e8a2d4
This commit is contained in:
Gregory Szorc 2016-09-27 16:31:26 -07:00
Родитель 5d3405fe79
Коммит 0b9bb32229
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -1,6 +1,6 @@
import hashlib
import json import json
import os import os
import sys
import urlparse import urlparse
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from Queue import Empty from Queue import Empty
@ -43,12 +43,14 @@ class Unchunked(TestChunker):
class HashChunker(TestChunker): class HashChunker(TestChunker):
def __call__(self): def __call__(self, manifest):
chunk_index = self.chunk_number - 1 chunk_index = self.chunk_number - 1
for test_path, tests in manifest: for test_path, tests in manifest:
if hash(test_path) % self.total_chunks == chunk_index: h = int(hashlib.md5(test_path).hexdigest(), 16)
if h % self.total_chunks == chunk_index:
yield test_path, tests yield test_path, tests
class EqualTimeChunker(TestChunker): class EqualTimeChunker(TestChunker):
def _group_by_directory(self, manifest_items): def _group_by_directory(self, manifest_items):
"""Split the list of manifest items into a ordered dict that groups tests in """Split the list of manifest items into a ordered dict that groups tests in