-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Index Management] Remove _cat/indices API from server code
#122867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yuliacech
merged 13 commits into
elastic:main
from
yuliacech:index_management_remove_cat
Jan 28, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2dfb191
[IM] Replace Cat Indices API with Indices Stats API that now return i…
yuliacech 91b4b71
[IM] Fixed types and updated how primary and replica shards info is c…
yuliacech 8aa9065
Merge branch 'main' into index_management_remove_cat
kibanamachine ff7fbed
[IM] Fixed primary and replica numbers and added server side tests
yuliacech 2a72f3e
[IM] Fixed flaky api integration test
yuliacech 0a52363
Merge branch 'main' into index_management_remove_cat
yuliacech aa88ccd
Merge branch 'main' into index_management_remove_cat
kibanamachine 3dba131
[Index Management] Updated `filter_path` to include necessary index p…
yuliacech c2b23ca
Merge branch 'main' into index_management_remove_cat
kibanamachine c8cd054
[ILM] Updated snapshots for extend index management tests
yuliacech c0ce850
Merge branch 'main' into index_management_remove_cat
kibanamachine ec90a68
[IM] Made fetch indices call work with indices missing in stats object
yuliacech 9912aa6
[IM] Updated the comment about response size
yuliacech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 6 additions & 6 deletions
12
...s/index_lifecycle_management/__jest__/__snapshots__/extend_index_management.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
185 changes: 185 additions & 0 deletions
185
x-pack/plugins/index_management/server/lib/fetch_indices.test.ts
This file contains hidden or 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,185 @@ | ||
| /* | ||
| * 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 { RequestMock, routeDependencies, RouterMock } from '../test/helpers'; | ||
| import { addBasePath } from '../routes/api'; | ||
| import { registerIndicesRoutes } from '../routes/api/indices'; | ||
| import { | ||
| createTestIndexResponse, | ||
| createTestIndexState, | ||
| createTestIndexStats, | ||
| } from '../test/helpers/indices_fixtures'; | ||
|
|
||
| describe('[Index management API Routes] fetch indices lib function', () => { | ||
| const router = new RouterMock(); | ||
|
|
||
| const getIndices = router.getMockESApiFn('indices.get'); | ||
| const getIndicesStats = router.getMockESApiFn('indices.stats'); | ||
| const mockRequest: RequestMock = { | ||
| method: 'get', | ||
| path: addBasePath('/indices'), | ||
| }; | ||
|
|
||
| beforeAll(() => { | ||
| registerIndicesRoutes({ | ||
| ...routeDependencies, | ||
| router, | ||
| }); | ||
| }); | ||
|
|
||
| test('regular index', async () => { | ||
| getIndices.mockResolvedValue({ | ||
| body: { | ||
| regular_index: createTestIndexState(), | ||
| }, | ||
| }); | ||
| getIndicesStats.mockResolvedValue({ | ||
| body: { | ||
| indices: { | ||
| regular_index: createTestIndexStats({ uuid: 'regular_index' }), | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| await expect(router.runRequest(mockRequest)).resolves.toEqual({ | ||
| body: [createTestIndexResponse({ name: 'regular_index', uuid: 'regular_index' })], | ||
| }); | ||
| }); | ||
| test('index with aliases', async () => { | ||
| getIndices.mockResolvedValue({ | ||
| body: { | ||
| index_with_aliases: createTestIndexState({ | ||
| aliases: { test_alias: {}, another_alias: {} }, | ||
| }), | ||
| }, | ||
| }); | ||
| getIndicesStats.mockResolvedValue({ | ||
| body: { | ||
| indices: { | ||
| index_with_aliases: createTestIndexStats({ uuid: 'index_with_aliases' }), | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| await expect(router.runRequest(mockRequest)).resolves.toEqual({ | ||
| body: [ | ||
| createTestIndexResponse({ | ||
| aliases: ['test_alias', 'another_alias'], | ||
| name: 'index_with_aliases', | ||
| uuid: 'index_with_aliases', | ||
| }), | ||
| ], | ||
| }); | ||
| }); | ||
| test('frozen index', async () => { | ||
| getIndices.mockResolvedValue({ | ||
| body: { | ||
| frozen_index: createTestIndexState({ | ||
| // @ts-expect-error | ||
| settings: { index: { number_of_shards: 1, number_of_replicas: 1, frozen: 'true' } }, | ||
| }), | ||
| }, | ||
| }); | ||
| getIndicesStats.mockResolvedValue({ | ||
| body: { | ||
| indices: { | ||
| frozen_index: createTestIndexStats({ uuid: 'frozen_index' }), | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| await expect(router.runRequest(mockRequest)).resolves.toEqual({ | ||
| body: [ | ||
| createTestIndexResponse({ | ||
| name: 'frozen_index', | ||
| uuid: 'frozen_index', | ||
| isFrozen: true, | ||
| }), | ||
| ], | ||
| }); | ||
| }); | ||
| test('hidden index', async () => { | ||
| getIndices.mockResolvedValue({ | ||
| body: { | ||
| hidden_index: createTestIndexState({ | ||
| settings: { index: { number_of_shards: 1, number_of_replicas: 1, hidden: 'true' } }, | ||
| }), | ||
| }, | ||
| }); | ||
| getIndicesStats.mockResolvedValue({ | ||
| body: { | ||
| indices: { | ||
| hidden_index: createTestIndexStats({ uuid: 'hidden_index' }), | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| await expect(router.runRequest(mockRequest)).resolves.toEqual({ | ||
| body: [ | ||
| createTestIndexResponse({ | ||
| name: 'hidden_index', | ||
| uuid: 'hidden_index', | ||
| hidden: true, | ||
| }), | ||
| ], | ||
| }); | ||
| }); | ||
| test('data stream index', async () => { | ||
| getIndices.mockResolvedValue({ | ||
| body: { | ||
| data_stream_index: createTestIndexState({ | ||
| data_stream: 'test_data_stream', | ||
| }), | ||
| }, | ||
| }); | ||
| getIndicesStats.mockResolvedValue({ | ||
| body: { | ||
| indices: { | ||
| data_stream_index: createTestIndexStats({ uuid: 'data_stream_index' }), | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| await expect(router.runRequest(mockRequest)).resolves.toEqual({ | ||
| body: [ | ||
| createTestIndexResponse({ | ||
| name: 'data_stream_index', | ||
| uuid: 'data_stream_index', | ||
| data_stream: 'test_data_stream', | ||
| }), | ||
| ], | ||
| }); | ||
| }); | ||
| test('index missing in stats call', async () => { | ||
| getIndices.mockResolvedValue({ | ||
| body: { | ||
| index_missing_stats: createTestIndexState(), | ||
| }, | ||
| }); | ||
| // simulates when an index has been deleted after get indices call | ||
| // deleted index won't be present in the indices stats call response | ||
| getIndicesStats.mockResolvedValue({ | ||
| body: { | ||
| indices: { | ||
| some_other_index: createTestIndexStats({ uuid: 'some_other_index' }), | ||
| }, | ||
| }, | ||
| }); | ||
| await expect(router.runRequest(mockRequest)).resolves.toEqual({ | ||
| body: [ | ||
| createTestIndexResponse({ | ||
| name: 'index_missing_stats', | ||
| uuid: undefined, | ||
| health: undefined, | ||
| status: undefined, | ||
| documents: 0, | ||
| size: '0b', | ||
| }), | ||
| ], | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about
ByteSizeValue!