Commit c8782f90 authored by Ashley Enstad's avatar Ashley Enstad Committed by Commit Bot

Fix and reenable unittest

Bug: 713357
Change-Id: I88006945277d7081ca71b33dac183e7619d29b82
Reviewed-on: https://chromium-review.googlesource.com/1097233Reviewed-by: default avatarEmily Hanley <eyaich@chromium.org>
Commit-Queue: Ashley Enstad <ashleymarie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566591}
parent 6cbdcdf1
...@@ -3,20 +3,18 @@ ...@@ -3,20 +3,18 @@
# found in the LICENSE file. # found in the LICENSE file.
from collections import OrderedDict from collections import OrderedDict
import copy
from core import sharding_map_generator from core import sharding_map_generator
import json import json
import os import os
import tempfile import tempfile
import unittest import unittest
from telemetry import decorators
class TestShardingMapGenerator(unittest.TestCase): class TestShardingMapGenerator(unittest.TestCase):
def _init_sample_timing_data(self, times): def _init_sample_timing_data(self, times):
timing_data = OrderedDict() timing_data = OrderedDict()
timing_list = []
all_stories = {} all_stories = {}
for i in range(len(times)): for i in range(len(times)):
all_stories['benchmark_' + str(i)] = [] all_stories['benchmark_' + str(i)] = []
...@@ -25,30 +23,22 @@ class TestShardingMapGenerator(unittest.TestCase): ...@@ -25,30 +23,22 @@ class TestShardingMapGenerator(unittest.TestCase):
all_stories['benchmark_' + str(i)].append('story_' + str(j)) all_stories['benchmark_' + str(i)].append('story_' + str(j))
timing_data['benchmark_' + str(i) + '/' + 'story_' + str(j)] = ( timing_data['benchmark_' + str(i) + '/' + 'story_' + str(j)] = (
story_times[j]) story_times[j])
timing_list.append({"run_time": story_times[j], return timing_data, all_stories
"run_name": 'benchmark_' + str(i) + '/' + 'story_' + str(j)})
return timing_data, all_stories, timing_list
# TODO(eyaich@, ashleymarie@): fix & reenable this test
@decorators.Disabled('all')
def testGenerateAndTestShardingMap(self): def testGenerateAndTestShardingMap(self):
timing_data, all_stories, timing_list = self._init_sample_timing_data( timing_data, all_stories = self._init_sample_timing_data(
[[60, 56, 57], [66, 54, 80, 4], [2, 8, 7, 37, 2]]) [[60, 56, 57], [66, 54, 80, 4], [2, 8, 7, 37, 2]])
timing_data_for_testing = copy.deepcopy(timing_data)
sharding_map = sharding_map_generator.generate_sharding_map( sharding_map = sharding_map_generator.generate_sharding_map(
timing_data, all_stories, 3, None) timing_data, all_stories, 3, None)
fd_map, map_path = tempfile.mkstemp(suffix='.json') fd_map, map_path = tempfile.mkstemp(suffix='.json')
fd_test_data, test_path = tempfile.mkstemp(suffix='.json')
try: try:
with os.fdopen(fd_map, 'w') as f: with os.fdopen(fd_map, 'w') as f:
json.dump(sharding_map, f) json.dump(sharding_map, f)
with os.fdopen(fd_test_data, 'w') as f:
json.dump(timing_list, f)
results = sharding_map_generator.test_sharding_map(map_path, results = sharding_map_generator.test_sharding_map(map_path,
test_path, all_stories) timing_data_for_testing, all_stories)
self.assertEqual(results['0'], 173) self.assertEqual(results['0']['full_time'], 173)
self.assertEqual(results['1'], 120) self.assertEqual(results['1']['full_time'], 120)
self.assertEqual(results['2'], 140) self.assertEqual(results['2']['full_time'], 140)
finally: finally:
os.remove(map_path) os.remove(map_path)
os.remove(test_path)
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