Skip to content

Commit

Permalink
Merge pull request #2824 from andrewbaldwin44/feature/locust-cloud
Browse files Browse the repository at this point in the history
Integrations for Locust Cloud
  • Loading branch information
cyberw authored Aug 2, 2024
2 parents 45c6166 + 1c0a4e2 commit 5209718
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
from .util.load_locustfile import load_locustfile
from .util.timespan import parse_timespan

# import external plugins if installed to allow for registering custom arguments etc
try:
# import locust_plugins if it is installed, to allow it to register custom arguments etc
import locust_plugins # pyright: ignore[reportMissingImports]
except ModuleNotFoundError:
pass
try:
import locust_cloud # pyright: ignore[reportMissingImports]
except ModuleNotFoundError:
pass

version = locust.__version__

Expand Down
4 changes: 4 additions & 0 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from .stats import StatsCSV, StatsCSVFileWriter, StatsErrorDict, sort_stats
from .user.inspectuser import get_ratio
from .util.cache import memoize
from .util.date import format_utc_timestamp
from .util.timespan import parse_timespan

if TYPE_CHECKING:
Expand Down Expand Up @@ -617,6 +618,8 @@ def update_template_args(self):
else None
)

start_time = format_utc_timestamp(stats.start_time)

self.template_args = {
"locustfile": self.environment.locustfile,
"state": self.environment.runner.state,
Expand All @@ -634,6 +637,7 @@ def update_template_args(self):
and not (self.userclass_picker_is_active or self.environment.shape_class.use_common_options)
),
"stats_history_enabled": options and options.stats_history_enabled,
"start_time": start_time,
"tasks": dumps({}),
"extra_options": extra_options,
"run_time": options and options.run_time,
Expand Down
1 change: 1 addition & 0 deletions locust/webui/src/redux/slice/swarm.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface ISwarmState {
runTime?: string | number;
showUserclassPicker: boolean;
spawnRate: number | null;
startTime: string;
state: string;
statsHistoryEnabled: boolean;
tasks: string;
Expand Down
1 change: 1 addition & 0 deletions locust/webui/src/test/mocks/swarmState.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const swarmStateMock = {
showUserclassPicker: false,
spawnRate: null,
state: 'ready',
startTime: '',
percentilesToChart: percentilesToChart,
statsHistoryEnabled: false,
tasks: '{}',
Expand Down

0 comments on commit 5209718

Please sign in to comment.