mirrored from https://chromium.googlesource.com/infra/luci/luci-py
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will cause run_isolated.py to report the fully resolved versions of the CIPD packages that it actually ended up using. DM will use this information to ensure that all executions of a given Attempt use the same versions. R=maruel@chromium.org, nodir@chromium.org, vadimsh@chromium.org BUG=639975 Review-Url: https://codereview.chromium.org/2267363004
- Loading branch information
Showing
17 changed files
with
544 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
# Copyright 2016 The LUCI Authors. All rights reserved. | ||
# Use of this source code is governed under the Apache License, Version 2.0 | ||
# that can be found in the LICENSE file. | ||
|
||
import collections | ||
import logging | ||
import re | ||
import sys | ||
import unittest | ||
|
||
# Setups environment. | ||
import test_env_handlers | ||
|
||
import cipd | ||
import swarming_rpcs | ||
|
||
|
||
class TestPinChecker(unittest.TestCase): | ||
def setUp(self): | ||
super(TestPinChecker, self).setUp() | ||
self.cp = collections.namedtuple('CipdPackage', 'path package_name version') | ||
|
||
def test_correct_pins(self): | ||
a = self.cp('path', 'package_name/${platform}-${os_ver}', 'latest') | ||
b = self.cp('path', 'package_name/windows-amd64-something_10', 'deadbeef'*5) | ||
|
||
with cipd.pin_check_fn(None, None) as check: | ||
# will not raise | ||
check(a, b) | ||
|
||
a = self.cp('path', 'other/${platform}-${os_ver}', 'latest') | ||
b = self.cp('path', 'other/windows-amd64-something_10', 'deadbeef'*5) | ||
|
||
# will not raise | ||
check(a, b) | ||
|
||
def test_mismatched_pins(self): | ||
# if a is already a pin, b must match its version exactly | ||
a = self.cp('path', 'package_name/${platform}-${os_ver}', 'deadbeef'*5) | ||
b = self.cp('path', 'package_name/windows-amd64-something_10', 'badc0ffe'*5) | ||
|
||
with cipd.pin_check_fn(None, None) as check: | ||
with self.assertRaisesRegexp(ValueError, 'Mismatched pins'): | ||
check(a, b) | ||
|
||
def test_mismatched_paths(self): | ||
a = self.cp('path', 'package_name/${platform}-${os_ver}', 'latest') | ||
b = self.cp('else', 'package_name/windows-amd64-something_10', 'deadbeef'*5) | ||
|
||
with cipd.pin_check_fn(None, None) as check: | ||
with self.assertRaisesRegexp(ValueError, 'Mismatched path'): | ||
check(a, b) | ||
|
||
def test_mismatched_names(self): | ||
a = self.cp('', 'package_name/${platform}-${os_ver}', 'latest') | ||
b = self.cp('', 'else/windows-amd64-something_10', 'deadbeef'*5) | ||
|
||
with cipd.pin_check_fn(None, None) as check: | ||
with self.assertRaisesRegexp(ValueError, 'Mismatched package_name'): | ||
check(a, b) | ||
|
||
a = self.cp('', 'package_name/${platform}-${os_ver}', 'latest') | ||
b = self.cp('', 'package_name/windows-amd64-something_10', 'deadbeef'*5) | ||
# will not raise | ||
check(a, b) | ||
|
||
# This doesn't match the previous knowledge of platform or os_ver, so it | ||
# will not match. | ||
a = self.cp('', 'package_name/${platform}-${os_ver}', 'latest') | ||
b = self.cp('', 'package_name/linux-32-nerds', 'deadbeef'*5) | ||
|
||
with self.assertRaisesRegexp(ValueError, 'Mismatched package_name'): | ||
check(a, b) | ||
|
||
|
||
if __name__ == '__main__': | ||
if '-v' in sys.argv: | ||
unittest.TestCase.maxDiff = None | ||
logging.basicConfig( | ||
level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, | ||
format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.