Skip to content

Commit 67bec19

Browse files
committed
Merge branch 'master' into grpc-js_retry
2 parents 339eb37 + fd76558 commit 67bec19

File tree

103 files changed

+2214
-1289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2214
-1289
lines changed

doc/environment_variables.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ can be set.
2929
- `channel` - Traces channel events
3030
- `connectivity_state` - Traces channel connectivity state changes
3131
- `dns_resolver` - Traces DNS resolution
32+
- `ip_resolver` - Traces IPv4/v6 resolution
3233
- `pick_first` - Traces the pick first load balancing policy
3334
- `proxy` - Traces proxy operations
3435
- `resolving_load_balancer` - Traces the resolving load balancer
@@ -40,6 +41,9 @@ can be set.
4041
- `subchannel_flowctrl` - Traces HTTP/2 flow control. Includes per-call logs.
4142
- `subchannel_internals` - Traces HTTP/2 session state. Includes per-call logs.
4243
- `channel_stacktrace` - Traces channel construction events with stack traces.
44+
- `keepalive` - Traces gRPC keepalive pings
45+
- `index` - Traces module loading
46+
- `outlier_detection` - Traces outlier detection events
4347

4448
The following tracers are added by the `@grpc/grpc-js-xds` library:
4549
- `cds_balancer` - Traces the CDS load balancing policy

