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.
Add rolling upgrade interstitials to UA (elastic#112907)
* Refactor FixLogsStep to be explicit in which props are passed to DeprecationLoggingToggle. * Centralize error-handling logic in the api service, instead of handling it within each individual API request. Covers: - Cloud backup status - ES deprecations - Deprecation logging - Remove index settings - ML - Reindexing Also: - Handle 426 error state and surface in UI. - Move ResponseError type into common/types. * Add note about intended use case of status API route. * Add endpoint dedicated to surfacing the cluster upgrade state, and a client-side poll. * Merge App and AppWithRouter components.
- Loading branch information
1 parent
02c36f7
commit 120960d
Showing
22 changed files
with
419 additions
and
71 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
x-pack/plugins/upgrade_assistant/__jest__/client_integration/app/app.helpers.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,50 @@ | ||
/* | ||
* 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 { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; | ||
|
||
import { App } from '../../../public/application/app'; | ||
import { WithAppDependencies } from '../helpers'; | ||
|
||
const testBedConfig: TestBedConfig = { | ||
memoryRouter: { | ||
initialEntries: [`/overview`], | ||
componentRoutePath: '/overview', | ||
}, | ||
doMountAsync: true, | ||
}; | ||
|
||
export type AppTestBed = TestBed & { | ||
actions: ReturnType<typeof createActions>; | ||
}; | ||
|
||
const createActions = (testBed: TestBed) => { | ||
const clickDeprecationToggle = async () => { | ||
const { find, component } = testBed; | ||
|
||
await act(async () => { | ||
find('deprecationLoggingToggle').simulate('click'); | ||
}); | ||
|
||
component.update(); | ||
}; | ||
|
||
return { | ||
clickDeprecationToggle, | ||
}; | ||
}; | ||
|
||
export const setupAppPage = async (overrides?: Record<string, unknown>): Promise<AppTestBed> => { | ||
const initTestBed = registerTestBed(WithAppDependencies(App, overrides), testBedConfig); | ||
const testBed = await initTestBed(); | ||
|
||
return { | ||
...testBed, | ||
actions: createActions(testBed), | ||
}; | ||
}; |
86 changes: 86 additions & 0 deletions
86
x-pack/plugins/upgrade_assistant/__jest__/client_integration/app/cluster_upgrade.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,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 { setupEnvironment } from '../helpers'; | ||
import { AppTestBed, setupAppPage } from './app.helpers'; | ||
|
||
describe('Cluster upgrade', () => { | ||
let testBed: AppTestBed; | ||
let server: ReturnType<typeof setupEnvironment>['server']; | ||
let httpRequestsMockHelpers: ReturnType<typeof setupEnvironment>['httpRequestsMockHelpers']; | ||
|
||
beforeEach(() => { | ||
({ server, httpRequestsMockHelpers } = setupEnvironment()); | ||
}); | ||
|
||
afterEach(() => { | ||
server.restore(); | ||
}); | ||
|
||
describe('when user is still preparing for upgrade', () => { | ||
beforeEach(async () => { | ||
testBed = await setupAppPage(); | ||
}); | ||
|
||
test('renders overview', () => { | ||
const { exists } = testBed; | ||
expect(exists('overview')).toBe(true); | ||
expect(exists('isUpgradingMessage')).toBe(false); | ||
expect(exists('isUpgradeCompleteMessage')).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('when cluster is in the process of a rolling upgrade', () => { | ||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, { | ||
statusCode: 426, | ||
message: '', | ||
attributes: { | ||
allNodesUpgraded: false, | ||
}, | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupAppPage(); | ||
}); | ||
}); | ||
|
||
test('renders rolling upgrade message', async () => { | ||
const { component, exists } = testBed; | ||
component.update(); | ||
expect(exists('overview')).toBe(false); | ||
expect(exists('isUpgradingMessage')).toBe(true); | ||
expect(exists('isUpgradeCompleteMessage')).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('when cluster has been upgraded', () => { | ||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, { | ||
statusCode: 426, | ||
message: '', | ||
attributes: { | ||
allNodesUpgraded: true, | ||
}, | ||
}); | ||
|
||
await act(async () => { | ||
testBed = await setupAppPage(); | ||
}); | ||
}); | ||
|
||
test('renders upgrade complete message', () => { | ||
const { component, exists } = testBed; | ||
component.update(); | ||
expect(exists('overview')).toBe(false); | ||
expect(exists('isUpgradingMessage')).toBe(false); | ||
expect(exists('isUpgradeCompleteMessage')).toBe(true); | ||
}); | ||
}); | ||
}); |
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
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
Oops, something went wrong.