Craig Tiller | 0bda0b3 | 2016-03-03 12:51:53 -0800 | [diff] [blame] | 1 | #!/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 | |
| 32 | import json |
| 33 | import pipes |
| 34 | import shutil |
| 35 | import sys |
| 36 | import os |
| 37 | import yaml |
| 38 | |
| 39 | run_tests_root = os.path.abspath(os.path.join( |
| 40 | os.path.dirname(sys.argv[0]), |
| 41 | '../../../tools/run_tests')) |
| 42 | sys.path.append(run_tests_root) |
| 43 | |
| 44 | import performance.scenario_config as scenario_config |
| 45 | |
Jan Tattermusch | a21c7e9 | 2016-05-05 17:31:52 -0700 | [diff] [blame] | 46 | def _scenario_json_string(scenario_json): |
Craig Tiller | e0ddc35 | 2016-05-23 15:57:48 -0700 | [diff] [blame] | 47 | # tweak parameters to get fast test times |
Craig Tiller | 38fb8de | 2016-07-13 08:23:32 -0700 | [diff] [blame] | 48 | scenario_json['warmup_seconds'] = 0 |
Craig Tiller | 61e2040 | 2016-07-12 17:26:52 -0700 | [diff] [blame] | 49 | scenario_json['benchmark_seconds'] = 1 |
Craig Tiller | 72376da | 2016-07-12 17:14:37 -0700 | [diff] [blame] | 50 | scenarios_json = {'scenarios': [scenario_config.remove_nonproto_fields(scenario_json)]} |
| 51 | return json.dumps(scenarios_json) |
Jan Tattermusch | a21c7e9 | 2016-05-05 17:31:52 -0700 | [diff] [blame] | 52 | |
Craig Tiller | bd24a46 | 2016-05-20 11:15:58 -0700 | [diff] [blame] | 53 | def 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 | |
| 61 | def 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 Tiller | ab34b12 | 2016-11-28 13:19:12 -0800 | [diff] [blame^] | 66 | if client == 0 or server == 0: return 'capacity' |
Craig Tiller | bd24a46 | 2016-05-20 11:15:58 -0700 | [diff] [blame] | 67 | return (scenario_json['num_clients'] * client + |
| 68 | scenario_json['num_servers'] * server) |
| 69 | |
Craig Tiller | 0bda0b3 | 2016-03-03 12:51:53 -0800 | [diff] [blame] | 70 | print yaml.dump({ |
| 71 | 'tests': [ |
| 72 | { |
| 73 | 'name': 'json_run_localhost', |
Jan Tattermusch | a21c7e9 | 2016-05-05 17:31:52 -0700 | [diff] [blame] | 74 | 'shortname': 'json_run_localhost:%s' % scenario_json['name'], |
Craig Tiller | 61e2040 | 2016-07-12 17:26:52 -0700 | [diff] [blame] | 75 | 'args': ['--scenarios_json', _scenario_json_string(scenario_json)], |
Craig Tiller | af9da92 | 2016-09-27 12:47:19 -0700 | [diff] [blame] | 76 | 'ci_platforms': ['linux'], |
| 77 | 'platforms': ['linux'], |
Craig Tiller | 0bda0b3 | 2016-03-03 12:51:53 -0800 | [diff] [blame] | 78 | 'flaky': False, |
| 79 | 'language': 'c++', |
| 80 | 'boringssl': True, |
| 81 | 'defaults': 'boringssl', |
Craig Tiller | bd24a46 | 2016-05-20 11:15:58 -0700 | [diff] [blame] | 82 | 'cpu_cost': guess_cpu(scenario_json), |
Craig Tiller | 38fb8de | 2016-07-13 08:23:32 -0700 | [diff] [blame] | 83 | 'exclude_configs': [], |
Craig Tiller | 314f439 | 2016-11-04 15:33:10 -0700 | [diff] [blame] | 84 | 'timeout_seconds': 6*60 |
Craig Tiller | 0bda0b3 | 2016-03-03 12:51:53 -0800 | [diff] [blame] | 85 | } |
Jan Tattermusch | a21c7e9 | 2016-05-05 17:31:52 -0700 | [diff] [blame] | 86 | for scenario_json in scenario_config.CXXLanguage().scenarios() |
Craig Tiller | 91bb624 | 2016-09-27 12:46:08 -0700 | [diff] [blame] | 87 | if 'scalable' in scenario_json.get('CATEGORIES', []) |
Craig Tiller | 0bda0b3 | 2016-03-03 12:51:53 -0800 | [diff] [blame] | 88 | ] |
| 89 | }) |