diff options
author | Florian Westphal <fw@strlen.de> | 2024-09-14 23:56:14 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2024-09-15 10:28:10 +0200 |
commit | 3a9cb020a27bb8447e6325eb20605f62e95bc599 (patch) | |
tree | 07efd4d2c9e3be1b53622f07926b75980cfbb2b3 /tests/shell/testcases | |
parent | 036a1eb3304995e4e000c552b9dfd33b1073ddb6 (diff) |
tests: shell: more randomization for timeout parameter
Either pass no timeout argument, pass timeout+expires or omit
timeout (uses default timeout, if any).
This should not expose further kernel code to run at this time, but unlike
the existing (deterministic) element-update test case this script does
have live traffic and different set types, including rhashtable which has
async gc.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/testcases')
-rwxr-xr-x | tests/shell/testcases/transactions/30s-stress | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/tests/shell/testcases/transactions/30s-stress b/tests/shell/testcases/transactions/30s-stress index e92b9226..e1e8b742 100755 --- a/tests/shell/testcases/transactions/30s-stress +++ b/tests/shell/testcases/transactions/30s-stress @@ -290,8 +290,34 @@ available_flags() fi } -random_element_string="" +random_timeout() +{ + local timeout="" + local expires + local r=$((RANDOM%3)) + + case "$r" in + 0) + timeout=$((RANDOM%60000)) + timeout="timeout ${timeout}ms" + ;; + 1) + timeout=$((RANDOM%60000)) + expires=$((timeout)) + if [ $timeout -gt 0 ];then + expires=$((RANDOM%expires)) + else + expires=0 + fi + timeout="timeout ${timeout}ms expires ${expires}ms" + ;; + esac + + echo -n "$timeout" +} + +random_element_string="" # create a random element. Could cause any of the following: # 1. Invalid set/map # 2. Element already exists in set/map w. create @@ -354,17 +380,17 @@ random_elem() r=$((RANDOM%7)) case "$r" in 0) - random_element_string=" inet $table set_${cnt} { $element }" + random_element_string="inet $table set_${cnt} { $element }" ;; - 1) random_element_string="inet $table sett${cnt} { $element timeout $((RANDOM%60))s }" + 1) random_element_string="inet $table sett${cnt} { $element $(random_timeout) }" ;; 2) random_element_string="inet $table dmap_${cnt} { $element : $RANDOM }" ;; - 3) random_element_string="inet $table dmapt${cnt} { $element timeout $((RANDOM%60))s : $RANDOM }" + 3) random_element_string="inet $table dmapt${cnt} { $element $(random_timeout) : $RANDOM }" ;; 4) random_element_string="inet $table vmap_${cnt} { $element : `random_verdict $count` }" ;; - 5) random_element_string="inet $table vmapt${cnt} { $element timeout $((RANDOM%60))s : `random_verdict $count` }" + 5) random_element_string="inet $table vmapt${cnt} { $element $(random_timeout) : `random_verdict $count` }" ;; 6) random_element_string="inet $table setc${cnt} { $element }" ;; @@ -625,11 +651,11 @@ for table in $tables; do esac echo "add element inet $table set_${cnt} { $element }" >> "$tmp" - echo "add element inet $table sett${cnt} { $element timeout $((RANDOM%60))s }" >> "$tmp" + echo "add element inet $table sett${cnt} { $element $(random_timeout) }" >> "$tmp" echo "add element inet $table dmap_${cnt} { $element : $RANDOM }" >> "$tmp" - echo "add element inet $table dmapt${cnt} { $element timeout $((RANDOM%60))s : $RANDOM }" >> "$tmp" + echo "add element inet $table dmapt${cnt} { $element $(random_timeout) : $RANDOM }" >> "$tmp" echo "add element inet $table vmap_${cnt} { $element : `random_verdict $count` }" >> "$tmp" - echo "add element inet $table vmapt${cnt} { $element timeout $((RANDOM%60))s : `random_verdict $count` }" >> "$tmp" + echo "add element inet $table vmapt${cnt} { $element $(random_timeout) : `random_verdict $count` }" >> "$tmp" done done done |