Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions e2e/helpers/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,20 @@ export function createUsageHelper(
expect(responseStatus).toBe(200);
},
async expectInsightOperation(operationName) {
await expect
.poll(
async () => {
await reloadInsightsPage();

return page.getByRole('link').filter({ hasText: operationName }).count();
},
{ timeout: 60_000, intervals: [2_000] },
)
.toBeGreaterThan(0);
const link = page.getByRole('link').filter({ hasText: operationName });
await expect(async () => {
await reloadInsightsPage();
// Reload re-fetches; wait for the row to render before retrying so a slow load
// isn't reloaded away mid-flight.
await expect(link.first()).toBeVisible({ timeout: 15_000 });
}).toPass({ timeout: 90_000, intervals: [1_000] });
},
async expectInsightVersion(version) {
await expect
.poll(
async () => {
await reloadInsightsPage();

return page.getByText(version, { exact: true }).count();
},
{ timeout: 60_000, intervals: [2_000] },
)
.toBeGreaterThan(0);
const versionText = page.getByText(version, { exact: true });
await expect(async () => {
await reloadInsightsPage();
await expect(versionText.first()).toBeVisible({ timeout: 15_000 });
}).toPass({ timeout: 90_000, intervals: [1_000] });
},
};
}
7 changes: 3 additions & 4 deletions e2e/specs/usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import type { AppHelper } from '../helpers/app';
import { generateRandomSlug, getUserData } from '../helpers/data';
import type { UsageHelper } from '../helpers/usage';

// Each test waits on ClickHouse ingestion through several stacked polls (see helpers/usage.ts).
// Keep the timeout above the sum of those poll budgets so a slow-but-succeeding poll isn't cut
// off mid-wait by the per-test deadline.
test.describe.configure({ mode: 'serial', timeout: 180_000 });
// Generous per-test budget: each test drives the full org/project/target/token setup through
// the UI before polling Insights.
test.describe.configure({ mode: 'serial', timeout: 120_000 });

type UsageReport = {
size: number;
Expand Down
15 changes: 0 additions & 15 deletions packages/services/usage-ingestor/src/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ export function createWriter({
https: httpsAgent,
};

logger.debug(
'ClickHouse writer initialized (async_insert=1, wait_for_async_insert=%s, async_insert_busy_timeout_ms=%s, async_insert_max_data_size=%s)',
clickhouse.wait_for_async_insert,
clickhouse.async_insert_busy_timeout_ms,
clickhouse.async_insert_max_data_size,
);

return {
async writeOperations(operations: string[]) {
if (operations.length === 0) {
Expand All @@ -73,7 +66,6 @@ export function createWriter({
const csv = joinIntoSingleMessage(operations);
const compressed = await compress(csv);

const startedAt = performance.now();
await writeCsv(
clickhouse,
agents,
Expand All @@ -82,13 +74,6 @@ export function createWriter({
logger,
3,
);
// With wait_for_async_insert=1 this blocks until the row is flushed (queryable);
// fire-and-forget returns in a few ms. Logged at debug so it stays out of prod (info).
logger.debug(
'operations INSERT completed in %sms (operations=%s)',
performance.now() - startedAt,
operations.length,
);
},
async writeSubscriptionOperations(operations: string[]) {
if (operations.length === 0) {
Expand Down
Loading