xref: /aosp_15_r20/external/grpc-grpc/tools/bazelify_tests/test/bazel_distribtests.bzl (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1# Copyright 2023 The 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"""
16Generates portability tests.
17"""
18
19load("supported_bazel_versions.bzl", "SUPPORTED_BAZEL_VERSIONS")
20load("//tools/bazelify_tests:build_defs.bzl", "grpc_run_bazel_distribtest_test")
21
22_TEST_SHARDS = [
23    "buildtest",
24    "distribtest_cpp",
25    "distribtest_python",
26]
27
28def generate_bazel_distribtests(name):
29    """Generates the bazel distribtests.
30
31    Args:
32        name: Name of the test suite that will be generated.
33    """
34    test_names = []
35
36    for bazel_version in SUPPORTED_BAZEL_VERSIONS:
37        for shard_name in _TEST_SHARDS:
38            # TODO(https://github.com/grpc/grpc/issues/35391): Fix bazel 7 + distribtest_python test
39            if bazel_version.startswith("7") and shard_name == "distribtest_python":
40                continue
41            test_name = "bazel_distribtest_%s_%s" % (bazel_version, shard_name)
42            grpc_run_bazel_distribtest_test(
43                name = test_name,
44                size = "enormous",
45                args = [bazel_version, shard_name],
46                docker_image_version = "tools/dockerfile/test/bazel.current_version",
47            )
48            test_names.append(test_name)
49
50    # Generate test suite that allows easily running all bazel distribtests.
51    native.test_suite(
52        name = name,
53        tests = [(":%s" % test_name) for test_name in test_names],
54    )
55