forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Add upgrade system indices section (elastic#110593)
- Loading branch information
1 parent
0748c08
commit 3c12ced
Showing
22 changed files
with
1,159 additions
and
27 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
22 changes: 22 additions & 0 deletions
22
...st__/client_integration/overview/migrate_system_indices/__snapshots__/flyout.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
...rade_assistant/__jest__/client_integration/overview/migrate_system_indices/flyout.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,42 @@ | ||
/* | ||
* 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 { act } from 'react-dom/test-utils'; | ||
|
||
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; | ||
import { setupEnvironment } from '../../helpers'; | ||
import { systemIndicesMigrationStatus } from './mocks'; | ||
|
||
describe('Overview - Migrate system indices - Flyout', () => { | ||
let testBed: OverviewTestBed; | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
|
||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus(systemIndicesMigrationStatus); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
testBed.component.update(); | ||
}); | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
test('shows correct features in flyout table', async () => { | ||
const { actions, table } = testBed; | ||
|
||
await actions.clickViewSystemIndicesState(); | ||
|
||
const { tableCellsValues } = table.getMetaData('flyoutDetails'); | ||
|
||
expect(tableCellsValues.length).toBe(systemIndicesMigrationStatus.features.length); | ||
expect(tableCellsValues).toMatchSnapshot(); | ||
}); | ||
}); |
136 changes: 136 additions & 0 deletions
136
...jest__/client_integration/overview/migrate_system_indices/migrate_system_indices.test.tsx
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,136 @@ | ||
/* | ||
* 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 { act } from 'react-dom/test-utils'; | ||
|
||
import { setupEnvironment } from '../../helpers'; | ||
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; | ||
|
||
describe('Overview - Migrate system indices', () => { | ||
let testBed: OverviewTestBed; | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
|
||
beforeEach(async () => { | ||
testBed = await setupOverviewPage(); | ||
testBed.component.update(); | ||
}); | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
describe('Error state', () => { | ||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus(undefined, { | ||
statusCode: 400, | ||
message: 'error', | ||
}); | ||
|
||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
test('Is rendered', () => { | ||
const { exists, component } = testBed; | ||
component.update(); | ||
|
||
expect(exists('systemIndicesStatusErrorCallout')).toBe(true); | ||
}); | ||
|
||
test('Lets the user attempt to reload migration status', async () => { | ||
const { exists, component, actions } = testBed; | ||
component.update(); | ||
|
||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'NO_UPGRADE_NEEDED', | ||
}); | ||
|
||
await actions.clickRetrySystemIndicesButton(); | ||
|
||
expect(exists('noMigrationNeededSection')).toBe(true); | ||
}); | ||
}); | ||
|
||
test('No migration needed', async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'NO_UPGRADE_NEEDED', | ||
}); | ||
|
||
testBed = await setupOverviewPage(); | ||
|
||
const { exists, component } = testBed; | ||
|
||
component.update(); | ||
|
||
expect(exists('noMigrationNeededSection')).toBe(true); | ||
expect(exists('startSystemIndicesMigrationButton')).toBe(false); | ||
expect(exists('viewSystemIndicesStateButton')).toBe(false); | ||
}); | ||
|
||
test('Migration in progress', async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'IN_PROGRESS', | ||
}); | ||
|
||
testBed = await setupOverviewPage(); | ||
|
||
const { exists, component, find } = testBed; | ||
|
||
component.update(); | ||
|
||
// Start migration is disabled | ||
expect(exists('startSystemIndicesMigrationButton')).toBe(true); | ||
expect(find('startSystemIndicesMigrationButton').props().disabled).toBe(true); | ||
// But we keep view system indices CTA | ||
expect(exists('viewSystemIndicesStateButton')).toBe(true); | ||
}); | ||
|
||
describe('Migration needed', () => { | ||
test('Initial state', async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
}); | ||
|
||
testBed = await setupOverviewPage(); | ||
|
||
const { exists, component, find } = testBed; | ||
|
||
component.update(); | ||
|
||
// Start migration should be enabled | ||
expect(exists('startSystemIndicesMigrationButton')).toBe(true); | ||
expect(find('startSystemIndicesMigrationButton').props().disabled).toBe(false); | ||
// Same for view system indices status | ||
expect(exists('viewSystemIndicesStateButton')).toBe(true); | ||
}); | ||
|
||
test('Handles errors when migrating', async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
}); | ||
httpRequestsMockHelpers.setSystemIndicesMigrationResponse(undefined, { | ||
statusCode: 400, | ||
message: 'error', | ||
}); | ||
|
||
testBed = await setupOverviewPage(); | ||
|
||
const { exists, component, find } = testBed; | ||
|
||
await act(async () => { | ||
find('startSystemIndicesMigrationButton').simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
|
||
// Error is displayed | ||
expect(exists('startSystemIndicesMigrationCalloutError')).toBe(true); | ||
// CTA is enabled | ||
expect(exists('startSystemIndicesMigrationButton')).toBe(true); | ||
expect(find('startSystemIndicesMigrationButton').props().disabled).toBe(false); | ||
}); | ||
}); | ||
}); |
58 changes: 58 additions & 0 deletions
58
...ns/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/mocks.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,58 @@ | ||
/* | ||
* 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 { SystemIndicesMigrationStatus } from '../../../../common/types'; | ||
|
||
export const systemIndicesMigrationStatus: SystemIndicesMigrationStatus = { | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
features: [ | ||
{ | ||
feature_name: 'security', | ||
minimum_index_version: '7.1.1', | ||
upgrade_status: 'ERROR', | ||
indices: [ | ||
{ | ||
index: '.security-7', | ||
version: '7.1.1', | ||
}, | ||
], | ||
}, | ||
{ | ||
feature_name: 'machine_learning', | ||
minimum_index_version: '7.1.2', | ||
upgrade_status: 'IN_PROGRESS', | ||
indices: [ | ||
{ | ||
index: '.ml-config', | ||
version: '7.1.2', | ||
}, | ||
], | ||
}, | ||
{ | ||
feature_name: 'kibana', | ||
minimum_index_version: '7.1.3', | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
indices: [ | ||
{ | ||
index: '.kibana', | ||
version: '7.1.3', | ||
}, | ||
], | ||
}, | ||
{ | ||
feature_name: 'logstash', | ||
minimum_index_version: '7.1.4', | ||
upgrade_status: 'NO_UPGRADE_NEEDED', | ||
indices: [ | ||
{ | ||
index: '.logstash-config', | ||
version: '7.1.4', | ||
}, | ||
], | ||
}, | ||
], | ||
}; |
86 changes: 86 additions & 0 deletions
86
...stant/__jest__/client_integration/overview/migrate_system_indices/step_completion.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,86 @@ | ||
/* | ||
* 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 { act } from 'react-dom/test-utils'; | ||
|
||
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers'; | ||
import { setupEnvironment, advanceTime } from '../../helpers'; | ||
import { SYSTEM_INDICES_MIGRATION_POLL_INTERVAL_MS } from '../../../../common/constants'; | ||
|
||
describe('Overview - Migrate system indices - Step completion', () => { | ||
let testBed: OverviewTestBed; | ||
const { server, httpRequestsMockHelpers } = setupEnvironment(); | ||
|
||
afterAll(() => { | ||
server.restore(); | ||
}); | ||
|
||
test(`It's complete when no upgrade is needed`, async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'NO_UPGRADE_NEEDED', | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
const { exists, component } = testBed; | ||
|
||
component.update(); | ||
|
||
expect(exists(`migrateSystemIndicesStep-complete`)).toBe(true); | ||
}); | ||
|
||
test(`It's incomplete when migration is needed`, async () => { | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
const { exists, component } = testBed; | ||
|
||
component.update(); | ||
|
||
expect(exists(`migrateSystemIndicesStep-incomplete`)).toBe(true); | ||
}); | ||
|
||
describe('Poll for new status', () => { | ||
beforeEach(async () => { | ||
jest.useFakeTimers(); | ||
|
||
// First request should make the step be incomplete | ||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'IN_PROGRESS', | ||
}); | ||
|
||
testBed = await setupOverviewPage(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
test('renders step as complete when a upgraded needed status is followed by a no upgrade needed', async () => { | ||
const { exists } = testBed; | ||
|
||
expect(exists('migrateSystemIndicesStep-incomplete')).toBe(true); | ||
|
||
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ | ||
upgrade_status: 'NO_UPGRADE_NEEDED', | ||
}); | ||
|
||
// Resolve the polling timeout. | ||
await advanceTime(SYSTEM_INDICES_MIGRATION_POLL_INTERVAL_MS); | ||
testBed.component.update(); | ||
|
||
expect(exists('migrateSystemIndicesStep-complete')).toBe(true); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.