| 1 |
#!/bin/bash |
| 2 |
# Copyright 2021 The 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 -ex |
| 17 |
|
| 18 |
LOGFILE="$(mktemp)" |
| 19 |
|
| 20 |
# Location of the interop test binary is different depending |
| 21 |
# on whether we are running externally/internally, so we try both. |
| 22 |
INTEROP_TEST_BINARY="test/cpp/interop/interop_test" |
| 23 |
test -x "${INTEROP_TEST_BINARY}" || INTEROP_TEST_BINARY="third_party/grpc/${INTEROP_TEST_BINARY}" |
| 24 |
|
| 25 |
# Test that the --log_metadata_and_status flag generates the expected logs in the right format |
| 26 |
# by running the "custom_metadata" interop test case and inspect the logs afterwards. |
| 27 |
"${INTEROP_TEST_BINARY}" --extra_client_flags="--test_case=custom_metadata,--log_metadata_and_status" 2>&1 | tee "${LOGFILE}" |
| 28 |
|
| 29 |
# grep will return an error if any of the patterns below are not found in the log |
| 30 |
grep -q "GRPC_INITIAL_METADATA x-grpc-test-echo-initial: test_initial_metadata_value" "${LOGFILE}" |
| 31 |
grep -q "GRPC_TRAILING_METADATA x-grpc-test-echo-trailing-bin: CgsKCwoL" "${LOGFILE}" |
| 32 |
grep -q "GRPC_ERROR_MESSAGE " "${LOGFILE}" |
| 33 |
grep -q "GRPC_STATUS 0" "${LOGFILE}" |
| 34 |
|
| 35 |
echo "Passed." |