mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-03 21:02:05 +08:00
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Mirror main branch to main-mirror-for-wdb / lint_and_build (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
Sync Main to Dev / sync-commits (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { performance } from "node:perf_hooks";
|
|
import { describe } from "vitest";
|
|
import { it } from "../../helpers";
|
|
import { InternalProjectKeys, backendContext, niceBackendFetch } from "../backend-helpers";
|
|
|
|
describe("/api/v1/users performance", () => {
|
|
backendContext.set({
|
|
projectKeys: InternalProjectKeys,
|
|
});
|
|
|
|
it("lists users within the expected response time", async ({ expect }) => {
|
|
// Warm up the endpoint so that caches/connection pools are ready
|
|
await niceBackendFetch("/api/v1/users?limit=10", { accessType: "server" });
|
|
|
|
const start = performance.now();
|
|
const response = await niceBackendFetch("/api/v1/users?limit=200000", { accessType: "server" });
|
|
const durationMs = performance.now() - start;
|
|
|
|
expect(response.status).toBe(200);
|
|
});
|
|
});
|
|
|
|
describe("/api/v1/internal/metrics performance", () => {
|
|
backendContext.set({
|
|
projectKeys: InternalProjectKeys,
|
|
});
|
|
|
|
it("lists metrics within the expected response time", async ({ expect }) => {
|
|
await niceBackendFetch("/api/v1/internal/metrics", { accessType: "admin" });
|
|
|
|
const measure = async () => {
|
|
const start = performance.now();
|
|
const response = await niceBackendFetch("/api/v1/internal/metrics", { accessType: "admin" });
|
|
const durationMs = performance.now() - start;
|
|
expect(response.status).toBe(200);
|
|
return durationMs;
|
|
};
|
|
|
|
const results = [];
|
|
for (let i = 0; i < 3; i++) {
|
|
results.push(await measure());
|
|
}
|
|
});
|
|
});
|