Skip to content

Instantly share code, notes, and snippets.

@anderbubble
Created June 9, 2020 06:25
Show Gist options
  • Save anderbubble/027de8b80366cd63df34b3838a7bab1d to your computer and use it in GitHub Desktop.
Save anderbubble/027de8b80366cd63df34b3838a7bab1d to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
TEST_DIR="$1"
TEST_FILE="$2"
ITERATIONS="$3"
function main
{
for i in $(seq $ITERATIONS)
do
iput_random_file
if [[ $((RANDOM % 2)) == '1' ]]
then
irm_random_file
fi
done
}
function iput_random_file
{
local target_dir="${TEST_DIR}/$(($RANDOM % 10))$(($RANDOM % 10))"
imkdir -p "${target_dir}"
iput -f "$TEST_FILE" "${target_dir}/$(($RANDOM % 10))"
}
function irm_random_file
{
irm "$(iquest "%s/%s" "SELECT COLL_NAME, DATA_NAME where COLL_NAME LIKE '${TEST_DIR}/%'" | sort -R | head -n 1)"
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment