Last active
May 13, 2024 17:28
-
-
Save fulghum/ce1c471940d690d3d66893c3005dbf40 to your computer and use it in GitHub Desktop.
Simple database load generator script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Change PORT if your Dolt sql-server is running on a different port, and change DATABASE if your database | |
# is named a different name | |
PORT=11234 | |
DATABASE=datadogTestDb | |
# Create the test table if it doesn't exist yet | |
mysql -uroot --port $PORT --protocol TCP -e 'CREATE TABLE IF NOT EXISTS testData (i INT);' $DATABASE | |
# Loop indefinitely | |
while true; do | |
# Randomly choose a command number between 1 and 5 | |
cmd=$((RANDOM % 5 + 1)) | |
# Execute the chosen command | |
case $cmd in | |
1) mysql -uroot --port $PORT --protocol TCP -e 'insert into testData values(rand()*100); select sleep(rand()*2);' $DATABASE & ;; | |
2) mysql -uroot --port $PORT --protocol TCP -e 'insert into testData values(rand()*100); select sleep(rand()*2);' $DATABASE & ;; | |
3) mysql -uroot --port $PORT --protocol TCP -e 'delete from testData where i > 100; select sleep(rand()*2);' $DATABASE & ;; | |
4) mysql -uroot --port $PORT --protocol TCP -e 'update testData set i = 42; select sleep(rand()*2);' $DATABASE & ;; | |
5) mysql -uroot --port $PORT --protocol TCP -e 'select * from testData; select sleep(rand()*2);' $DATABASE & ;; | |
esac | |
# Sleep for a random time between 1 and 3 seconds | |
sleep $((RANDOM % 3 + 1)) | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment