Commit 7f3661fd authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Restrict manage_render_test_goldens to golden images

Restricts manage_render_test_goldens.py to only uploading images that
are expected to be golden images. This is achieved by looking for
device/SDK pairs in the filename.

This is to prevent random images that happen to be in the directory from
being uploaded when they shouldn't be.

Bug: 1022632
Change-Id: Iead7b574f38b73a88994d2a6e9f61fdcd72b4ea5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913571
Auto-Submit: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714769}
parent 2d97e5b1
...@@ -41,6 +41,11 @@ to the results_details/Render Results pages that you grabbed the new goldens ...@@ -41,6 +41,11 @@ to the results_details/Render Results pages that you grabbed the new goldens
from. This will help reviewers confirm that the changes to the goldens are from. This will help reviewers confirm that the changes to the goldens are
acceptable. acceptable.
If you add a new device/SDK combination that you expect golden images for, be
sure to add it to `ALLOWED_DEVICE_SDK_COMBINATIONS` in
`//chrome/test/data/android/manage_render_test_goldens.py`, otherwise the
goldens for it will not be uploaded.
### Failing locally ### Failing locally
Follow the steps in [*Running the tests locally*](#running-the-tests-locally) Follow the steps in [*Running the tests locally*](#running-the-tests-locally)
......
...@@ -34,6 +34,16 @@ GOLDEN_DIRECTORIES = [ ...@@ -34,6 +34,16 @@ GOLDEN_DIRECTORIES = [
'render_tests'), 'render_tests'),
] ]
# This is to prevent accidentally uploading random, non-golden images that
# might be in the directory.
ALLOWED_DEVICE_SDK_COMBINATIONS = [
# From RenderTestRule.java
'Nexus_5-19',
# For VR tests.
'Pixel_XL-25',
'Pixel_XL-26',
]
# Assume a quad core if we can't get the actual core count. # Assume a quad core if we can't get the actual core count.
try: try:
...@@ -63,22 +73,34 @@ def download(directory): ...@@ -63,22 +73,34 @@ def download(directory):
def upload(directory): def upload(directory):
def is_file_of_interest(f):
if not f.endswith('.png'):
return False
for combo in ALLOWED_DEVICE_SDK_COMBINATIONS:
if combo in f:
return True
return False
files_to_upload = [] files_to_upload = []
for f in os.listdir(directory): for f in os.listdir(directory):
if f.endswith('.png'): # Skip any files that we don't care about.
png_path = os.path.join(directory, f) if not is_file_of_interest(f):
# upload_to_google_storage will upload a file even if it already exists continue
# in the bucket. As an optimization, hash locally and only pass files to
# the upload script if they don't have a matching .sha1 file already. png_path = os.path.join(directory, f)
sha_path = png_path + '.sha1' # upload_to_google_storage will upload a file even if it already exists
if os.path.isfile(sha_path): # in the bucket. As an optimization, hash locally and only pass files to
with open(sha_path) as sha_file: # the upload script if they don't have a matching .sha1 file already.
with open(png_path, 'rb') as png_file: sha_path = png_path + '.sha1'
h = hashlib.sha1() if os.path.isfile(sha_path):
h.update(png_file.read()) with open(sha_path) as sha_file:
if sha_file.read() == h.hexdigest(): with open(png_path, 'rb') as png_file:
continue h = hashlib.sha1()
files_to_upload.append(png_path) h.update(png_file.read())
if sha_file.read() == h.hexdigest():
continue
files_to_upload.append(png_path)
if len(files_to_upload): if len(files_to_upload):
subprocess.check_call([ subprocess.check_call([
'upload_to_google_storage.py', 'upload_to_google_storage.py',
......
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