Skip to content

Commit

Permalink
added support for regex selection of scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
jtattermusch committed Apr 14, 2016
1 parent 4fec48b commit 38becc2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tools/run_tests/run_performance_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import multiprocessing
import os
import pipes
import re
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -82,6 +83,8 @@ def create_qpsworker_job(language, shortname=None,
else:
host_and_port='localhost:%s' % port

# TODO(jtattermusch): with some care, we can calculate the right timeout
# of a worker from the sum of warmup + benchmark times for all the scenarios
jobspec = jobset.JobSpec(
cmdline=cmdline,
shortname=shortname,
Expand Down Expand Up @@ -221,15 +224,16 @@ def start_qpsworkers(languages, worker_hosts):
for worker_idx, worker in enumerate(workers)]


def create_scenarios(languages, workers_by_lang, remote_host=None):
def create_scenarios(languages, workers_by_lang, remote_host=None, regex='.*'):
"""Create jobspecs for scenarios to run."""
scenarios = []
for language in languages:
for scenario_json in language.scenarios():
scenario = create_scenario_jobspec(scenario_json,
workers_by_lang[str(language)],
remote_host=remote_host)
scenarios.append(scenario)
if re.search(args.regex, scenario_json['name']):
scenario = create_scenario_jobspec(scenario_json,
workers_by_lang[str(language)],
remote_host=remote_host)
scenarios.append(scenario)

# the very last scenario requests shutting down the workers.
all_workers = [worker
Expand Down Expand Up @@ -268,6 +272,8 @@ def finish_qps_workers(jobs):
nargs='+',
default=[],
help='Worker hosts where to start QPS workers.')
argp.add_argument('-r', '--regex', default='.*', type=str,
help='Regex to select scenarios to run.')

args = argp.parse_args()

Expand Down Expand Up @@ -295,6 +301,9 @@ def finish_qps_workers(jobs):

qpsworker_jobs = start_qpsworkers(languages, args.remote_worker_host)

# TODO(jtattermusch): see https://github.com/grpc/grpc/issues/6174
time.sleep(5)

# get list of worker addresses for each language.
worker_addresses = dict([(str(language), []) for language in languages])
for job in qpsworker_jobs:
Expand All @@ -303,7 +312,8 @@ def finish_qps_workers(jobs):
try:
scenarios = create_scenarios(languages,
workers_by_lang=worker_addresses,
remote_host=args.remote_driver_host)
remote_host=args.remote_driver_host,
regex=args.regex)
if not scenarios:
raise Exception('No scenarios to run')

Expand Down

0 comments on commit 38becc2

Please sign in to comment.