From 4b1fec792b8bac4b9a84aabf7bd7b34509b0ac0e Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 4 Nov 2026 07:41:49 -0500 Subject: [PATCH 1/3] test(e2e): stop machine auth tests from hitting BAPI rate limits Run each machine auth describe block in default mode so beforeAll runs once per block instead of once per worker, and wrap the machine and OAuth Clerk clients in withRetry so 429s back off instead of failing. --- .changeset/machine-tests-rate-limit.md | 2 ++ integration/testUtils/machineAuthHelpers.ts | 25 ++++++++++++--------- integration/tests/next-machine.test.ts | 4 ++-- 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 .changeset/machine-tests-rate-limit.md diff --git a/.changeset/machine-tests-rate-limit.md b/.changeset/machine-tests-rate-limit.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/machine-tests-rate-limit.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/integration/testUtils/machineAuthHelpers.ts b/integration/testUtils/machineAuthHelpers.ts index cf94fdf309f..4f8f268b4f7 100644 --- a/integration/testUtils/machineAuthHelpers.ts +++ b/integration/testUtils/machineAuthHelpers.ts @@ -13,6 +13,7 @@ import type { EnvironmentConfig } from '../models/environment'; import { appConfigs } from '../presets'; import { instanceKeys } from '../presets/envs'; import { createTestUtils } from './index'; +import { withRetry } from './retryableClerkClient'; import type { FakeAPIKey, FakeUser } from './usersService'; export type FakeMachineNetwork = { @@ -182,9 +183,11 @@ export type MachineAuthTestAdapter = { const createApiKeysEnv = (): EnvironmentConfig => appConfigs.envs.withAPIKeys.clone(); export const createMachineClient = () => - createClerkClient({ - secretKey: instanceKeys.get('with-api-keys').sk, - }); + withRetry( + createClerkClient({ + secretKey: instanceKeys.get('with-api-keys').sk, + }), + ); const buildApp = async (adapter: MachineAuthTestAdapter, addRoutes: RouteBuilder): Promise => { const config = addRoutes(adapter.baseConfig.clone()); @@ -192,14 +195,16 @@ const buildApp = async (adapter: MachineAuthTestAdapter, addRoutes: RouteBuilder }; const createOAuthClient = (app: Application) => - createClerkClient({ - secretKey: app.env.privateVariables.get('CLERK_SECRET_KEY'), - publishableKey: app.env.publicVariables.get('CLERK_PUBLISHABLE_KEY'), - }); + withRetry( + createClerkClient({ + secretKey: app.env.privateVariables.get('CLERK_SECRET_KEY'), + publishableKey: app.env.publicVariables.get('CLERK_PUBLISHABLE_KEY'), + }), + ); export const registerApiKeyAuthTests = (adapter: MachineAuthTestAdapter): void => { test.describe('API key auth', () => { - test.describe.configure({ mode: 'parallel' }); + test.describe.configure({ mode: 'default' }); let app: Application; let fakeUser: FakeUser; let fakeBapiUser: User; @@ -293,7 +298,7 @@ export const registerApiKeyAuthTests = (adapter: MachineAuthTestAdapter): void = export const registerM2MAuthTests = (adapter: MachineAuthTestAdapter): void => { test.describe('M2M auth', () => { - test.describe.configure({ mode: 'parallel' }); + test.describe.configure({ mode: 'default' }); let app: Application; let network: FakeMachineNetwork; @@ -376,7 +381,7 @@ export const registerM2MAuthTests = (adapter: MachineAuthTestAdapter): void => { export const registerOAuthAuthTests = (adapter: MachineAuthTestAdapter): void => { test.describe('OAuth auth', () => { - test.describe.configure({ mode: 'parallel' }); + test.describe.configure({ mode: 'default' }); let app: Application; let fakeUser: FakeUser; let fakeOAuth: FakeOAuthApp; diff --git a/integration/tests/next-machine.test.ts b/integration/tests/next-machine.test.ts index faaffe5944c..169029eeed4 100644 --- a/integration/tests/next-machine.test.ts +++ b/integration/tests/next-machine.test.ts @@ -108,7 +108,7 @@ test.describe('Next.js machine authentication @machine', () => { registerOAuthAuthTests(adapter); test.describe('auth.protect() authorization with API keys', () => { - test.describe.configure({ mode: 'parallel' }); + test.describe.configure({ mode: 'default' }); let app: Application; let fakeUser: FakeUser; let fakeBapiUser: User; @@ -198,7 +198,7 @@ test.describe('Next.js machine authentication @machine', () => { }); test.describe('session helpers with machine tokens', () => { - test.describe.configure({ mode: 'parallel' }); + test.describe.configure({ mode: 'default' }); let app: Application; let network: FakeMachineNetwork; let jwtToken: string; From 61e28dd1c3feb8a341443cc8d1dfd689a21943e0 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 4 Nov 2026 08:17:39 -0500 Subject: [PATCH 2/3] chore(ci): TEMP force uncached machine integration runs (revert before merge) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8f50d993e5..41c75d2f9d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -703,7 +703,7 @@ jobs: if [ "${{ matrix.test-name }}" = "electron" ]; then xvfb-run -a pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS else - pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS + pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS ${{ matrix.test-name == 'machine' && '--force' || '' }} fi env: CLERK_E2E_OAUTH_PROVIDER_CLIENT_SECRET: ${{ secrets.CLERK_E2E_OAUTH_PROVIDER_CLIENT_SECRET }} From a765c9ddc3f7249d2d441b648805969cbfe53eea Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 4 Nov 2026 10:08:53 -0500 Subject: [PATCH 3/3] Revert "chore(ci): TEMP force uncached machine integration runs (revert before merge)" This reverts commit 61e28dd1c3feb8a341443cc8d1dfd689a21943e0. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41c75d2f9d6..a8f50d993e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -703,7 +703,7 @@ jobs: if [ "${{ matrix.test-name }}" = "electron" ]; then xvfb-run -a pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS else - pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS ${{ matrix.test-name == 'machine' && '--force' || '' }} + pnpm turbo test:integration:${{ matrix.test-name }} $TURBO_ARGS fi env: CLERK_E2E_OAUTH_PROVIDER_CLIENT_SECRET: ${{ secrets.CLERK_E2E_OAUTH_PROVIDER_CLIENT_SECRET }}