grpc/tools/bazelify_tests
Arjan Singh Bal d038e0ed19 [Interop] Test grpc-go 1.64 using go 1.22 runtime (#36755)
Use the latest golang base image for Go interop tests. Presently the latest image points to Go 1.22.
<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

## Commands run
To render the Dockerfile from its template
```sh
$ tools/buildgen/generate_projects.sh
```
To build and upload the base docker image.
```sh
$ tools/dockerfile/push_testing_images.sh
```

To build and upload the interop docker image for grpc-go 1.64.0
```sh
$ tools/interop_matrix/create_matrix_images.py --git_checkout --release=v1.64.0  --upload_images --language go
```

To verify the image is uploaded
```sh
$ gcloud container images list-tags gcr.io/grpc-testing/grpc_interop_go1.x
DIGEST        TAGS                                         TIMESTAMP
b36be4961ec4  infrastructure-public-image-v1.64.0,v1.64.0  2024-06-03T22:26:48
```

Verify the backward compatability tests pass
```sh
$ export docker_image=gcr.io/grpc-testing/grpc_interop_go1.x:v1.64.0
$ tools/interop_matrix/testcases/go__master
Testing gcr.io/grpc-testing/grpc_interop_go1.x:v1.64.0
```

Fixes: https://github.com/grpc/grpc/issues/36060

Closes #36755

PiperOrigin-RevId: 641272572
2024-06-07 09:31:49 -07:00
..
test [Test] Silence gcc 7 (#36752) 2024-05-31 14:53:46 -07:00
BUILD [bazelified tests] First attempt at bazelified rules for building artifacts/packages (#34462) 2023-10-04 11:08:49 -07:00
README.md [bazel] Teach bazel how to run non-bazel test suites under docker locally and on RBE (#33707) 2023-08-02 14:15:19 +02:00
build_defs.bzl Fix Bazel 7 build (more) (#35392) 2023-12-27 09:32:51 -08:00
dockerimage_current_versions.bzl [Interop] Test grpc-go 1.64 using go 1.22 runtime (#36755) 2024-06-07 09:31:49 -07:00
generate_dockerimage_current_versions_bzl.sh [bazel] Teach bazel how to run non-bazel test suites under docker locally and on RBE (#33707) 2023-08-02 14:15:19 +02:00
grpc_build_artifact_task.sh [bazelified tests] First attempt at bazelified rules for building artifacts/packages (#34462) 2023-10-04 11:08:49 -07:00
grpc_build_artifact_task_build_test.sh [bazelified tests] First attempt at bazelified rules for building artifacts/packages (#34462) 2023-10-04 11:08:49 -07:00
grpc_repo_archive.sh [bazel] Teach bazel how to run non-bazel test suites under docker locally and on RBE (#33707) 2023-08-02 14:15:19 +02:00
grpc_run_bazel_distribtest_test.sh [bazelified tests] Bazelify tests from "linux/grpc_bazel_build" and make the original test job a noop. (#34429) 2023-09-22 08:25:42 -07:00
grpc_run_cpp_distribtest_test.sh [bazel] Add more bazelified tests (#34005) 2023-08-10 09:02:48 +02:00
grpc_run_distribtest_test.sh [bazelified tests] First attempt at bazelified rules for building artifacts/packages (#34462) 2023-10-04 11:08:49 -07:00
grpc_run_simple_command_test.sh [bazelified tests] Bazelify tests from "linux/grpc_bazel_build" and make the original test job a noop. (#34429) 2023-09-22 08:25:42 -07:00
grpc_run_tests_harness_test.sh [bazel] Add more bazelified tests (#34005) 2023-08-10 09:02:48 +02:00
workspace_status_cmd.sh [bazel] Teach bazel how to run non-bazel test suites under docker locally and on RBE (#33707) 2023-08-02 14:15:19 +02:00

README.md

Non-Bazel native tests

This directory contains logic that wraps builds and tests from the non-bazel realm to make them runnable under bazel.

Examples: cmake builds, run_tests.py tests, artifacts, distribtests etc.

NOTE: all tests and their setup under this directory are currently EXPERIMENTAL.

How it works

The //tools/bazelify_tests:repo_archive target produces an archive that contains grpc at the current head with all its submodules. The rule uses a few tricks to achieve this:

  • Uses a workspace status command to obtain the commit SHAs of grpc and all submodules from the workspace.
  • When running, it actually jailbreaks from the bazel execroot to access the bazel workspace and create the necessary archives.
  • The produced archives are deterministic (they have the same checksum if neither grpc or its submodules have changed).
  • The target is defined in such a way so that it behaves "reasonably" from bazel's perspective (always re-runs if commit SHAs have changed, can be cached if not).

After grpc source code is archived, the "bazelified" tests basically depend on the archive and they run a script under a docker container. The script unpacks the archived grpc code and creates a temporary workspace (under bazel's target execroot) and then performs the actions that are needed (e.g. run the run_tests.py test harness, run cmake build etc).

There are two ways the test targets can run under a docker container:

  • When running on RBE, all actions run under a docker container by definition.
  • When running locally, bazel will start a docker container for each action when docker sandbox is used. (Note that the docker sandbox currently doesn't work on windows)

In both cases, the docker image which is used for any given action is determined by the action's exec_properties and can be specified as a default (e.g. by RBE toolchain or by setting --experimental_docker_image flag) or explicitly for each action. For most tests in this directory, the test rules actually configure the exec_properties for you, based on selecting one of the gRPC's testing docker images.

Run tests on RBE

# "--genrule_strategy=remote,local" allows fallback to local execution if action doesn't support running remotely
# (required to be able to run the //tools/bazelify_tests:repo_archive target).
tools/bazel --bazelrc=tools/remote_build/linux.bazelrc test --genrule_strategy=remote,local --workspace_status_command=tools/bazelify_tests/workspace_status_cmd.sh //tools/bazelify_tests/test:basic_tests_linux

Run tests locally under bazel's docker sandbox

tools/bazel --bazelrc=tools/remote_build/linux_docker_sandbox.bazelrc test --workspace_status_command=tools/bazelify_tests/workspace_status_cmd.sh //tools/bazelify_tests/test:basic_tests_linux