Skip to content

Commit 4aa8d7e

Browse files
committed
feat(drivers): add an option to skip connection test probes in bigquery, aurora, postgres(redshift), snowflake
feat(bigquery-driver): add an option to skip connection test probes feat(aurora-serverless-driver): add an option to skip connection test probes feat(postgres-driver): add an option to skip connection test probes feat(snowflake-driver): add an option to skip connection test probes
1 parent 1fd7a3e commit 4aa8d7e

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

packages/cubejs-bigquery-driver/src/BigQueryDriver.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ export class BigQueryDriver extends BaseDriver implements DriverInterface {
9393
testConnectionTimeout?: number,
9494
} = {}
9595
) {
96-
super({
97-
testConnectionTimeout: config.testConnectionTimeout,
98-
});
99-
10096
const dataSource =
10197
config.dataSource ||
10298
assertDataSource('default');
10399

100+
super({
101+
testConnectionTimeout: config.testConnectionTimeout,
102+
isTestConnectionDisabled: getEnv('dbDisableTestConnection', { dataSource }),
103+
});
104+
104105
this.options = {
105106
scopes: [
106107
'https://www.googleapis.com/auth/bigquery',
@@ -155,6 +156,10 @@ export class BigQueryDriver extends BaseDriver implements DriverInterface {
155156
}
156157

157158
public async testConnection() {
159+
if (this.isTestConnectionDisabled()) {
160+
return;
161+
}
162+
158163
await this.bigquery.query({
159164
query: 'SELECT ? AS number',
160165
params: ['1'],

packages/cubejs-mysql-aurora-serverless-driver/driver/AuroraServerlessMySqlDriver.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ class AuroraServerlessMySqlDriver extends BaseDriver {
3333
* Class constructor.
3434
*/
3535
constructor(config = {}) {
36-
super({
37-
testConnectionTimeout: config.testConnectionTimeout,
38-
});
39-
4036
const dataSource =
4137
config.dataSource ||
4238
assertDataSource('default');
43-
39+
40+
super({
41+
testConnectionTimeout: config.testConnectionTimeout,
42+
isTestConnectionDisabled: getEnv('dbDisableTestConnection', { dataSource }),
43+
});
44+
4445
this.config = {
4546
secretArn:
4647
config.secretArn ||
@@ -66,7 +67,11 @@ class AuroraServerlessMySqlDriver extends BaseDriver {
6667
}
6768

6869
async testConnection() {
69-
return this.dataApi.query('SELECT 1');
70+
if (this.isTestConnectionDisabled()) {
71+
return;
72+
}
73+
74+
await this.dataApi.query('SELECT 1');
7075
}
7176

7277
positionBindings(sql) {

packages/cubejs-postgres-driver/src/PostgresDriver.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ export class PostgresDriver<Config extends PostgresDriverConfiguration = Postgre
111111
testConnectionTimeout?: number,
112112
} = {}
113113
) {
114+
const dataSource =
115+
config.dataSource ||
116+
assertDataSource('default');
117+
114118
super({
115119
testConnectionTimeout: config.testConnectionTimeout,
120+
isTestConnectionDisabled: getEnv('dbDisableTestConnection', { dataSource }),
116121
});
117122

118-
const dataSource =
119-
config.dataSource ||
120-
assertDataSource('default');
121-
122123
this.pool = new Pool({
123124
idleTimeoutMillis: 30000,
124125
max:
@@ -146,9 +147,9 @@ export class PostgresDriver<Config extends PostgresDriverConfiguration = Postgre
146147
}
147148

148149
protected primaryKeysQuery(conditionString?: string): string | null {
149-
return `SELECT
150+
return `SELECT
150151
columns.table_schema as ${this.quoteIdentifier('table_schema')},
151-
columns.table_name as ${this.quoteIdentifier('table_name')},
152+
columns.table_name as ${this.quoteIdentifier('table_name')},
152153
columns.column_name as ${this.quoteIdentifier('column_name')}
153154
FROM information_schema.table_constraints tc
154155
JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
@@ -225,6 +226,10 @@ export class PostgresDriver<Config extends PostgresDriverConfiguration = Postgre
225226
}
226227

227228
public async testConnection(): Promise<void> {
229+
if (this.isTestConnectionDisabled()) {
230+
return;
231+
}
232+
228233
try {
229234
await this.pool.query('SELECT $1::int AS number', ['1']);
230235
} catch (e) {

packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,15 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
241241
testConnectionTimeout?: number,
242242
} = {}
243243
) {
244-
super({
245-
testConnectionTimeout: config.testConnectionTimeout,
246-
});
247-
248244
const dataSource =
249245
config.dataSource ||
250246
assertDataSource('default');
251247

248+
super({
249+
testConnectionTimeout: config.testConnectionTimeout,
250+
isTestConnectionDisabled: getEnv('dbDisableTestConnection', { dataSource }),
251+
});
252+
252253
let privateKey = getEnv('snowflakePrivateKey', { dataSource });
253254
if (privateKey && !privateKey.endsWith('\n')) {
254255
privateKey += '\n';
@@ -420,6 +421,10 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
420421
* Test driver's connection.
421422
*/
422423
public async testConnection() {
424+
if (this.isTestConnectionDisabled()) {
425+
return;
426+
}
427+
423428
const connection = await this.createConnection();
424429

425430
await new Promise(

0 commit comments

Comments
 (0)