test-performance.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. # Copyright 2014 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. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../../../
  19. source "${KUBE_ROOT}/hack/lib/init.sh"
  20. kube::golang::setup_env
  21. DIR_BASENAME=$(dirname "${BASH_SOURCE[0]}")
  22. pushd "${DIR_BASENAME}"
  23. cleanup() {
  24. popd 2> /dev/null
  25. kube::etcd::cleanup
  26. kube::log::status "performance test cleanup complete"
  27. }
  28. trap cleanup EXIT
  29. kube::etcd::start
  30. # We are using the benchmark suite to do profiling. Because it only runs a few pods and
  31. # theoretically it has less variance.
  32. if ${RUN_BENCHMARK:-false}; then
  33. kube::log::status "performance test (benchmark) compiling"
  34. go test -c -o "perf.test"
  35. kube::log::status "performance test (benchmark) start"
  36. "./perf.test" -test.bench=. -test.run=xxxx -test.cpuprofile=prof.out -test.short=false
  37. kube::log::status "...benchmark tests finished"
  38. fi
  39. # Running density tests. It might take a long time.
  40. kube::log::status "performance test (density) start"
  41. go test -test.run=. -test.timeout=60m -test.short=false
  42. kube::log::status "...density tests finished"