Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,33 +338,6 @@ describe('SynchronizationTaskRunner', () => {
});

describe('Error handling', () => {
it('An error is thrown for invalid task state', async () => {
const getESClient = async () => esClient;

taskRunner = new SynchronizationTaskRunner({
logger,
getESClient,
taskInstance: {
...taskInstance,
state: {
// A missing esReindexTaskId should have missing sync times
lastSyncAttempt: 'some-time',
},
},
});

try {
await taskRunner.run();
} catch (e) {
expect(isRetryableError(e)).toBe(null);
}

expect(logger.error).toBeCalledWith(
'[.internal.cases] Synchronization reindex failed. Error: Invalid task state.',
{ tags: ['cai-synchronization', 'cai-synchronization-error', '.internal.cases'] }
);
});

it('calls throwRetryableError if the esClient throws a retryable error', async () => {
esClient.tasks.get.mockRejectedValueOnce(new esErrors.ConnectionError('My retryable error'));

Expand Down
1 change: 1 addition & 0 deletions x-pack/platform/plugins/shared/cases/server/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('config validation', () => {
it('sets the defaults correctly', () => {
expect(ConfigSchema.validate({})).toMatchInlineSnapshot(`
Object {
"analytics": Object {},
"files": Object {
"allowedMimeTypes": Array [
"image/aces",
Expand Down
7 changes: 7 additions & 0 deletions x-pack/platform/plugins/shared/cases/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export const ConfigSchema = schema.object({
stack: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
analytics: schema.object({
index: schema.maybe(
schema.object({
enabled: schema.boolean({ defaultValue: false }),
})
),
}),
});

export type ConfigType = TypeOf<typeof ConfigSchema>;
1 change: 1 addition & 0 deletions x-pack/platform/plugins/shared/cases/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function getConfig(overrides = {}) {
markdownPlugins: { lens: true },
files: { maxSize: 1, allowedMimeTypes: ALLOWED_MIME_TYPES },
stack: { enabled: true },
analytics: {},
...overrides,
};
}
Expand Down
17 changes: 9 additions & 8 deletions x-pack/platform/plugins/shared/cases/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,17 @@ export class CasePlugin

if (plugins.taskManager) {
scheduleCasesTelemetryTask(plugins.taskManager, this.logger);
scheduleCasesAnalyticsSyncTasks({ taskManager: plugins.taskManager, logger: this.logger });
if (this.caseConfig.analytics.index?.enabled) {
scheduleCasesAnalyticsSyncTasks({ taskManager: plugins.taskManager, logger: this.logger });
createCasesAnalyticsIndexes({
esClient: core.elasticsearch.client.asInternalUser,
logger: this.logger,
isServerless: this.isServerless,
taskManager: plugins.taskManager,
}).catch(() => {}); // it shouldn't reject, but just in case
}
}

createCasesAnalyticsIndexes({
esClient: core.elasticsearch.client.asInternalUser,
logger: this.logger,
isServerless: this.isServerless,
taskManager: plugins.taskManager,
}).catch(() => {}); // it shouldn't reject, but just in case

this.userProfileService.initialize({
spaces: plugins.spaces,
// securityPluginSetup will be set to a defined value in the setup() function
Expand Down