Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: build/android/pylib/utils/logdog_helper.py

Issue 2701473003: Add failure screenshots and render test images to results detail. (Closed)
Patch Set: Add failure screenshots and render test images to results detail. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Helper functions to upload data to logdog.""" 5 """Helper functions to upload data to logdog."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import sys 9 import sys
10 import time
11
12 from devil.utils import cmd_helper
10 13
11 from pylib import constants 14 from pylib import constants
15 from pylib.constants import host_paths
12 from pylib.utils import decorators 16 from pylib.utils import decorators
13 17
14 sys.path.insert(0, os.path.abspath(os.path.join( 18 sys.path.insert(0, os.path.abspath(os.path.join(
15 constants.DIR_SOURCE_ROOT, 'tools', 'swarming_client'))) 19 constants.DIR_SOURCE_ROOT, 'tools', 'swarming_client')))
16 from libs.logdog import bootstrap # pylint: disable=import-error 20 from libs.logdog import bootstrap # pylint: disable=import-error
17 21
22 sys.path.append(os.path.join(host_paths.DIR_SOURCE_ROOT, 'build'))
23 import find_depot_tools # pylint: disable=import-error
24
18 25
19 @decorators.NoRaiseException(default_return_value='') 26 @decorators.NoRaiseException(default_return_value='')
20 def text(name, data): 27 def text(name, data):
21 """Uploads text to logdog. 28 """Uploads text to logdog.
22 29
23 Args: 30 Args:
24 name: Name of the logdog stream. 31 name: Name of the logdog stream.
25 data: String with data you want to upload. 32 data: String with data you want to upload.
26 33
27 Returns: 34 Returns:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 78
72 Args: 79 Args:
73 name: Name of the logdog stream. 80 name: Name of the logdog stream.
74 81
75 Returns: 82 Returns:
76 Link to view uploaded binary in logdog viewer. 83 Link to view uploaded binary in logdog viewer.
77 """ 84 """
78 return get_logdog_client().get_viewer_url(name) 85 return get_logdog_client().get_viewer_url(name)
79 86
80 87
88 @decorators.NoRaiseException(default_return_value='')
89 def image(name, image_path):
90 """Uploads image to Google Storage.
jbudorick 2017/02/21 18:32:40 This should not be in logdog_helper if it's not up
mikecase (-- gone --) 2017/02/23 00:21:26 done. Moved to its own module.
91
92 Args:
93 name: Name of the image on Google Storage.
94 image_path: Path to image you want to upload.
95 """
96 # TODO(mikecase): Merge this with binary() function. Currently, logdog has no
97 # support for viewing images in its log viewer. As a work-around, upload to
98 # google storage directly.
99
100 RENDER_TEST_BASE_URL = 'https://storage.googleapis.com/chromium-render-tests/'
101 RENDER_TEST_BUCKET = 'gs://chromium-render-tests/'
102
103 cmd_helper.RunCmd(
104 [os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py'), 'cp',
105 image_path,
106 os.path.join(RENDER_TEST_BUCKET, name)])
jbudorick 2017/02/21 18:32:40 super nit: why is this not on the same line as ima
mikecase (-- gone --) 2017/02/23 00:21:26 it is now!
107
108 return os.path.join(RENDER_TEST_BASE_URL, name)
109
110
111 def unique_name(basename, timestamp=True, device=None):
112 """Helper function for creating a unique name for a logdog stream.
113
114 Args:
115 basename: Base of the unique name.
116 timestamp: Whether or not to add a timestamp to name.
117 device: Device to add device serial of to name.
118 """
119 return '%s%s%s' % (
120 basename,
121 '_%s' % time.strftime('%Y%m%dT%H%M%S', time.localtime())
122 if timestamp else '',
123 '_%s' % device.serial if device else '')
124
125
81 @decorators.Memoize 126 @decorators.Memoize
82 def get_logdog_client(): 127 def get_logdog_client():
83 logging.debug('Getting logdog client.') 128 logging.debug('Getting logdog client.')
84 return bootstrap.ButlerBootstrap.probe().stream_client() 129 return bootstrap.ButlerBootstrap.probe().stream_client()
85 130
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698