From c126a3ba170facd8bb7784bb82b127369c2e021a Mon Sep 17 00:00:00 2001 From: arsalansufi Date: Wed, 13 Dec 2023 15:19:18 -0500 Subject: [PATCH] Decrease VxSuite test flakiness (#4407) * Bump timeouts for long-running tests * Decrease parallelization of VxScan backend tests in CI * Account for Live Check edge case --- apps/mark-scan/frontend/src/app_end_to_end.test.tsx | 2 +- apps/mark/frontend/src/app_end_to_end.test.tsx | 2 +- apps/scan/backend/package.json | 2 +- apps/scan/backend/src/app_usb_drive.test.ts | 2 +- libs/auth/src/live_check.test.ts | 8 +++++++- libs/backend/src/cast_vote_records/export.test.ts | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/mark-scan/frontend/src/app_end_to_end.test.tsx b/apps/mark-scan/frontend/src/app_end_to_end.test.tsx index f436f8dcb3..77f0cd78ab 100644 --- a/apps/mark-scan/frontend/src/app_end_to_end.test.tsx +++ b/apps/mark-scan/frontend/src/app_end_to_end.test.tsx @@ -41,7 +41,7 @@ afterEach(() => { apiMock.mockApiClient.assertComplete(); }); -jest.setTimeout(40_000); +jest.setTimeout(60_000); test('MarkAndPrint end-to-end flow', async () => { const logger = fakeLogger(); diff --git a/apps/mark/frontend/src/app_end_to_end.test.tsx b/apps/mark/frontend/src/app_end_to_end.test.tsx index fb4b3944a1..6a7b38d813 100644 --- a/apps/mark/frontend/src/app_end_to_end.test.tsx +++ b/apps/mark/frontend/src/app_end_to_end.test.tsx @@ -42,7 +42,7 @@ afterEach(() => { apiMock.mockApiClient.assertComplete(); }); -jest.setTimeout(30000); +jest.setTimeout(60_000); test('MarkAndPrint end-to-end flow', async () => { const logger = fakeLogger(); diff --git a/apps/scan/backend/package.json b/apps/scan/backend/package.json index f8a9143a80..aa3c508567 100644 --- a/apps/scan/backend/package.json +++ b/apps/scan/backend/package.json @@ -19,7 +19,7 @@ "pre-commit": "lint-staged", "start": "node ./build/index.js", "test": "is-ci test:ci test:watch", - "test:ci": "jest --coverage --reporters=default --reporters=jest-junit --maxWorkers=6", + "test:ci": "jest --coverage --reporters=default --reporters=jest-junit --maxWorkers=2 # VxScan backend tests (which involve lots of polling and I/O operations) get flaky when we set --maxWorkers higher", "test:coverage": "jest --coverage", "test:debug": "node --inspect-brk $(which jest) --runInBand --no-cache", "test:watch": "jest --watch", diff --git a/apps/scan/backend/src/app_usb_drive.test.ts b/apps/scan/backend/src/app_usb_drive.test.ts index 8ae2cd6623..c2b892cb0b 100644 --- a/apps/scan/backend/src/app_usb_drive.test.ts +++ b/apps/scan/backend/src/app_usb_drive.test.ts @@ -76,4 +76,4 @@ test('doesUsbDriveRequireCastVoteRecordSync is properly populated', async () => }); } ); -}); +}, 30_000); diff --git a/libs/auth/src/live_check.test.ts b/libs/auth/src/live_check.test.ts index 17ed871a94..3a069f13d6 100644 --- a/libs/auth/src/live_check.test.ts +++ b/libs/auth/src/live_check.test.ts @@ -64,6 +64,12 @@ test.each<{ machineId, electionHash: isMachineConfiguredForAnElection ? electionHash : undefined, }); - expect(qrCodeValue).toHaveLength(expectedQrCodeValueLength); + expect([ + expectedQrCodeValueLength, + // There's a slight chance that the base64-encoded signature within the QR code value is 92 + // characters long instead of 96. (The length of a base64-encoded string is always a multiple + // of 4.) + expectedQrCodeValueLength - 4, + ]).toContain(qrCodeValue.length); } ); diff --git a/libs/backend/src/cast_vote_records/export.test.ts b/libs/backend/src/cast_vote_records/export.test.ts index 2d7d1b428b..8194e954b3 100644 --- a/libs/backend/src/cast_vote_records/export.test.ts +++ b/libs/backend/src/cast_vote_records/export.test.ts @@ -48,7 +48,7 @@ import { readCastVoteRecord, } from './test_utils'; -jest.setTimeout(10_000); +jest.setTimeout(30_000); const mockFeatureFlagger = getFeatureFlagMock();