Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PA165 - Airport - project
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
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
Ján Macháček
PA165 - Airport - project
Commits
66c6db01
There was an error fetching the commit references. Please try again later.
Commit
66c6db01
authored
1 year ago
by
Ján Macháček
Browse files
Options
Downloads
Patches
Plain Diff
scenario - adding on start
parent
a32a0660
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
locust-scenarios/locustfile.py
+68
-0
68 additions, 0 deletions
locust-scenarios/locustfile.py
with
68 additions
and
0 deletions
locust-scenarios/locustfile.py
+
68
−
0
View file @
66c6db01
...
...
@@ -2,6 +2,74 @@ from locust import HttpUser, task
class
Admin
(
HttpUser
):
def
on_start
(
self
):
#create airplane type - just once because creating airplane type more times would report fail due to not unique name
self
.
client
.
post
(
"
:8080/api/airplaneTypes
"
,
json
=
{
"
name
"
:
"
Práškovač 2000
"
})
self
.
client
.
post
(
"
:8080/api/countries
"
,
json
=
{
"
name
"
:
"
Slovensko
"
})
self
.
client
.
post
(
"
:8080/api/cities
"
,
json
=
{
"
name
"
:
"
Holíč
"
})
self
.
client
.
post
(
"
:8080/api/cities
"
,
json
=
{
"
name
"
:
"
Senica
"
})
self
.
client
.
post
(
"
:8080/api/cities/1/countries/1
"
,
json
=
{
"
name
"
:
"
Senica
"
})
self
.
client
.
post
(
"
:8080/api/cities/2/countries/1
"
,
json
=
{
"
name
"
:
"
Senica
"
})
#create 2 airports - just once because airport need to have unique code
self
.
client
.
post
(
"
:8080/api/airports
"
,
json
=
{
"
name
"
:
"
Trávník Holíč
"
,
"
code
"
:
"
TH
"
,
"
location
"
:
{
"
latitude
"
:
48.48440
,
"
longitude
"
:
17.9380
}
})
self
.
client
.
post
(
"
:8080/api/airports
"
,
json
=
{
"
name
"
:
"
Hlinište Senica
"
,
"
code
"
:
"
HS
"
,
"
location
"
:
{
"
latitude
"
:
48.40500
,
"
longitude
"
:
17.22000
}
})
def
on_start
(
self
):
tenant_id
=
"
tenant123
"
client_id
=
"
client123
"
secret
=
"
secret123
"
scope
=
"
api://123/.default
"
body
=
"
grant_type=client_credentials&client_id=
"
+
client_id
+
"
&client_secret=
"
+
secret
+
"
&scope=
"
+
scope
tokenResponse
=
self
.
client
.
post
(
f
"
https://login.microsoftonline.com/
{
tenant_id
}
/oauth2/v2.0/token
"
,
body
,
headers
=
{
"
ContentType
"
:
"
application/x-www-form-urlencoded
"
}
)
response
=
tokenResponse
.
json
()
responseToken
=
response
[
'
access_token
'
]
self
.
headers
=
{
'
Authorization
'
:
'
Bearer
'
+
responseToken
}
@task
def
create_airplane_type
(
self
):
self
.
client
.
post
(
"
:8080/api/airplaneTypes
"
,
json
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment