-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestWorkload.sh
More file actions
91 lines (76 loc) · 1.8 KB
/
testWorkload.sh
File metadata and controls
91 lines (76 loc) · 1.8 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
set -euo pipefail
source bashUtilFunctions.sh
pids=()
dataset_url="https://db.in.tum.de/teaching/ws2223/clouddataprocessing/data/clickbench.00.csv"
write_urls=()
function prepare_urls_for_workload() {
# Download data
curl --silent -o dataset.csv "$dataset_url"
counter=0
# Fill write_urls array
while read line; do
if [ $counter -eq 500 ]; then
break
fi
write_urls+=("$line")
counter=$((counter + 1))
done <dataset.csv
}
function cleanup {
# Kill all background processes
for pid in "${pids[@]}"; do
kill -s TERM "$pid" >/dev/null 2>&1
done
# Remove files
rm -f loadBalancerOutput.txt
rm -f raft*Output.txt
rm -f raft_*.db
rm -f dataset.csv
if [[ $? -ne 0 ]]; then
echo "incorrect"
else
echo "correct"
fi
}
function check_correctness() {
output=$1
if [ $(echo "$output" | wc -l) -ne 2 ]; then
exit 1
fi
}
trap cleanup EXIT
# Spawn raft nodes
for i in {0..3}; do
cmake-build-debug/src/raft "$i" >"raft${i}Output.txt" &
pids+=($!)
sleep 2
done
# Spawn the load balancer
cmake-build-debug/src/loadBalancer >"loadBalancerOutput.txt" &
pids+=($!)
prepare_urls_for_workload
sleep 25
# Write (should return success)
for url in "${write_urls[@]}"; do
elapsed_time=$({ time {
client_output=$(cmake-build-debug/src/client "write" "$url")
if [ $(echo "$client_output" | wc -l) -ne 2 ]; then
exit 1
fi
}; } 2>&1 1>>/dev/null)
echo "$elapsed_time" >>writeTime.txt
done
echo "write bitt"
# Wait leader to replicate log to other raft nodes
sleep 20
# Read
for url in "${write_urls[@]}"; do
elapsed_time=$({ time {
output=$(cmake-build-debug/src/client "read" "$url")
if [ $(echo "$output" | wc -l) -ne 2 ]; then
exit 1
fi
}; } 2>&1 1>>/dev/null)
echo "$elapsed_time" >>readTime.txt
done