OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """This file allows the bots to be easily configure and run the tests. | 6 """This file allows the bots to be easily configure and run the tests. |
7 | 7 |
8 Running this script requires passing --config-path with a path to a config file | 8 Running this script requires passing --config-path with a path to a config file |
9 of the following structure: | 9 of the following structure: |
10 [data_files] | 10 [data_files] |
(...skipping 18 matching lines...) Expand all Loading... |
29 import ConfigParser | 29 import ConfigParser |
30 import sys | 30 import sys |
31 import httplib2 | 31 import httplib2 |
32 import os | 32 import os |
33 import shutil | 33 import shutil |
34 import subprocess | 34 import subprocess |
35 import tempfile | 35 import tempfile |
36 import time | 36 import time |
37 sheet_libraries_import_error = None | 37 sheet_libraries_import_error = None |
38 try: | 38 try: |
| 39 # TODO(vabr) Remove this dependency http://crbug.com/418485#c4. |
39 from Sheet import Sheet | 40 from Sheet import Sheet |
40 from apiclient.discovery import build | 41 from apiclient.discovery import build |
41 from gdata.gauth import OAuth2TokenFromCredentials | 42 from gdata.gauth import OAuth2TokenFromCredentials |
42 from gdata.spreadsheet.service import SpreadsheetsService | 43 from gdata.spreadsheet.service import SpreadsheetsService |
43 from oauth2client.client import SignedJwtAssertionCredentials | 44 from oauth2client.client import SignedJwtAssertionCredentials |
44 import oauth2client.tools | 45 import oauth2client.tools |
45 except ImportError as err: | 46 except ImportError as err: |
46 sheet_libraries_import_error = err | 47 sheet_libraries_import_error = err |
47 | 48 |
48 | 49 |
49 from environment import Environment | 50 from environment import Environment |
50 import tests | 51 import tests |
51 | 52 |
52 _CREDENTIAL_SCOPES = "https://spreadsheets.google.com/feeds" | 53 _CREDENTIAL_SCOPES = "https://spreadsheets.google.com/feeds" |
53 | 54 |
54 # TODO(dvadym) Change all prints in this file to correspond logging. | 55 # TODO(dvadym) Change all prints in this file to correspond logging. |
55 | 56 |
56 # TODO(dvadym) Consider to move this class to separate file. | 57 # TODO(dvadym) Consider to move this class to separate file. |
57 class SheetWriter(object): | 58 class SheetWriter(object): |
58 | 59 |
59 def __init__(self, config): | 60 def __init__(self, config): |
60 self.write_to_sheet = config.getboolean("run_options", "write_to_sheet") | 61 self.write_to_sheet = config.getboolean("run_options", "write_to_sheet") |
61 if not self.write_to_sheet: | 62 if not self.write_to_sheet: |
62 return | 63 return |
63 if sheet_libraries_import_error: | 64 if sheet_libraries_import_error: |
64 raise sheet_libraries_import_error | 65 raise sheet_libraries_import_error |
65 self.pkey = config.get("sheet_info", "pkey") | 66 self.pkey = config.get("sheet_info", "pkey") |
66 self.client_mail = config.get("sheet_info", "client_email") | 67 self.client_email = config.get("sheet_info", "client_email") |
67 self.sheet_key = config.get("sheet_info", "sheet_key") | 68 self.sheet_key = config.get("sheet_info", "sheet_key") |
68 _, self.access_token = self._authenticate() | 69 _, self.access_token = self._authenticate() |
69 self.sheet = self._spredsheeet_for_logging() | 70 self.sheet = self._spredsheeet_for_logging() |
70 | 71 |
71 # TODO(melandory): Function _authenticate belongs to separate module. | 72 # TODO(melandory): Function _authenticate belongs to separate module. |
72 def _authenticate(self): | 73 def _authenticate(self): |
73 http, token = None, None | 74 http, token = None, None |
74 with open(self.pkey) as pkey_file: | 75 with open(self.pkey) as pkey_file: |
75 private_key = pkey_file.read() | 76 private_key = pkey_file.read() |
76 credentials = SignedJwtAssertionCredentials( | 77 credentials = SignedJwtAssertionCredentials( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 i += 1 | 216 i += 1 |
216 while len(runners) < max_tests_in_parrallel and len(tests_to_run) > 0: | 217 while len(runners) < max_tests_in_parrallel and len(tests_to_run) > 0: |
217 runners.append(TestRunner(general_test_cmd, tests_to_run.pop())) | 218 runners.append(TestRunner(general_test_cmd, tests_to_run.pop())) |
218 time.sleep(1) # Let us wait for worker process to finish. | 219 time.sleep(1) # Let us wait for worker process to finish. |
219 | 220 |
220 if __name__ == "__main__": | 221 if __name__ == "__main__": |
221 if len(sys.argv) != 2: | 222 if len(sys.argv) != 2: |
222 print "Synopsis:\n python run_tests.py <config_path>" | 223 print "Synopsis:\n python run_tests.py <config_path>" |
223 config_path = sys.argv[1] | 224 config_path = sys.argv[1] |
224 run_tests(config_path) | 225 run_tests(config_path) |
OLD | NEW |