Skip to content
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

[UA] ES deprecation logs in its own page #118659

Merged
merged 9 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export class DocLinksService {
mappingTermVector: `${ELASTICSEARCH_DOCS}term-vector.html`,
mappingTypesRemoval: `${ELASTICSEARCH_DOCS}removal-of-types.html`,
migrateIndexAllocationFilters: `${ELASTICSEARCH_DOCS}migrate-index-allocation-filters.html`,
migrationApiDeprecation: `${ELASTICSEARCH_DOCS}migration-api-deprecation.html`,
nodeRoles: `${ELASTICSEARCH_DOCS}modules-node.html#node-roles`,
releaseHighlights: `${ELASTICSEARCH_DOCS}release-highlights.html`,
remoteClusters: `${ELASTICSEARCH_DOCS}remote-clusters.html`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface Props {
isLoading: boolean;
hasPrivileges: boolean;
privilegesMissing: MissingPrivileges;
}) => JSX.Element;
}) => JSX.Element | null;
}

type Privilege = [string, string];
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -25561,7 +25561,6 @@
"xpack.upgradeAssistant.overview.deprecationLogs.reloadButtonLabel": "再試行",
"xpack.upgradeAssistant.overview.deprecationLogs.updateErrorMessage": "ログ状態を更新できませんでした。",
"xpack.upgradeAssistant.overview.documentationLinkText": "ドキュメント",
"xpack.upgradeAssistant.overview.identifyStepTitle": "廃止予定APIの使用を特定し、アプリケーションを更新",
"xpack.upgradeAssistant.overview.loadingLogsLabel": "ログ収集状態を読み込み中...",
"xpack.upgradeAssistant.overview.observe.discoveryDescription": "廃止予定ログを検索およびフィルターし、必要な変更のタイプを把握します。",
"xpack.upgradeAssistant.overview.observe.observabilityDescription": "使用中のAPIのうち廃止予定のAPIと、更新が必要なアプリケーションを特定できます。",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -25994,7 +25994,6 @@
"xpack.upgradeAssistant.overview.deprecationLogs.reloadButtonLabel": "重试",
"xpack.upgradeAssistant.overview.deprecationLogs.updateErrorMessage": "无法更新日志记录状态。",
"xpack.upgradeAssistant.overview.documentationLinkText": "文档",
"xpack.upgradeAssistant.overview.identifyStepTitle": "识别已弃用 API 的使用并更新您的应用程序",
"xpack.upgradeAssistant.overview.loadingLogsLabel": "正在加载日志收集状态……",
"xpack.upgradeAssistant.overview.observe.discoveryDescription": "搜索并筛选弃用日志以了解需要进行的更改类型。",
"xpack.upgradeAssistant.overview.observe.observabilityDescription": "深入了解正在使用哪些已弃用 API 以及需要更新哪些应用程序。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ describe('Cluster upgrade', () => {
});
});

