Skip to content

Commit

Permalink
feat(server-core): disable health checks for API instances with rollu…
Browse files Browse the repository at this point in the history
…p only mode
  • Loading branch information
buntarb committed Jul 27, 2022
1 parent 37589a9 commit a6601e5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
26 changes: 20 additions & 6 deletions packages/cubejs-server-core/src/core/OrchestratorApi.ts
Expand Up @@ -161,15 +161,29 @@ export class OrchestratorApi {
return this.orchestrator.testConnections();
}

/**
* Tests worker's connections to the Cubstore and, if not in the rollup only
* mode, to the datasources.
*/
public async testConnection() {
return Promise.all([
...Object.keys(this.seenDataSources).map(
ds => this.testDriverConnection(this.driverFactory, ds),
),
this.testDriverConnection(this.options.externalDriverFactory),
]);
if (this.options.rollupOnlyMode) {
return Promise.all([
this.testDriverConnection(this.options.externalDriverFactory),
]);
} else {
return Promise.all([
...Object.keys(this.seenDataSources).map(
ds => this.testDriverConnection(this.driverFactory, ds),
),
this.testDriverConnection(this.options.externalDriverFactory),
]);
}
}

/**
* Tests connection to the data source specified by the driver factory
* function and data source name.
*/
public async testDriverConnection(
driverFn?: DriverFactoryByDataSource,
dataSource: string = 'default',
Expand Down
8 changes: 4 additions & 4 deletions packages/cubejs-server-core/test/unit/OptsHandler.test.ts
Expand Up @@ -686,7 +686,7 @@ describe('OptsHandler class', () => {
);

test(
'must set preAggregationsOptions.externalRefresh to false and ' +
'must set preAggregationsOptions.externalRefresh to false and doesn\'t' +
'test driver connection for dev server with rollupOnlyMode set to true',
async () => {
process.env.NODE_ENV = 'test';
Expand All @@ -713,10 +713,10 @@ describe('OptsHandler class', () => {
expect(core.optsHandler.configuredForScheduledRefresh()).toBe(true);
expect(opts.rollupOnlyMode).toBe(true);
expect(opts.preAggregationsOptions.externalRefresh).toBe(false);
await expect(async () => {
expect(async () => {
await oapi.testConnection();
}).rejects.toThrow();
expect(testDriverConnectionSpy.mock.calls.length).toEqual(2);
}).not.toThrow();
expect(testDriverConnectionSpy.mock.calls.length).toEqual(1);

testDriverConnectionSpy.mockRestore();
}
Expand Down

0 comments on commit a6601e5

Please sign in to comment.