Commit 4ced119f authored by Lori Oliver's avatar Lori Oliver Committed by Commit Bot

Add disabled platforms column to go/csh-stories

- PopulateExpectations accepts a dictionary:
    all_expectations = {story_name: [[conditions], reason]}
  Returns disables dictionary:
    disables = {story_name: "Disabled Platforms"}

- generate_system_health_csv_unittest.py tests the new
PopulateExpectations function.

Bug: chromium:723636
Change-Id: Ic94b08f53c004bab5aa813399da34dd7d4b09279
Reviewed-on: https://chromium-review.googlesource.com/674099Reviewed-by: default avatarNed Nguyen <nednguyen@google.com>
Commit-Queue: Lori Oliver <loloangela@google.com>
Cr-Commit-Position: refs/heads/master@{#504729}
parent a9867919
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import unittest
import sys
from core import system_health_csv_generator
from core import path_util
sys.path.insert(1, path_util.GetTelemetryDir()) # To resolve telemetry imports
class GenerateSystemHealthCSVTest(unittest.TestCase):
def testPopulateExpectations(self):
expected_result = {
'browse:media:tumblr': 'Mac 10.11',
'browse:news:cnn': 'Mac Platforms',
'browse:news:hackernews': 'Win Platforms, Mac Platforms',
'browse:search:google': 'Win Platforms',
'browse:tools:earth': 'All Platforms',
'browse:tools:maps': 'All Platforms',
'play:media:google_play_music': 'All Platforms',
'play:media:pandora': 'All Platforms',
'play:media:soundcloud': 'Win Platforms'}
all_expects = [{
'browse:news:cnn': [(
['Mac Platforms'], 'crbug.com/728576')],
'browse:tools:earth': [(
['All Platforms'], 'crbug.com/760966')],
'browse:news:hackernews': [(
['Win Platforms', 'Mac Platforms'],
'crbug.com/712694')],
'play:media:soundcloud': [(
['Win Platforms'], 'crbug.com/649392')],
'play:media:google_play_music': [(
['All Platforms'], 'crbug.com/649392')],
'browse:tools:maps': [(
['All Platforms'], 'crbug.com/712694')],
'browse:search:google': [(
['Win Platforms'], 'win:crbug.com/673775, mac:crbug.com/756027')],
'browse:media:tumblr': [(
['Mac 10.11'], 'crbug.com/760966')],
'play:media:pandora': [(
['All Platforms'], 'crbug.com/649392')],
}]
self.assertEquals(
expected_result,
system_health_csv_generator.PopulateExpectations(all_expects))
...@@ -3,8 +3,13 @@ ...@@ -3,8 +3,13 @@
# found in the LICENSE file. # found in the LICENSE file.
import csv import csv
import page_sets import sys
from core import path_util
sys.path.insert(1, path_util.GetPerfDir()) # To resolve perf imports
sys.path.insert(1, path_util.GetTelemetryDir()) # To resolve telemetry imports
import page_sets
from page_sets.system_health import expectations
def IterAllSystemHealthStories(): def IterAllSystemHealthStories():
for s in page_sets.SystemHealthStorySet(platform='desktop'): for s in page_sets.SystemHealthStorySet(platform='desktop'):
...@@ -14,18 +19,57 @@ def IterAllSystemHealthStories(): ...@@ -14,18 +19,57 @@ def IterAllSystemHealthStories():
yield s yield s
def PopulateExpectations(all_expectations):
"""Accepts Expectations and parses out the storyname and disabled platforms.
Args:
all_expectations = {
story_name: [[conditions], reason]}
conditions: list of disabled platforms for story_name
reason: Bug referencing why the test is disabled on the platform
Returns:
A dictionary containing the disabled platforms for each story.
disables = {
story_name: "Disabled Platforms"}
"""
disables = {}
for exp in all_expectations:
exp_keys = exp.keys()
exp_keys.sort()
for story in exp_keys:
for conditions, _ in exp[story]:
conditions_str = ", ".join(map(str, conditions))
if story in disables:
if conditions_str not in disables[story]:
disables[story] += ", " + conditions_str
else:
disables[story] = conditions_str
return disables
def GenerateSystemHealthCSV(file_path): def GenerateSystemHealthCSV(file_path):
system_health_stories = list(IterAllSystemHealthStories()) system_health_stories = list(IterAllSystemHealthStories())
all_expectations = [
expectations.SystemHealthDesktopCommonExpectations().AsDict()['stories'],
expectations.SystemHealthDesktopMemoryExpectations().AsDict()['stories'],
expectations.SystemHealthMobileCommonExpectations().AsDict()['stories'],
expectations.SystemHealthMobileMemoryExpectations().AsDict()['stories'],]
disabed_platforms = PopulateExpectations(all_expectations)
system_health_stories.sort(key=lambda s: s.name) system_health_stories.sort(key=lambda s: s.name)
with open(file_path, 'w') as f: with open(file_path, 'w') as f:
csv_writer = csv.writer(f) csv_writer = csv.writer(f)
csv_writer.writerow([ csv_writer.writerow([
'Story name', 'Platform', 'Description']) 'Story name', 'Platform', 'Description', 'Disabled Platforms'])
for s in system_health_stories: for s in system_health_stories:
p = s.SUPPORTED_PLATFORMS p = s.SUPPORTED_PLATFORMS
if len(p) == 2: if len(p) == 2:
p = 'all' p = 'all'
else: else:
p = list(p)[0] p = list(p)[0]
csv_writer.writerow([s.name, p, s.GetStoryDescription()]) if s.name in disabed_platforms:
csv_writer.writerow(
[s.name, p, s.GetStoryDescription(), disabed_platforms[s.name]])
else:
csv_writer.writerow([s.name, p, s.GetStoryDescription(), " "])
return 0 return 0
This diff is collapsed.
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