test-performance.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. TEST_ARGS=""
  19. RUN_PATTERN=".*"
  20. PROFILE_OPTS=""
  21. function usage() {
  22. echo "usage: $0 <options>"
  23. echo " -h display this help message"
  24. echo " -d enable debug logs in tests"
  25. echo " -r <pattern> regex pattern to match for tests"
  26. echo " -o <filename> file to write JSON formatted results to"
  27. echo " -p <id> enable cpu and memory profiles, output written to mem-<id>.out and cpu-<id>.out"
  28. echo " -c enable custom test configuration"
  29. echo " -a <name> allocator name, one of RangeAllocator, CloudAllocator, IPAMFromCluster, IPAMFromCloud"
  30. echo " -k <num> api server qps for allocator"
  31. echo " -n <num> number of nodes to simulate"
  32. echo " -m <num> api server qps for node creation"
  33. echo " -l <num> gce cloud endpoint qps"
  34. exit 1
  35. }
  36. while getopts ":hdr:o:p:ca:k:n:m:l:" opt; do
  37. case ${opt} in
  38. d) TEST_ARGS="${TEST_ARGS} -v=6"
  39. ;;
  40. r) RUN_PATTERN="${OPTARG}"
  41. ;;
  42. o) TEST_ARGS="${TEST_ARGS} -log ${OPTARG}"
  43. ;;
  44. p) PROFILE_OPTS="-memprofile mem-${OPTARG}.out -cpuprofile cpu-${OPTARG}.out"
  45. ;;
  46. c) TEST_ARGS="${TEST_ARGS} -custom"
  47. ;;
  48. a) TEST_ARGS="${TEST_ARGS} -allocator ${OPTARG}"
  49. ;;
  50. k) TEST_ARGS="${TEST_ARGS} -kube-qps ${OPTARG}"
  51. ;;
  52. n) TEST_ARGS="${TEST_ARGS} -num-nodes ${OPTARG}"
  53. ;;
  54. m) TEST_ARGS="${TEST_ARGS} -create-qps ${OPTARG}"
  55. ;;
  56. l) TEST_ARGS="${TEST_ARGS} -cloud-qps ${OPTARG}"
  57. ;;
  58. h) usage
  59. ;;
  60. \?) usage
  61. ;;
  62. esac
  63. done
  64. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../../../
  65. source "${KUBE_ROOT}/hack/lib/init.sh"
  66. kube::golang::setup_env
  67. DIR_BASENAME=$(dirname "${BASH_SOURCE[0]}")
  68. pushd "${DIR_BASENAME}"
  69. cleanup() {
  70. popd 2> /dev/null
  71. kube::etcd::cleanup
  72. kube::log::status "performance test cleanup complete"
  73. }
  74. trap cleanup EXIT
  75. kube::etcd::start
  76. # Running IPAM tests. It might take a long time.
  77. kube::log::status "performance test (IPAM) start"
  78. go test "${PROFILE_OPTS}" -test.run="${RUN_PATTERN}" -test.timeout=60m -test.short=false -v -args "${TEST_ARGS}"
  79. kube::log::status "... IPAM tests finished."