Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sprachschulsystem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Jan Pokorný
Sprachschulsystem
Commits
b2a6b462
There was an error fetching the commit references. Please try again later.
Commit
b2a6b462
authored
1 year ago
by
Jan Pokorný
Browse files
Options
Downloads
Patches
Plain Diff
WIP: adding locustfile.py with functional create course+lecture
parent
fb23854f
No related branches found
No related tags found
1 merge request
!37
M3 locust
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/locustfile.py
+88
-0
88 additions, 0 deletions
application/locustfile.py
with
88 additions
and
0 deletions
application/locustfile.py
0 → 100644
+
88
−
0
View file @
b2a6b462
import
random
from
locust
import
HttpUser
,
task
,
between
from
locust.exception
import
StopUser
class
StudentActor
(
HttpUser
):
wait_time
=
between
(.
250
,
.
500
)
weight
=
1
course_ids
=
set
()
lecture_ids
=
set
()
student_ids
=
set
()
@task
(
3
)
def
get_courses_english
(
self
):
self
.
client
.
get
(
'
/courses/findAllByLang?lang=ENGLISH
'
)
@task
(
3
)
def
get_courses_spanish
(
self
):
self
.
client
.
get
(
'
/courses/findAllByLang?lang=SPANISH
'
)
@task
def
enrol
(
self
):
self
.
client
.
get
(
f
'
http://localhost:5000/courses/enrol/
{
1
}
?studentId=
{
1
}
'
)
@task
def
get_lecture_by_id
(
self
):
self
.
client
.
get
(
f
'
/lectures/findByCourse?courseId=
{
1
}
'
)
def
on_start
(
self
):
# TODO auth
return
super
().
on_start
()
class
LecturerActor
(
HttpUser
):
weight
=
0
fixed_count
=
1
wait_time
=
between
(.
100
,
.
400
)
courses_created
=
0
lecture_created
=
0
course_ids
=
set
()
@task
def
new_course
(
self
):
if
self
.
courses_created
<
3
:
self
.
client
.
headers
[
'
Content-Type
'
]
=
"
application/json
"
response
=
self
.
client
.
post
(
"
/courses
"
,
json
=
{
"
name
"
:
"
string
"
,
"
capacity
"
:
10
,
"
language
"
:
random
.
choice
([
"
SPANISH
"
,
"
ENGLISH
"
]),
"
proficiency
"
:
random
.
choice
([
"
A1
"
,
"
B1
"
,
"
C1
"
])
}
)
values
=
response
.
json
()
print
(
"
course
"
+
str
(
values
[
'
id
'
])
+
"
created.
"
)
self
.
course_ids
.
add
(
values
[
'
id
'
])
self
.
courses_created
+=
1
@task
def
new_lecture
(
self
):
if
self
.
courses_created
>
0
and
self
.
lecture_created
<
10
:
self
.
client
.
headers
[
'
Content-Type
'
]
=
"
application/json
"
response
=
self
.
client
.
post
(
"
/lectures
"
,
json
=
{
"
lectureFrom
"
:
"
2024-04-26T18:06:30.658Z
"
,
"
lectureTo
"
:
"
2024-04-27T18:06:30.658Z
"
,
"
topic
"
:
"
string
"
,
"
capacity
"
:
random
.
choice
([
10
,
20
,
30
]),
"
courseId
"
:
random
.
choice
(
list
(
self
.
course_ids
))
}
)
print
(
"
lecture
"
+
str
(
response
.
json
()[
'
id
'
])
+
"
created.
"
)
self
.
lecture_created
+=
1
if
self
.
lecture_created
>=
9
:
raise
StopUser
()
def
on_start
(
self
):
# TODO auth
return
super
().
on_start
()
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