[Reporting] add capture.maxAttempts setting (#44011)
* [Reporting] add capture.maxAttempts setting * restore default in code, so tests will pass * --wip-- [skip ci] * write test * fix test * update error message with value
This commit is contained in:
parent
06ee760e09
commit
264ac76f77
|
@ -83,6 +83,10 @@ Defaults to `120000` (two minutes).
|
|||
Reporting works by capturing screenshots from Kibana. The following settings
|
||||
control the capturing process.
|
||||
|
||||
`xpack.reporting.capture.maxAttempts`::
|
||||
If capturing a report fails for any reason, Kibana will re-attempt othe reporting
|
||||
job, as many times as this setting. Defaults to `3`.
|
||||
|
||||
`xpack.reporting.capture.loadDelay`::
|
||||
When visualizations are not evented, this is the amount of time before
|
||||
taking a screenshot. All visualizations that ship with Kibana are evented, so this
|
||||
|
|
|
@ -16,6 +16,7 @@ Object {
|
|||
},
|
||||
"concurrency": 4,
|
||||
"loadDelay": 3000,
|
||||
"maxAttempts": 1,
|
||||
"settleTime": 1000,
|
||||
"timeout": 20000,
|
||||
"viewport": Object {
|
||||
|
@ -78,6 +79,7 @@ Object {
|
|||
},
|
||||
"concurrency": 4,
|
||||
"loadDelay": 3000,
|
||||
"maxAttempts": 3,
|
||||
"settleTime": 1000,
|
||||
"timeout": 20000,
|
||||
"viewport": Object {
|
||||
|
@ -139,6 +141,7 @@ Object {
|
|||
},
|
||||
"concurrency": 4,
|
||||
"loadDelay": 3000,
|
||||
"maxAttempts": 1,
|
||||
"settleTime": 1000,
|
||||
"timeout": 20000,
|
||||
"viewport": Object {
|
||||
|
@ -201,6 +204,7 @@ Object {
|
|||
},
|
||||
"concurrency": 4,
|
||||
"loadDelay": 3000,
|
||||
"maxAttempts": 3,
|
||||
"settleTime": 1000,
|
||||
"timeout": 20000,
|
||||
"viewport": Object {
|
||||
|
|
|
@ -130,6 +130,11 @@ export const reporting = (kibana) => {
|
|||
}).default(),
|
||||
maxScreenshotDimension: Joi.number().integer().default(1950)
|
||||
}).default()
|
||||
}).default(),
|
||||
maxAttempts: Joi.number().integer().greater(0).when('$dist', {
|
||||
is: true,
|
||||
then: Joi.default(3),
|
||||
otherwise: Joi.default(1),
|
||||
}).default()
|
||||
}).default(),
|
||||
csv: Joi.object({
|
||||
|
|
|
@ -23,6 +23,7 @@ function enqueueJobFn(server: KbnServer) {
|
|||
const config = server.config();
|
||||
const queueConfig = config.get('xpack.reporting.queue');
|
||||
const browserType = config.get('xpack.reporting.capture.browser.type');
|
||||
const maxAttempts = config.get('xpack.reporting.capture.maxAttempts');
|
||||
const exportTypesRegistry = server.plugins.reporting.exportTypesRegistry;
|
||||
|
||||
return async function enqueueJob(
|
||||
|
@ -42,6 +43,7 @@ function enqueueJobFn(server: KbnServer) {
|
|||
timeout: queueConfig.timeout,
|
||||
created_by: get(user, 'username', false),
|
||||
browser_type: browserType,
|
||||
max_attempts: maxAttempts,
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
@ -67,6 +67,11 @@ describe('Job Class', function () {
|
|||
const init = () => new Job(mockQueue, index, 'type1', [1, 2, 3]);
|
||||
expect(init).to.throwException(/plain.+object/i);
|
||||
});
|
||||
|
||||
it(`should throw error if invalid maxAttempts`, function () {
|
||||
const init = () => new Job(mockQueue, index, 'type1', { id: '123' }, { max_attempts: -1 });
|
||||
expect(init).to.throwException(/invalid.+max_attempts/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('construction', function () {
|
||||
|
|
|
@ -32,6 +32,10 @@ export class Job extends events.EventEmitter {
|
|||
this.indexSettings = options.indexSettings || {};
|
||||
this.browser_type = options.browser_type;
|
||||
|
||||
if (typeof this.maxAttempts !== 'number' || this.maxAttempts < 1) {
|
||||
throw new Error(`Invalid max_attempts: ${this.maxAttempts}`);
|
||||
}
|
||||
|
||||
this.debug = (msg, err) => {
|
||||
const logger = options.logger || function () {};
|
||||
const message = `${this.id} - ${msg}`;
|
||||
|
|
Loading…
Reference in a new issue