mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
fix tests
This commit is contained in:
parent
4b7dd53bf8
commit
044377e087
1
.github/workflows/e2e-api-tests.yaml
vendored
1
.github/workflows/e2e-api-tests.yaml
vendored
@ -20,6 +20,7 @@ jobs:
|
||||
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
|
||||
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
|
||||
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
@ -20,6 +20,7 @@ jobs:
|
||||
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:6728/stackframe"
|
||||
NEXT_PUBLIC_STACK_PORT_PREFIX: "67"
|
||||
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
@ -22,6 +22,7 @@ jobs:
|
||||
STACK_TEST_SOURCE_OF_TRUTH: true
|
||||
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
|
||||
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
@ -20,6 +20,7 @@ jobs:
|
||||
env:
|
||||
NEXT_PUBLIC_STACK_PORT_PREFIX: "69"
|
||||
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
1
.github/workflows/restart-dev-and-test.yaml
vendored
1
.github/workflows/restart-dev-and-test.yaml
vendored
@ -19,6 +19,7 @@ jobs:
|
||||
runs-on: ubicloud-standard-16
|
||||
env:
|
||||
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
@ -20,6 +20,7 @@ jobs:
|
||||
env:
|
||||
NEXT_PUBLIC_STACK_PORT_PREFIX: "69"
|
||||
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
1
.github/workflows/setup-tests.yaml
vendored
1
.github/workflows/setup-tests.yaml
vendored
@ -19,6 +19,7 @@ jobs:
|
||||
runs-on: ubicloud-standard-16
|
||||
env:
|
||||
STACK_FORCE_EXTERNAL_DB_SYNC: "true"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "5000"
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
|
||||
@ -28,7 +28,9 @@ export const GET = createSmartRouteHandler({
|
||||
headers: yupObject({
|
||||
authorization: yupTuple([yupString()]).defined(),
|
||||
}).defined(),
|
||||
query: yupObject({}).defined(),
|
||||
query: yupObject({
|
||||
maxDurationMs: yupNumber().integer().min(1).optional(),
|
||||
}).defined(),
|
||||
}),
|
||||
response: yupObject({
|
||||
statusCode: yupNumber().oneOf([200]).defined(),
|
||||
@ -38,14 +40,14 @@ export const GET = createSmartRouteHandler({
|
||||
requests_processed: yupNumber().defined(),
|
||||
}).defined(),
|
||||
}),
|
||||
handler: async ({ headers }) => {
|
||||
handler: async ({ headers, query }) => {
|
||||
const authHeader = headers.authorization[0];
|
||||
if (authHeader !== `Bearer ${getEnvVariable("CRON_SECRET")}`) {
|
||||
throw new StatusError(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const startTime = performance.now();
|
||||
const maxDurationMs = 3 * 60 * 1000;
|
||||
const maxDurationMs = query.maxDurationMs ?? 3 * 60 * 1000;
|
||||
const pollIntervalMs = 50;
|
||||
const staleClaimIntervalMinutes = 5;
|
||||
|
||||
|
||||
@ -246,7 +246,9 @@ export const GET = createSmartRouteHandler({
|
||||
headers: yupObject({
|
||||
authorization: yupTuple([yupString()]).defined(),
|
||||
}).defined(),
|
||||
query: yupObject({}).defined(),
|
||||
query: yupObject({
|
||||
maxDurationMs: yupNumber().integer().min(1).optional(),
|
||||
}).defined(),
|
||||
}),
|
||||
response: yupObject({
|
||||
statusCode: yupNumber().oneOf([200]).defined(),
|
||||
@ -256,7 +258,7 @@ export const GET = createSmartRouteHandler({
|
||||
iterations: yupNumber().defined(),
|
||||
}).defined(),
|
||||
}),
|
||||
handler: async ({ headers }) => {
|
||||
handler: async ({ headers, query }) => {
|
||||
const authHeader = headers.authorization[0];
|
||||
if (authHeader !== `Bearer ${getEnvVariable("CRON_SECRET")}`) {
|
||||
throw new StatusError(401, "Unauthorized");
|
||||
@ -267,7 +269,7 @@ export const GET = createSmartRouteHandler({
|
||||
const tenancyRefreshIntervalMs = 5_000;
|
||||
|
||||
const startTime = performance.now();
|
||||
const maxDurationMs = 3 * 60 * 1000;
|
||||
const maxDurationMs = query.maxDurationMs ?? 3 * 60 * 1000;
|
||||
const pollIntervalMs = 50;
|
||||
|
||||
let iterations = 0;
|
||||
|
||||
@ -11,6 +11,15 @@ export const POSTGRES_PASSWORD = process.env.EXTERNAL_DB_TEST_PASSWORD || 'PASSW
|
||||
export const TEST_TIMEOUT = 120000;
|
||||
export const HIGH_VOLUME_TIMEOUT = 600000; // 10 minutes for 1500+ users
|
||||
const SHOULD_FORCE_EXTERNAL_DB_SYNC = process.env.STACK_FORCE_EXTERNAL_DB_SYNC === 'true';
|
||||
const FORCE_SYNC_MAX_DURATION_MS = (() => {
|
||||
const raw = process.env.STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS;
|
||||
if (!raw) return 5000;
|
||||
const parsed = Number.parseInt(raw, 10);
|
||||
if (!Number.isFinite(parsed) || parsed <= 0) {
|
||||
throw new Error('STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS must be a positive integer');
|
||||
}
|
||||
return parsed;
|
||||
})();
|
||||
const FORCE_SYNC_INTERVAL_MS = 2000;
|
||||
let lastForcedSyncAt = -Infinity;
|
||||
|
||||
@ -165,11 +174,17 @@ async function maybeForceExternalDbSync() {
|
||||
}
|
||||
|
||||
await niceFetch(new URL('/api/latest/internal/external-db-sync/sequencer', STACK_BACKEND_BASE_URL), {
|
||||
query: {
|
||||
maxDurationMs: String(FORCE_SYNC_MAX_DURATION_MS),
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${cronSecret}`,
|
||||
},
|
||||
});
|
||||
await niceFetch(new URL('/api/latest/internal/external-db-sync/poller', STACK_BACKEND_BASE_URL), {
|
||||
query: {
|
||||
maxDurationMs: String(FORCE_SYNC_MAX_DURATION_MS),
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${cronSecret}`,
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user