Modify ParseURL() to accept archive_url with a target prefix
Devserver parses the archive_url as base_url/target/version and store
the downloaded files in {local_path}/{target}/{version}. This fix allows
devserver to accept a relative path (rel_path) which contains the build
target but can have depth greater than one level.
E.g. target=paladin-lumpy
rel_path can be either 'trybot/date/paladin-lumpy' or 'paladin-lumpy'.
BUG=chromium-os:32131
TEST=unittest
Change-Id: I2e6e11a8d7ce95d486b2608bf9101c0a41cfacc3
Reviewed-on: https://gerrit.chromium.org/gerrit/26061
Tested-by: Yu-Ju Hong <yjhong@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Yu-Ju Hong <yjhong@chromium.org>
diff --git a/downloader_unittest.py b/downloader_unittest.py
index a470f84..b9a1c85 100755
--- a/downloader_unittest.py
+++ b/downloader_unittest.py
@@ -187,16 +187,30 @@
def testBuildStaged(self):
"""Test whether we can correctly check if a build is previously staged."""
- archive_url = 'x86-awesome-release/R99-1234.0-r1'
- archive_url_non_staged = 'x86-awesome-release/R99-1234.0-r2'
+ base_url = 'gs://chrome-awesome/'
+ build_dir = 'x86-awesome-release/R99-1234.0-r1'
+ archive_url = base_url + build_dir
+ archive_url_non_staged = base_url + 'x86-awesome-release/R99-1234.0-r2'
# Create the directory to reflect staging.
- os.makedirs(os.path.join(self._work_dir, archive_url))
+ os.makedirs(os.path.join(self._work_dir, build_dir))
self.assertTrue(downloader.Downloader.BuildStaged(archive_url,
self._work_dir))
self.assertFalse(downloader.Downloader.BuildStaged(archive_url_non_staged,
self._work_dir))
+ def testTrybotBuildStaged(self):
+ """Test whether a previous staged trybot-build can be corrected detected"""
+ base_url = 'gs://chrome-awesome/'
+ build_dir = 'trybot/date/x86-awesome-release/R99-1234.0-r1'
+ archive_url = base_url + build_dir
+ archive_url_non_staged = base_url + 'x86-awesome-release/R99-1234.0-r2'
+ # Create the directory to reflect staging.
+ os.makedirs(os.path.join(self._work_dir, build_dir))
+ self.assertTrue(downloader.Downloader.BuildStaged(archive_url,
+ self._work_dir))
+ self.assertFalse(downloader.Downloader.BuildStaged(archive_url_non_staged,
+ self._work_dir))
class SymbolDownloaderTest(DownloaderTestBase):
"""Unit tests for downloader.SymbolDownloader.