packages/grpc-js-xds/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ const client = new MyServiceClient('xds:///example.com:123');
2828
- [xDS Circuit Breaking](https://github.com/grpc/proposal/blob/master/A32-xds-circuit-breaking.md)
2929
- [xDS Client-Side Fault Injection](https://github.com/grpc/proposal/blob/master/A33-Fault-Injection.md)
3030
- [Client Status Discovery Service](https://github.com/grpc/proposal/blob/master/A40-csds-support.md)
31-
- [Outlier Detection](https://github.com/grpc/proposal/blob/master/A50-xds-outlier-detection.md) (experimental, disabled by default, enabled by setting the environment variable `GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION=true`)
31+
- [Outlier Detection](https://github.com/grpc/proposal/blob/master/A50-xds-outlier-detection.md)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2022 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+
# Dockerfile for building the xDS interop client. To build the image, run the
16+
# following command from grpc-node directory:
17+
# docker build -t <TAG> -f packages/grpc-js-xds/interop/Dockerfile .
18+
19+
FROM node:16-alpine as build
20+
21+
# Make a grpc-node directory and copy the repo into it.
22+
WORKDIR /node/src/grpc-node
23+
COPY . .
24+
25+
WORKDIR /node/src/grpc-node/packages/grpc-js
26+
RUN npm install
27+
WORKDIR /node/src/grpc-node/packages/grpc-js-xds
28+
RUN npm install
29+
30+
FROM node:16-alpine
31+
WORKDIR /node/src/grpc-node
32+
COPY --from=build /node/src/grpc-node/packages/grpc-js ./packages/grpc-js/
33+
COPY --from=build /node/src/grpc-node/packages/grpc-js-xds ./packages/grpc-js-xds/
34+
35+
ENV GRPC_VERBOSITY="DEBUG"
36+
ENV GRPC_TRACE=xds_client,xds_resolver,cds_balancer,eds_balancer,priority,weighted_target,round_robin,resolving_load_balancer,subchannel,keepalive,dns_resolver,fault_injection,http_filter,csds,outlier_detection
37+
38+
ENTRYPOINT [ "node", "/node/src/grpc-node/packages/grpc-js-xds/build/interop/xds-interop-client" ]

packages/grpc-js-xds/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grpc/grpc-js-xds",
3-
"version": "1.6.1",
3+
"version": "1.7.0",
44
"description": "Plugin for @grpc/grpc-js. Adds the xds:// URL scheme and associated features.",
55
"main": "build/src/index.js",
66
"scripts": {
@@ -47,7 +47,7 @@
4747
"re2-wasm": "^1.0.1"
4848
},
4949
"peerDependencies": {
50-
"@grpc/grpc-js": "~1.6.0"
50+
"@grpc/grpc-js": "~1.7.0"
5151
},
5252
"engines": {
5353
"node": ">=10.10.0"
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2022 gRPC authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
# Constants
19+
readonly GITHUB_REPOSITORY_NAME="grpc-node"
20+
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/grpc/${TEST_DRIVER_BRANCH:-master}/tools/internal_ci/linux/grpc_xds_k8s_install_test_driver.sh"
21+
## xDS test client Docker images
22+
readonly SERVER_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/java-server:v1.46.x"
23+
readonly CLIENT_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/node-client"
24+
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
25+
readonly BUILD_APP_PATH="packages/grpc-js-xds/interop/Dockerfile"
26+
readonly LANGUAGE_NAME="Node"
27+
28+
#######################################
29+
# Builds test app Docker images and pushes them to GCR
30+
# Globals:
31+
# BUILD_APP_PATH
32+
# CLIENT_IMAGE_NAME: Test client Docker image name
33+
# GIT_COMMIT: SHA-1 of git commit being built
34+
# TESTING_VERSION: version branch under test, f.e. v1.42.x, master
35+
# Arguments:
36+
# None
37+
# Outputs:
38+
# Writes the output of `gcloud builds submit` to stdout, stderr
39+
#######################################
40+
build_test_app_docker_images() {
41+
echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images"
42+
43+
pushd "${SRC_DIR}"
44+
docker build \
45+
-f "${BUILD_APP_PATH}" \
46+
-t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
47+
.
48+
49+
gcloud -q auth configure-docker
50+
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
51+
if is_version_branch "${TESTING_VERSION}"; then
52+
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
53+
fi
54+
popd
55+
}
56+
57+
#######################################
58+
# Builds test app and its docker images unless they already exist
59+
# Globals:
60+
# CLIENT_IMAGE_NAME: Test client Docker image name
61+
# GIT_COMMIT: SHA-1 of git commit being built
62+
# FORCE_IMAGE_BUILD
63+
# Arguments:
64+
# None
65+
# Outputs:
66+
# Writes the output to stdout, stderr
67+
#######################################
68+
build_docker_images_if_needed() {
69+
# Check if images already exist
70+
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
71+
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
72+
echo "${client_tags:-Client image not found}"
73+
74+
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
75+
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${client_tags}" ]]; then
76+
build_test_app_docker_images
77+
else
78+
echo "Skipping ${LANGUAGE_NAME} test app build"
79+
fi
80+
}
81+
82+
#######################################
83+
# Executes the test case
84+
# Globals:
85+
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
86+
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
87+
# SECONDARY_KUBE_CONTEXT: The name of kubectl context with secondary GKE cluster access, if any
88+
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
89+
# CLIENT_IMAGE_NAME: Test client Docker image name
90+
# GIT_COMMIT: SHA-1 of git commit being built
91+
# Arguments:
92+
# Test case name
93+
# Outputs:
94+
# Writes the output of test execution to stdout, stderr
95+
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
96+
#######################################
97+
run_test() {
98+
# Test driver usage:
99+
# https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
100+
local test_name="${1:?Usage: run_test test_name}"
101+
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
102+
mkdir -pv "${out_dir}"
103+
# testing_version is used by the framework to determine the supported PSM
104+
# features. It's captured from Kokoro job name of the Node repo, which takes
105+
# the form:
106+
# grpc/node/<branch name>/<job name>
107+
python3 -m "tests.${test_name}" \
108+
--flagfile="${TEST_DRIVER_FLAGFILE}" \
109+
--kube_context="${KUBE_CONTEXT}" \
110+
--secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \
111+
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
112+
--server_image="${SERVER_IMAGE_NAME}" \
113+
--testing_version="${TESTING_VERSION}" \
114+
--force_cleanup \
115+
--collect_app_logs \
116+
--log_dir="${out_dir}" \
117+
--xml_output_file="${out_dir}/sponge_log.xml" \
118+
|& tee "${out_dir}/sponge_log.log"
119+
}
120+
121+
#######################################
122+
# Main function: provision software necessary to execute tests, and run them
123+
# Globals:
124+
# KOKORO_ARTIFACTS_DIR
125+
# GITHUB_REPOSITORY_NAME
126+
# SRC_DIR: Populated with absolute path to the source repo
127+
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
128+
# the test driver
129+
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
130+
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
131+
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
132+
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
133+
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
134+
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
135+
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
136+
# SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster access, if any
137+
# Arguments:
138+
# None
139+
# Outputs:
140+
# Writes the output of test execution to stdout, stderr
141+
#######################################
142+
main() {
143+
local script_dir
144+
script_dir="$(dirname "$0")"
145+
146+
cd "${script_dir}"
147+
148+
git submodule update --init --recursive
149+
150+
# Source the test driver from the master branch.
151+
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
152+
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
153+
154+
activate_gke_cluster GKE_CLUSTER_PSM_LB
155+
activate_secondary_gke_cluster GKE_CLUSTER_PSM_LB
156+
157+
set -x
158+
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
159+
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
160+
else
161+
local_setup_test_driver "${script_dir}"
162+
fi
163+
build_docker_images_if_needed
164+
165+
# Run tests
166+
cd "${TEST_DRIVER_FULL_DIR}"
167+
local failed_tests=0
168+
test_suites=("baseline_test" "api_listener_test" "change_backend_service_test" "failover_test" "remove_neg_test" "round_robin_test" "outlier_detection_test")
169+
for test in "${test_suites[@]}"; do
170+
run_test $test || (( failed_tests++ ))
171+
done
172+
echo "Failed test suites: ${failed_tests}"
173+
if (( failed_tests > 0 )); then
174+
exit 1
175+
fi
176+
}
177+
178+
main "$@"

0 commit comments

Comments
 (0)