grpc_e2e_performance_gke_experiment.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/usr/bin/env 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. # Enter the gRPC repo root.
  17. cd "$(dirname "$0")/../../.."
  18. source tools/internal_ci/helper_scripts/prepare_build_linux_rc
  19. # This is to ensure we can push and pull images from gcr.io. We do not
  20. # necessarily need it to run load tests, but will need it when we employ
  21. # pre-built images in the optimization.
  22. gcloud auth configure-docker
  23. # Connect to benchmarks-prod2 cluster.
  24. gcloud config set project grpc-testing
  25. gcloud container clusters get-credentials benchmarks-prod2 \
  26. --zone us-central1-b --project grpc-testing
  27. # Set up environment variables.
  28. LOAD_TEST_PREFIX="${KOKORO_BUILD_INITIATOR}"
  29. # BEGIN differentiate experimental configuration from master configuration.
  30. if [[ "${KOKORO_BUILD_INITIATOR%%-*}" == kokoro ]]; then
  31. LOAD_TEST_PREFIX=kokoro-test
  32. fi
  33. BIGQUERY_TABLE_8CORE=e2e_benchmarks.experimental_results
  34. BIGQUERY_TABLE_32CORE=e2e_benchmarks.experimental_results_32core
  35. # END differentiate experimental configuration from master configuration.
  36. CLOUD_LOGGING_URL="https://source.cloud.google.com/results/invocations/${KOKORO_BUILD_ID}"
  37. PREBUILT_IMAGE_PREFIX="gcr.io/grpc-testing/e2etest/prebuilt/${LOAD_TEST_PREFIX}"
  38. UNIQUE_IDENTIFIER="$(date +%Y%m%d%H%M%S)"
  39. ROOT_DIRECTORY_OF_DOCKERFILES="../test-infra/containers/pre_built_workers/"
  40. # Head of the workspace checked out by Kokoro.
  41. GRPC_GITREF="$(git show --format="%H" --no-patch)"
  42. # Prebuilt workers for core languages are always built from grpc/grpc.
  43. if [[ "${KOKORO_GITHUB_COMMIT_URL%/*}" == "https://github.com/grpc/grpc/commit" ]]; then
  44. GRPC_CORE_GITREF="${KOKORO_GIT_COMMIT}"
  45. else
  46. GRPC_CORE_GITREF="$(git ls-remote https://github.com/grpc/grpc.git master | cut -f1)"
  47. fi
  48. GRPC_GO_GITREF="$(git ls-remote https://github.com/grpc/grpc-go.git master | cut -f1)"
  49. GRPC_JAVA_GITREF="$(git ls-remote https://github.com/grpc/grpc-java.git master | cut -f1)"
  50. # Kokoro jobs run on dedicated pools.
  51. DRIVER_POOL=drivers-ci
  52. WORKER_POOL_8CORE=workers-c2-8core-ci
  53. # c2-standard-30 is the closest machine spec to 32 core there is
  54. WORKER_POOL_32CORE=workers-c2-30core-ci
  55. # Update go version.
  56. TEST_INFRA_GOVERSION=go1.17.1
  57. go get "golang.org/dl/${TEST_INFRA_GOVERSION}"
  58. "${TEST_INFRA_GOVERSION}" download
  59. # Clone test-infra repository and build all tools.
  60. pushd ..
  61. git clone https://github.com/grpc/test-infra.git
  62. cd test-infra
  63. # Tools are built from HEAD.
  64. git checkout --detach
  65. make GOCMD="${TEST_INFRA_GOVERSION}" all-tools
  66. popd
  67. # Build test configurations.
  68. buildConfigs() {
  69. local -r pool="$1"
  70. local -r table="$2"
  71. shift 2
  72. tools/run_tests/performance/loadtest_config.py "$@" \
  73. -t ./tools/run_tests/performance/templates/loadtest_template_prebuilt_all_languages.yaml \
  74. -s driver_pool="${DRIVER_POOL}" -s driver_image= \
  75. -s client_pool="${pool}" -s server_pool="${pool}" \
  76. -s big_query_table="${table}" -s timeout_seconds=900 \
  77. -s prebuilt_image_prefix="${PREBUILT_IMAGE_PREFIX}" \
  78. -s prebuilt_image_tag="${UNIQUE_IDENTIFIER}" \
  79. -a ci_buildNumber="${KOKORO_BUILD_NUMBER}" \
  80. -a ci_buildUrl="${CLOUD_LOGGING_URL}" \
  81. -a ci_jobName="${KOKORO_JOB_NAME}" \
  82. -a ci_gitCommit="${GRPC_GITREF}" \
  83. -a ci_gitCommit_go="${GRPC_GO_GITREF}" \
  84. -a ci_gitCommit_java="${GRPC_JAVA_GITREF}" \
  85. -a ci_gitActualCommit="${KOKORO_GIT_COMMIT}" \
  86. --prefix="${LOAD_TEST_PREFIX}" -u "${UNIQUE_IDENTIFIER}" -u "${pool}" \
  87. -a pool="${pool}" --category=scalable \
  88. --allow_client_language=c++ --allow_server_language=c++ \
  89. -o "loadtest_with_prebuilt_workers_${pool}.yaml"
  90. }
  91. buildConfigs "${WORKER_POOL_8CORE}" "${BIGQUERY_TABLE_8CORE}" -l c++ -l csharp -l go -l java -l php7 -l php7_protobuf_c -l python -l ruby
  92. buildConfigs "${WORKER_POOL_32CORE}" "${BIGQUERY_TABLE_32CORE}" -l c++ -l csharp -l go -l java
  93. # Delete prebuilt images on exit.
  94. deleteImages() {
  95. echo "deleting images on exit"
  96. ../test-infra/bin/delete_prebuilt_workers \
  97. -p "${PREBUILT_IMAGE_PREFIX}" \
  98. -t "${UNIQUE_IDENTIFIER}"
  99. }
  100. trap deleteImages EXIT
  101. # Build and push prebuilt images for running tests.
  102. time ../test-infra/bin/prepare_prebuilt_workers \
  103. -l "cxx:${GRPC_CORE_GITREF}" \
  104. -l "csharp:${GRPC_CORE_GITREF}" \
  105. -l "go:${GRPC_GO_GITREF}" \
  106. -l "java:${GRPC_JAVA_GITREF}" \
  107. -l "php7:${GRPC_CORE_GITREF}" \
  108. -l "python:${GRPC_CORE_GITREF}" \
  109. -l "ruby:${GRPC_CORE_GITREF}" \
  110. -p "${PREBUILT_IMAGE_PREFIX}" \
  111. -t "${UNIQUE_IDENTIFIER}" \
  112. -r "${ROOT_DIRECTORY_OF_DOCKERFILES}"
  113. # Run tests.
  114. time ../test-infra/bin/runner \
  115. -i "loadtest_with_prebuilt_workers_${WORKER_POOL_8CORE}.yaml" \
  116. -i "loadtest_with_prebuilt_workers_${WORKER_POOL_32CORE}.yaml" \
  117. -polling-interval 5s \
  118. -delete-successful-tests \
  119. -c "${WORKER_POOL_8CORE}:2" -c "${WORKER_POOL_32CORE}:2" \
  120. -o "runner/sponge_log.xml"