Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
devops-workshop
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Surya Bahadur Kathayat
devops-workshop
Merge requests
!14
Fixed gatling
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fixed gatling
testing2
into
master
Overview
0
Commits
1
Pipelines
0
Changes
3
Merged
Surya Bahadur Kathayat
requested to merge
testing2
into
master
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
3
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
6c59013a
1 commit,
2 years ago
3 files
+
64
−
66
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
gatling/chat/ChatSimulation.scala
+
59
−
61
Options
@@ -8,70 +8,68 @@ import io.gatling.jdbc.Predef._
class
ChatSimulation
extends
Simulation
{
val
httpProtocol
=
http
.
baseU
RL
(
"http://localhost"
)
.
inferHtmlResources
(
BlackList
(
""".*\.css"""
,
""".*\.js"""
,
""".*\.ico"""
),
WhiteList
())
.
accept
Header
(
"
*/*
"
)
.
acceptEncodingHeader
(
"gzip, deflate"
)
.
acceptLanguageHeader
(
"no,en;q=0.9,en-US;q=0.8,nb-NO;q=0.7,nb;q=0.6"
)
.
userAgentHeader
(
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36"
)
val
httpProtocol
=
http
// 4
.
baseU
rl
(
"http://localhost"
)
// 5
.
acceptHeader
(
"*/*"
)
// 6
.
doNotTrack
Header
(
"
1
"
)
.
acceptEncodingHeader
(
"gzip, deflate"
)
.
acceptLanguageHeader
(
"no,en;q=0.9,en-US;q=0.8,nb-NO;q=0.7,nb;q=0.6"
)
.
userAgentHeader
(
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36"
)
val
headers_0
=
Map
(
"Content-Type"
->
"application/json; charset=utf-8;"
,
"Origin"
->
"http://localhost"
)
val
headers_0
=
Map
(
"Content-Type"
->
"application/json; charset=utf-8;"
,
"Origin"
->
"http://localhost"
)
val
headers_3
=
Map
(
"Accept"
->
"application/json"
,
"Content-Type"
->
"application/json"
,
"Origin"
->
"http://localhost"
)
val
headers_3
=
Map
(
"Accept"
->
"application/json"
,
"Content-Type"
->
"application/json"
,
"Origin"
->
"http://localhost"
)
val
uri1
=
"http://localhost/api"
val
uri1
=
"http://localhost/api"
private
val
userFeeder
=
csv
(
"usernames.csv"
).
random
private
val
userFeeder
=
csv
(
"usernames.csv"
).
random
val
scn
=
scenario
(
"ChatSimulation"
)
.
feed
(
userFeeder
)
.
exec
(
http
(
"Login"
)
.
post
(
"/api/user"
)
.
headers
(
headers_0
)
.
body
(
StringBody
(
"""{
| "username": "${username}",
| "password": "passordpassord"
|}"""
.
stripMargin
))
.
resources
(
http
(
"Fetch users"
)
.
get
(
"/api/user/"
))
.
check
(
jsonPath
(
"$[?(@.username=='${username}')].userId"
).
findAll
.
saveAs
(
"userId"
)
))
.
pause
(
6
)
.
exec
(
http
(
"Click on Ola"
)
.
get
(
"/api/message/${userId(0)}/1"
))
.
pause
(
16
)
.
exec
(
http
(
"Send msg to Ola"
)
.
post
(
"/api/message"
)
.
headers
(
headers_3
)
.
body
(
StringBody
(
"""{
| "userId1": ${userId(0)},
| "userId2": 1,
| "messageContent":"Hei fra gatling"
|}"""
.
stripMargin
)))
.
pause
(
15
)
.
exec
(
http
(
"Click on kari"
)
.
get
(
"/api/message/${userId(0)}/2"
))
.
pause
(
2
)
.
exec
(
http
(
"Send msg to Kari"
)
.
post
(
"/api/message"
)
.
headers
(
headers_3
)
.
body
(
StringBody
(
"""{
| "userId1": ${userId(0)},
| "userId2": 2,
| "messageContent":"Hei fra gatling"
|}"""
.
stripMargin
)))
val
scn
=
scenario
(
"ChatSimulation"
)
.
feed
(
userFeeder
)
.
exec
(
http
(
"Login"
)
.
post
(
"/api/user"
)
.
headers
(
headers_0
)
.
body
(
StringBody
(
"""{
| "username": "${username}",
| "password": "passordpassord"
|}"""
.
stripMargin
))
.
resources
(
http
(
"Fetch users"
)
.
get
(
"/api/user/"
))
.
check
(
jsonPath
(
"$[?(@.username=='${username}')].userId"
).
findAll
.
saveAs
(
"userId"
)
))
.
pause
(
6
)
.
exec
(
http
(
"Click on Ola"
)
.
get
(
"/api/message/${userId(0)}/1"
))
.
pause
(
16
)
.
exec
(
http
(
"Send msg to Ola"
)
.
post
(
"/api/message"
)
.
headers
(
headers_3
)
.
body
(
StringBody
(
"""{
| "userId1": ${userId(0)},
| "userId2": 1,
| "messageContent":"Hei fra gatling"
|}"""
.
stripMargin
)))
.
pause
(
15
)
.
exec
(
http
(
"Click on kari"
)
.
get
(
"/api/message/${userId(0)}/2"
))
.
pause
(
2
)
.
exec
(
http
(
"Send msg to Kari"
)
.
post
(
"/api/message"
)
.
headers
(
headers_3
)
.
body
(
StringBody
(
"""{
| "userId1": ${userId(0)},
| "userId2": 2,
| "messageContent":"Hei fra gatling"
|}"""
.
stripMargin
)))
setUp
(
scn
.
inject
(
atOnceUsers
(
100
))).
protocols
(
httpProtocol
)
}
setUp
(
scn
.
inject
(
atOnceUsers
(
100
))).
protocols
(
httpProtocol
)
}
\ No newline at end of file
Loading