| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import copy | |
| 7 import datetime | |
| 8 import os | |
| 9 import posixpath | |
| 10 import subprocess | |
| 11 import sys | |
| 12 import unittest | |
| 13 import urlparse | |
| 14 | |
| 15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| 16 BUILD_TOOLS_DIR = os.path.dirname(SCRIPT_DIR) | |
| 17 | |
| 18 sys.path.append(BUILD_TOOLS_DIR) | |
| 19 import manifest_util | |
| 20 import update_nacl_manifest | |
| 21 from update_nacl_manifest import CANARY_BUNDLE_NAME | |
| 22 | |
| 23 | |
| 24 HTTPS_BASE_URL = 'https://commondatastorage.googleapis.com' \ | |
| 25 '/nativeclient_mirror/nacl/nacl_sdk/' | |
| 26 | |
| 27 OS_CR = ('cros',) | |
| 28 OS_M = ('mac',) | |
| 29 OS_ML = ('mac', 'linux') | |
| 30 OS_MW = ('mac', 'win') | |
| 31 OS_MLW = ('mac', 'linux', 'win') | |
| 32 STABLE = 'stable' | |
| 33 BETA = 'beta' | |
| 34 DEV = 'dev' | |
| 35 CANARY = 'canary' | |
| 36 | |
| 37 | |
| 38 def GetArchiveUrl(host_os, version): | |
| 39 basename = 'naclsdk_%s.tar.bz2' % (host_os,) | |
| 40 return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename)) | |
| 41 | |
| 42 | |
| 43 def MakeGsUrl(rel_path): | |
| 44 return update_nacl_manifest.GS_BUCKET_PATH + rel_path | |
| 45 | |
| 46 | |
| 47 def GetPathFromGsUrl(url): | |
| 48 assert url.startswith(update_nacl_manifest.GS_BUCKET_PATH) | |
| 49 return url[len(update_nacl_manifest.GS_BUCKET_PATH):] | |
| 50 | |
| 51 | |
| 52 def GetPathFromHttpsUrl(url): | |
| 53 assert url.startswith(HTTPS_BASE_URL) | |
| 54 return url[len(HTTPS_BASE_URL):] | |
| 55 | |
| 56 | |
| 57 def MakeArchive(host_os, version): | |
| 58 archive = manifest_util.Archive(host_os) | |
| 59 archive.url = GetArchiveUrl(host_os, version) | |
| 60 # dummy values that won't succeed if we ever use them, but will pass | |
| 61 # validation. :) | |
| 62 archive.checksum = {'sha1': 'foobar'} | |
| 63 archive.size = 1 | |
| 64 return archive | |
| 65 | |
| 66 | |
| 67 def MakeNonPepperBundle(name, with_archives=False): | |
| 68 bundle = manifest_util.Bundle(name) | |
| 69 bundle.version = 1 | |
| 70 bundle.revision = 1 | |
| 71 bundle.description = 'Dummy bundle' | |
| 72 bundle.recommended = 'yes' | |
| 73 bundle.stability = 'stable' | |
| 74 | |
| 75 if with_archives: | |
| 76 for host_os in OS_MLW: | |
| 77 archive = manifest_util.Archive(host_os) | |
| 78 archive.url = 'http://example.com' | |
| 79 archive.checksum = {'sha1': 'blah'} | |
| 80 archive.size = 2 | |
| 81 bundle.AddArchive(archive) | |
| 82 return bundle | |
| 83 | |
| 84 | |
| 85 def MakeBundle(major_version, revision=0, version=None, host_oses=None, | |
| 86 stability='dev'): | |
| 87 assert (version is None or | |
| 88 version.split('.')[0] == 'trunk' or | |
| 89 version.split('.')[0] == str(major_version)) | |
| 90 if stability == CANARY: | |
| 91 bundle_name = CANARY_BUNDLE_NAME | |
| 92 else: | |
| 93 bundle_name = 'pepper_' + str(major_version) | |
| 94 | |
| 95 bundle = manifest_util.Bundle(bundle_name) | |
| 96 bundle.version = major_version | |
| 97 bundle.revision = revision | |
| 98 bundle.description = 'Chrome %s bundle, revision %s' % (major_version, | |
| 99 revision) | |
| 100 bundle.repath = 'pepper_' + str(major_version) | |
| 101 bundle.recommended = 'no' | |
| 102 bundle.stability = stability | |
| 103 | |
| 104 if host_oses: | |
| 105 for host_os in host_oses: | |
| 106 bundle.AddArchive(MakeArchive(host_os, version)) | |
| 107 return bundle | |
| 108 | |
| 109 | |
| 110 class MakeManifest(manifest_util.SDKManifest): | |
| 111 def __init__(self, *args): | |
| 112 manifest_util.SDKManifest.__init__(self) | |
| 113 | |
| 114 for bundle in args: | |
| 115 self.AddBundle(bundle) | |
| 116 | |
| 117 def AddBundle(self, bundle): | |
| 118 self.MergeBundle(bundle, allow_existing=False) | |
| 119 | |
| 120 | |
| 121 class MakeHistory(object): | |
| 122 def __init__(self): | |
| 123 # used for a dummy timestamp | |
| 124 self.datetime = datetime.datetime.utcnow() | |
| 125 self.history = [] | |
| 126 | |
| 127 def Add(self, host_oses, channel, version): | |
| 128 for host_os in host_oses: | |
| 129 timestamp = self.datetime.strftime('%Y-%m-%d %H:%M:%S.%f') | |
| 130 self.history.append((host_os, channel, version, timestamp)) | |
| 131 self.datetime += datetime.timedelta(0, -3600) # one hour earlier | |
| 132 self.datetime += datetime.timedelta(-1) # one day earlier | |
| 133 | |
| 134 | |
| 135 class MakeFiles(dict): | |
| 136 def Add(self, bundle, add_archive_for_os=OS_MLW, add_json_for_os=OS_MLW): | |
| 137 for archive in bundle.GetArchives(): | |
| 138 if not archive.host_os in add_archive_for_os: | |
| 139 continue | |
| 140 | |
| 141 # add a dummy file for each archive | |
| 142 path = GetPathFromHttpsUrl(archive.url) | |
| 143 self[path] = 'My Dummy Archive' | |
| 144 | |
| 145 if archive.host_os in add_json_for_os: | |
| 146 # add .json manifest snippet, it should look like a normal Bundle, but | |
| 147 # only has one archive. | |
| 148 new_bundle = manifest_util.Bundle('') | |
| 149 new_bundle.CopyFrom(bundle) | |
| 150 del new_bundle.archives[:] | |
| 151 new_bundle.AddArchive(archive) | |
| 152 self[path + '.json'] = new_bundle.GetDataAsString() | |
| 153 | |
| 154 | |
| 155 class TestDelegate(update_nacl_manifest.Delegate): | |
| 156 def __init__(self, manifest, history, files, version_mapping): | |
| 157 self.manifest = manifest | |
| 158 self.history = history | |
| 159 self.files = files | |
| 160 self.version_mapping = version_mapping | |
| 161 | |
| 162 def GetRepoManifest(self): | |
| 163 return self.manifest | |
| 164 | |
| 165 def GetHistory(self): | |
| 166 return self.history | |
| 167 | |
| 168 def GetTrunkRevision(self, version): | |
| 169 return self.version_mapping[version] | |
| 170 | |
| 171 def GsUtil_ls(self, url): | |
| 172 path = GetPathFromGsUrl(url) | |
| 173 result = [] | |
| 174 for filename, _ in self.files.iteritems(): | |
| 175 if filename.startswith(path): | |
| 176 result.append(MakeGsUrl(filename)) | |
| 177 return result | |
| 178 | |
| 179 def GsUtil_cat(self, url): | |
| 180 path = GetPathFromGsUrl(url) | |
| 181 if path not in self.files: | |
| 182 raise subprocess.CalledProcessError(1, 'gsutil cat %s' % (url,)) | |
| 183 return self.files[path] | |
| 184 | |
| 185 def GsUtil_cp(self, src, dest, stdin=None): | |
| 186 dest_path = GetPathFromGsUrl(dest) | |
| 187 if src == '-': | |
| 188 self.files[dest_path] = stdin | |
| 189 else: | |
| 190 src_path = GetPathFromGsUrl(src) | |
| 191 if src_path not in self.files: | |
| 192 raise subprocess.CalledProcessError(1, 'gsutil cp %s %s' % (src, dest)) | |
| 193 self.files[dest_path] = self.files[src_path] | |
| 194 | |
| 195 def Print(self, *args): | |
| 196 # eat all informational messages | |
| 197 pass | |
| 198 | |
| 199 | |
| 200 # Shorthand for premade bundles/versions | |
| 201 V18_0_1025_163 = '18.0.1025.163' | |
| 202 V18_0_1025_175 = '18.0.1025.175' | |
| 203 V18_0_1025_184 = '18.0.1025.184' | |
| 204 V19_0_1084_41 = '19.0.1084.41' | |
| 205 V19_0_1084_67 = '19.0.1084.67' | |
| 206 V21_0_1145_0 = '21.0.1145.0' | |
| 207 V21_0_1166_0 = '21.0.1166.0' | |
| 208 VTRUNK_138079 = 'trunk.138079' | |
| 209 B18_0_1025_163_R1_MLW = MakeBundle(18, 1, V18_0_1025_163, OS_MLW) | |
| 210 B18_0_1025_184_R1_MLW = MakeBundle(18, 1, V18_0_1025_184, OS_MLW) | |
| 211 B18_R1_NONE = MakeBundle(18) | |
| 212 B19_0_1084_41_R1_MLW = MakeBundle(19, 1, V19_0_1084_41, OS_MLW) | |
| 213 B19_0_1084_67_R1_MLW = MakeBundle(19, 1, V19_0_1084_67, OS_MLW) | |
| 214 B19_R1_NONE = MakeBundle(19) | |
| 215 BCANARY_R1_NONE = MakeBundle(0, stability=CANARY) | |
| 216 B21_0_1145_0_R1_MLW = MakeBundle(21, 1, V21_0_1145_0, OS_MLW) | |
| 217 B21_0_1166_0_R1_MW = MakeBundle(21, 1, V21_0_1166_0, OS_MW) | |
| 218 BTRUNK_138079_R1_MLW = MakeBundle(21, 1, VTRUNK_138079, OS_MLW) | |
| 219 NON_PEPPER_BUNDLE_NOARCHIVES = MakeNonPepperBundle('foo') | |
| 220 NON_PEPPER_BUNDLE_ARCHIVES = MakeNonPepperBundle('bar', with_archives=True) | |
| 221 | |
| 222 | |
| 223 class TestUpdateManifest(unittest.TestCase): | |
| 224 def setUp(self): | |
| 225 self.history = MakeHistory() | |
| 226 self.files = MakeFiles() | |
| 227 self.version_mapping = {} | |
| 228 self.delegate = None | |
| 229 self.uploaded_manifest = None | |
| 230 self.manifest = None | |
| 231 | |
| 232 def _MakeDelegate(self): | |
| 233 self.delegate = TestDelegate(self.manifest, self.history.history, | |
| 234 self.files, self.version_mapping) | |
| 235 | |
| 236 def _Run(self, host_oses): | |
| 237 update_nacl_manifest.Run(self.delegate, host_oses) | |
| 238 | |
| 239 def _HasUploadedManifest(self): | |
| 240 return 'naclsdk_manifest2.json' in self.files | |
| 241 | |
| 242 def _ReadUploadedManifest(self): | |
| 243 self.uploaded_manifest = manifest_util.SDKManifest() | |
| 244 self.uploaded_manifest.LoadDataFromString( | |
| 245 self.files['naclsdk_manifest2.json']) | |
| 246 | |
| 247 def _AssertUploadedManifestHasBundle(self, bundle, stability): | |
| 248 if stability == CANARY: | |
| 249 bundle_name = CANARY_BUNDLE_NAME | |
| 250 else: | |
| 251 bundle_name = bundle.name | |
| 252 | |
| 253 uploaded_manifest_bundle = self.uploaded_manifest.GetBundle(bundle_name) | |
| 254 # Bundles that we create in the test (and in the manifest snippets) have | |
| 255 # their stability set to "dev". update_nacl_manifest correctly updates it. | |
| 256 # So we have to force the stability of |bundle| so they compare equal. | |
| 257 test_bundle = copy.copy(bundle) | |
| 258 test_bundle.stability = stability | |
| 259 if stability == CANARY: | |
| 260 test_bundle.name = CANARY_BUNDLE_NAME | |
| 261 self.assertEqual(uploaded_manifest_bundle, test_bundle) | |
| 262 | |
| 263 def _AddCsvHistory(self, history): | |
| 264 import csv | |
| 265 import cStringIO | |
| 266 history_stream = cStringIO.StringIO(history) | |
| 267 self.history.history = [(platform, channel, version, date) | |
| 268 for platform, channel, version, date in csv.reader(history_stream)] | |
| 269 | |
| 270 def testNoUpdateNeeded(self): | |
| 271 self.manifest = MakeManifest(B18_0_1025_163_R1_MLW) | |
| 272 self._MakeDelegate() | |
| 273 self._Run(OS_MLW) | |
| 274 self.assertEqual(self._HasUploadedManifest(), False) | |
| 275 | |
| 276 # Add another bundle, make sure it still doesn't update | |
| 277 self.manifest.AddBundle(B19_0_1084_41_R1_MLW) | |
| 278 self._Run(OS_MLW) | |
| 279 self.assertEqual(self._HasUploadedManifest(), False) | |
| 280 | |
| 281 def testSimpleUpdate(self): | |
| 282 self.manifest = MakeManifest(B18_R1_NONE) | |
| 283 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 284 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 285 self._MakeDelegate() | |
| 286 self._Run(OS_MLW) | |
| 287 self._ReadUploadedManifest() | |
| 288 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 289 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 290 | |
| 291 def testOnePlatformHasNewerRelease(self): | |
| 292 self.manifest = MakeManifest(B18_R1_NONE) | |
| 293 self.history.Add(OS_M, BETA, V18_0_1025_175) # Mac has newer version | |
| 294 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 295 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 296 self._MakeDelegate() | |
| 297 self._Run(OS_MLW) | |
| 298 self._ReadUploadedManifest() | |
| 299 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 300 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 301 | |
| 302 def testMultipleMissingPlatformsInHistory(self): | |
| 303 self.manifest = MakeManifest(B18_R1_NONE) | |
| 304 self.history.Add(OS_ML, BETA, V18_0_1025_184) | |
| 305 self.history.Add(OS_M, BETA, V18_0_1025_175) | |
| 306 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 307 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 308 self._MakeDelegate() | |
| 309 self._Run(OS_MLW) | |
| 310 self._ReadUploadedManifest() | |
| 311 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 312 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 313 | |
| 314 def testUpdateOnlyOneBundle(self): | |
| 315 self.manifest = MakeManifest(B18_R1_NONE, B19_0_1084_41_R1_MLW) | |
| 316 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 317 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 318 self._MakeDelegate() | |
| 319 self._Run(OS_MLW) | |
| 320 self._ReadUploadedManifest() | |
| 321 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 322 self._AssertUploadedManifestHasBundle(B19_0_1084_41_R1_MLW, DEV) | |
| 323 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 2) | |
| 324 | |
| 325 def testUpdateTwoBundles(self): | |
| 326 self.manifest = MakeManifest(B18_R1_NONE, B19_R1_NONE) | |
| 327 self.history.Add(OS_MLW, DEV, V19_0_1084_41) | |
| 328 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 329 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 330 self.files.Add(B19_0_1084_41_R1_MLW) | |
| 331 self._MakeDelegate() | |
| 332 self._Run(OS_MLW) | |
| 333 self._ReadUploadedManifest() | |
| 334 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 335 self._AssertUploadedManifestHasBundle(B19_0_1084_41_R1_MLW, DEV) | |
| 336 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 2) | |
| 337 | |
| 338 def testUpdateWithMissingPlatformsInArchives(self): | |
| 339 self.manifest = MakeManifest(B18_R1_NONE) | |
| 340 self.history.Add(OS_MLW, BETA, V18_0_1025_184) | |
| 341 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 342 self.files.Add(B18_0_1025_184_R1_MLW, add_archive_for_os=OS_M) | |
| 343 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 344 self._MakeDelegate() | |
| 345 self._Run(OS_MLW) | |
| 346 self._ReadUploadedManifest() | |
| 347 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 348 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 349 | |
| 350 def testUpdateWithMissingManifestSnippets(self): | |
| 351 self.manifest = MakeManifest(B18_R1_NONE) | |
| 352 self.history.Add(OS_MLW, BETA, V18_0_1025_184) | |
| 353 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 354 self.files.Add(B18_0_1025_184_R1_MLW, add_json_for_os=OS_ML) | |
| 355 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 356 self._MakeDelegate() | |
| 357 self._Run(OS_MLW) | |
| 358 self._ReadUploadedManifest() | |
| 359 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 360 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 361 | |
| 362 def testRecommendedIsStable(self): | |
| 363 for channel in STABLE, BETA, DEV, CANARY: | |
| 364 self.setUp() | |
| 365 bundle = copy.deepcopy(B18_R1_NONE) | |
| 366 self.manifest = MakeManifest(bundle) | |
| 367 self.history.Add(OS_MLW, channel, V18_0_1025_163) | |
| 368 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 369 self._MakeDelegate() | |
| 370 self._Run(OS_MLW) | |
| 371 self._ReadUploadedManifest() | |
| 372 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 373 uploaded_bundle = self.uploaded_manifest.GetBundle('pepper_18') | |
| 374 if channel == STABLE: | |
| 375 self.assertEqual(uploaded_bundle.recommended, 'yes') | |
| 376 else: | |
| 377 self.assertEqual(uploaded_bundle.recommended, 'no') | |
| 378 | |
| 379 def testNoUpdateWithNonPepperBundle(self): | |
| 380 self.manifest = MakeManifest(NON_PEPPER_BUNDLE_NOARCHIVES, | |
| 381 B18_0_1025_163_R1_MLW) | |
| 382 self._MakeDelegate() | |
| 383 self._Run(OS_MLW) | |
| 384 self.assertEqual(self._HasUploadedManifest(), False) | |
| 385 | |
| 386 def testUpdateWithHistoryWithExtraneousPlatforms(self): | |
| 387 self.manifest = MakeManifest(B18_R1_NONE) | |
| 388 self.history.Add(OS_ML, BETA, V18_0_1025_184) | |
| 389 self.history.Add(OS_CR, BETA, V18_0_1025_184) | |
| 390 self.history.Add(OS_CR, BETA, V18_0_1025_175) | |
| 391 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 392 self.files.Add(B18_0_1025_163_R1_MLW) | |
| 393 self._MakeDelegate() | |
| 394 self._Run(OS_MLW) | |
| 395 self._ReadUploadedManifest() | |
| 396 self._AssertUploadedManifestHasBundle(B18_0_1025_163_R1_MLW, BETA) | |
| 397 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 398 | |
| 399 def testSnippetWithStringRevisionAndVersion(self): | |
| 400 # This test exists because some manifest snippets were uploaded with | |
| 401 # strings for their revisions and versions. I want to make sure the | |
| 402 # resulting manifest is still consistent with the old format. | |
| 403 self.manifest = MakeManifest(B18_R1_NONE) | |
| 404 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 405 bundle_string_revision = MakeBundle('18', '1234', V18_0_1025_163, OS_MLW) | |
| 406 self.files.Add(bundle_string_revision) | |
| 407 self._MakeDelegate() | |
| 408 self._Run(OS_MLW) | |
| 409 self._ReadUploadedManifest() | |
| 410 uploaded_bundle = self.uploaded_manifest.GetBundle( | |
| 411 bundle_string_revision.name) | |
| 412 self.assertEqual(uploaded_bundle.revision, 1234) | |
| 413 self.assertEqual(uploaded_bundle.version, 18) | |
| 414 | |
| 415 def testUpdateCanary(self): | |
| 416 # Note that the bundle in naclsdk_manifest2.json will be called | |
| 417 # CANARY_BUNDLE_NAME, whereas the bundle in the manifest "snippet" will be | |
| 418 # called "pepper_21". | |
| 419 canary_bundle = copy.deepcopy(BCANARY_R1_NONE) | |
| 420 self.manifest = MakeManifest(canary_bundle) | |
| 421 self.history.Add(OS_MW, CANARY, V21_0_1145_0) | |
| 422 self.files.Add(B21_0_1145_0_R1_MLW) | |
| 423 self._MakeDelegate() | |
| 424 self._Run(OS_MLW) | |
| 425 self._ReadUploadedManifest() | |
| 426 self._AssertUploadedManifestHasBundle(B21_0_1145_0_R1_MLW, CANARY) | |
| 427 | |
| 428 def testUpdateCanaryUseTrunkArchives(self): | |
| 429 canary_bundle = copy.deepcopy(BCANARY_R1_NONE) | |
| 430 self.manifest = MakeManifest(canary_bundle) | |
| 431 self.history.Add(OS_MW, CANARY, V21_0_1166_0) | |
| 432 self.files.Add(B21_0_1166_0_R1_MW) | |
| 433 self.files.Add(BTRUNK_138079_R1_MLW) | |
| 434 self.version_mapping[V21_0_1166_0] = VTRUNK_138079 | |
| 435 self._MakeDelegate() | |
| 436 self._Run(OS_MLW) | |
| 437 self._ReadUploadedManifest() | |
| 438 | |
| 439 test_bundle = copy.deepcopy(B21_0_1166_0_R1_MW) | |
| 440 test_bundle.AddArchive(BTRUNK_138079_R1_MLW.GetArchive('linux')) | |
| 441 self._AssertUploadedManifestHasBundle(test_bundle, CANARY) | |
| 442 | |
| 443 def testCanaryUseOnlyTrunkArchives(self): | |
| 444 self.manifest = MakeManifest(copy.deepcopy(BCANARY_R1_NONE)) | |
| 445 history = """win,canary,21.0.1163.0,2012-06-04 12:35:44.784446 | |
| 446 mac,canary,21.0.1163.0,2012-06-04 11:54:09.433166""" | |
| 447 self._AddCsvHistory(history) | |
| 448 self.version_mapping['21.0.1163.0'] = 'trunk.140240' | |
| 449 my_bundle = MakeBundle(21, 140240, '21.0.1163.0', OS_MLW) | |
| 450 self.files.Add(my_bundle) | |
| 451 self._MakeDelegate() | |
| 452 self._Run(OS_MLW) | |
| 453 self._ReadUploadedManifest() | |
| 454 self._AssertUploadedManifestHasBundle(my_bundle, CANARY) | |
| 455 | |
| 456 def testCanaryShouldOnlyUseCanaryVersions(self): | |
| 457 canary_bundle = copy.deepcopy(BCANARY_R1_NONE) | |
| 458 self.manifest = MakeManifest(canary_bundle) | |
| 459 self.history.Add(OS_MW, CANARY, V21_0_1166_0) | |
| 460 self.history.Add(OS_MW, BETA, V19_0_1084_41) | |
| 461 self.files.Add(B19_0_1084_41_R1_MLW) | |
| 462 self.version_mapping[V21_0_1166_0] = VTRUNK_138079 | |
| 463 self._MakeDelegate() | |
| 464 self.assertRaises(Exception, self._Run, OS_MLW) | |
| 465 | |
| 466 def testMissingCanaryFollowedByStableShouldWork(self): | |
| 467 history = """win,canary,21.0.1160.0,2012-06-01 19:44:35.936109 | |
| 468 mac,canary,21.0.1160.0,2012-06-01 18:20:02.003123 | |
| 469 mac,stable,19.0.1084.52,2012-06-01 17:59:21.559710 | |
| 470 win,canary,21.0.1159.2,2012-06-01 02:31:43.877688 | |
| 471 mac,stable,19.0.1084.53,2012-06-01 01:39:57.549149 | |
| 472 win,canary,21.0.1158.0,2012-05-31 20:16:55.615236 | |
| 473 win,canary,21.0.1157.0,2012-05-31 17:41:29.516013 | |
| 474 mac,canary,21.0.1158.0,2012-05-31 17:41:27.591354 | |
| 475 mac,beta,20.0.1132.21,2012-05-30 23:45:38.535586 | |
| 476 linux,beta,20.0.1132.21,2012-05-30 23:45:37.025015 | |
| 477 cf,beta,20.0.1132.21,2012-05-30 23:45:36.767529 | |
| 478 win,beta,20.0.1132.21,2012-05-30 23:44:56.675123 | |
| 479 win,canary,21.0.1156.1,2012-05-30 22:28:01.872056 | |
| 480 mac,canary,21.0.1156.1,2012-05-30 21:20:29.920390 | |
| 481 win,canary,21.0.1156.0,2012-05-30 12:46:48.046627 | |
| 482 mac,canary,21.0.1156.0,2012-05-30 12:14:21.305090""" | |
| 483 self.manifest = MakeManifest(copy.deepcopy(BCANARY_R1_NONE)) | |
| 484 self._AddCsvHistory(history) | |
| 485 self.version_mapping = { | |
| 486 '21.0.1160.0': 'trunk.139984', | |
| 487 '21.0.1159.2': 'trunk.139890', | |
| 488 '21.0.1158.0': 'trunk.139740', | |
| 489 '21.0.1157.0': 'unknown', | |
| 490 '21.0.1156.1': 'trunk.139576', | |
| 491 '21.0.1156.0': 'trunk.139984'} | |
| 492 self.files.Add(MakeBundle(21, 139890, '21.0.1159.2', OS_MLW)) | |
| 493 self.files.Add(MakeBundle(21, 0, '21.0.1157.1', ('linux', 'win'))) | |
| 494 my_bundle = MakeBundle(21, 139576, '21.0.1156.1', OS_MLW) | |
| 495 self.files.Add(my_bundle) | |
| 496 self._MakeDelegate() | |
| 497 self._Run(OS_MLW) | |
| 498 self._ReadUploadedManifest() | |
| 499 self._AssertUploadedManifestHasBundle(my_bundle, CANARY) | |
| 500 | |
| 501 def testExtensionWorksAsBz2(self): | |
| 502 # Allow old bundles with just .bz2 extension to work | |
| 503 self.manifest = MakeManifest(B18_R1_NONE) | |
| 504 self.history.Add(OS_MLW, BETA, V18_0_1025_163) | |
| 505 bundle = copy.deepcopy(B18_0_1025_163_R1_MLW) | |
| 506 archive_url = bundle.GetArchive('mac').url | |
| 507 bundle.GetArchive('mac').url = archive_url.replace('.tar', '') | |
| 508 self.files.Add(bundle) | |
| 509 self._MakeDelegate() | |
| 510 self._Run(OS_MLW) | |
| 511 self._ReadUploadedManifest() | |
| 512 self._AssertUploadedManifestHasBundle(bundle, BETA) | |
| 513 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | |
| 514 | |
| 515 | |
| 516 def main(): | |
| 517 suite = unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]) | |
| 518 result = unittest.TextTestRunner(verbosity=2).run(suite) | |
| 519 | |
| 520 return int(not result.wasSuccessful()) | |
| 521 | |
| 522 if __name__ == '__main__': | |
| 523 sys.exit(main()) | |
| OLD | NEW |