Unverified Commit 9f71d7f8 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #61393 from totherme/fix-test-cmd-on-osx

Automatic merge from submit-queue (batch tested with PRs 61453, 61393, 61379, 61373, 61494). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. 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. **What this PR does / why we need it**: Currently `make test-cmd` doesn't work on OSX. This PR makes `make test-cmd` work on OSX. **Release note**: ```release-note `make test-cmd` now works on OSX. ``` cc: @apelisse
parents a0ea7f38 fa96484d
......@@ -3869,7 +3869,7 @@ run_assert_categories_tests() {
set -o errexit
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"\]'
set +o nounset
......@@ -4770,13 +4770,15 @@ runTests() {
kube::log::status "Checking kubectl version"
kubectl version
# use timestamp as the name of namespace because increasing the variable inside subshell
# does not affect the value of the variable outside the subshell.
# Generate a random namespace name, based on the current time (to make
# debugging slightly easier) and a random number. Don't use `date +%N`
# because that doesn't work on OSX.
create_and_use_new_namespace() {
namespace_number=$(date +%s%N)
kube::log::status "Creating namespace namespace${namespace_number}"
kubectl create namespace "namespace${namespace_number}"
kubectl config set-context "${CONTEXT}" --namespace="namespace${namespace_number}"
local ns_name
ns_name="namespace-$(date +%s)-${RANDOM}"
kube::log::status "Creating namespace ${ns_name}"
kubectl create namespace "${ns_name}"
kubectl config set-context "${CONTEXT}" --namespace="${ns_name}"
}
kube_flags=(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment