| OLD | NEW |
| 1 # coding: utf-8 | 1 # coding: utf-8 |
| 2 # Copyright 2014 The LUCI Authors. All rights reserved. | 2 # Copyright 2014 The LUCI 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 """Base class for handlers_*_test.py""" | 6 """Base class for handlers_*_test.py""" |
| 7 | 7 |
| 8 import base64 | 8 import base64 |
| 9 import json | 9 import json |
| 10 import os | 10 import os |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 from components import auth_testing | 25 from components import auth_testing |
| 26 from components import stats_framework | 26 from components import stats_framework |
| 27 import gae_ts_mon | 27 import gae_ts_mon |
| 28 from test_support import test_case | 28 from test_support import test_case |
| 29 | 29 |
| 30 from server import acl | 30 from server import acl |
| 31 from server import large | 31 from server import large |
| 32 from server import stats | 32 from server import stats |
| 33 | 33 |
| 34 | 34 |
| 35 PINNED_PACKAGE_VERSION = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' |
| 36 |
| 37 |
| 35 class AppTestBase(test_case.TestCase): | 38 class AppTestBase(test_case.TestCase): |
| 36 APP_DIR = test_env.APP_DIR | 39 APP_DIR = test_env.APP_DIR |
| 37 | 40 |
| 38 def setUp(self): | 41 def setUp(self): |
| 39 super(AppTestBase, self).setUp() | 42 super(AppTestBase, self).setUp() |
| 40 self.bot_version = None | 43 self.bot_version = None |
| 41 self.source_ip = '192.168.2.2' | 44 self.source_ip = '192.168.2.2' |
| 42 self.testbed.init_user_stub() | 45 self.testbed.init_user_stub() |
| 43 self.testbed.init_search_stub() | 46 self.testbed.init_search_stub() |
| 44 | 47 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 212 |
| 210 # Client | 213 # Client |
| 211 | 214 |
| 212 def endpoint_call(self, service, name, args): | 215 def endpoint_call(self, service, name, args): |
| 213 body = json.loads(protojson.encode_message(args)) | 216 body = json.loads(protojson.encode_message(args)) |
| 214 return test_case.Endpoints(service).call_api(name, body=body).json | 217 return test_case.Endpoints(service).call_api(name, body=body).json |
| 215 | 218 |
| 216 def _client_create_task(self, properties=None, **kwargs): | 219 def _client_create_task(self, properties=None, **kwargs): |
| 217 """Creates an isolated command TaskRequest via the Cloud Endpoints API.""" | 220 """Creates an isolated command TaskRequest via the Cloud Endpoints API.""" |
| 218 params = { | 221 params = { |
| 222 'packages': [{ |
| 223 'package_name': 'rm', |
| 224 'version': PINNED_PACKAGE_VERSION, |
| 225 }], |
| 219 'dimensions': [ | 226 'dimensions': [ |
| 220 {'key': 'os', 'value': 'Amiga'}, | 227 {'key': 'os', 'value': 'Amiga'}, |
| 221 {'key': 'pool', 'value': 'default'}, | 228 {'key': 'pool', 'value': 'default'}, |
| 222 ], | 229 ], |
| 223 'env': [], | 230 'env': [], |
| 224 'execution_timeout_secs': 3600, | 231 'execution_timeout_secs': 3600, |
| 225 'io_timeout_secs': 1200, | 232 'io_timeout_secs': 1200, |
| 226 } | 233 } |
| 227 params.update(properties or {}) | 234 params.update(properties or {}) |
| 228 props = swarming_rpcs.TaskProperties(**params) | 235 props = swarming_rpcs.TaskProperties(**params) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 251 | 258 |
| 252 def client_create_task_raw(self, properties=None, **kwargs): | 259 def client_create_task_raw(self, properties=None, **kwargs): |
| 253 """Creates a raw command TaskRequest via the Cloud Endpoints API.""" | 260 """Creates a raw command TaskRequest via the Cloud Endpoints API.""" |
| 254 properties = (properties or {}).copy() | 261 properties = (properties or {}).copy() |
| 255 properties['command'] = ['python', 'run_test.py'] | 262 properties['command'] = ['python', 'run_test.py'] |
| 256 return self._client_create_task(properties, **kwargs) | 263 return self._client_create_task(properties, **kwargs) |
| 257 | 264 |
| 258 def client_get_results(self, task_id): | 265 def client_get_results(self, task_id): |
| 259 api = test_case.Endpoints(handlers_endpoints.SwarmingTaskService) | 266 api = test_case.Endpoints(handlers_endpoints.SwarmingTaskService) |
| 260 return api.call_api('result', body={'task_id': task_id}).json | 267 return api.call_api('result', body={'task_id': task_id}).json |
| OLD | NEW |