mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Make test-cmd
work with OS-X tooling
OS-X thips with the BSD versions of `date` and `grep`. Those don't have certain features the script relies on: - BSD date does not support nanoseconds (`%N`) - BSD grep does not support perl RegEx (`-P`) As we use `bash` specifically in the hashbang anyway it is probably fine to rely on the `$RANDOM` bashism here.
This commit is contained in:
parent
18d9e1c450
commit
1bb3537c98
@ -3868,7 +3868,7 @@ run_assert_categories_tests() {
|
|||||||
set -o errexit
|
set -o errexit
|
||||||
|
|
||||||
kube::log::status "Testing propagation of categories for resources"
|
kube::log::status "Testing propagation of categories for resources"
|
||||||
output_message=$(kubectl get --raw=/api/v1 | grep -Po '"name":"pods".*?}')
|
output_message=$(kubectl get --raw=/api/v1 | grep -o '"name":"pods"[^}]*}')
|
||||||
kube::test::if_has_string "${output_message}" '"categories":\["all"\]'
|
kube::test::if_has_string "${output_message}" '"categories":\["all"\]'
|
||||||
|
|
||||||
set +o nounset
|
set +o nounset
|
||||||
@ -4729,13 +4729,15 @@ runTests() {
|
|||||||
kube::log::status "Checking kubectl version"
|
kube::log::status "Checking kubectl version"
|
||||||
kubectl version
|
kubectl version
|
||||||
|
|
||||||
# use timestamp as the name of namespace because increasing the variable inside subshell
|
# Generate a random namespace name, based on the current time (to make
|
||||||
# does not affect the value of the variable outside the subshell.
|
# debugging slightly easier) and a random number. Don't use `date +%N`
|
||||||
|
# because that doesn't work on OSX.
|
||||||
create_and_use_new_namespace() {
|
create_and_use_new_namespace() {
|
||||||
namespace_number=$(date +%s%N)
|
local ns_name
|
||||||
kube::log::status "Creating namespace namespace${namespace_number}"
|
ns_name="namespace-$(date +%s)-${RANDOM}"
|
||||||
kubectl create namespace "namespace${namespace_number}"
|
kube::log::status "Creating namespace ${ns_name}"
|
||||||
kubectl config set-context "${CONTEXT}" --namespace="namespace${namespace_number}"
|
kubectl create namespace "$ns_name"
|
||||||
|
kubectl config set-context "${CONTEXT}" --namespace="$ns_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
kube_flags=(
|
kube_flags=(
|
||||||
|
Loading…
Reference in New Issue
Block a user