...

Text file src/k8s.io/kubernetes/test/integration/ipamperf/test-performance.sh

Documentation: k8s.io/kubernetes/test/integration/ipamperf

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

View as plain text