.travis-script.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #!/bin/bash -e
  2. # Copyright 2019, gRPC Authors All rights reserved.
  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. # See: Makefile
  16. BUILD_OUTPUT=./.build/debug
  17. GREEN='\033[0;32m'
  18. BLUE='\033[0;34m'
  19. NO_COLOR='\033[0m'
  20. info() {
  21. printf "${BLUE}$1${NO_COLOR}\n"
  22. }
  23. success() {
  24. printf "${GREEN}$1${NO_COLOR}\n"
  25. }
  26. setup_environment() {
  27. echo -en 'travis_fold:start:script.environment\\r'
  28. export PATH=$HOME/local/bin:$PATH
  29. export LD_LIBRARY_PATH=$HOME/local/lib
  30. echo -en 'travis_fold:end:script.environment\\r'
  31. }
  32. make_all() {
  33. echo -en 'travis_fold:start:make.all\\r'
  34. info "Running make all"
  35. make all
  36. success "make all succeeded"
  37. echo -en 'travis_fold:end:make.all\\r'
  38. }
  39. make_test() {
  40. echo -en 'travis_fold:start:make.test\\r'
  41. if [[ ${NO_TSAN} == "true" ]]; then
  42. info "Running Swift tests"
  43. make test
  44. else
  45. info "Running Swift tests with TSAN"
  46. make test-tsan
  47. fi
  48. success "Swift tests passed"
  49. echo -en 'travis_fold:end:make.test\\r'
  50. }
  51. make_test_plugin() {
  52. echo -en 'travis_fold:start:make.test_plugin\\r'
  53. info "Validating protoc plugins on the Echo service"
  54. make test-plugin
  55. success "Validated protoc plugins on the Echo service"
  56. echo -en 'travis_fold:end:make.test_plugin\\r'
  57. }
  58. make_check_linuxmain() {
  59. echo -en 'travis_fold:start:make.test_generate_linuxmain\\r'
  60. info "Validating LinuxMain is up-to-date"
  61. if [ "$TRAVIS_OS_NAME" = "osx" ]; then
  62. make test-generate-linuxmain
  63. success "LinuxMain is up-to-date"
  64. else
  65. info "Not running on macOS, skipping LinuxMain validation"
  66. fi
  67. echo -en 'travis_fold:end:make.test_generate_linuxmain\\r'
  68. }
  69. make_project() {
  70. echo -en 'travis_fold:start:make.project\\r'
  71. info "Validating .xcodeproj can be generated"
  72. if [ "$TRAVIS_OS_NAME" = "osx" ]; then
  73. make project
  74. info ".xcodeproj was successfully generated"
  75. else
  76. info "Not running on macOS, skipping .xcodeproj generation"
  77. fi
  78. echo -en 'travis_fold:end:make.project\\r'
  79. }
  80. run_interop_tests() {
  81. echo -en 'travis_fold:start:test.interop_tests\\r'
  82. make interop-test-runner
  83. INTEROP_TEST_SERVER_PORT=8080
  84. # interop_server should be on $PATH
  85. info "Starting C++ interop server on port $INTEROP_TEST_SERVER_PORT"
  86. "$HOME"/local/bin/interop_server -port "$INTEROP_TEST_SERVER_PORT" &
  87. INTEROP_SERVER_PID=$!
  88. success "C++ interop server started, pid=$INTEROP_SERVER_PID"
  89. # Names of the tests we should run:
  90. TESTS=(
  91. empty_unary
  92. large_unary
  93. client_streaming
  94. server_streaming
  95. ping_pong
  96. empty_stream
  97. custom_metadata
  98. status_code_and_message
  99. special_status_message
  100. unimplemented_method
  101. unimplemented_service
  102. cancel_after_begin
  103. cancel_after_first_response
  104. timeout_on_sleeping_server
  105. )
  106. # Run the tests; logs are written to stderr, capture them per-test.
  107. for test in "${TESTS[@]}"; do
  108. info "Running $test"
  109. $BUILD_OUTPUT/GRPCInteroperabilityTests run_test \
  110. "localhost" \
  111. "$INTEROP_TEST_SERVER_PORT" \
  112. "$test" \
  113. 2> "interop.$test.log"
  114. success "PASSED $test"
  115. done
  116. success "Interop tests PASSED"
  117. info "Stopping C++ interop server"
  118. kill "$INTEROP_SERVER_PID"
  119. success "Stopped C++ interop server"
  120. echo -en 'travis_fold:end:test.interop_tests\\r'
  121. }
  122. run_interop_reconnect_test() {
  123. echo -en 'travis_fold:start:test.interop_reconnect\\r'
  124. make interop-backoff-test-runner
  125. INTEROP_TEST_SERVER_CONTROL_PORT=8081
  126. INTEROP_TEST_SERVER_RETRY_PORT=8082
  127. # reconnect_interop_server should be on $PATH
  128. info "Starting C++ reconnect interop server:"
  129. info " - control port: ${INTEROP_TEST_SERVER_CONTROL_PORT}"
  130. info " - retry port: ${INTEROP_TEST_SERVER_RETRY_PORT}"
  131. "$HOME"/local/bin/reconnect_interop_server \
  132. -control_port "$INTEROP_TEST_SERVER_CONTROL_PORT" \
  133. -retry_port "$INTEROP_TEST_SERVER_RETRY_PORT" &
  134. INTEROP_RECONNECT_SERVER_PID=$!
  135. success "C++ reconnect interop server started, pid=$INTEROP_RECONNECT_SERVER_PID"
  136. info "Running connection backoff interop test"
  137. # Run the test; logs are written to stderr, redirect them to a file.
  138. ${BUILD_OUTPUT}/GRPCConnectionBackoffInteropTest \
  139. ${INTEROP_TEST_SERVER_CONTROL_PORT} \
  140. ${INTEROP_TEST_SERVER_RETRY_PORT} \
  141. 2> "interop.connection_backoff.log"
  142. success "connection backoff interop test PASSED"
  143. info "Stopping C++ reconnect interop server"
  144. kill "$INTEROP_RECONNECT_SERVER_PID"
  145. success "Stopped C++ reconnect interop server"
  146. echo -en 'travis_fold:end:test.interop_reconnect\\r'
  147. }
  148. main() {
  149. setup_environment
  150. # If we're running interop tests don't bother with the other stuff.
  151. if [ "$RUN_INTEROP_TESTS" = "true" ]; then
  152. run_interop_tests
  153. run_interop_reconnect_test
  154. else
  155. make_all
  156. make_check_linuxmain
  157. make_test
  158. make_test_plugin
  159. make_project
  160. fi
  161. }
  162. # Run the thing!
  163. main