k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/hack/jenkins/benchmark-dockerized.sh (about) 1 #!/usr/bin/env bash 2 3 # Copyright 2018 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -o errexit 18 set -o nounset 19 set -o pipefail 20 set -o xtrace 21 22 retry() { 23 for i in {1..5}; do 24 if "$@" 25 then 26 return 0 27 else 28 sleep "${i}" 29 fi 30 done 31 "$@" 32 } 33 34 # The root of the build/dist directory 35 KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. 36 export KUBE_ROOT 37 38 # Runs benchmark integration tests, producing pretty-printed results 39 # in ${WORKSPACE}/artifacts. This script can also be run within a 40 # kubekins-test container with a kubernetes repo mounted (at the path 41 # /go/src/k8s.io/kubernetes). 42 43 export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH} 44 45 # Until all GOPATH references are removed from all build scripts as well, 46 # explicitly disable module mode to avoid picking up user-set GO111MODULE preferences. 47 # As individual scripts make use of go modules, they can explicitly set GO111MODULE=on 48 export GO111MODULE=off 49 50 # Install tools we need 51 GO111MODULE=on go -C "${KUBE_ROOT}/hack/tools" install github.com/cespare/prettybench 52 GO111MODULE=on go -C "${KUBE_ROOT}/hack/tools" install gotest.tools/gotestsum 53 54 # Disable the Go race detector. 55 export KUBE_RACE=" " 56 # Disable coverage report 57 export KUBE_COVER="n" 58 export ARTIFACTS=${ARTIFACTS:-"${WORKSPACE}/artifacts"} 59 export FULL_LOG="true" 60 61 mkdir -p "${ARTIFACTS}" 62 cd "${GOPATH}/src/k8s.io/kubernetes" 63 64 ./hack/install-etcd.sh 65 66 # Run the benchmark tests and pretty-print the results into a separate file. 67 # Log output of the tests go to stderr. 68 make test-integration WHAT="$*" KUBE_TEST_ARGS="-run='XXX' -bench=${TEST_PREFIX:-.} -benchtime=${BENCHTIME:-1s} -benchmem -data-items-dir=${ARTIFACTS}" \ 69 | (go run test/integration/benchmark/extractlog/main.go) \ 70 | tee \ 71 >(prettybench -no-passthrough > "${ARTIFACTS}/BenchmarkResults.txt") \ 72 >(go run test/integration/benchmark/jsonify/main.go "${ARTIFACTS}/BenchmarkResults_benchmark_$(date -u +%Y-%m-%dT%H:%M:%SZ).json" || cat > /dev/null)