-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathrandgen_to_sql.sh
executable file
·29 lines (25 loc) · 1.23 KB
/
randgen_to_sql.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Created by Roel Van de Paar, Percona LLC
RANDOM_RUNS_PER_GRAMMAR=50
QUERIES_PER_GRAMMAR=50
DSN="dummy:print"
#DSN="dbi:mysql:host=127.0.0.1:port=14270:user=root:database=sakila"
if [ ! -r gensql.pl ]; then
echo "Assert: we're not in a randgen directory, as ./gensql.pl was not found"
fi
rm -f /tmp/newsql.sql
touch /tmp/newsql.sql
for FILE in $(find . | grep "\.yy$"); do
echo "Processing ${FILE}..."
for LOOP in $(seq 0 ${RANDOM_RUNS_PER_GRAMMAR}); do
RANDOM=$(date +%s%N | cut -b14-19) # RANDOM: Random entropy pool init
SEED=$(echo $RANDOM$RANDOM$RANDOM | sed 's/..\(......\).*/\1/') # Random number generator (6 digits)
MASK=$(echo $RANDOM$RANDOM$RANDOM | sed 's/..\(......\).*/\1/') # Random number generator (6 digits)
MASK_LEVEL=$(echo $[ $RANDOM % 3 ])
if [ ${LOOP} -eq 0 ]; then # Only show errors for the first run, much less screen filling
./gensql.pl --dsn=${DSN} --grammar=${FILE} --seed=${SEED} --queries=${QUERIES_PER_GRAMMAR} --mask-level=${MASK_LEVEL} --mask=${MASK} >> /tmp/newsql.sql
else
./gensql.pl --dsn=${DSN} --grammar=${FILE} --seed=${SEED} --queries=${QUERIES_PER_GRAMMAR} --mask-level=${MASK_LEVEL} --mask=${MASK} >> /tmp/newsql.sql 2>/dev/null
fi
done
done