// The way we detect if we are currently upgrading or if the upgrade has been completed is if
// we ever get back a 426 error in *any* API response that UA makes. For that reason we can
// just mock one of the APIs that are being called from the overview page to return an error
// in order to trigger these interstitial states. In this case we're going to mock the
// `es deprecations` response.
describe('when cluster is in the process of a rolling upgrade', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, {
statusCode: 426,
message: '',
attributes: {
Expand All @@ -62,7 +67,7 @@ describe('Cluster upgrade', () => {

describe('when cluster has been upgraded', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, {
httpRequestsMockHelpers.setLoadEsDeprecationsResponse(undefined, {
statusCode: 426,
message: '',
attributes: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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, AsyncTestBedConfig } from '@kbn/test/jest';
import { EsDeprecationLogs } from '../../../public/application/components/es_deprecation_logs';
import { WithAppDependencies } from '../helpers';

const testBedConfig: AsyncTestBedConfig = {
memoryRouter: {
initialEntries: ['/es_deprecation_logs'],
componentRoutePath: '/es_deprecation_logs',
},
doMountAsync: true,
};

export type EsDeprecationLogsTestBed = TestBed & {
actions: ReturnType<typeof createActions>;
};

const createActions = (testBed: TestBed) => {
/**
* User Actions
*/

const clickDeprecationToggle = async () => {
const { find, component } = testBed;

await act(async () => {
find('deprecationLoggingToggle').simulate('click');
});

component.update();
};

const clickRetryButton = async () => {
const { find, component } = testBed;

await act(async () => {
find('retryButton').simulate('click');
});

component.update();
};

const clickResetButton = async () => {
const { find, component } = testBed;

await act(async () => {
find('resetLastStoredDate').simulate('click');
});

component.update();
};

return {
clickDeprecationToggle,
clickRetryButton,
clickResetButton,
};
};

export const setupESDeprecationLogsPage = async (
overrides?: Record<string, unknown>
): Promise<EsDeprecationLogsTestBed> => {
const initTestBed = registerTestBed(
WithAppDependencies(EsDeprecationLogs, overrides),
testBedConfig
);
const testBed = await initTestBed();

return {
...testBed,
actions: createActions(testBed),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
*/

import { act } from 'react-dom/test-utils';
import {
EsDeprecationLogsTestBed,
setupESDeprecationLogsPage,
} from './es_deprecation_logs.helpers';
import { setupEnvironment, advanceTime } from '../helpers';
import { DeprecationLoggingStatus } from '../../../common/types';
import {
DEPRECATION_LOGS_INDEX,
DEPRECATION_LOGS_SOURCE_ID,
DEPRECATION_LOGS_COUNT_POLL_INTERVAL_MS,
} from '../../../common/constants';

// Once the logs team register the kibana locators in their app, we should be able
// to remove this mock and follow a similar approach to how discover link is tested.
// See: https://github.com/elastic/kibana/issues/104855
const MOCKED_TIME = '2021-09-05T10:49:01.805Z';
jest.mock('../../../../public/application/lib/logs_checkpoint', () => {
const originalModule = jest.requireActual('../../../../public/application/lib/logs_checkpoint');
jest.mock('../../../public/application/lib/logs_checkpoint', () => {
const originalModule = jest.requireActual('../../../public/application/lib/logs_checkpoint');

return {
__esModule: true,
Expand All @@ -21,83 +32,30 @@ jest.mock('../../../../public/application/lib/logs_checkpoint', () => {
};
});

import { DeprecationLoggingStatus } from '../../../../common/types';
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';
import { setupEnvironment, advanceTime } from '../../helpers';
import {
DEPRECATION_LOGS_INDEX,
DEPRECATION_LOGS_SOURCE_ID,
DEPRECATION_LOGS_COUNT_POLL_INTERVAL_MS,
} from '../../../../common/constants';

const getLoggingResponse = (toggle: boolean): DeprecationLoggingStatus => ({
isDeprecationLogIndexingEnabled: toggle,
isDeprecationLoggingEnabled: toggle,
});

describe('Overview - Fix deprecation logs step', () => {
let testBed: OverviewTestBed;
describe('ES deprecation logs', () => {
let testBed: EsDeprecationLogsTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment();

beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(getLoggingResponse(true));
testBed = await setupOverviewPage();

const { component } = testBed;
component.update();
testBed = await setupESDeprecationLogsPage();
testBed.component.update();
});

afterAll(() => {
server.restore();
});

describe('Step status', () => {
test(`It's complete when there are no deprecation logs since last checkpoint`, async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 0 });

await act(async () => {
testBed = await setupOverviewPage();
});

const { exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-complete`)).toBe(true);
});

test(`It's incomplete when there are deprecation logs since last checkpoint`, async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 5 });

await act(async () => {
testBed = await setupOverviewPage();
});

const { exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-incomplete`)).toBe(true);
});

test(`It's incomplete when log collection is disabled `, async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({ count: 0 });

await act(async () => {
testBed = await setupOverviewPage();
});

const { actions, exists, component } = testBed;

component.update();

expect(exists(`fixLogsStep-complete`)).toBe(true);

httpRequestsMockHelpers.setUpdateDeprecationLoggingResponse(getLoggingResponse(false));

await actions.clickDeprecationToggle();
describe('Documentation link', () => {
test('Has a link for migration info api docs in page header', () => {
const { exists } = testBed;

expect(exists(`fixLogsStep-incomplete`)).toBe(true);
expect(exists('documentationLink')).toBe(true);
});
});

Expand All @@ -123,7 +81,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, component } = testBed;
Expand Down Expand Up @@ -159,7 +117,7 @@ describe('Overview - Fix deprecation logs step', () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(undefined, error);

await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { component, exists } = testBed;
Expand All @@ -176,7 +134,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, component } = testBed;
Expand All @@ -196,7 +154,7 @@ describe('Overview - Fix deprecation logs step', () => {

test('Has a link to see logs in observability app', async () => {
await act(async () => {
testBed = await setupOverviewPage({
testBed = await setupESDeprecationLogsPage({
http: {
basePath: {
prepend: (url: string) => url,
Expand Down Expand Up @@ -228,7 +186,7 @@ describe('Overview - Fix deprecation logs step', () => {

test('Has a link to see logs in discover app', async () => {
await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, component, find } = testBed;
Expand Down Expand Up @@ -257,7 +215,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { find, exists, component } = testBed;
Expand All @@ -274,7 +232,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { find, exists, component } = testBed;
Expand All @@ -295,7 +253,7 @@ describe('Overview - Fix deprecation logs step', () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse(undefined, error);

await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, actions, component } = testBed;
Expand All @@ -319,7 +277,7 @@ describe('Overview - Fix deprecation logs step', () => {
});

await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, actions, component } = testBed;
Expand Down Expand Up @@ -351,7 +309,7 @@ describe('Overview - Fix deprecation logs step', () => {

const addDanger = jest.fn();
await act(async () => {
testBed = await setupOverviewPage({
testBed = await setupESDeprecationLogsPage({
services: {
core: {
notifications: {
Expand Down Expand Up @@ -389,17 +347,17 @@ describe('Overview - Fix deprecation logs step', () => {
count: 0,
});

testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

afterEach(() => {
jest.useRealTimers();
});

test('renders step as incomplete when a success state is followed by an error state', async () => {
test('success state is followed by an error state', async () => {
const { exists } = testBed;

expect(exists('fixLogsStep-complete')).toBe(true);
expect(exists('resetLastStoredDate')).toBe(true);

// second request will error
const error = {
Expand All @@ -413,7 +371,7 @@ describe('Overview - Fix deprecation logs step', () => {
await advanceTime(DEPRECATION_LOGS_COUNT_POLL_INTERVAL_MS);
testBed.component.update();

expect(exists('fixLogsStep-incomplete')).toBe(true);
expect(exists('errorCallout')).toBe(true);
});
});
});
Expand All @@ -425,7 +383,7 @@ describe('Overview - Fix deprecation logs step', () => {

test('It shows copy with compatibility api header advice', async () => {
await act(async () => {
testBed = await setupOverviewPage();
testBed = await setupESDeprecationLogsPage();
});

const { exists, component } = testBed;
Expand All @@ -449,7 +407,7 @@ describe('Overview - Fix deprecation logs step', () => {

test(`doesn't show analyze and resolve logs if it doesn't have the right privileges`, async () => {
await act(async () => {
testBed = await setupOverviewPage({
testBed = await setupESDeprecationLogsPage({
privileges: {
hasAllPrivileges: false,
missingPrivileges: {
Expand Down
Loading