-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.sh
executable file
·93 lines (62 loc) · 2.03 KB
/
run-tests.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
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
92
93
#!/bin/bash
# Function to log progress
log_progress() {
# clear_terminal
printf "\033c"
echo "-- fastn update/performance test scenarios --"
echo $1
}
process_logs() {
echo "# $dir_name"
echo
# Process logs to count occurrences
read_content_count=$(grep 'read_content' "$temp_trace_file" | wc -l)
write_content_count=$(grep 'write_content' "$temp_trace_file" | wc -l)
# Print counts in table
echo "| Event Type | Count |"
echo "| ---------------- | ---------------- |"
echo "| read_content | $read_content_count |"
echo "| write_content | $write_content_count |"
# Extract read_content data
echo "## Read Content Data:"
grep -n 'read_content' "$temp_trace_file" | sed -n 's/.*read_content \([^ ]*\).*/- \1/p'
# Extract write_content data
echo "## Write Content Data:"
grep -n 'write_content' "$temp_trace_file" | sed -n 's/.*write_content \([^ ]*\).*/- \1/p'
echo
}
process_directory() {
local dir=$1
dir_name=$(basename "$dir")
cd "$dir" || { echo "Error: Could not enter directory $dir"; return; }
temp_trace_file="traces.log"
report_file="REPORT.md"
log_progress "Entered $dir_name"
if [ -d ".packages" ]; then
echo "Removing .packages directory"
rm -rf .packages
echo "Removed .packages directory"
fi
log_progress "Starting the server"
(fastn --trace serve | tee "$temp_trace_file") > /dev/null 2>&1 &
log_progress "Server started"
log_progress "Testing $dir_name ..."
sleep 2
open -a Safari --background "http://127.0.0.1:8000/"
sleep 5
pkill Safari
log_progress "$dir_name testing complete!"
sh ../kill.sh > /dev/null 2>&1
log_progress "Now generating report for $dir_name ..."
process_logs > $report_file
log_progress "Report generated for $dir_name!"
cd ..
}
if [ $# -eq 0 ]; then
for dir in */; do
process_directory "$dir"
done
else
process_directory "$1"
fi
log_progress "All done!"