diff --git a/tests/cli/test_helper/fluvio_dev.bash b/tests/cli/test_helper/fluvio_dev.bash index dddc294491..20e93357c2 100644 --- a/tests/cli/test_helper/fluvio_dev.bash +++ b/tests/cli/test_helper/fluvio_dev.bash @@ -17,16 +17,20 @@ function debug_msg() { # Note: We only generate strings w/ *lowercase* alphanum or '-' # for topic naming compatibility +# We don't check for minimum length, but $DEFAULT_LEN >= 3 +# or `shuf` will err when requested $BODY length less than zero function random_string() { DEFAULT_LEN=7 STRING_LEN=${1:-$DEFAULT_LEN} - # Ensure we don't end up with a string that starts with '-' + # Ensure we don't end up with a string that starts or ends with '-' + # https://github.com/infinyon/fluvio/issues/1864 - STRING1=$(shuf -zer -n1 {a..z} {0..9}) - STRING2=$(shuf -zer -n"$(($STRING_LEN-1))" {a..z} {0..9} "-") + HEAD=$(shuf -zer -n1 {a..z} {0..9}) + BODY=$(shuf -zer -n"$(($STRING_LEN-2))" {a..z} {0..9} "-") + FOOT=$(shuf -zer -n1 {a..z} {0..9}) - RANDOM_STRING=$STRING1$STRING2 + RANDOM_STRING=$HEAD$BODY$FOOT if [[ -n $DEBUG ]]; then echo "# DEBUG: Random str (len: $STRING_LEN): $RANDOM_STRING" >&3