Skip to content

Commit

Permalink
Update swarm state with spawnRate and numUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Baldwin committed Jan 8, 2024
1 parent fe47974 commit 4c4b79b
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 259 deletions.
250 changes: 0 additions & 250 deletions locust/webui/dist/assets/index-01afe4fa.js

This file was deleted.

237 changes: 237 additions & 0 deletions locust/webui/dist/assets/index-d4b87b54.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locust/webui/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="theme-color" content="#000000" />

<title>Locust</title>
<script type="module" crossorigin src="/assets/index-01afe4fa.js"></script>
<script type="module" crossorigin src="/assets/index-d4b87b54.js"></script>
</head>
<body>
<div id="root"></div>
Expand Down
10 changes: 5 additions & 5 deletions locust/webui/src/components/SwarmForm/SwarmEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { useStartSwarmMutation } from 'redux/api/swarm';
import { ISwarmState } from 'redux/slice/swarm.slice';
import { IRootState } from 'redux/store';

type ISwarmFormInput = Pick<ISwarmState, 'spawnRate' | 'userCount'>;
type ISwarmFormInput = Pick<ISwarmState, 'spawnRate' | 'numUsers'>;

interface ISwarmForm extends ISwarmFormInput {
onSubmit: () => void;
}

function SwarmEditForm({ onSubmit, spawnRate, userCount }: ISwarmForm) {
function SwarmEditForm({ onSubmit, numUsers, spawnRate }: ISwarmForm) {
const [startSwarm] = useStartSwarmMutation();

const onEditSwarm = (inputData: ISwarmFormInput) => {
Expand All @@ -28,7 +28,7 @@ function SwarmEditForm({ onSubmit, spawnRate, userCount }: ISwarmForm) {
<Form<ISwarmFormInput> onSubmit={onEditSwarm}>
<Box sx={{ my: 2, display: 'flex', flexDirection: 'column', rowGap: 4 }}>
<TextField
defaultValue={userCount || 1}
defaultValue={numUsers || 1}
label='Number of users (peak concurrency)'
name='userCount'
/>
Expand All @@ -48,9 +48,9 @@ function SwarmEditForm({ onSubmit, spawnRate, userCount }: ISwarmForm) {
);
}

const storeConnector = ({ swarm: { spawnRate, userCount } }: IRootState) => ({
const storeConnector = ({ swarm: { spawnRate, numUsers } }: IRootState) => ({
spawnRate,
userCount,
numUsers,
});

export default connect(storeConnector)(SwarmEditForm);
9 changes: 7 additions & 2 deletions locust/webui/src/components/SwarmForm/SwarmForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ function SwarmForm({
const [startSwarm] = useStartSwarmMutation();

const onStartSwarm = (inputData: ISwarmFormInput) => {
setSwarm({ state: SWARM_STATE.RUNNING, host: inputData.host || host });
setSwarm({
state: SWARM_STATE.RUNNING,
host: inputData.host || host,
runTime: inputData.runTime,
spawnRate: Number(inputData.spawnRate) || null,
numUsers: Number(inputData.userCount) || null,
});

startSwarm(inputData);
};
Expand All @@ -85,7 +91,6 @@ function SwarmForm({
<Select label='Shape Class' name='shapeClass' options={availableShapeClasses} />
</>
)}

<TextField
defaultValue={(isShape && '-') || numUsers || 1}
disabled={!!isShape}
Expand Down
2 changes: 1 addition & 1 deletion locust/webui/src/redux/slice/swarm.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface ISwarmState {
numUsers: number | null;
overrideHostWarning: boolean;
percentilesToChart: number[];
runTime?: number;
runTime?: string | number;
showUserclassPicker: boolean;
spawnRate: number | null;
state: string;
Expand Down

0 comments on commit 4c4b79b

Please sign in to comment.