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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ GraphQL; both nais/api and the local proxy must support Loki forwarding.

- Search, level, instance and label filters run automatically. Text inputs debounce for
400 ms. Workload scope stays fixed, and historical instances remain searchable.
- Postgres defaults to its active branch and also supports **All branches**. Branch
selection excludes similarly named branches and pooler pods; instance filters narrow
the selected branch rather than replacing its scope.
- Postgres logs are scoped to the database by the API. Instance filters narrow
that scope to selected pods.
- Time presets range from 15 seconds to 7 days. Previous/next move by one complete window;
**Jump to now** preserves its duration and restores a relative range. Times use the
browser's time zone; fixed windows retain their exact UTC instants across daylight-saving
Expand Down
6 changes: 0 additions & 6 deletions src/lib/domain/issues/PostgresIssue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ test('renders only the logical Postgres database in the issue list during SSR',
expect(body).toContain('database');
expect(body).toContain('href="/team/nais/dev-gcp/postgres/database"');
expect(body).toContain('Postgres');
expect(body).not.toContain('Postgres Branch');
expect(body).not.toContain('database /');
expect(body).not.toContain('branch=');
expect(body).toContain('dev-gcp');
expect(body).toContain('has reported a failure.');
expect(body).not.toContain('Unknown');
Expand All @@ -61,8 +58,6 @@ test('renders only the logical Postgres database in the critical issues card dur
const { body } = await render(CriticalIssueRow, { props: { issue: item } });
expect(body).toContain('Postgres failure for database in dev-gcp');
expect(body).toContain('href="/team/nais/dev-gcp/postgres/database"');
expect(body).not.toContain('database /');
expect(body).not.toContain('branch=');
expect(body).toContain('has reported a failure.');
expect(body).not.toContain('Unknown');
});
Expand All @@ -86,5 +81,4 @@ test.each([
);
expect(selection.teamEnvironment.selection.fields.team.selection.fields.slug.visible).toBe(true);
expect(selection.postgres.selection.fields.name.visible).toBe(true);
expect(selection).not.toHaveProperty('branch');
});
3 changes: 1 addition & 2 deletions src/lib/domain/issues/WorkloadIssuesFacets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import WorkloadIssuesFacets from './WorkloadIssuesFacets.svelte';
// Use the generated enums without loading Houdini's SvelteKit runtime in the SSR test.
vi.mock('$houdini', () => import('../../../../.houdini/graphql/enums'));

