Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of requests lower than expected in web UI #3001

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions locust/webui/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import { fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import _import from 'eslint-plugin-import';
import prettier from 'eslint-plugin-prettier';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import unusedImports from 'eslint-plugin-unused-imports';
import _import from 'eslint-plugin-import';
import { fixupPluginRules } from '@eslint/compat';
import tsParser from '@typescript-eslint/parser';

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down
6 changes: 0 additions & 6 deletions locust/webui/src/hooks/tests/useFetchStats.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ describe('useFetchStats', () => {
swarm: { state: SWARM_STATE.RUNNING },
});

await act(async () => {
await vi.advanceTimersByTimeAsync(2000);
});
await act(async () => {
await vi.advanceTimersByTimeAsync(2000);
});
Expand All @@ -67,9 +64,6 @@ describe('useFetchStats', () => {
store.dispatch(swarmActions.setSwarm({ state: SWARM_STATE.RUNNING }));
});

await act(async () => {
await vi.advanceTimersByTimeAsync(2000);
});
await act(async () => {
await vi.advanceTimersByTimeAsync(2000);
});
Expand Down
15 changes: 4 additions & 11 deletions locust/webui/src/hooks/useFetchStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ export default function useFetchStats() {
const shouldRunRefetchInterval =
swarm.state === SWARM_STATE.SPAWNING || swarm.state == SWARM_STATE.RUNNING;

const updateStats = () => {
useEffect(() => {
if (!statsData) {
return;
}

const {
state,
currentResponseTimePercentiles,
extendedStats,
stats,
Expand Down Expand Up @@ -80,17 +81,9 @@ export default function useFetchStats() {
userCount,
});
updateCharts(newChartEntry);
};

useEffect(() => {
if (statsData) {
setSwarm({ state: statsData.state });
}
}, [statsData && statsData.state]);

useInterval(updateStats, STATS_REFETCH_INTERVAL, {
shouldRunInterval: !!statsData && shouldRunRefetchInterval,
});
setSwarm({ state });
}, [statsData]);

useInterval(refetchStats, STATS_REFETCH_INTERVAL, {
shouldRunInterval: shouldRunRefetchInterval,
Expand Down