grafana/e2e/benchmarks/live/4-20hz-panels.spec.ts
Ashley Harrison 3fdf96d241
Chore: consolidate e2e scripts in package.json (#74906)
consolidate e2e scripts in package.json + almost fix benchmarking tests
2023-09-14 15:00:29 +01:00

42 lines
906 B
TypeScript

import { e2e } from '../../utils';
type WithGrafanaRuntime<T> = T & {
grafanaRuntime: {
livePerformance: {
start: () => void;
getStats: () => Record<string, unknown>;
};
};
};
const hasGrafanaRuntime = <T>(obj: T): obj is WithGrafanaRuntime<T> => {
return 'grafanaRuntime' in obj;
};
e2e.benchmark({
name: 'Live performance benchmarking - 4x20hz panels',
dashboard: {
folder: '../benchmarks/dashboards/live',
delayAfterOpening: 1000,
skipPanelValidation: true,
},
repeat: 10,
duration: 120000,
appStats: {
startCollecting: (window) => {
if (!hasGrafanaRuntime(window)) {
return;
}
return window.grafanaRuntime.livePerformance.start();
},
collect: (window) => {
if (!hasGrafanaRuntime(window)) {
return {};
}
return window.grafanaRuntime.livePerformance.getStats() ?? {};
},
},
});