-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Surface data streams in Index Management. #67806
Changes from 8 commits
69a79a8
43db94b
0c32434
aaa14c1
ecc96db
e17df1d
fdd85ad
97369b0
da3706f
e7d48d1
f797a23
ddc8666
5264922
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export type TestSubjects = | ||
| 'aliasesTab' | ||
| 'appTitle' | ||
| 'cell' | ||
| 'closeDetailsButton' | ||
| 'createLegacyTemplateButton' | ||
| 'createTemplateButton' | ||
| 'dataStreamTable' | ||
| 'dataStreamTable' | ||
| 'deleteSystemTemplateCallOut' | ||
| 'deleteTemplateButton' | ||
| 'deleteTemplatesConfirmation' | ||
| 'documentationLink' | ||
| 'emptyPrompt' | ||
| 'filterList.filterItem' | ||
| 'indexTable' | ||
| 'indexTableIncludeHiddenIndicesToggle' | ||
| 'indexTableIndexNameLink' | ||
| 'indicesList' | ||
| 'indicesTab' | ||
| 'legacyTemplateTable' | ||
| 'manageTemplateButton' | ||
| 'mappingsTab' | ||
| 'noAliasesCallout' | ||
| 'noMappingsCallout' | ||
| 'noSettingsCallout' | ||
| 'reloadButton' | ||
| 'reloadIndicesButton' | ||
| 'row' | ||
| 'sectionError' | ||
| 'sectionLoading' | ||
| 'settingsTab' | ||
| 'summaryTab' | ||
| 'summaryTitle' | ||
| 'systemTemplatesSwitch' | ||
| 'templateDetails' | ||
| 'templateDetails.manageTemplateButton' | ||
| 'templateDetails.sectionLoading' | ||
| 'templateDetails.tab' | ||
| 'templateDetails.title' | ||
| 'templateList' | ||
| 'templatesTab' | ||
| 'templateTable' | ||
| 'viewButton'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
|
||
import { | ||
registerTestBed, | ||
TestBed, | ||
TestBedConfig, | ||
findTestSubject, | ||
} from '../../../../../test_utils'; | ||
import { DataStream } from '../../../common'; | ||
import { IndexManagementHome } from '../../../public/application/sections/home'; // eslint-disable-line @kbn/eslint/no-restricted-paths | ||
import { indexManagementStore } from '../../../public/application/store'; // eslint-disable-line @kbn/eslint/no-restricted-paths | ||
import { WithAppDependencies, services, TestSubjects } from '../helpers'; | ||
|
||
const testBedConfig: TestBedConfig = { | ||
store: () => indexManagementStore(services as any), | ||
memoryRouter: { | ||
initialEntries: [`/indices`], | ||
componentRoutePath: `/:section(indices|data_streams)`, | ||
}, | ||
doMountAsync: true, | ||
}; | ||
|
||
const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig); | ||
|
||
export interface DataStreamsTabTestBed extends TestBed<TestSubjects> { | ||
actions: { | ||
goToDataStreamsList: () => void; | ||
clickReloadButton: () => void; | ||
clickIndicesAt: (index: number) => void; | ||
}; | ||
} | ||
|
||
export const setup = async (): Promise<DataStreamsTabTestBed> => { | ||
const testBed = await initTestBed(); | ||
|
||
/** | ||
* User Actions | ||
*/ | ||
|
||
const goToDataStreamsList = () => { | ||
testBed.find('data_streamsTab').simulate('click'); | ||
}; | ||
|
||
const clickReloadButton = () => { | ||
const { find } = testBed; | ||
find('reloadButton').simulate('click'); | ||
}; | ||
|
||
const clickIndicesAt = async (index: number) => { | ||
const { component, table, router } = testBed; | ||
const { rows } = table.getMetaData('dataStreamTable'); | ||
const indicesLink = findTestSubject(rows[index].reactWrapper, 'indicesLink'); | ||
|
||
await act(async () => { | ||
router.navigateTo(indicesLink.props().href!); | ||
}); | ||
|
||
component.update(); | ||
}; | ||
|
||
return { | ||
...testBed, | ||
actions: { | ||
goToDataStreamsList, | ||
clickReloadButton, | ||
clickIndicesAt, | ||
}, | ||
}; | ||
}; | ||
|
||
export const createDataStreamPayload = (name: string): DataStream => ({ | ||
name, | ||
timeStampField: '@timestamp', | ||
indices: [ | ||
{ | ||
name: 'indexName', | ||
uuid: 'indexId', | ||
}, | ||
], | ||
generation: 1, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
|
||
import { API_BASE_PATH } from '../../../common/constants'; | ||
import { setupEnvironment } from '../helpers'; | ||
|
||
import { DataStreamsTabTestBed, setup, createDataStreamPayload } from './data_streams_tab.helpers'; | ||
|
||
describe('Data Streams tab', () => { | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
let testBed: DataStreamsTabTestBed; | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadIndicesResponse([ | ||
{ | ||
health: '', | ||
status: '', | ||
primary: '', | ||
replica: '', | ||
documents: '', | ||
documents_deleted: '', | ||
size: '', | ||
primary_size: '', | ||
name: 'data-stream-index', | ||
data_stream: 'dataStream1', | ||
}, | ||
{ | ||
health: 'green', | ||
status: 'open', | ||
primary: 1, | ||
replica: 1, | ||
documents: 10000, | ||
documents_deleted: 100, | ||
size: '156kb', | ||
primary_size: '156kb', | ||
name: 'non-data-stream-index', | ||
}, | ||
]); | ||
|
||
await act(async () => { | ||
testBed = await setup(); | ||
}); | ||
}); | ||
|
||
describe('when there are no data streams', () => { | ||
beforeEach(async () => { | ||
const { actions, component } = testBed; | ||
|
||
httpRequestsMockHelpers.setLoadDataStreamsResponse([]); | ||
|
||
await act(async () => { | ||
actions.goToDataStreamsList(); | ||
}); | ||
|
||
component.update(); | ||
}); | ||
|
||
test('displays an empty prompt', async () => { | ||
const { exists } = testBed; | ||
|
||
expect(exists('sectionLoading')).toBe(false); | ||
expect(exists('emptyPrompt')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('when there are data streams', () => { | ||
beforeEach(async () => { | ||
const { actions, component } = testBed; | ||
|
||
httpRequestsMockHelpers.setLoadDataStreamsResponse([ | ||
createDataStreamPayload('dataStream1'), | ||
createDataStreamPayload('dataStream2'), | ||
]); | ||
|
||
await act(async () => { | ||
actions.goToDataStreamsList(); | ||
}); | ||
|
||
component.update(); | ||
}); | ||
|
||
test('lists them in the table', async () => { | ||
const { table } = testBed; | ||
|
||
const { tableCellsValues } = table.getMetaData('dataStreamTable'); | ||
|
||
expect(tableCellsValues).toEqual([ | ||
['dataStream1', '1', '@timestamp', '1'], | ||
['dataStream2', '1', '@timestamp', '1'], | ||
]); | ||
}); | ||
|
||
test('has a button to reload the data streams', async () => { | ||
const { exists, actions } = testBed; | ||
const totalRequests = server.requests.length; | ||
|
||
expect(exists('reloadButton')).toBe(true); | ||
|
||
await act(async () => { | ||
actions.clickReloadButton(); | ||
}); | ||
|
||
expect(server.requests.length).toBe(totalRequests + 1); | ||
expect(server.requests[server.requests.length - 1].url).toBe(`${API_BASE_PATH}/data_streams`); | ||
}); | ||
|
||
test('clicking the indices count navigates to the backing indices', async () => { | ||
const { table, actions } = testBed; | ||
|
||
await actions.clickIndicesAt(0); | ||
|
||
expect(table.getMetaData('indexTable').tableCellsValues).toEqual([ | ||
['', '', '', '', '', '', '', 'dataStream1'], | ||
]); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,27 +6,33 @@ | |
|
||
import { act } from 'react-dom/test-utils'; | ||
|
||
import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; | ||
import { IndexList } from '../../../public/application/sections/home/index_list'; // eslint-disable-line @kbn/eslint/no-restricted-paths | ||
import { | ||
registerTestBed, | ||
TestBed, | ||
TestBedConfig, | ||
findTestSubject, | ||
} from '../../../../../test_utils'; | ||
import { IndexManagementHome } from '../../../public/application/sections/home'; // eslint-disable-line @kbn/eslint/no-restricted-paths | ||
import { indexManagementStore } from '../../../public/application/store'; // eslint-disable-line @kbn/eslint/no-restricted-paths | ||
import { WithAppDependencies, services, TestSubjects } from '../helpers'; | ||
|
||
const testBedConfig: TestBedConfig = { | ||
store: () => indexManagementStore(services as any), | ||
memoryRouter: { | ||
initialEntries: [`/indices?includeHiddenIndices=true`], | ||
componentRoutePath: `/:section(indices|templates)`, | ||
componentRoutePath: `/:section(indices|data_streams)`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we'd need to add |
||
}, | ||
doMountAsync: true, | ||
}; | ||
|
||
const initTestBed = registerTestBed(WithAppDependencies(IndexList), testBedConfig); | ||
const initTestBed = registerTestBed(WithAppDependencies(IndexManagementHome), testBedConfig); | ||
|
||
export interface IndicesTestBed extends TestBed<TestSubjects> { | ||
actions: { | ||
selectIndexDetailsTab: (tab: 'settings' | 'mappings' | 'stats' | 'edit_settings') => void; | ||
getIncludeHiddenIndicesToggleStatus: () => boolean; | ||
clickIncludeHiddenIndicesToggle: () => void; | ||
clickDataStreamAt: (index: number) => void; | ||
}; | ||
} | ||
|
||
|
@@ -59,12 +65,25 @@ export const setup = async (): Promise<IndicesTestBed> => { | |
component.update(); | ||
}; | ||
|
||
const clickDataStreamAt = async (index: number) => { | ||
const { component, table, router } = testBed; | ||
const { rows } = table.getMetaData('indexTable'); | ||
const dataStreamLink = findTestSubject(rows[index].reactWrapper, 'dataStreamLink'); | ||
|
||
await act(async () => { | ||
router.navigateTo(dataStreamLink.props().href!); | ||
}); | ||
|
||
component.update(); | ||
}; | ||
|
||
return { | ||
...testBed, | ||
actions: { | ||
selectIndexDetailsTab, | ||
getIncludeHiddenIndicesToggleStatus, | ||
clickIncludeHiddenIndicesToggle, | ||
clickDataStreamAt, | ||
}, | ||
}; | ||
}; |
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.
Should this be
indices|data_streams|templates
?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.
Same reasoning here. WDYT?
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.
Though now that I've added the link to index templates from the empty prompt, I see a reason to add it here. :)