benchmark-dockerized.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env bash
  2. # Copyright 2018 The Kubernetes 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 -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. set -o xtrace
  19. retry() {
  20. for i in {1..5}; do
  21. if "$@"
  22. then
  23. return 0
  24. else
  25. sleep "${i}"
  26. fi
  27. done
  28. "$@"
  29. }
  30. # Runs benchmark integration tests, producing pretty-printed results
  31. # in ${WORKSPACE}/artifacts. This script can also be run within a
  32. # kubekins-test container with a kubernetes repo mounted (at the path
  33. # /go/src/k8s.io/kubernetes).
  34. export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH}
  35. go install k8s.io/kubernetes/vendor/github.com/cespare/prettybench
  36. go install k8s.io/kubernetes/vendor/github.com/jstemmer/go-junit-report
  37. # Disable the Go race detector.
  38. export KUBE_RACE=" "
  39. # Disable coverage report
  40. export KUBE_COVER="n"
  41. export ARTIFACTS=${ARTIFACTS:-"${WORKSPACE}/artifacts"}
  42. export FULL_LOG="true"
  43. mkdir -p "${ARTIFACTS}"
  44. cd /go/src/k8s.io/kubernetes
  45. ./hack/install-etcd.sh
  46. # Run the benchmark tests and pretty-print the results into a separate file.
  47. make test-integration WHAT="$*" KUBE_TEST_ARGS="-run='XXX' -bench=. -benchmem" \
  48. | tee \
  49. >(prettybench -no-passthrough > "${ARTIFACTS}/BenchmarkResults.txt") \
  50. >(go run test/integration/benchmark/jsonify/main.go "${ARTIFACTS}/BenchmarkResults_benchmark_$(date -u +%Y-%m-%dT%H:%M:%SZ).json" || cat > /dev/null)