...

Text file src/k8s.io/kubernetes/test/cmd/request-timeout.sh

Documentation: k8s.io/kubernetes/test/cmd

     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
    21run_kubectl_request_timeout_tests() {
    22  set -o nounset
    23  set -o errexit
    24
    25  kube::log::status "Testing kubectl request timeout"
    26  ### Test global request timeout option
    27  # Pre-condition: no POD exists
    28  create_and_use_new_namespace
    29  kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" ''
    30  # Command
    31  kubectl create "${kube_flags[@]:?}" -f test/fixtures/doc-yaml/admin/limitrange/valid-pod.yaml
    32  # Post-condition: valid-pod POD is created
    33  kubectl get "${kube_flags[@]}" pods -o json
    34  kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" 'valid-pod:'
    35
    36  ## check --request-timeout on 'get pod'
    37  output_message=$(kubectl get pod valid-pod --request-timeout=1)
    38  kube::test::if_has_string "${output_message}" 'valid-pod'
    39
    40  ## check --request-timeout on 'get pod' with --watch
    41  output_message=$(kubectl get pod valid-pod --request-timeout=1 --watch --v=5 2>&1)
    42  kube::test::if_has_string "${output_message}" 'Timeout'
    43
    44  ## check --request-timeout value with no time unit
    45  output_message=$(kubectl get pod valid-pod --request-timeout=1 2>&1)
    46  kube::test::if_has_string "${output_message}" 'valid-pod'
    47
    48  ## check --request-timeout value with invalid time unit
    49  output_message=$(! kubectl get pod valid-pod --request-timeout="1p" 2>&1)
    50  kube::test::if_has_string "${output_message}" 'Invalid timeout value'
    51
    52  # cleanup
    53  kubectl delete pods valid-pod "${kube_flags[@]}"
    54
    55  set +o nounset
    56  set +o errexit
    57}

View as plain text