-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add support for load shapes - add load shapes for step load and spike patterns - update dependencies - update README.md
- Loading branch information
Showing
10 changed files
with
1,198 additions
and
1,030 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from locust import LoadTestShape | ||
|
||
|
||
class SpikeLoadShape(LoadTestShape): | ||
""" | ||
A step load shape class that has the following shape: | ||
10% of users start at the beginning for 40% of the test duration, then 100% of users for 20% of the test duration, | ||
then 10% of users until the end of the test duration. | ||
""" | ||
|
||
use_common_options = True | ||
|
||
def tick(self): | ||
run_time = self.get_run_time() | ||
total_run_time = self.runner.environment.parsed_options.run_time | ||
period_duration = round(total_run_time / 10) | ||
spike_run_time_start = period_duration * 4 | ||
spike_run_time_end = period_duration * 6 | ||
|
||
if run_time < spike_run_time_start: | ||
user_count = round(self.runner.environment.parsed_options.num_users / 10) | ||
return user_count, self.runner.environment.parsed_options.spawn_rate | ||
elif run_time < spike_run_time_end: | ||
return self.runner.environment.parsed_options.num_users, self.runner.environment.parsed_options.spawn_rate | ||
elif run_time < total_run_time: | ||
user_count = round(self.runner.environment.parsed_options.num_users / 10) | ||
return user_count, self.runner.environment.parsed_options.spawn_rate | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import math | ||
|
||
from locust import LoadTestShape | ||
|
||
|
||
class StepLoadShape(LoadTestShape): | ||
""" | ||
This load shape determines the number of steps by using the total number of users divided by the spawn rate. | ||
Duration of each step is calculated by dividing the total run time by the number of steps equally. | ||
""" | ||
|
||
use_common_options = True | ||
|
||
def tick(self): | ||
run_time = self.get_run_time() | ||
total_run_time = self.runner.environment.parsed_options.run_time | ||
|
||
if run_time < total_run_time: | ||
step = self.runner.environment.parsed_options.spawn_rate | ||
users = self.runner.environment.parsed_options.num_users | ||
no_of_steps = round(users / step) | ||
step_time = total_run_time / no_of_steps | ||
user_count = min(step * math.ceil(run_time / step_time), users) | ||
return user_count, step | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.