-
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.
[Fleet] Make logs-* and metrics-* data views available across all spa…
…ces (#172991) ## Summary Closes #172009 Adds a call to `updateObjectsSpaces` with `['*']` as the spaces list after Fleet's managed data views are created. Existing data views will be updated to be global whenever `installKibanaAssets` is called. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
Showing
4 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.test.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,54 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server'; | ||
import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks'; | ||
|
||
import { createAppContextStartContractMock } from '../../../../mocks'; | ||
|
||
import { appContextService } from '../../../app_context'; | ||
|
||
import { makeManagedIndexPatternsGlobal } from './install'; | ||
|
||
describe('Fleet index patterns', () => { | ||
let mockSoClient: jest.Mocked<SavedObjectsClientContract>; | ||
let mockContract: ReturnType<typeof createAppContextStartContractMock>; | ||
|
||
beforeEach(() => { | ||
mockSoClient = savedObjectsClientMock.create(); | ||
mockContract = createAppContextStartContractMock(); | ||
appContextService.start(mockContract); | ||
}); | ||
|
||
afterEach(() => { | ||
appContextService.stop(); | ||
}); | ||
|
||
describe('makeManagedIndexPatternsGlobal', () => { | ||
it('should call updateObjectsSpaces with the correct params', async () => { | ||
const result = await makeManagedIndexPatternsGlobal(mockSoClient); | ||
|
||
for (const pattern of ['logs-*', 'metrics-*']) { | ||
expect(mockSoClient.updateObjectsSpaces).toHaveBeenCalledWith( | ||
[{ id: pattern, type: 'index-pattern' }], | ||
['*'], | ||
[] | ||
); | ||
} | ||
|
||
expect(result).toHaveLength(2); | ||
}); | ||
|
||
it('handles errors from updateObjectsSpaces', async () => { | ||
mockSoClient.updateObjectsSpaces.mockRejectedValue(new Error('foo')); | ||
|
||
const result = await makeManagedIndexPatternsGlobal(mockSoClient); | ||
|
||
expect(result).toHaveLength(0); | ||
}); | ||
}); | ||
}); |
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