mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-10 08:05:14 +02:00
fix: write canonical historic sql setup filters
This commit is contained in:
parent
fc1fdb6bc9
commit
9fb98e3c32
2 changed files with 42 additions and 6 deletions
|
|
@ -1230,10 +1230,17 @@ describe('setup databases step', () => {
|
|||
enabled: true,
|
||||
dialect: 'snowflake',
|
||||
windowDays: 30,
|
||||
serviceAccountUserPatterns: ['^svc_'],
|
||||
filters: {
|
||||
dropTrivialProbes: true,
|
||||
serviceAccounts: {
|
||||
patterns: ['^svc_'],
|
||||
mode: 'exclude',
|
||||
},
|
||||
},
|
||||
redactionPatterns: ['(?i)secret'],
|
||||
},
|
||||
});
|
||||
expect(config.connections.snowflake.historicSql).not.toHaveProperty('serviceAccountUserPatterns');
|
||||
expect(config.ingest.adapters).toContain('historic-sql');
|
||||
});
|
||||
|
||||
|
|
@ -1272,12 +1279,19 @@ describe('setup databases step', () => {
|
|||
enabled: true,
|
||||
dialect: 'postgres',
|
||||
minExecutions: 12,
|
||||
serviceAccountUserPatterns: ['^svc_'],
|
||||
filters: {
|
||||
dropTrivialProbes: true,
|
||||
serviceAccounts: {
|
||||
patterns: ['^svc_'],
|
||||
mode: 'exclude',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('minCalls');
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('windowDays');
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('redactionPatterns');
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('serviceAccountUserPatterns');
|
||||
expect(config.ingest.adapters).toContain('historic-sql');
|
||||
expect(io.stdout()).toContain('Historic SQL probe...');
|
||||
expect(io.stdout()).toContain('pg_stat_statements ready');
|
||||
|
|
@ -1324,10 +1338,13 @@ describe('setup databases step', () => {
|
|||
enabled: true,
|
||||
dialect: 'bigquery',
|
||||
windowDays: 45,
|
||||
serviceAccountUserPatterns: [],
|
||||
filters: {
|
||||
dropTrivialProbes: true,
|
||||
},
|
||||
redactionPatterns: [],
|
||||
},
|
||||
});
|
||||
expect(config.connections.analytics.historicSql).not.toHaveProperty('serviceAccountUserPatterns');
|
||||
expect(config.ingest.adapters).toContain('historic-sql');
|
||||
});
|
||||
|
||||
|
|
@ -1372,9 +1389,12 @@ describe('setup databases step', () => {
|
|||
enabled: true,
|
||||
dialect: 'postgres',
|
||||
minExecutions: 8,
|
||||
serviceAccountUserPatterns: [],
|
||||
filters: {
|
||||
dropTrivialProbes: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('serviceAccountUserPatterns');
|
||||
});
|
||||
|
||||
it('prints a non-blocking Postgres Historic SQL probe failure after connection test succeeds', async () => {
|
||||
|
|
|
|||
|
|
@ -665,12 +665,13 @@ async function maybeApplyHistoricSqlConfig(input: {
|
|||
return { ...input.connection, historicSql: { ...existing, enabled: false, dialect } };
|
||||
}
|
||||
|
||||
const common = {
|
||||
const common: Record<string, unknown> = {
|
||||
...existing,
|
||||
enabled: true,
|
||||
dialect,
|
||||
serviceAccountUserPatterns: input.args.historicSqlServiceAccountPatterns ?? [],
|
||||
filters: historicSqlFiltersForSetup(input.args.historicSqlServiceAccountPatterns),
|
||||
};
|
||||
delete common.serviceAccountUserPatterns;
|
||||
|
||||
if (dialect === 'postgres') {
|
||||
return {
|
||||
|
|
@ -692,6 +693,21 @@ async function maybeApplyHistoricSqlConfig(input: {
|
|||
};
|
||||
}
|
||||
|
||||
function historicSqlFiltersForSetup(patterns: string[] | undefined) {
|
||||
const serviceAccountPatterns = patterns ?? [];
|
||||
return {
|
||||
dropTrivialProbes: true,
|
||||
...(serviceAccountPatterns.length > 0
|
||||
? {
|
||||
serviceAccounts: {
|
||||
patterns: serviceAccountPatterns,
|
||||
mode: 'exclude' as const,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
async function defaultTestConnection(projectDir: string, connectionId: string, io: KtxCliIo): Promise<number> {
|
||||
return await runKtxConnection({ command: 'test', projectDir, connectionId }, io);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue