blob: 7fccf012615c8639f88ccf288deffb3e2218dcbf [file] [log] [blame]
Craig Tiller0bda0b32016-03-03 12:51:53 -08001#!/usr/bin/env python2.7
2
3# Copyright 2015, Google Inc.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# * Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# * Redistributions in binary form must reproduce the above
13# copyright notice, this list of conditions and the following disclaimer
14# in the documentation and/or other materials provided with the
15# distribution.
16# * Neither the name of Google Inc. nor the names of its
17# contributors may be used to endorse or promote products derived from
18# this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32import json
33import pipes
34import shutil
35import sys
36import os
37import yaml
38
39run_tests_root = os.path.abspath(os.path.join(
40 os.path.dirname(sys.argv[0]),
41 '../../../tools/run_tests'))
42sys.path.append(run_tests_root)
43
44import performance.scenario_config as scenario_config
45
Jan Tattermuscha21c7e92016-05-05 17:31:52 -070046def _scenario_json_string(scenario_json):
Craig Tillere0ddc352016-05-23 15:57:48 -070047 # tweak parameters to get fast test times
Craig Tiller38fb8de2016-07-13 08:23:32 -070048 scenario_json['warmup_seconds'] = 0
Craig Tiller61e20402016-07-12 17:26:52 -070049 scenario_json['benchmark_seconds'] = 1
Craig Tiller72376da2016-07-12 17:14:37 -070050 scenarios_json = {'scenarios': [scenario_config.remove_nonproto_fields(scenario_json)]}
51 return json.dumps(scenarios_json)
Jan Tattermuscha21c7e92016-05-05 17:31:52 -070052
Craig Tillerbd24a462016-05-20 11:15:58 -070053def threads_of_type(scenario_json, path):
54 d = scenario_json
55 for el in path.split('/'):
56 if el not in d:
57 return 0
58 d = d[el]
59 return d
60
61def guess_cpu(scenario_json):
62 client = threads_of_type(scenario_json, 'client_config/async_client_threads')
63 server = threads_of_type(scenario_json, 'server_config/async_server_threads')
64 # make an arbitrary guess if set to auto-detect
65 # about the size of the jenkins instances we have for unit tests
Craig Tillerab34b122016-11-28 13:19:12 -080066 if client == 0 or server == 0: return 'capacity'
Craig Tillerbd24a462016-05-20 11:15:58 -070067 return (scenario_json['num_clients'] * client +
68 scenario_json['num_servers'] * server)
69
Craig Tiller0bda0b32016-03-03 12:51:53 -080070print yaml.dump({
71 'tests': [
72 {
73 'name': 'json_run_localhost',
Jan Tattermuscha21c7e92016-05-05 17:31:52 -070074 'shortname': 'json_run_localhost:%s' % scenario_json['name'],
Craig Tiller61e20402016-07-12 17:26:52 -070075 'args': ['--scenarios_json', _scenario_json_string(scenario_json)],
Craig Tilleraf9da922016-09-27 12:47:19 -070076 'ci_platforms': ['linux'],
77 'platforms': ['linux'],
Craig Tiller0bda0b32016-03-03 12:51:53 -080078 'flaky': False,
79 'language': 'c++',
80 'boringssl': True,
81 'defaults': 'boringssl',
Craig Tillerbd24a462016-05-20 11:15:58 -070082 'cpu_cost': guess_cpu(scenario_json),
Craig Tiller38fb8de2016-07-13 08:23:32 -070083 'exclude_configs': [],
Craig Tiller314f4392016-11-04 15:33:10 -070084 'timeout_seconds': 6*60
Craig Tiller0bda0b32016-03-03 12:51:53 -080085 }
Jan Tattermuscha21c7e92016-05-05 17:31:52 -070086 for scenario_json in scenario_config.CXXLanguage().scenarios()
Craig Tiller91bb6242016-09-27 12:46:08 -070087 if 'scalable' in scenario_json.get('CATEGORIES', [])
Craig Tiller0bda0b32016-03-03 12:51:53 -080088 ]
89})