-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] allow removing ad-hoc data view from event annotation group (#…
- Loading branch information
1 parent
f9bc627
commit 08a48f3
Showing
9 changed files
with
272 additions
and
6 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
test/api_integration/apis/event_annotations/event_annotations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
const CONTENT_ENDPOINT = '/api/content_management/rpc'; | ||
|
||
const CONTENT_TYPE_ID = 'event-annotation-group'; | ||
|
||
const API_VERSION = 1; | ||
|
||
const EXISTING_ID_1 = 'fcebef20-3ba4-11ee-85d3-3dd00bdd66ef'; // from loaded archive | ||
const EXISTING_ID_2 = '0d1aa670-3baf-11ee-a4a7-c11cb33a9549'; // from loaded archive | ||
|
||
const DEFAULT_EVENT_ANNOTATION_GROUP = { | ||
title: 'a group', | ||
description: '', | ||
ignoreGlobalFilters: true, | ||
dataViewSpec: null, | ||
annotations: [ | ||
{ | ||
label: 'Event', | ||
type: 'manual', | ||
key: { | ||
type: 'point_in_time', | ||
timestamp: '2023-08-10T15:00:00.000Z', | ||
}, | ||
icon: 'triangle', | ||
id: '499ee351-f541-46e0-b327-b3dcae91aff5', | ||
}, | ||
], | ||
}; | ||
|
||
const DEFAULT_REFERENCES = [ | ||
{ | ||
type: 'index-pattern', | ||
id: '90943e30-9a47-11e8-b64d-95841ca0b247', | ||
name: 'event-annotation-group_dataView-ref-90943e30-9a47-11e8-b64d-95841ca0b247', | ||
}, | ||
]; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const kibanaServer = getService('kibanaServer'); | ||
const supertest = getService('supertest'); | ||
|
||
describe('group API', () => { | ||
before(async () => { | ||
await kibanaServer.importExport.load( | ||
'test/api_integration/fixtures/kbn_archiver/event_annotations/event_annotations.json' | ||
); | ||
}); | ||
|
||
after(async () => { | ||
await kibanaServer.importExport.unload( | ||
'test/api_integration/fixtures/kbn_archiver/event_annotations/event_annotations.json' | ||
); | ||
}); | ||
|
||
describe('search', () => { | ||
// TODO test tag searching, ordering, pagination, etc | ||
|
||
it(`should retrieve existing groups`, async () => { | ||
const resp = await supertest | ||
.post(`${CONTENT_ENDPOINT}/search`) | ||
.set('kbn-xsrf', 'kibana') | ||
.send({ | ||
contentTypeId: CONTENT_TYPE_ID, | ||
query: { | ||
limit: 1000, | ||
tags: { | ||
included: [], | ||
excluded: [], | ||
}, | ||
}, | ||
version: API_VERSION, | ||
}) | ||
.expect(200); | ||
|
||
const results = resp.body.result.result.hits; | ||
expect(results.length).to.be(2); | ||
expect(results.map(({ id }: { id: string }) => id)).to.eql([EXISTING_ID_2, EXISTING_ID_1]); | ||
}); | ||
}); | ||
|
||
describe('create', () => { | ||
it(`should require dataViewSpec to be specified`, async () => { | ||
const createWithDataViewSpec = (dataViewSpec: any) => | ||
supertest | ||
.post(`${CONTENT_ENDPOINT}/create`) | ||
.set('kbn-xsrf', 'kibana') | ||
.send({ | ||
contentTypeId: CONTENT_TYPE_ID, | ||
data: { ...DEFAULT_EVENT_ANNOTATION_GROUP, dataViewSpec }, | ||
options: { | ||
references: DEFAULT_REFERENCES, | ||
}, | ||
version: API_VERSION, | ||
}); | ||
|
||
const errorResp = await createWithDataViewSpec(undefined).expect(400); | ||
|
||
expect(errorResp.body.message).to.be( | ||
'Invalid data. [dataViewSpec]: expected at least one defined value but got [undefined]' | ||
); | ||
|
||
await createWithDataViewSpec(null).expect(200); | ||
|
||
await createWithDataViewSpec({ | ||
someDataViewProp: 'some-value', | ||
}).expect(200); | ||
}); | ||
}); | ||
|
||
describe('update', () => { | ||
it(`should require dataViewSpec to be specified`, async () => { | ||
const updateWithDataViewSpec = (dataViewSpec: any) => | ||
supertest | ||
.post(`${CONTENT_ENDPOINT}/update`) | ||
.set('kbn-xsrf', 'kibana') | ||
.send({ | ||
contentTypeId: CONTENT_TYPE_ID, | ||
data: { ...DEFAULT_EVENT_ANNOTATION_GROUP, dataViewSpec }, | ||
id: EXISTING_ID_1, | ||
options: { | ||
references: DEFAULT_REFERENCES, | ||
}, | ||
version: API_VERSION, | ||
}); | ||
|
||
const errorResp = await updateWithDataViewSpec(undefined).expect(400); | ||
|
||
expect(errorResp.body.message).to.be( | ||
'Invalid data. [dataViewSpec]: expected at least one defined value but got [undefined]' | ||
); | ||
|
||
await updateWithDataViewSpec(null).expect(200); | ||
|
||
await updateWithDataViewSpec({ | ||
someDataViewProp: 'some-value', | ||
}).expect(200); | ||
}); | ||
}); | ||
|
||
// TODO - delete | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ loadTestFile }: FtrProviderContext) { | ||
describe('event annotations', () => { | ||
loadTestFile(require.resolve('./event_annotations')); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
test/api_integration/fixtures/kbn_archiver/event_annotations/event_annotations.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"attributes": { | ||
"fieldFormatMap": "{\"hour_of_day\":{}}", | ||
"name": "Kibana Sample Data Logs", | ||
"runtimeFieldMap": "{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"emit(doc['timestamp'].value.getHour());\"}}}", | ||
"timeFieldName": "timestamp", | ||
"title": "kibana_sample_data_logs" | ||
}, | ||
"coreMigrationVersion": "8.8.0", | ||
"created_at": "2023-08-15T19:49:25.494Z", | ||
"id": "90943e30-9a47-11e8-b64d-95841ca0b247", | ||
"managed": false, | ||
"references": [], | ||
"type": "index-pattern", | ||
"typeMigrationVersion": "8.0.0", | ||
"updated_at": "2023-08-15T19:49:25.494Z", | ||
"version": "WzIyLDFd" | ||
} | ||
|
||
{ | ||
"attributes": { | ||
"annotations": [ | ||
{ | ||
"color": "#6092c0", | ||
"filter": { | ||
"language": "kuery", | ||
"query": "agent.keyword : \"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)\" ", | ||
"type": "kibana_query" | ||
}, | ||
"icon": "asterisk", | ||
"id": "499ee351-f541-46e0-b327-b3dcae91aff5", | ||
"key": { | ||
"type": "point_in_time" | ||
}, | ||
"label": "Event", | ||
"lineStyle": "dashed", | ||
"timeField": "timestamp", | ||
"type": "query" | ||
} | ||
], | ||
"dataViewSpec": null, | ||
"description": "", | ||
"ignoreGlobalFilters": true, | ||
"title": "Another group" | ||
}, | ||
"coreMigrationVersion": "8.8.0", | ||
"created_at": "2023-08-15T21:02:32.023Z", | ||
"id": "0d1aa670-3baf-11ee-a4a7-c11cb33a9549", | ||
"managed": false, | ||
"references": [ | ||
{ | ||
"id": "90943e30-9a47-11e8-b64d-95841ca0b247", | ||
"name": "event-annotation-group_dataView-ref-90943e30-9a47-11e8-b64d-95841ca0b247", | ||
"type": "index-pattern" | ||
} | ||
], | ||
"type": "event-annotation-group", | ||
"updated_at": "2023-08-15T22:15:43.724Z", | ||
"version": "WzU4LDFd" | ||
} | ||
|
||
{ | ||
"attributes": { | ||
"annotations": [ | ||
{ | ||
"icon": "triangle", | ||
"id": "1d9627a8-11dc-44f1-badb-4d40a80b6bee", | ||
"key": { | ||
"timestamp": "2023-08-10T15:00:00.000Z", | ||
"type": "point_in_time" | ||
}, | ||
"label": "Event", | ||
"type": "manual" | ||
} | ||
], | ||
"dataViewSpec": null, | ||
"description": "", | ||
"ignoreGlobalFilters": true, | ||
"title": "A group" | ||
}, | ||
"coreMigrationVersion": "8.8.0", | ||
"created_at": "2023-08-15T19:50:29.907Z", | ||
"id": "fcebef20-3ba4-11ee-85d3-3dd00bdd66ef", | ||
"managed": false, | ||
"references": [ | ||
{ | ||
"id": "90943e30-9a47-11e8-b64d-95841ca0b247", | ||
"name": "event-annotation-group_dataView-ref-90943e30-9a47-11e8-b64d-95841ca0b247", | ||
"type": "index-pattern" | ||
} | ||
], | ||
"type": "event-annotation-group", | ||
"updated_at": "2023-08-15T22:13:19.290Z", | ||
"version": "WzU0LDFd" | ||
} |