Skip to content

Commit

Permalink
chore: gather more telemetry data in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Sep 17, 2024
1 parent 989d3ce commit b61aaef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const runTests = async (): Promise<void> => {
const removeListener = server.addTestDoneListener(() => {
Logger.success(iterationText);

const metrics = MeasureUtils.stop();
const metrics = MeasureUtils.stop('done');
const test = server.getTestConfig();

if (server.isReadyToAcceptTestResults) {
Expand Down Expand Up @@ -195,7 +195,8 @@ const runTests = async (): Promise<void> => {
});
MeasureUtils.start(appPackage, {
onAttachFailed: async () => {
MeasureUtils.stop();
Logger.warn('The PID has changed, trying to restart the test...');
MeasureUtils.stop('retry');
resetTimeout();
removeListener();
// something went wrong, let's wait a little bit and try again
Expand Down Expand Up @@ -268,7 +269,9 @@ const runTests = async (): Promise<void> => {
// We run each test multiple time to average out the results
for (let testIteration = 0; testIteration < config.RUNS; testIteration++) {
const onError = (e: Error) => {
MeasureUtils.stop();
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.error(`Unexpected error during test execution: ${e}. `);
MeasureUtils.stop('error');
server.clearAllTestDoneListeners();
errorCountRef.errorCount += 1;
if (testIteration === 0 || errorCountRef.errorCount === errorCountRef.allowedExceptions) {
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/utils/measure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {profiler} from '@perf-profiler/profiler';
import {getAverageCpuUsage, getAverageCpuUsagePerProcess, getAverageFPSUsage, getAverageRAMUsage} from '@perf-profiler/reporter';
import {ThreadNames} from '@perf-profiler/types';
import type {Measure} from '@perf-profiler/types';
import * as Logger from './logger';

let measures: Measure[] = [];
const POLLING_STOPPED = {
Expand All @@ -27,9 +28,12 @@ const start = (bundleId: string, {onAttachFailed}: StartOptions) => {
onAttachFailed();
},
});

Logger.info(`Starting performance measurements for ${bundleId}`);
};

const stop = () => {
const stop = (whoTriggered: string) => {
Logger.info(`Stop performance measurements... Was triggered by ${whoTriggered}`);
polling.stop();
polling = POLLING_STOPPED;

Expand Down

0 comments on commit b61aaef

Please sign in to comment.