Skip to content

Commit

Permalink
fix(@cubejs-backend/server-core): orchestratorOptions validation brea…
Browse files Browse the repository at this point in the history
…ks serverless deployments (#1113)
  • Loading branch information
RusovDmitriy committed Sep 19, 2020
1 parent 98ffad3 commit 48ca5aa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
17 changes: 15 additions & 2 deletions packages/cubejs-server-core/core/index.test.js
Expand Up @@ -48,13 +48,23 @@ describe('index.test', () => {
.toThrowError(/"compilerCacheSize" must be larger than or equal to 0/);
});


test('Should create instance of CubejsServerCore, orchestratorOptions as func', () => {
const options = { dbType: 'mysql', orchestratorOptions: () => {} };

expect(new CubejsServerCore(options))
.toBeInstanceOf(CubejsServerCore);
});

test('Should create instance of CubejsServerCore, pass all options', () => {
const queueOptions = {
concurrency: 3,
continueWaitTimeout: 5,
executionTimeout: 600,
orphanedTimeout: 120,
heartBeatInterval: 500
heartBeatInterval: 500,
sendProcessMessageFn: () => {},
sendCancelMessageFn: () => {}
};

const options = {
Expand Down Expand Up @@ -87,7 +97,10 @@ describe('index.test', () => {
queryCacheOptions: {
refreshKeyRenewalThreshold: 1000,
backgroundRenew: true,
queueOptions
queueOptions,
externalQueueOptions: {
...queueOptions
}
},
preAggregationsOptions: {
queueOptions
Expand Down
30 changes: 18 additions & 12 deletions packages/cubejs-server-core/core/optionsValidate.js
Expand Up @@ -7,7 +7,9 @@ const schemaQueueOptions = Joi.object().keys({
continueWaitTimeout: Joi.number().min(0).integer(),
executionTimeout: Joi.number().min(0).integer(),
orphanedTimeout: Joi.number().min(0).integer(),
heartBeatInterval: Joi.number().min(0).integer()
heartBeatInterval: Joi.number().min(0).integer(),
sendProcessMessageFn: Joi.func(),
sendCancelMessageFn: Joi.func(),
});

const dbTypes = Joi.alternatives().try(
Expand Down Expand Up @@ -47,17 +49,21 @@ const schemaOptions = Joi.object().keys({
updateCompilerCacheKeepAlive: Joi.boolean(),
telemetry: Joi.boolean(),
allowUngroupedWithoutPrimaryKey: Joi.boolean(),
orchestratorOptions: Joi.object().keys({
redisPrefix: Joi.string().allow(''),
queryCacheOptions: Joi.object().keys({
refreshKeyRenewalThreshold: Joi.number().min(0).integer(),
backgroundRenew: Joi.boolean(),
queueOptions: schemaQueueOptions
}),
preAggregationsOptions: {
queueOptions: schemaQueueOptions
}
}),
orchestratorOptions: Joi.alternatives().try(
Joi.func(),
Joi.object().keys({
redisPrefix: Joi.string().allow(''),
queryCacheOptions: Joi.object().keys({
refreshKeyRenewalThreshold: Joi.number().min(0).integer(),
backgroundRenew: Joi.boolean(),
queueOptions: schemaQueueOptions,
externalQueueOptions: schemaQueueOptions
}),
preAggregationsOptions: {
queueOptions: schemaQueueOptions
}
})
),
allowJsDuplicatePropsInSchema: Joi.boolean(),
scheduledRefreshContexts: Joi.func()
});
Expand Down

0 comments on commit 48ca5aa

Please sign in to comment.