blob: a7728e7f7d53aac8a424929cc678a57f0f4c89a9 [file] [log] [blame]
Jan Tattermuschb2758442016-03-28 09:32:20 -07001#!/usr/bin/env python2.7
2# Copyright 2016, Google Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met:
8#
9# * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above
12# copyright notice, this list of conditions and the following disclaimer
13# in the documentation and/or other materials provided with the
14# distribution.
15# * Neither the name of Google Inc. nor the names of its
16# contributors may be used to endorse or promote products derived from
17# this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31"""Run performance tests locally or remotely."""
32
33import argparse
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070034import itertools
Jan Tattermuschb2758442016-03-28 09:32:20 -070035import jobset
Craig Tiller0bda0b32016-03-03 12:51:53 -080036import json
Jan Tattermuschb2758442016-03-28 09:32:20 -070037import multiprocessing
38import os
Craig Tiller0bda0b32016-03-03 12:51:53 -080039import pipes
Jan Tattermusch38becc22016-04-14 08:00:35 -070040import re
Jan Tattermuschb2758442016-03-28 09:32:20 -070041import subprocess
42import sys
43import tempfile
44import time
Jan Tattermuschee9032c2016-04-14 08:35:51 -070045import traceback
Jan Tattermuschb2758442016-03-28 09:32:20 -070046import uuid
Craig Tillerd92d5c52016-04-04 13:49:29 -070047import performance.scenario_config as scenario_config
Jan Tattermuschb2758442016-03-28 09:32:20 -070048
49
50_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
51os.chdir(_ROOT)
52
53
54_REMOTE_HOST_USERNAME = 'jenkins'
55
56
Jan Tattermuschb2758442016-03-28 09:32:20 -070057class QpsWorkerJob:
58 """Encapsulates a qps worker server job."""
59
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070060 def __init__(self, spec, language, host_and_port):
Jan Tattermuschb2758442016-03-28 09:32:20 -070061 self._spec = spec
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070062 self.language = language
Jan Tattermuschb2758442016-03-28 09:32:20 -070063 self.host_and_port = host_and_port
64 self._job = jobset.Job(spec, bin_hash=None, newline_on_success=True, travis=True, add_env={})
65
66 def is_running(self):
67 """Polls a job and returns True if given job is still running."""
68 return self._job.state(jobset.NoCache()) == jobset._RUNNING
69
70 def kill(self):
71 return self._job.kill()
72
73
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070074def create_qpsworker_job(language, shortname=None,
75 port=10000, remote_host=None):
Jan Tattermuschb2758442016-03-28 09:32:20 -070076 # TODO: support more languages
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070077 cmdline = language.worker_cmdline() + ['--driver_port=%s' % port]
Jan Tattermuschb2758442016-03-28 09:32:20 -070078 if remote_host:
79 user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070080 cmdline = ['ssh',
81 str(user_at_host),
82 'cd ~/performance_workspace/grpc/ && %s' % ' '.join(cmdline)]
Jan Tattermuschb2758442016-03-28 09:32:20 -070083 host_and_port='%s:%s' % (remote_host, port)
84 else:
85 host_and_port='localhost:%s' % port
86
Jan Tattermusch38becc22016-04-14 08:00:35 -070087 # TODO(jtattermusch): with some care, we can calculate the right timeout
88 # of a worker from the sum of warmup + benchmark times for all the scenarios
Jan Tattermuschb2758442016-03-28 09:32:20 -070089 jobspec = jobset.JobSpec(
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070090 cmdline=cmdline,
91 shortname=shortname,
Jan Tattermusch541d5d72016-05-05 16:08:49 -070092 timeout_seconds=2*60*60)
Jan Tattermuschbb1a4532016-03-30 18:04:01 -070093 return QpsWorkerJob(jobspec, language, host_and_port)
Jan Tattermuschb2758442016-03-28 09:32:20 -070094
95
Jan Tattermusch6d7fa552016-04-14 17:42:54 -070096def create_scenario_jobspec(scenario_json, workers, remote_host=None,
97 bq_result_table=None):
Jan Tattermuschb2758442016-03-28 09:32:20 -070098 """Runs one scenario using QPS driver."""
99 # setting QPS_WORKERS env variable here makes sure it works with SSH too.
Jan Tattermusch6d7fa552016-04-14 17:42:54 -0700100 cmd = 'QPS_WORKERS="%s" ' % ','.join(workers)
101 if bq_result_table:
102 cmd += 'BQ_RESULT_TABLE="%s" ' % bq_result_table
103 cmd += 'tools/run_tests/performance/run_qps_driver.sh '
104 cmd += '--scenarios_json=%s ' % pipes.quote(json.dumps({'scenarios': [scenario_json]}))
105 cmd += '--scenario_result_file=scenario_result.json'
Jan Tattermuschb2758442016-03-28 09:32:20 -0700106 if remote_host:
107 user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
Jan Tattermusch6d7fa552016-04-14 17:42:54 -0700108 cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (user_at_host, pipes.quote(cmd))
Jan Tattermuschb2758442016-03-28 09:32:20 -0700109
110 return jobset.JobSpec(
111 cmdline=[cmd],
Craig Tiller0bda0b32016-03-03 12:51:53 -0800112 shortname='qps_json_driver.%s' % scenario_json['name'],
113 timeout_seconds=3*60,
114 shell=True,
115 verbose_success=True)
116
117
118def create_quit_jobspec(workers, remote_host=None):
119 """Runs quit using QPS driver."""
120 # setting QPS_WORKERS env variable here makes sure it works with SSH too.
vjpai29089c72016-04-20 12:38:16 -0700121 cmd = 'QPS_WORKERS="%s" bins/opt/qps_json_driver --quit' % ','.join(workers)
Craig Tiller0bda0b32016-03-03 12:51:53 -0800122 if remote_host:
123 user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
Jan Tattermusch6d7fa552016-04-14 17:42:54 -0700124 cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (user_at_host, pipes.quote(cmd))
Craig Tiller0bda0b32016-03-03 12:51:53 -0800125
126 return jobset.JobSpec(
127 cmdline=[cmd],
vjpai29089c72016-04-20 12:38:16 -0700128 shortname='qps_json_driver.quit',
Jan Tattermuschb2758442016-03-28 09:32:20 -0700129 timeout_seconds=3*60,
130 shell=True,
131 verbose_success=True)
132
133
Jan Tattermusch4de2c322016-05-10 14:33:07 -0700134def create_netperf_jobspec(server_host='localhost', client_host=None,
135 bq_result_table=None):
136 """Runs netperf benchmark."""
137 cmd = 'NETPERF_SERVER_HOST="%s" ' % server_host
138 if bq_result_table:
139 cmd += 'BQ_RESULT_TABLE="%s" ' % bq_result_table
Jan Tattermuschad17bf72016-05-11 12:41:37 -0700140 if client_host:
141 # If netperf is running remotely, the env variables populated by Jenkins
142 # won't be available on the client, but we need them for uploading results
143 # to BigQuery.
144 jenkins_job_name = os.getenv('JOB_NAME')
145 if jenkins_job_name:
146 cmd += 'JOB_NAME="%s" ' % jenkins_job_name
147 jenkins_build_number = os.getenv('BUILD_NUMBER')
148 if jenkins_build_number:
149 cmd += 'BUILD_NUMBER="%s" ' % jenkins_build_number
150
Jan Tattermusch4de2c322016-05-10 14:33:07 -0700151 cmd += 'tools/run_tests/performance/run_netperf.sh'
152 if client_host:
153 user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, client_host)
154 cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (user_at_host, pipes.quote(cmd))
155
156 return jobset.JobSpec(
157 cmdline=[cmd],
158 shortname='netperf',
159 timeout_seconds=60,
160 shell=True,
161 verbose_success=True)
162
163
Jan Tattermuschde874a12016-04-18 09:21:37 -0700164def archive_repo(languages):
Jan Tattermuschb2758442016-03-28 09:32:20 -0700165 """Archives local version of repo including submodules."""
Jan Tattermuschde874a12016-04-18 09:21:37 -0700166 cmdline=['tar', '-cf', '../grpc.tar', '../grpc/']
167 if 'java' in languages:
168 cmdline.append('../grpc-java')
169 if 'go' in languages:
170 cmdline.append('../grpc-go')
171
Jan Tattermuschb2758442016-03-28 09:32:20 -0700172 archive_job = jobset.JobSpec(
Jan Tattermuschde874a12016-04-18 09:21:37 -0700173 cmdline=cmdline,
Jan Tattermuschb2758442016-03-28 09:32:20 -0700174 shortname='archive_repo',
175 timeout_seconds=3*60)
176
177 jobset.message('START', 'Archiving local repository.', do_newline=True)
178 num_failures, _ = jobset.run(
179 [archive_job], newline_on_success=True, maxjobs=1)
180 if num_failures == 0:
181 jobset.message('SUCCESS',
Jan Tattermuschde874a12016-04-18 09:21:37 -0700182 'Archive with local repository created successfully.',
Jan Tattermuschb2758442016-03-28 09:32:20 -0700183 do_newline=True)
184 else:
185 jobset.message('FAILED', 'Failed to archive local repository.',
186 do_newline=True)
187 sys.exit(1)
188
189
Jan Tattermusch14089202016-04-27 17:55:27 -0700190def prepare_remote_hosts(hosts, prepare_local=False):
191 """Prepares remote hosts (and maybe prepare localhost as well)."""
192 prepare_timeout = 5*60
Jan Tattermuschb2758442016-03-28 09:32:20 -0700193 prepare_jobs = []
194 for host in hosts:
195 user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, host)
196 prepare_jobs.append(
197 jobset.JobSpec(
198 cmdline=['tools/run_tests/performance/remote_host_prepare.sh'],
199 shortname='remote_host_prepare.%s' % host,
200 environ = {'USER_AT_HOST': user_at_host},
Jan Tattermusch14089202016-04-27 17:55:27 -0700201 timeout_seconds=prepare_timeout))
202 if prepare_local:
203 # Prepare localhost as well
204 prepare_jobs.append(
205 jobset.JobSpec(
206 cmdline=['tools/run_tests/performance/kill_workers.sh'],
207 shortname='local_prepare',
208 timeout_seconds=prepare_timeout))
209 jobset.message('START', 'Preparing hosts.', do_newline=True)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700210 num_failures, _ = jobset.run(
211 prepare_jobs, newline_on_success=True, maxjobs=10)
212 if num_failures == 0:
213 jobset.message('SUCCESS',
Jan Tattermusch14089202016-04-27 17:55:27 -0700214 'Prepare step completed successfully.',
Jan Tattermuschb2758442016-03-28 09:32:20 -0700215 do_newline=True)
216 else:
217 jobset.message('FAILED', 'Failed to prepare remote hosts.',
218 do_newline=True)
219 sys.exit(1)
220
221
Craig Tillerd92d5c52016-04-04 13:49:29 -0700222def build_on_remote_hosts(hosts, languages=scenario_config.LANGUAGES.keys(), build_local=False):
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700223 """Builds performance worker on remote hosts (and maybe also locally)."""
Jan Tattermuschb2758442016-03-28 09:32:20 -0700224 build_timeout = 15*60
225 build_jobs = []
226 for host in hosts:
227 user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, host)
228 build_jobs.append(
229 jobset.JobSpec(
Craig Tiller7797e3f2016-04-01 07:41:05 -0700230 cmdline=['tools/run_tests/performance/remote_host_build.sh'] + languages,
Jan Tattermuschb2758442016-03-28 09:32:20 -0700231 shortname='remote_host_build.%s' % host,
232 environ = {'USER_AT_HOST': user_at_host, 'CONFIG': 'opt'},
233 timeout_seconds=build_timeout))
234 if build_local:
235 # Build locally as well
236 build_jobs.append(
237 jobset.JobSpec(
Craig Tiller7797e3f2016-04-01 07:41:05 -0700238 cmdline=['tools/run_tests/performance/build_performance.sh'] + languages,
Jan Tattermuschb2758442016-03-28 09:32:20 -0700239 shortname='local_build',
240 environ = {'CONFIG': 'opt'},
241 timeout_seconds=build_timeout))
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700242 jobset.message('START', 'Building.', do_newline=True)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700243 num_failures, _ = jobset.run(
244 build_jobs, newline_on_success=True, maxjobs=10)
245 if num_failures == 0:
246 jobset.message('SUCCESS',
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700247 'Built successfully.',
Jan Tattermuschb2758442016-03-28 09:32:20 -0700248 do_newline=True)
249 else:
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700250 jobset.message('FAILED', 'Build failed.',
Jan Tattermuschb2758442016-03-28 09:32:20 -0700251 do_newline=True)
252 sys.exit(1)
253
254
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700255def start_qpsworkers(languages, worker_hosts):
Jan Tattermuschb2758442016-03-28 09:32:20 -0700256 """Starts QPS workers as background jobs."""
257 if not worker_hosts:
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700258 # run two workers locally (for each language)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700259 workers=[(None, 10000), (None, 10010)]
260 elif len(worker_hosts) == 1:
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700261 # run two workers on the remote host (for each language)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700262 workers=[(worker_hosts[0], 10000), (worker_hosts[0], 10010)]
263 else:
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700264 # run one worker per each remote host (for each language)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700265 workers=[(worker_host, 10000) for worker_host in worker_hosts]
266
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700267 return [create_qpsworker_job(language,
268 shortname= 'qps_worker_%s_%s' % (language,
269 worker_idx),
270 port=worker[1] + language.worker_port_offset(),
Jan Tattermuschb2758442016-03-28 09:32:20 -0700271 remote_host=worker[0])
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700272 for language in languages
273 for worker_idx, worker in enumerate(workers)]
Jan Tattermuschb2758442016-03-28 09:32:20 -0700274
275
Jan Tattermusch6d7fa552016-04-14 17:42:54 -0700276def create_scenarios(languages, workers_by_lang, remote_host=None, regex='.*',
Jan Tattermusch4de2c322016-05-10 14:33:07 -0700277 category='all', bq_result_table=None,
278 netperf=False, netperf_hosts=[]):
Jan Tattermuschb2758442016-03-28 09:32:20 -0700279 """Create jobspecs for scenarios to run."""
Ken Payson0482c102016-04-19 12:08:34 -0700280 all_workers = [worker
281 for workers in workers_by_lang.values()
282 for worker in workers]
Jan Tattermuschb2758442016-03-28 09:32:20 -0700283 scenarios = []
Jan Tattermusch4de2c322016-05-10 14:33:07 -0700284
285 if netperf:
286 if not netperf_hosts:
287 netperf_server='localhost'
288 netperf_client=None
289 elif len(netperf_hosts) == 1:
290 netperf_server=netperf_hosts[0]
291 netperf_client=netperf_hosts[0]
292 else:
293 netperf_server=netperf_hosts[0]
294 netperf_client=netperf_hosts[1]
295 scenarios.append(create_netperf_jobspec(server_host=netperf_server,
296 client_host=netperf_client,
297 bq_result_table=bq_result_table))
298
Jan Tattermuschb2758442016-03-28 09:32:20 -0700299 for language in languages:
Craig Tiller0bda0b32016-03-03 12:51:53 -0800300 for scenario_json in language.scenarios():
Jan Tattermusch38becc22016-04-14 08:00:35 -0700301 if re.search(args.regex, scenario_json['name']):
Jan Tattermusch427699b2016-05-05 18:10:14 -0700302 if category in scenario_json.get('CATEGORIES', []) or category == 'all':
303 workers = workers_by_lang[str(language)]
304 # 'SERVER_LANGUAGE' is an indicator for this script to pick
305 # a server in different language.
306 custom_server_lang = scenario_json.get('SERVER_LANGUAGE', None)
307 scenario_json = scenario_config.remove_nonproto_fields(scenario_json)
308 if custom_server_lang:
309 if not workers_by_lang.get(custom_server_lang, []):
310 print 'Warning: Skipping scenario %s as' % scenario_json['name']
311 print('SERVER_LANGUAGE is set to %s yet the language has '
312 'not been selected with -l' % custom_server_lang)
313 continue
314 for idx in range(0, scenario_json['num_servers']):
315 # replace first X workers by workers of a different language
316 workers[idx] = workers_by_lang[custom_server_lang][idx]
317 scenario = create_scenario_jobspec(scenario_json,
318 workers,
319 remote_host=remote_host,
320 bq_result_table=bq_result_table)
321 scenarios.append(scenario)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700322
323 # the very last scenario requests shutting down the workers.
Craig Tiller0bda0b32016-03-03 12:51:53 -0800324 scenarios.append(create_quit_jobspec(all_workers, remote_host=remote_host))
Jan Tattermuschb2758442016-03-28 09:32:20 -0700325 return scenarios
326
327
328def finish_qps_workers(jobs):
329 """Waits for given jobs to finish and eventually kills them."""
330 retries = 0
331 while any(job.is_running() for job in jobs):
332 for job in qpsworker_jobs:
333 if job.is_running():
334 print 'QPS worker "%s" is still running.' % job.host_and_port
335 if retries > 10:
336 print 'Killing all QPS workers.'
337 for job in jobs:
338 job.kill()
339 retries += 1
340 time.sleep(3)
341 print 'All QPS workers finished.'
342
343
344argp = argparse.ArgumentParser(description='Run performance tests.')
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700345argp.add_argument('-l', '--language',
Craig Tillerd92d5c52016-04-04 13:49:29 -0700346 choices=['all'] + sorted(scenario_config.LANGUAGES.keys()),
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700347 nargs='+',
Jan Tattermusch427699b2016-05-05 18:10:14 -0700348 required=True,
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700349 help='Languages to benchmark.')
Jan Tattermuschb2758442016-03-28 09:32:20 -0700350argp.add_argument('--remote_driver_host',
351 default=None,
352 help='Run QPS driver on given host. By default, QPS driver is run locally.')
353argp.add_argument('--remote_worker_host',
354 nargs='+',
355 default=[],
356 help='Worker hosts where to start QPS workers.')
Jan Tattermusch38becc22016-04-14 08:00:35 -0700357argp.add_argument('-r', '--regex', default='.*', type=str,
358 help='Regex to select scenarios to run.')
Jan Tattermusch6d7fa552016-04-14 17:42:54 -0700359argp.add_argument('--bq_result_table', default=None, type=str,
360 help='Bigquery "dataset.table" to upload results to.')
Jan Tattermusch427699b2016-05-05 18:10:14 -0700361argp.add_argument('--category',
362 choices=['smoketest','all'],
363 default='smoketest',
364 help='Select a category of tests to run. Smoketest runs by default.')
Jan Tattermusch4de2c322016-05-10 14:33:07 -0700365argp.add_argument('--netperf',
366 default=False,
367 action='store_const',
368 const=True,
369 help='Run netperf benchmark as one of the scenarios.')
Jan Tattermuschb2758442016-03-28 09:32:20 -0700370
371args = argp.parse_args()
372
Craig Tillerd92d5c52016-04-04 13:49:29 -0700373languages = set(scenario_config.LANGUAGES[l]
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700374 for l in itertools.chain.from_iterable(
Craig Tillerd92d5c52016-04-04 13:49:29 -0700375 scenario_config.LANGUAGES.iterkeys() if x == 'all' else [x]
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700376 for x in args.language))
377
Jan Tattermusch6d7fa552016-04-14 17:42:54 -0700378
Jan Tattermuschb2758442016-03-28 09:32:20 -0700379# Put together set of remote hosts where to run and build
380remote_hosts = set()
381if args.remote_worker_host:
382 for host in args.remote_worker_host:
383 remote_hosts.add(host)
384if args.remote_driver_host:
385 remote_hosts.add(args.remote_driver_host)
386
387if remote_hosts:
Jan Tattermuschde874a12016-04-18 09:21:37 -0700388 archive_repo(languages=[str(l) for l in languages])
Jan Tattermusch14089202016-04-27 17:55:27 -0700389 prepare_remote_hosts(remote_hosts, prepare_local=True)
390else:
391 prepare_remote_hosts([], prepare_local=True)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700392
393build_local = False
394if not args.remote_driver_host:
395 build_local = True
Craig Tiller7797e3f2016-04-01 07:41:05 -0700396build_on_remote_hosts(remote_hosts, languages=[str(l) for l in languages], build_local=build_local)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700397
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700398qpsworker_jobs = start_qpsworkers(languages, args.remote_worker_host)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700399
Jan Tattermusch38becc22016-04-14 08:00:35 -0700400# TODO(jtattermusch): see https://github.com/grpc/grpc/issues/6174
401time.sleep(5)
402
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700403# get list of worker addresses for each language.
404worker_addresses = dict([(str(language), []) for language in languages])
405for job in qpsworker_jobs:
406 worker_addresses[str(job.language)].append(job.host_and_port)
Jan Tattermuschb2758442016-03-28 09:32:20 -0700407
408try:
Jan Tattermuschbb1a4532016-03-30 18:04:01 -0700409 scenarios = create_scenarios(languages,
410 workers_by_lang=worker_addresses,
Jan Tattermusch38becc22016-04-14 08:00:35 -0700411 remote_host=args.remote_driver_host,
Jan Tattermusch6d7fa552016-04-14 17:42:54 -0700412 regex=args.regex,
Jan Tattermusch427699b2016-05-05 18:10:14 -0700413 category=args.category,
Jan Tattermusch4de2c322016-05-10 14:33:07 -0700414 bq_result_table=args.bq_result_table,
415 netperf=args.netperf,
416 netperf_hosts=args.remote_worker_host)
417
Jan Tattermuschb2758442016-03-28 09:32:20 -0700418 if not scenarios:
419 raise Exception('No scenarios to run')
420
421 jobset.message('START', 'Running scenarios.', do_newline=True)
422 num_failures, _ = jobset.run(
423 scenarios, newline_on_success=True, maxjobs=1)
424 if num_failures == 0:
425 jobset.message('SUCCESS',
426 'All scenarios finished successfully.',
427 do_newline=True)
428 else:
429 jobset.message('FAILED', 'Some of the scenarios failed.',
430 do_newline=True)
431 sys.exit(1)
Jan Tattermuschee9032c2016-04-14 08:35:51 -0700432except:
433 traceback.print_exc()
Jan Tattermuschb688db02016-04-21 08:53:45 -0700434 raise
Jan Tattermuschb2758442016-03-28 09:32:20 -0700435finally:
436 finish_qps_workers(qpsworker_jobs)