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

Unified Diff: scripts/slave/recipe_modules/chromedriver/api.py

Issue 2181693004: Add a check that the Chromedriver prebuilt name is expected. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Changed to Sam's impl Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/chromedriver/api.py
diff --git a/scripts/slave/recipe_modules/chromedriver/api.py b/scripts/slave/recipe_modules/chromedriver/api.py
index cea308a0bc08f75ccfd655393de06239b71c5938..af8d2d4853c3f2eee722831d96a389ca04bb181c 100644
--- a/scripts/slave/recipe_modules/chromedriver/api.py
+++ b/scripts/slave/recipe_modules/chromedriver/api.py
@@ -4,10 +4,14 @@
from recipe_engine import recipe_api
+import re
+
GS_CHROMEDRIVER_DATA_BUCKET = 'chromedriver-data'
GS_PREBUILTS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/prebuilts'
GS_SERVER_LOGS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/server_logs'
+PREBUILT_FILE_RE = re.compile(r'r\d+\.zip')
+
TEST_LOG_FORMAT = '%s_log.json'
TEST_LOG_MAX_LENGTH = 500
@@ -21,15 +25,22 @@ class ChromedriverApi(recipe_api.RecipeApi):
"""Downloads the most recent prebuilts from Google storage."""
with self.m.step.nest('Download Prebuilts'):
with self.m.tempfile.temp_dir('prebuilt') as prebuilt_dir:
- zipfile = prebuilt_dir.join('build.zip')
unzip_dir = prebuilt_dir.join('unzipped')
self.m.gsutil.download_latest_file(
base_url='gs://%s' % GS_PREBUILTS_URL,
partial_name='gs://%s/r' % GS_PREBUILTS_URL,
- destination=zipfile,
+ destination=prebuilt_dir,
name='download latest prebuilt')
+ file_list = self.m.file.listdir(
+ name='get prebuilt filename',
+ path=prebuilt_dir,
+ step_test_data=lambda: self.m.json.test_api.output(['r111111.zip']))
+ prebuilt_file = file_list[0]
+ if not PREBUILT_FILE_RE.match(prebuilt_file):
+ raise self.m.step.StepFailure('Unexpected prebuilt filename: %s'
+ % prebuilt_file)
self.m.zip.unzip(step_name='unzip prebuilt',
- zip_file=zipfile,
+ zip_file=prebuilt_dir.join(prebuilt_file),
output=unzip_dir)
self.m.file.move(name='move prebuilt',
source=unzip_dir.join('chromedriver'),
« no previous file with comments | « scripts/slave/recipe_modules/chromedriver/__init__.py ('k') | scripts/slave/recipe_modules/chromedriver/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698