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

Unified Diff: client/tests/run_isolated_test.py

Issue 2069903003: swarming: custom cipd package paths (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@cipd-win
Patch Set: fix _validate_cipd_path Created 4 years, 6 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
« no previous file with comments | « client/swarming.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/run_isolated_test.py
diff --git a/client/tests/run_isolated_test.py b/client/tests/run_isolated_test.py
index 616287cb58eb798e582ed7cf78830f27bfb0b38e..5bb28c3d427ea417b2c13acd9a82e8bbd7a8cc6b 100755
--- a/client/tests/run_isolated_test.py
+++ b/client/tests/run_isolated_test.py
@@ -208,8 +208,7 @@ class RunIsolatedTest(RunIsolatedTestBase):
None,
None,
None,
- None,
- None)
+ lambda run_dir: None)
self.assertEqual(0, ret)
return make_tree_call
@@ -335,45 +334,73 @@ class RunIsolatedTest(RunIsolatedTestBase):
self.popen_calls)
def test_main_naked_with_packages(self):
- cmd = [
- '--no-log',
- '--cipd-package', 'infra/tools/echo/${platform}:latest',
- '--cipd-server', self.cipd_server.url,
- '${CIPD_PATH}/echo',
- 'hello',
- 'world',
- ]
- ret = run_isolated.main(cmd)
- self.assertEqual(0, ret)
-
- self.assertEqual(2, len(self.popen_calls))
-
- # Test cipd-ensure command.
- cipd_ensure_cmd, _ = self.popen_calls[0]
- self.assertEqual(cipd_ensure_cmd[:2], [
- os.path.abspath('cipd_cache/cipd' + cipd.EXECUTABLE_SUFFIX),
- 'ensure',
- ])
- cache_dir_index = cipd_ensure_cmd.index('-cache-dir')
- self.assertEqual(
- cipd_ensure_cmd[cache_dir_index+1],
- os.path.abspath('cipd_cache/cipd_internal'))
-
- # Test cipd cache.
- version_file = unicode(os.path.abspath(
- 'cipd_cache/versions/1481d0a0ceb16ea4672fed76a0710306eb9f3a33'))
- self.assertTrue(fs.isfile(version_file))
- with open(version_file) as f:
- self.assertEqual(f.read(), 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
-
- client_binary_file = unicode(os.path.abspath(
- 'cipd_cache/clients/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))
- self.assertTrue(fs.isfile(client_binary_file))
+ packages_fd, packages_path = tempfile.mkstemp(prefix=u'packages')
+ try:
+ try:
+ os.write(packages_fd, json.dumps({
+ 'packages': [
+ {
+ 'path': 'bin',
+ 'package_name': 'infra/tools/echo/${platform}',
+ 'version': 'latest',
+ },
+ {
+ 'path': '.',
+ 'package_name': 'infra/data/x',
+ 'version': 'latest',
+ },
+ {
+ 'package_name': 'infra/data/y',
+ 'version': 'canary',
+ },
+ ]
+ }))
+ finally:
+ os.close(packages_fd)
+
+ cmd = [
+ '--no-log',
+ '--cipd-package-list', packages_path,
+ '--cipd-server', self.cipd_server.url,
+ 'bin/echo${EXECUTABLE_SUFFIX}',
+ 'hello',
+ 'world',
+ ]
+ ret = run_isolated.main(cmd)
+ self.assertEqual(0, ret)
- # Test echo call.
- echo_cmd, _ = self.popen_calls[1]
- self.assertTrue(echo_cmd[0].endswith('cipd_site_root/echo'))
- self.assertEqual(echo_cmd[1:], ['hello', 'world'])
+ print self.popen_calls
+ self.assertEqual(3, len(self.popen_calls))
+
+ # Test cipd-ensure command for installing packages.
+ for cipd_ensure_cmd, _ in self.popen_calls[0:2]:
+ self.assertEqual(cipd_ensure_cmd[:2], [
+ os.path.abspath('cipd_cache/cipd' + cipd.EXECUTABLE_SUFFIX),
+ 'ensure',
+ ])
+ cache_dir_index = cipd_ensure_cmd.index('-cache-dir')
+ self.assertEqual(
+ cipd_ensure_cmd[cache_dir_index+1],
+ os.path.abspath('cipd_cache/cipd_internal'))
+
+ # Test cipd cache.
+ version_file = unicode(os.path.abspath(
+ 'cipd_cache/versions/1481d0a0ceb16ea4672fed76a0710306eb9f3a33'))
+ self.assertTrue(fs.isfile(version_file))
+ with open(version_file) as f:
+ self.assertEqual(f.read(), 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
+
+ client_binary_file = unicode(os.path.abspath(
+ 'cipd_cache/clients/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))
+ self.assertTrue(fs.isfile(client_binary_file))
+
+ # Test echo call.
+ echo_cmd, _ = self.popen_calls[2]
+ self.assertTrue(echo_cmd[0].endswith(
+ '/bin/echo' + cipd.EXECUTABLE_SUFFIX))
+ self.assertEqual(echo_cmd[1:], ['hello', 'world'])
+ finally:
+ os.remove(packages_path)
def test_modified_cwd(self):
isolated = json_dumps({
@@ -454,9 +481,8 @@ class RunIsolatedTestRun(RunIsolatedTestBase):
None,
None,
None,
- [],
None,
- None)
+ lambda run_dir: None)
self.assertEqual(0, ret)
# It uploaded back. Assert the store has a new item containing foo.
« no previous file with comments | « client/swarming.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698