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

Side by Side Diff: appengine/swarming/remote_smoke_test.py

Issue 1390773002: Add an assert to ensure UTF-8 locale when handling file paths. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: More fixes Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | appengine/swarming/server/bot_code_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Swarming Authors. All rights reserved. 2 # Copyright 2014 The Swarming Authors. All rights reserved.
3 # Use of this source code is governed by the Apache v2.0 license that can be 3 # Use of this source code is governed by the Apache v2.0 license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Integration test for the Swarming server.""" 6 """Integration test for the Swarming server."""
7 7
8 import Queue 8 import Queue
9 import json 9 import json
10 import logging 10 import logging
11 import optparse 11 import optparse
12 import os 12 import os
13 import shutil
14 import subprocess 13 import subprocess
15 import sys 14 import sys
16 import tempfile 15 import tempfile
17 import threading 16 import threading
18 import time 17 import time
19 18
20 APP_DIR = os.path.dirname(os.path.abspath(__file__)) 19 APP_DIR = os.path.dirname(os.path.abspath(__file__))
21 CHECKOUT_DIR = os.path.dirname(os.path.dirname(APP_DIR)) 20 CHECKOUT_DIR = os.path.dirname(os.path.dirname(APP_DIR))
22 CLIENT_DIR = os.path.join(CHECKOUT_DIR, 'client') 21 CLIENT_DIR = os.path.join(CHECKOUT_DIR, 'client')
23 SWARMING_SCRIPT = os.path.join(CLIENT_DIR, 'swarming.py') 22 SWARMING_SCRIPT = os.path.join(CLIENT_DIR, 'swarming.py')
24 23
24 sys.path.insert(0, CLIENT_DIR)
25 from third_party.depot_tools import fix_encoding
26 from utils import file_path
27 sys.path.pop(0)
28
25 29
26 def gen_isolated(isolate, script, includes=None): 30 def gen_isolated(isolate, script, includes=None):
27 """Archives a script to `isolate` server.""" 31 """Archives a script to `isolate` server."""
28 tmp = tempfile.mkdtemp(prefix='swarming_smoke') 32 tmp = tempfile.mkdtemp(prefix='swarming_smoke')
29 data = { 33 data = {
30 'variables': { 34 'variables': {
31 'command': ['python', '-u', 'script.py'], 35 'command': ['python', '-u', 'script.py'],
32 'files': ['script.py'], 36 'files': ['script.py'],
33 }, 37 },
34 } 38 }
(...skipping 19 matching lines...) Expand all
54 data['includes'] = includes 58 data['includes'] = includes
55 with open(isolated, 'wb') as f: 59 with open(isolated, 'wb') as f:
56 json.dump(data, f, sort_keys=True, separators=(',', ':')) 60 json.dump(data, f, sort_keys=True, separators=(',', ':'))
57 cmd = [ 61 cmd = [
58 os.path.join(CLIENT_DIR, 'isolateserver.py'), 'archive', 62 os.path.join(CLIENT_DIR, 'isolateserver.py'), 'archive',
59 '-I', isolate, '--namespace', 'default-gzip', isolated, 63 '-I', isolate, '--namespace', 'default-gzip', isolated,
60 ] 64 ]
61 out = subprocess.check_output(cmd) 65 out = subprocess.check_output(cmd)
62 return out.split(' ', 1)[0] 66 return out.split(' ', 1)[0]
63 finally: 67 finally:
64 shutil.rmtree(tmp) 68 file_path.rmtree(tmp)
65 69
66 70
67 def capture(cmd, **kwargs): 71 def capture(cmd, **kwargs):
68 """Captures output and return exit code.""" 72 """Captures output and return exit code."""
69 proc = subprocess.Popen( 73 proc = subprocess.Popen(
70 cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs) 74 cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs)
71 out = proc.communicate()[0] 75 out = proc.communicate()[0]
72 return out, proc.returncode 76 return out, proc.returncode
73 77
74 78
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 def run_test(results, swarming, isolate, extra_flags, name, test_case): 190 def run_test(results, swarming, isolate, extra_flags, name, test_case):
187 start = time.time() 191 start = time.time()
188 try: 192 try:
189 result = test_case(swarming, isolate, extra_flags) 193 result = test_case(swarming, isolate, extra_flags)
190 except Exception as e: 194 except Exception as e:
191 result = e 195 result = e
192 results.put((name, result, time.time() - start)) 196 results.put((name, result, time.time() - start))
193 197
194 198
195 def main(): 199 def main():
200 fix_encoding.fix_encoding()
196 # It's necessary for relative paths in .isolate. 201 # It's necessary for relative paths in .isolate.
197 os.chdir(APP_DIR) 202 os.chdir(APP_DIR)
198 203
199 parser = optparse.OptionParser() 204 parser = optparse.OptionParser()
200 parser.add_option('-S', '--swarming', help='Swarming server') 205 parser.add_option('-S', '--swarming', help='Swarming server')
201 parser.add_option('-I', '--isolate-server', help='Isolate server') 206 parser.add_option('-I', '--isolate-server', help='Isolate server')
202 parser.add_option('-d', '--dimensions', nargs=2, default=[], action='append') 207 parser.add_option('-d', '--dimensions', nargs=2, default=[], action='append')
203 parser.add_option('-v', '--verbose', action='store_true', help='Logs more') 208 parser.add_option('-v', '--verbose', action='store_true', help='Logs more')
204 options, args = parser.parse_args() 209 options, args = parser.parse_args()
205 210
(...skipping 28 matching lines...) Expand all
234 for i in xrange(len(tests)): 239 for i in xrange(len(tests)):
235 name, result, duration = results.get() 240 name, result, duration = results.get()
236 print('[%d/%d] %-*s: %4.1fs: %s' % 241 print('[%d/%d] %-*s: %4.1fs: %s' %
237 (i, len(tests), maxlen, name, duration, result)) 242 (i, len(tests), maxlen, name, duration, result))
238 243
239 return 0 244 return 0
240 245
241 246
242 if __name__ == '__main__': 247 if __name__ == '__main__':
243 sys.exit(main()) 248 sys.exit(main())
OLDNEW
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | appengine/swarming/server/bot_code_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698