xref: /aosp_15_r20/external/grpc-grpc/test/cpp/qps/qps_benchmark_script.bzl (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1# Copyright 2018 gRPC authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#
16# This is for the gRPC build system. This isn't intended to be used outsite of
17# the BUILD file for gRPC. It contains the mapping for the template system we
18# use to generate other platform's build system files.
19#
20# Please consider that there should be a high bar for additions and changes to
21# this file.
22# Each rule listed must be re-written for Google's internal build system, and
23# each change must be ported from one to the other.
24#
25
26"""Script to run qps benchmark."""
27
28load("//bazel:grpc_build_system.bzl", "grpc_cc_test")
29load("//test/cpp/qps:json_run_localhost_scenarios.bzl", "JSON_RUN_LOCALHOST_SCENARIOS")
30load("//test/cpp/qps:qps_json_driver_scenarios.bzl", "QPS_JSON_DRIVER_SCENARIOS")
31
32def add_suffix(name):
33    # NOTE(https://github.com/grpc/grpc/issues/24178): Add the suffix to the name
34    # to avoid having the target name that 87, 88, 89 or 90 long.
35    m = len(name) - (87 - len("//test/cpp/qps:"))
36    if m >= 0 and m <= 3:
37        return name + "_" * (4 - m)
38    else:
39        return name
40
41# buildifier: disable=unnamed-macro
42def qps_json_driver_batch():
43    for scenario in QPS_JSON_DRIVER_SCENARIOS:
44        grpc_cc_test(
45            name = add_suffix("qps_json_driver_test_%s" % scenario),
46            srcs = ["qps_json_driver.cc"],
47            args = [
48                "--run_inproc",
49                "--scenarios_json",
50                QPS_JSON_DRIVER_SCENARIOS[scenario],
51            ],
52            deps = [
53                ":benchmark_config",
54                ":driver_impl",
55                "//:grpc++",
56                "//test/cpp/util:test_config",
57                "//test/cpp/util:test_util",
58            ],
59            tags = [
60                "qps_json_driver",
61                "no_mac",
62                "nomsan",
63                "noubsan",
64            ],
65            # TODO(b/156975956): address OOMing benchmark tests
66            flaky = True,
67        )
68
69# buildifier: disable=unnamed-macro
70def json_run_localhost_batch():
71    for scenario in JSON_RUN_LOCALHOST_SCENARIOS:
72        grpc_cc_test(
73            name = add_suffix("json_run_localhost_%s" % scenario),
74            srcs = ["json_run_localhost.cc"],
75            args = [
76                "--scenarios_json",
77                JSON_RUN_LOCALHOST_SCENARIOS[scenario],
78            ],
79            data = [
80                "//test/cpp/qps:qps_json_driver",
81                "//test/cpp/qps:qps_worker",
82            ],
83            deps = [
84                "//:gpr",
85                "//test/core/util:grpc_test_util",
86                "//test/cpp/util:test_config",
87                "//test/cpp/util:test_util",
88            ],
89            tags = [
90                "json_run_localhost",
91                "no_windows",
92                "no_mac",
93                "nomsan",
94                "notsan",
95                "noubsan",
96            ],
97            # TODO(b/156975956): address OOMing benchmark tests
98            flaky = True,
99        )
100