test('offers canonical Postgres issue filtering without the compatibility-only branch type', async () => {
test('offers Postgres issue filtering', async () => {
const { body } = await render(WorkloadIssuesFacets, {
props: {
selectedSeverity: '',
Expand All @@ -16,5 +16,4 @@ test('offers canonical Postgres issue filtering without the compatibility-only b
});

expect(body).toMatch(/checked[^>]*>\s*<span[^>]*>Postgres<\/span>/);
expect(body).not.toContain('Postgres Branch');
});
6 changes: 3 additions & 3 deletions src/lib/domain/logs/LogExplorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ describe('LogExplorer', () => {
const { body } = await render(LogExplorer, {
props: {
...props,
filters: createRawSnippet(() => ({ render: () => '<span>Branch controls</span>' }))
filters: createRawSnippet(() => ({ render: () => '<span>Resource filters</span>' }))
}
});
expect(body).toContain('Branch controls');
expect(body.indexOf('Branch controls')).toBeLessThan(body.indexOf('Log level'));
expect(body).toContain('Resource filters');
expect(body.indexOf('Resource filters')).toBeLessThan(body.indexOf('Log level'));
});

it('keeps raw Postgres pod values while formatting their instance suggestions', async () => {
Expand Down
56 changes: 26 additions & 30 deletions src/lib/domain/persistence/Persistence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,32 @@ vi.mock('$houdini', () => ({
}));

describe('Postgres persistence usages', () => {
test.each(['Application', 'Job'])(
'renders one logical database without requiring branches for a %s',
async (__typename) => {
fixture.data = {
__typename,
name: 'workload',
team: { slug: 'nais' },
teamEnvironment: { environment: { name: 'dev-gcp' } },
buckets: { edges: [] },
bigQueryDatasets: { edges: [] },
sqlInstances: { edges: [] },
kafkaTopicAcls: { edges: [] },
openSearch: null,
valkeys: { edges: [] },
postgreses: {
edges: ['main', 'restore'].map((name) => ({
cursor: `usage-${name}`,
node: {
postgres: { id: 'same-database', name: 'database' }
}
}))
}
};
test.each(['Application', 'Job'])('deduplicates database usages for a %s', async (__typename) => {
fixture.data = {
__typename,
name: 'workload',
team: { slug: 'nais' },
teamEnvironment: { environment: { name: 'dev-gcp' } },
buckets: { edges: [] },
bigQueryDatasets: { edges: [] },
sqlInstances: { edges: [] },
kafkaTopicAcls: { edges: [] },
openSearch: null,
valkeys: { edges: [] },
postgreses: {
edges: ['usage-1', 'usage-2'].map((cursor) => ({
cursor,
node: {
postgres: { id: 'same-database', name: 'database' }
}
}))
}
};

const { body } = await render(Persistence, {
props: { workload: { ' $fragments': { Persistence: {} } } }
});
const { body } = await render(Persistence, {
props: { workload: { ' $fragments': { Persistence: {} } } }
});

expect(body).not.toContain('Branch:');
expect(body.match(/href="\/team\/nais\/dev-gcp\/postgres\/database"/g)).toHaveLength(1);
}
);
expect(body.match(/href="\/team\/nais\/dev-gcp\/postgres\/database"/g)).toHaveLength(1);
});
});
2 changes: 1 addition & 1 deletion src/lib/domain/postgres/PostgresTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Postgres table', () => {
['AVAILABLE', 'success', 'available'],
['DEGRADED', 'danger', 'degraded'],
['PROGRESSING', 'warning', 'progressing']
])('shows direct Postgres state=%s without branch resources', async (state, tone, label) => {
])('shows Postgres state=%s', async (state, tone, label) => {
fixture.nodes = [
{
id: 'database',
Expand Down
14 changes: 5 additions & 9 deletions src/lib/domain/postgres/insights.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ describe('Postgres Insights queries', () => {
expect(new Set(charts.map((candidate) => candidate.title)).size).toBe(charts.length);
});

test.each(charts)(
'$title is scoped to the selected team and database without a branch label',
({ query }) => {
expect(query).toContain('namespace="my-team"');
expect(query).toContain('team="my-team"');
expect(query).toContain('postgres="my-database"');
expect(query).not.toContain('branch=');
}
);
test.each(charts)('$title is scoped to the selected team and database', ({ query }) => {
expect(query).toContain('namespace="my-team"');
expect(query).toContain('team="my-team"');
expect(query).toContain('postgres="my-database"');
});

test('escapes label values without changing their meaning', () => {
const scoped = postgresInsightsSections('a"b', 'c\\d');
Expand Down
10 changes: 1 addition & 9 deletions src/lib/domain/postgres/insightsPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,13 @@ describe('Postgres Insights page', () => {
expect(body).toContain('Commits and rollbacks per second on the primary');
});

test('preserves all time ranges without branch selection or pagination', async () => {
test('offers all supported time ranges', async () => {
const { body } = await renderPage();
expect(body).not.toContain('<select');
expect(body).not.toContain('Load more branches');
for (const interval of ['1h', '6h', '1d', '7d', '30d']) {
expect(body).toContain(`>${interval}<`);
}
});

test('renders database metrics without branch wording', async () => {
const { body } = await renderPage();
expect(body).not.toContain('branch ');
expect(body.match(/class="prometheus-chart-wrapper\b/g)).toHaveLength(10);
});

test('shows metric query errors instead of an indefinite loading or empty-data state', async () => {
fixture.metricErrors = [{ message: 'Failed to query metrics' }];
const { body } = await renderPage();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/domain/postgres/labels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fixture = vi.hoisted(() => ({ overview: {} }));

vi.mock('$app/paths', () => ({
resolve: (_route: string, params: { team: string; env: string; postgres: string }) =>
`/team/${params.team}/${params.env}/postgres/${params.postgres}/branches`
`/team/${params.team}/${params.env}/postgres/${params.postgres}`
}));
vi.mock('$app/state', () => ({
page: { params: { team: 'test', env: 'dev', postgres: 'database' } }
Expand Down
63 changes: 0 additions & 63 deletions src/lib/domain/postgres/legacyLinks.test.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/lib/domain/postgres/legacyLinks.ts

This file was deleted.

7 changes: 2 additions & 5 deletions src/lib/domain/postgres/logsPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ vi.mock('$app/state', () => ({
page: {
params: { team: 'test', env: 'dev', postgres: 'database' },
data: { tenantName: 'nav' },
url: new URL('https://console.test/?branch=main')
url: new URL('https://console.test/')
}
}));
vi.mock('#lib/domain/logs/LogExplorer.svelte', () => ({ default: vi.fn() }));
Expand Down Expand Up @@ -57,10 +57,7 @@ describe('Postgres logs page', () => {
'passes logical Postgres ID %s without requiring a physical cluster identity',
async (id) => {
fixture.postgres = { id };
const { body } = await renderPage();
expect(body).not.toContain('All branches');
expect(body).not.toContain('Load more branches');
expect(body).not.toContain('value="preview"');
await renderPage();
expect(LogExplorer).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
Expand Down
36 changes: 10 additions & 26 deletions src/lib/domain/postgres/overviewPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const fixture = vi.hoisted(() => ({ overview: {} }));

vi.mock('$app/paths', () => ({
resolve: (_route: string, params: { team: string; env: string; postgres: string }) =>
`/team/${params.team}/${params.env}/postgres/${params.postgres}/branches`
`/team/${params.team}/${params.env}/postgres/${params.postgres}`
}));
vi.mock('$app/state', () => ({
page: { params: { team: 'test', env: 'dev', postgres: 'database' } }
Expand Down Expand Up @@ -97,7 +97,7 @@ function parameterPanel(body: string) {

describe('Postgres overview', () => {
test.each(['Application', 'Job'] as const)(
'keeps %s workload links without branch labels or navigation',
'links to the consuming %s workload',
async (__typename) => {
const { body } = await renderPage({
workloads: [
Expand All @@ -115,9 +115,7 @@ describe('Postgres overview', () => {
});
const kind = __typename === 'Job' ? 'job' : 'app';
expect(body).toContain(`href="/team/test/dev/${kind}/worker"`);
expect(body).not.toContain('Branch:');
expect(body).not.toContain('Not used by any workloads.');
expect(body).not.toContain('/branches');
}
);

Expand All @@ -142,7 +140,6 @@ describe('Postgres overview', () => {
test('preserves resource configuration with collapsed, labelled PostgreSQL parameters', async () => {
const { body } = await renderPage();
expect(body).not.toContain('<h1');
expect(body).not.toContain('/branches');
for (const value of ['Ready', '100m', '512Mi', '10Gi', 'Postgres version']) {
expect(body).toContain(value);
}
Expand All @@ -169,7 +166,7 @@ describe('Postgres overview', () => {
);
});

test('shows unavailable parameters while provisioning without a branch resource', async () => {
test('shows unavailable parameters while provisioning', async () => {
const { body } = await renderPage({ state: 'PROGRESSING', configuration: null });
expect(body).toContain('Postgres is being prepared. Status updates automatically.');
expect(body).toContain('Preparing');
Expand All @@ -179,18 +176,11 @@ describe('Postgres overview', () => {
expect(html).not.toContain('<select');
});

test('shows degraded direct state without branch controls', async () => {
test('shows degraded state with available parameters', async () => {
const { body } = await renderPage({ state: 'DEGRADED' });
expect(body).toContain('Degraded');
expect(body).not.toContain('Activation requested');
expect(body).not.toContain('Active branch');
const { html } = parameterPanel(body);
expect(html).toContain('16MB');
expect(html).not.toContain('preview');
expect(html).not.toContain('main');
expect(html).not.toContain('Active branch');
expect(html).not.toContain('activeBranch');
expect(html).not.toContain('<select');
});

test('renders names and raw values with units in server order', async () => {
Expand Down Expand Up @@ -236,16 +226,10 @@ describe('Postgres overview', () => {
[false, false],
[true, false],
[false, true]
])(
'is read-only with no branch label or dropdown for member=%s admin=%s',
async (viewerIsMember, isAdmin) => {
const { body } = await renderPage({ viewerIsMember, isAdmin });
const { html } = parameterPanel(body);
expect(html).toContain('work_mem');
expect(html).not.toMatch(/<(button|input|select|textarea|form)\b/);
expect(html).not.toContain('Active branch');
expect(html).not.toContain('activeBranch');
expect(html).not.toContain('Load more branches');
}
);
])('parameters are read-only for member=%s admin=%s', async (viewerIsMember, isAdmin) => {
const { body } = await renderPage({ viewerIsMember, isAdmin });
const { html } = parameterPanel(body);
expect(html).toContain('work_mem');
expect(html).not.toMatch(/<(button|input|select|textarea|form)\b/);
});
});
Loading