xref: /aosp_15_r20/external/grpc-grpc/tools/interop_matrix/README.md (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1*cc02d7e2SAndroid Build Coastguard Worker# Overview
2*cc02d7e2SAndroid Build Coastguard Worker
3*cc02d7e2SAndroid Build Coastguard WorkerThis directory contains scripts that facilitate building and running gRPC interoperability tests for combinations of language/runtimes (known as matrix).
4*cc02d7e2SAndroid Build Coastguard Worker
5*cc02d7e2SAndroid Build Coastguard WorkerThe setup builds gRPC docker images for each language/runtime and upload it to Google Container Registry (GCR). These images, encapsulating gRPC stack
6*cc02d7e2SAndroid Build Coastguard Workerfrom specific releases/tag, are used to test version compatibility between gRPC release versions.
7*cc02d7e2SAndroid Build Coastguard Worker
8*cc02d7e2SAndroid Build Coastguard Worker## Step-by-step instructions for adding a GCR image for a new release for compatibility test
9*cc02d7e2SAndroid Build Coastguard WorkerWe have continuous nightly test setup to test gRPC backward compatibility between old clients and latest server.  When a gRPC developer creates a new gRPC release, s/he is also responsible to add the just-released gRPC client to the nightly test.  The steps are:
10*cc02d7e2SAndroid Build Coastguard Worker- Add (or update) an entry in `./client_matrix.py` file to reference the github tag for the release.
11*cc02d7e2SAndroid Build Coastguard Worker- Build new client docker image(s).  For example, for C and wrapper languages release `v1.9.9`, do
12*cc02d7e2SAndroid Build Coastguard Worker  - `tools/interop_matrix/create_matrix_images.py --git_checkout --release=v1.9.9 --upload_images --language cxx python ruby php`
13*cc02d7e2SAndroid Build Coastguard Worker- Verify that the new docker image was built successfully and uploaded to GCR.  For example,
14*cc02d7e2SAndroid Build Coastguard Worker  - `gcloud container images list --repository gcr.io/grpc-testing` lists available images.
15*cc02d7e2SAndroid Build Coastguard Worker  - `gcloud container images list-tags gcr.io/grpc-testing/grpc_interop_java` should show an image entry with tag `v1.9.9`.
16*cc02d7e2SAndroid Build Coastguard Worker  - images can also be viewed in https://pantheon.corp.google.com/gcr/images/grpc-testing?project=grpc-testing
17*cc02d7e2SAndroid Build Coastguard Worker- Verify the just-created docker client image would pass backward compatibility test (it should).  For example,
18*cc02d7e2SAndroid Build Coastguard Worker  - `gcloud docker -- pull gcr.io/grpc-testing/grpc_interop_java:v1.9.9` followed by
19*cc02d7e2SAndroid Build Coastguard Worker  - `docker_image=gcr.io/grpc-testing/grpc_interop_java:v1.9.9 tools/interop_matrix/testcases/java__master`
20*cc02d7e2SAndroid Build Coastguard Worker- Commit the change and create a PR to upstream/master.
21*cc02d7e2SAndroid Build Coastguard Worker- Trigger an adhoc run of interop matrix tests: https://fusion.corp.google.com/projectanalysis/summary/KOKORO/prod:grpc%2Fcore%2Fexperimental%2Flinux%2Fgrpc_interop_matrix_adhoc
22*cc02d7e2SAndroid Build Coastguard Worker- Once tests pass, request a PR review.
23*cc02d7e2SAndroid Build Coastguard Worker- (Optional) clean up the tmp directory to where grpc source is cloned at `/export/hda3/tmp/grpc_matrix/`.
24*cc02d7e2SAndroid Build Coastguard WorkerFor more details on each step, refer to sections below.
25*cc02d7e2SAndroid Build Coastguard Worker
26*cc02d7e2SAndroid Build Coastguard Worker## Instructions for adding new language/runtimes
27*cc02d7e2SAndroid Build Coastguard Worker- Create new `Dockerfile.template`, `build_interop.sh.template` for the language/runtime under `template/tools/dockerfile/`.
28*cc02d7e2SAndroid Build Coastguard Worker- Run `tools/buildgen/generate_projects.sh` to create corresponding files under `tools/dockerfile/`.
29*cc02d7e2SAndroid Build Coastguard Worker- Add language/runtimes to `client_matrix.py` following existing language/runtimes examples.
30*cc02d7e2SAndroid Build Coastguard Worker- Run `tools/interop_matrix/create_matrix_images.py` which will build (and upload) images to GCR.
31*cc02d7e2SAndroid Build Coastguard Worker
32*cc02d7e2SAndroid Build Coastguard Worker## Instructions for creating new test cases
33*cc02d7e2SAndroid Build Coastguard Worker- Create test cases by running `LANG=<lang> [RELEASE=<release>] ./create_testcases.sh`.  For example,
34*cc02d7e2SAndroid Build Coastguard Worker  - `LANG=go ./create_testcases.sh` will generate `./testcases/go__master`, which is also a functional bash script.
35*cc02d7e2SAndroid Build Coastguard Worker  - `LANG=go KEEP_IMAGE=1 ./create_testcases.sh` will generate `./testcases/go__master` and keep the local docker image so it can be invoked simply via `./testcases/go__master`.  Note: remove local docker images manually afterwards with `docker rmi <image_id>`.
36*cc02d7e2SAndroid Build Coastguard Worker- Stage and commit the generated test case file `./testcases/<lang>__<release>`.
37*cc02d7e2SAndroid Build Coastguard Worker
38*cc02d7e2SAndroid Build Coastguard Worker## Instructions for running test cases against GCR images
39*cc02d7e2SAndroid Build Coastguard Worker- Run `tools/interop_matrix/run_interop_matrix_tests.py`.  Useful options:
40*cc02d7e2SAndroid Build Coastguard Worker  - `--release` specifies a git release tag.  Defaults to `--release=all`.  Make sure the GCR images with the tag have been created using `create_matrix_images.py` above.
41*cc02d7e2SAndroid Build Coastguard Worker  - `--language` specifies a language.  Defaults to `--language=all`.
42*cc02d7e2SAndroid Build Coastguard Worker  For example, To test all languages for all gRPC releases across all runtimes, do `tools/interop_matrix/run_interop_matrix_test.py --release=all`.
43*cc02d7e2SAndroid Build Coastguard Worker- The output for all the test cases is recorded in a junit style xml file (defaults to 'report.xml').
44*cc02d7e2SAndroid Build Coastguard Worker
45*cc02d7e2SAndroid Build Coastguard Worker## Instructions for running test cases against a GCR image manually
46*cc02d7e2SAndroid Build Coastguard Worker- Download docker image from GCR.  For example: `gcloud docker -- pull gcr.io/grpc-testing/grpc_interop_go1.8:v1.16.0`.
47*cc02d7e2SAndroid Build Coastguard Worker- Run test cases by specifying `docker_image` variable inline with the test case script created above.
48*cc02d7e2SAndroid Build Coastguard WorkerFor example:
49*cc02d7e2SAndroid Build Coastguard Worker  - `docker_image=gcr.io/grpc-testing/grpc_interop_go1.8:v1.16.0 ./testcases/go__master` will run go__master test cases against `go1.8` with gRPC release `v1.16.0` docker image in GCR.
50*cc02d7e2SAndroid Build Coastguard Worker
51*cc02d7e2SAndroid Build Coastguard WorkerNote:
52*cc02d7e2SAndroid Build Coastguard Worker- File path starting with `tools/` or `template/` are relative to the grpc repo root dir.  File path starting with `./` are relative to current directory (`tools/interop_matrix`).
53*cc02d7e2SAndroid Build Coastguard Worker- Creating and referencing images in GCR require read and write permission to Google Container Registry path gcr.io/grpc-testing.
54