-
Notifications
You must be signed in to change notification settings - Fork 3
/
runGatling.sh
executable file
·221 lines (192 loc) · 9.36 KB
/
runGatling.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
set -ex
kill -9 "$(lsof -t -i :8080)" || true
mvn -version
mvn -ntp clean package
JAVA_VERSION=$(java -version 2>&1 |grep version)
RUST_VERSION=$(rustc --version)
DATE=$(date +"%Y-%m-%d %T")
SB=$(grep spring-boot-starter-parent spring-boot-web/pom.xml -A1|grep -oPm1 "(?<=<version>)[^<]+")
HEL=$(grep helidon-se helidon-se-netty/pom.xml -A1|grep ver|grep -oPm1 "(?<=<version>)[^<]+")
QU=$(grep quarkus.platform.version quarkus/pom.xml |grep -v "\\$"|grep -oPm1 "(?<=<quarkus.platform.version>)[^<]+")
KUMULUZ=$(grep kumuluzee.version eclipse-microprofile-kumuluz-test/pom.xml |grep -v "\\$"|grep -oPm1 "(?<=<kumuluzee.version>)[^<]+")
MICRO=$(grep micronaut-parent micronaut/pom.xml -A1|grep -oPm1 "(?<=<version>)[^<]+")
VERTX=$(grep vertx vertx/pom.xml|grep -oPm1 "(?<=<vertx.version>)[^<]+")
KTOR=$(grep ktor ktor/pom.xml|grep -oPm1 "(?<=<ktor_version>)[^<]+")
KOTLIN=$(grep kotlin ktor/pom.xml|grep -oPm1 "(?<=<kotlin.version>)[^<]+")
OS_NAME=$(uname -a)
FOLDERHOME=`pwd`
MVNTESTCMD="mvn -ntp -f ${FOLDERHOME}/gatling/pom.xml gatling:test -Dusers=8000 -Drepeat=4"
echo "---
layout: post
title: 'Java microservice framework tests in SB:$SB Q:$QU M:$MICRO V:$VERTX H:$HEL Dotnet:7,8,9 $JAVA_VERSION $RUST_VERSION'
date: $DATE
categories: [java,rust,fasterxml,json,'$OS_NAME']
---
In $OS_NAME,
Below is total package generation times for separate modules,
{% highlight bash %}" > test-result.md
mvn -ntp -T 4C test package|grep SUCCESS|grep -Ev "(framework|gatling|BUILD)" >>test-result.md
echo '{% endhighlight %}' >> test-result.md
echo 'Size of created packages:
| Size in MB | Name |
|------------|-------|' >> test-result.md
find ./*/target/ -maxdepth 1 -name "*.jar" ! -name "*shaded*" -size +1M -exec ls -lh {} + | awk '{print "|", $5, "|", $9, "|"}' >>test-result.md
printf '\n\n' >> test-result.md
echo 'Running jars and collecting test results...'
writeGraph(){
TABLE=$1
MR=`echo $TABLE| tr '>' '\n'|grep 'mean response time'|awk '{print $4}'`
R1=`echo $2|sed 's/ //g'|sed 's/-//g'` # clearing empty string and dashes
sed -i "s/$R1/$MR/g" $FOLDERHOME/graph.html
}
checkIs8080Up(){
COUNTER=10
until curl -vsf http://localhost:8080/hello; do
sleep 1
lsof -i :8080 || true
tail log.log
let COUNTER-=1
if [[ "$COUNTER" == '0' ]]; then
exit 1
fi
done
}
test (){
jarPath=$1
verInfo=$2
startTime=$3
projectLink=$4
java --add-opens java.base/java.lang=ALL-UNNAMED -jar $jarPath &> log.log &
JPID=$!
checkIs8080Up
frameworkVersion=`grep -m1 -o "$verInfo.*" log.log`
startTime=`grep -m1 -o "$startTime.*" log.log || true; `
echo "[${frameworkVersion}](${projectLink}) " >> test-result.md
echo $startTime >> test-result.md
printf "\nGatling test starting... for $jarPath"
echo '{% highlight bash %}' >> test-result.md
TABLE=`$MVNTESTCMD|grep -A10 "Global Information"`
echo "$TABLE" >> test-result.md
writeGraph "$TABLE" "$3"
echo '{% endhighlight %}' >> test-result.md
kill -9 $JPID
printf '\n' >> test-result.md
kill -9 "$(lsof -t -i :8080)" || true
}
rustTest (){
exec 3>> somefile.log
exePath=$1
verInfo=$2
$exePath > log.log &
JPID=$!
checkIs8080Up
CARGOP=`echo $exePath |awk -F'/' '{print $2, $4}'|tr ' ' '/'`
frameworkVersion=`grep -m1 -o "$verInfo.*" $CARGOP/Cargo.toml|tr -d '"'`
link=`echo $frameworkVersion| cut -d' ' -f1`
echo "[${frameworkVersion}](http://docs.rs/${link})" >&3
printf "\nGatling test starting... for $exePath"
echo '{% highlight bash %}'>&3
TABLE=`$MVNTESTCMD|grep -A10 "Global Information"`
echo "$TABLE" >&3
writeGraph "$TABLE" "$3"
echo '{% endhighlight %}' >&3
kill -9 $JPID
printf '\n' >&3
sleep 2
cd $FOLDERHOME
cat somefile.log >> test-result.md
rm somefile.log
}
runNativeBinaryTests(){
exePath=$1
title=$2
graphVar=$3
chmod +x "$exePath"
$exePath 2>&1 log.log &
EXETEST=$!
checkIs8080Up
printf '*** \n' >> test-result.md
printf "## $title \n" >> test-result.md
echo '{% highlight bash %}' >> test-result.md
TABLE=`$MVNTESTCMD|grep -A10 "Global Information"`
echo "$TABLE" >> test-result.md
writeGraph "$TABLE" "$graphVar"
echo '{% endhighlight %}' >> test-result.md
printf '\n\n' >> test-result.md
kill -9 $EXETEST
kill -9 "$(lsof -t -i :8080)" || true
}
test "spring-boot-webflux/target/springboot-webflux-demo-$SB.jar" ":: Spring Boot ::" "Started DemoWebFluxApplication" "https://spring.io/projects/spring-boot"
test "spring-boot-web/target/springboot-demo-web-$SB.jar" ":: Spring Boot ::" "Started DemoApplication" "https://spring.io/projects/spring-boot"
test "quarkus/target/quarkus-demo-runner.jar" "powered by Quarkus" "QUARKUS" "https://quarkus.io/"
test "micronaut/target/micronaut-demo-$MICRO.jar" "micronaut version" "Startup completed in" "https://micronaut.io/"
test "vertx/target/vertx-demo-$VERTX-fat.jar" "vertx version" "VERTX" "https://vertx.io/"
test "eclipse-microprofile-kumuluz-test/target/eclipse-microprofile-kumuluz-test-$KUMULUZ.jar" "kumuluz version:" "Server -- Started" "https://ee.kumuluz.com/"
test "helidon-se-netty/target/helidon-quickstart-se.jar" "Helidon SE" "HELIDON" "https://helidon.io/"
test "ktor/target/ktor-demo-${KTOR}-kotlin-${KOTLIN}-jar-with-dependencies.jar" "ktor" "KTOR" "https://ktor.io/"
printf '*** \n' >> test-result.md
printf '## Rust rest services \n' >> test-result.md
echo $RUST_VERSION >> test-result.md
printf '\n\n' >> test-result.md
rm -rf rust-examples
git clone https://github.com/ozkanpakdil/rust-examples.git
mkdir rust-examples/exe
cd rust-examples/exe
wget https://github.com/ozkanpakdil/rust-examples/releases/download/latest/actix-rest-api
wget https://github.com/ozkanpakdil/rust-examples/releases/download/latest/rocket-rest-api
wget https://github.com/ozkanpakdil/rust-examples/releases/download/latest/warp-rest-api
wget https://github.com/ozkanpakdil/rust-examples/releases/download/latest/axum-rest-api
chmod a+x warp-rest-api actix-rest-api rocket-rest-api axum-rest-api
cd ../..
rustTest "./rust-examples/exe/warp-rest-api" "warp =" "WARP"
rustTest "./rust-examples/exe/actix-rest-api" "actix-web =" "ACTIX"
rustTest "./rust-examples/exe/rocket-rest-api" "rocket =" "ROCKET"
rustTest "./rust-examples/exe/axum-rest-api" "axum =" "AXUM"
rm -rf rust-examples
##### DOTNET
wget -qc https://github.com/ozkanpakdil/dotnet-examples/releases/download/latest/Dotnet7Microservice
runNativeBinaryTests "./Dotnet7Microservice" "Dotnet 7 rest service" "DOTNET7AOT"
wget -qc https://github.com/ozkanpakdil/dotnet-examples/releases/download/latest/Dotnet8Microservice
runNativeBinaryTests "./Dotnet8Microservice" "Dotnet 8 rest service" "DOTNET8AOT"
wget -qc https://github.com/ozkanpakdil/dotnet-examples/releases/download/latest/Dotnet9Microservice
runNativeBinaryTests "./Dotnet9Microservice" "Dotnet 9 rest service" "DOTNET9AOT"
##### DOTNET
##### graalvm
wget -qc https://github.com/ozkanpakdil/test-microservice-frameworks/releases/download/latest/quarkus-demo-runner
wget -qc https://github.com/ozkanpakdil/test-microservice-frameworks/releases/download/latest/micronaut-demo
wget -qc https://github.com/ozkanpakdil/test-microservice-frameworks/releases/download/latest/springboot-demo-web
wget -qc https://github.com/ozkanpakdil/test-microservice-frameworks/releases/download/latest/springboot-webflux-demo
wget -qc https://github.com/ozkanpakdil/test-microservice-frameworks/releases/download/latest/vertx-demo
wget -qc https://github.com/ozkanpakdil/test-microservice-frameworks/releases/download/latest/helidon-quickstart-se
wget -qc https://github.com/ozkanpakdil/test-microservice-frameworks/releases/download/latest/ktor-demo
chmod a+x quarkus-demo-runner micronaut-demo springboot-demo-web springboot-webflux-demo vertx-demo helidon-quickstart-se ktor-demo
runNativeBinaryTests "./quarkus-demo-runner" "graalvm native quarkus" "GRAALQ1UARKUS"
runNativeBinaryTests "./micronaut-demo" "graalvm native micronaut" "GRAALM1ICRONAUT"
runNativeBinaryTests "./springboot-demo-web" "graalvm native spring-boot-web" "GRAALSPRING"
runNativeBinaryTests "./springboot-webflux-demo" "graalvm native spring-boot-webflux" "GRAALWEBFLUX"
runNativeBinaryTests "./vertx-demo" "graalvm native vertx" "GRAALV1ERTX"
runNativeBinaryTests "./helidon-quickstart-se" "graalvm native helidon" "GRAALH1ELIDON"
runNativeBinaryTests "./ktor-demo" "graalvm native ktor rest service" "GRAALK1TOR"
printf '*** \n' >> test-result.md
printf '## GraalVM Native Binaries Sizes:
| Size in MB | Name |
|------------|-------|\n' >> test-result.md
for binary in "./quarkus-demo-runner" \
"./micronaut-demo" \
"./springboot-demo-web" \
"./springboot-webflux-demo" \
"./vertx-demo" \
"./helidon-quickstart-se" \
"./ktor-demo"; do
size=$(du -m "$binary" | cut -f1) # Get size in MB
printf "| %s | %s |\n" "$size" "$(basename "$binary")" >> test-result.md
done
printf '\n\n*** \n\n' >> test-result.md
##### graalvm
BUILD_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
printf '[source code for the java and dotnet tests](https://github.com/ozkanpakdil/test-microservice-frameworks) :point_left: ' >> test-result.md
printf '[source code for the rust tests](https://github.com/ozkanpakdil/rust-examples) :point_left: ' >> test-result.md
printf "[github action]($BUILD_URL) :point_left: \n" >> test-result.md
cat graph.html >> test-result.md
cat graph.html