interop_test_with_metadata_log.sh 1.5 KB

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