forked from ozkanpakdil/test-microservice-frameworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runGatling.sh
executable file
·257 lines (220 loc) · 8.85 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/bin/bash
> test-result.md
mvn -ntp clean package
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not perform mvn clean package, exit code [$rc]; exit $rc
fi
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>)[^<]+")
MICRO=$(grep parent micronaut/pom.xml -A1|grep -oPm1 "(?<=<version>)[^<]+")
VERTX=$(grep vertx vertx/pom.xml|grep -oPm1 "(?<=<vertx.version>)[^<]+")
sed -i "s/Spring boot:.*/Spring boot:$SB/g" README.md
sed -i "s/Helidon:.*/Helidon:$HEL/g" README.md
sed -i "s/Quarkus:.*/Quarkus:$QU/g" README.md
sed -i "s/Micronaut:.*/Micronaut:$MICRO/g" README.md
sed -i "s/Vertx:.*/Vertx:$VERTX/g" README.md
OS_NAME=$(uname -a)
echo "---
layout: post
title: 'Java microservice framework tests in SB:$SB Q:$QU M:$MICRO V:$VERTX H:$HEL Dotnet:6 $JAVA_VERSION $RUST_VERSION'
date: $DATE
categories: java,rust,fasterxml,json,$OS_NAME
---
In $OS_NAME, Here 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
ls -lh */target/*.jar|grep M|grep -v shaded|awk '{print "|",$5,"|",$9,"|"}' >>test-result.md
printf '\n\n' >> test-result.md
echo 'Running jars and collecting test results...'
test (){
jarPath=$1
verInfo=$2
startTime=$3
projectLink=$4
java --add-opens java.base/java.lang=ALL-UNNAMED -jar $jarPath > log.log &
JPID=$!
COUNTER=120
until curl -sf http://localhost:8080/hello; do
printf '.'
sleep 1
let COUNTER-=1
if [[ "$COUNTER" == '0' ]]; then
break
fi
done
frameworkVersion=`grep -m1 -o "$verInfo.*" log.log`
startTime=`grep -m1 -o "$startTime.*" log.log`
echo "[${frameworkVersion}](${projectLink}) " >> test-result.md
echo $startTime >> test-result.md
printf "\nGatling test starting... for $jarPath"
echo '{% highlight bash %}' >> test-result.md
mvn -ntp -f gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> test-result.md
echo '{% endhighlight %}' >> test-result.md
kill -9 $JPID
printf '\n' >> test-result.md
sleep 2
}
rustTest (){
exec 3>> somefile.log
exePath=$1
verInfo=$2
retDir=`pwd`
cd $exePath
cargo run > log.log &
JPID=$!
COUNTER=120
until curl -sf http://localhost:8080/hello; do
printf '.'
sleep 1
let COUNTER-=1
if [[ "$COUNTER" == '0' ]]; then
break
fi
done
set -x
frameworkVersion=`grep -m1 -o "$verInfo.*" 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
mvn -ntp -f $retDir/gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >&3
echo '{% endhighlight %}' >&3
kill -9 $JPID
printf '\n' >&3
sleep 2
cd $retDir
cat somefile.log >> test-result.md
rm somefile.log
}
test "spring-boot-webflux/target/springboot-demo-0.0.1-SNAPSHOT.jar" ":: Spring Boot ::" "Started DemoWebFluxApplication" "https://spring.io/projects/spring-boot"
test "spring-boot-web/target/springboot-demo-web-0.0.1-SNAPSHOT.jar" ":: Spring Boot ::" "Started DemoApplication" "https://spring.io/projects/spring-boot"
test "quarkus/target/quarkus-demo-1.0.0-SNAPSHOT-runner.jar" "powered by Quarkus" "WWWWW" "https://quarkus.io/"
test "micronaut/target/micronaut-demo-0.1.jar" "micronaut version" "Startup completed in" "https://micronaut.io/"
test "vertx/target/vertx-demo-1.0.0-SNAPSHOT-fat.jar" "vertx version" "XXXXX" "https://vertx.io/"
test "eclipse-microprofile-kumuluz-test/target/eclipse-microprofile-kumuluz-test-1.0-SNAPSHOT.jar" "kumuluz version:" "Server -- Started" "https://ee.kumuluz.com/"
test "helidon-se-netty/target/helidon-quickstart-se.jar" "Helidon SE" "XXXXX" "https://helidon.io/"
# too slow test "ktor-demo/target/ktor-demo-1.0.1-SNAPSHOT-jar-with-dependencies.jar" "ktor" "XXXXX"
printf '*** \n' >> test-result.md
printf '## Rust rest services \n' >> test-result.md
$RUST_VERSION >> test-result.md
printf '\n\n' >> test-result.md
git clone https://github.com/ozkanpakdil/rust-examples.git
cd rust-examples/warp-rest-api
cargo build
cd ../actix-rest-api/
cargo build
cd ../../
rustTest "rust-examples/warp-rest-api" "warp ="
rustTest "rust-examples/actix-rest-api" "actix-web ="
rm -rf rust-examples
##### DOTNET
dotnet build --configuration Release Dotnet6Microservice/
cd Dotnet6Microservice
./bin/Release/net6.0/Dotnet6Microservice &
DOTNETTEST=$!
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not start Dotnet6Microservice [$rc]; exit $rc
fi
sleep 5
printf '*** \n' >> ../test-result.md
printf '## Dotnet 6 rest service \n' >> ../test-result.md
echo '{% highlight bash %}' >> ../test-result.md
mvn -ntp -f ../gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> ../test-result.md
echo '{% endhighlight %}' >> ../test-result.md
printf '\n\n' >> ../test-result.md
kill -9 $DOTNETTEST
cd ..
##### DOTNET
##### graalvm
gu install native-image
mvn -ntp package -Pnative,native-image -Dpackaging=native-image -DskipTests
set -x
./quarkus/target/quarkus-demo-1.0.0-SNAPSHOT-runner &
EXETEST=$!
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not start quarkus native [$rc]; exit $rc
fi
printf '*** \n' >> test-result.md
printf '## graalvm native quarkus rest service \n' >> test-result.md
echo '{% highlight bash %}' >> test-result.md
mvn -ntp -f ./gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> test-result.md
echo '{% endhighlight %}' >> test-result.md
kill -9 $EXETEST
printf '\n\n' >> test-result.md
./micronaut/target/micronaut-demo &
EXETEST=$!
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not start micronaut native [$rc]; exit $rc
fi
printf '## graalvm native micronaut rest service \n' >> test-result.md
echo '{% highlight bash %}' >> test-result.md
mvn -ntp -f ./gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> test-result.md
echo '{% endhighlight %}' >> test-result.md
kill -9 $EXETEST
printf '\n\n' >> test-result.md
./spring-boot-web/target/springboot-demo-web &
EXETEST=$!
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not start spring-boot-web native [$rc]; exit $rc
fi
printf '## graalvm native spring-boot-web rest service \n' >> test-result.md
echo '{% highlight bash %}' >> test-result.md
mvn -ntp -f ./gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> test-result.md
echo '{% endhighlight %}' >> test-result.md
kill -9 $EXETEST
printf '\n\n' >> test-result.md
./spring-boot-webflux/target/springboot-demo &
EXETEST=$!
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not start spring-boot-webflux native [$rc]; exit $rc
fi
printf '## graalvm native spring-boot-webflux rest service \n' >> test-result.md
echo '{% highlight bash %}' >> test-result.md
mvn -ntp -f ./gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> test-result.md
echo '{% endhighlight %}' >> test-result.md
kill -9 $EXETEST
printf '\n\n' >> test-result.md
./vertx/target/vertx-demo &
EXETEST=$!
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not start vertx native [$rc]; exit $rc
fi
printf '## graalvm native vertx rest service \n' >> test-result.md
echo '{% highlight bash %}' >> test-result.md
mvn -ntp -f ./gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> test-result.md
echo '{% endhighlight %}' >> test-result.md
kill -9 $EXETEST
printf '\n\n' >> test-result.md
./helidon-se-netty/target/helidon-quickstart-se &
EXETEST=$!
rc=$?
if [ $rc -ne 0 ] ; then
echo Could not start helidon native [$rc]; exit $rc
fi
printf '## graalvm native helidon rest service \n' >> test-result.md
echo '{% highlight bash %}' >> test-result.md
mvn -ntp -f ./gatling/pom.xml gatling:test -Dusers=2000 -Drepeat=2|grep -A10 "Global Information" >> test-result.md
echo '{% endhighlight %}' >> test-result.md
kill -9 $EXETEST
printf '\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