Skip to content

Commit

Permalink
[Upgrade Assistant] Add deprecation logging as step on overview page (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored Mar 14, 2022
1 parent 6d87f12 commit f4358d5
Show file tree
Hide file tree
Showing 10 changed files with 425 additions and 60 deletions.
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -28379,7 +28379,6 @@
"xpack.upgradeAssistant.noDeprecationsPrompt.nextStepsDescription": "他のスタック廃止予定については、{overviewButton}を確認してください。",
"xpack.upgradeAssistant.noDeprecationsPrompt.overviewLinkText": "概要ページ",
"xpack.upgradeAssistant.noPartialDeprecationsMessage": "なし",
"xpack.upgradeAssistant.overview.accessEsDeprecationLogsLabel": "Elasticsearch APIを呼び出すアプリケーションコードがある場合は、{esDeprecationLogsLink}を確認して、廃止予定のAPIを使用していないことを確かめてください。",
"xpack.upgradeAssistant.overview.analyzeTitle": "廃止予定ログを分析",
"xpack.upgradeAssistant.overview.apiCompatibilityNoteBody": "アップグレード前にすべての廃止予定の問題を解決することをお勧めします。必要に応じて、廃止予定の機能を使用する要求にAPI互換性ヘッダーを適用できます。{learnMoreLink}。",
"xpack.upgradeAssistant.overview.apiCompatibilityNoteLink": "詳細",
Expand All @@ -28405,8 +28404,6 @@
"xpack.upgradeAssistant.overview.deprecationsCountCheckpointTitle": "廃止予定の問題を解決して変更を検証",
"xpack.upgradeAssistant.overview.documentationLinkText": "ドキュメント",
"xpack.upgradeAssistant.overview.errorLoadingUpgradeStatus": "アップグレードステータスの取得中にエラーが発生しました",
"xpack.upgradeAssistant.overview.esDeprecationLogsLink": "Elasticsearchの廃止予定ログ",
"xpack.upgradeAssistant.overview.fixIssuesStepDescription": "Elastic 8.xにアップグレードする前に、重大なElasticsearchおよびKibana構成の問題を解決する必要があります。警告を無視すると、アップグレード後に動作が変更される場合があります。{accessDeprecationLogsMessage}",
"xpack.upgradeAssistant.overview.fixIssuesStepTitle": "廃止予定設定を確認し、問題を解決",
"xpack.upgradeAssistant.overview.loadingLogsLabel": "廃止予定ログ収集状態を読み込んでいます...",
"xpack.upgradeAssistant.overview.loadingUpgradeStatus": "アップグレードステータスを読み込んでいます",
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -28412,7 +28412,6 @@
"xpack.upgradeAssistant.noDeprecationsPrompt.nextStepsDescription": "查看{overviewButton}以了解其他 Stack 弃用。",
"xpack.upgradeAssistant.noDeprecationsPrompt.overviewLinkText": "“概览”页面",
"xpack.upgradeAssistant.noPartialDeprecationsMessage": "无",
"xpack.upgradeAssistant.overview.accessEsDeprecationLogsLabel": "如果有应用程序代码调用 Elasticsearch API,请复查 {esDeprecationLogsLink}以确保您未使用已弃用的 API。",
"xpack.upgradeAssistant.overview.analyzeTitle": "分析弃用日志",
"xpack.upgradeAssistant.overview.apiCompatibilityNoteBody": "建议您在升级之前解决所有弃用问题。如果需要,您可以将 API 兼容性标头应用于使用过时功能的请求。{learnMoreLink}。",
"xpack.upgradeAssistant.overview.apiCompatibilityNoteLink": "了解详情",
Expand All @@ -28438,8 +28437,6 @@
"xpack.upgradeAssistant.overview.deprecationsCountCheckpointTitle": "解决弃用问题并验证您的更改",
"xpack.upgradeAssistant.overview.documentationLinkText": "文档",
"xpack.upgradeAssistant.overview.errorLoadingUpgradeStatus": "检索升级状态时出错",
"xpack.upgradeAssistant.overview.esDeprecationLogsLink": "Elasticsearch 弃用日志",
"xpack.upgradeAssistant.overview.fixIssuesStepDescription": "在升级到 Elastic 8.x 之前,必须解决任何严重的 Elasticsearch 和 Kibana 配置问题。在您升级后,忽略警告可能会导致行为差异。{accessDeprecationLogsMessage}",
"xpack.upgradeAssistant.overview.fixIssuesStepTitle": "复查已弃用设置并解决问题",
"xpack.upgradeAssistant.overview.loadingLogsLabel": "正在加载弃用日志收集状态……",
"xpack.upgradeAssistant.overview.loadingUpgradeStatus": "正在加载升级状态",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*
* 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 { DEPRECATION_LOGS_INDEX } from '../../../../common/constants';
import { setupEnvironment } from '../../helpers';
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';

describe('Overview - Logs Step', () => {
let testBed: OverviewTestBed;

const { server, httpRequestsMockHelpers } = setupEnvironment();

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

describe('error state', () => {
beforeEach(async () => {
const error = {
statusCode: 500,
error: 'Internal server error',
message: 'Internal server error',
};

httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse(undefined, error);

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

testBed.component.update();
});

test('is rendered', () => {
const { exists } = testBed;
expect(exists('deprecationLogsErrorCallout')).toBe(true);
expect(exists('deprecationLogsRetryButton')).toBe(true);
});
});

describe('success state', () => {
describe('logging enabled', () => {
beforeEach(() => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse({
isDeprecationLogIndexingEnabled: true,
isDeprecationLoggingEnabled: true,
});
});

test('renders step as complete when a user has 0 logs', async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({
count: 0,
});

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

const { component, exists } = testBed;

component.update();

expect(exists('logsStep-complete')).toBe(true);
});

test('renders step as incomplete when a user has >0 logs', async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({
count: 10,
});

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

const { component, exists } = testBed;

component.update();

expect(exists('logsStep-incomplete')).toBe(true);
});

test('renders deprecation issue count and button to view logs', async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({
count: 10,
});

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

const { component, find } = testBed;

component.update();

expect(find('logsCountDescription').text()).toContain('You have 10 deprecation issues');
expect(find('viewLogsLink').text()).toContain('View logs');
});
});

describe('logging disabled', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse({
isDeprecationLogIndexingEnabled: false,
isDeprecationLoggingEnabled: true,
});

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

const { component } = testBed;

component.update();
});

test('renders button to enable logs', () => {
const { find, exists } = testBed;

expect(exists('logsCountDescription')).toBe(false);
expect(find('enableLogsLink').text()).toContain('Enable logging');
});
});
});

describe('privileges', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse({
isDeprecationLogIndexingEnabled: true,
isDeprecationLoggingEnabled: true,
});

await act(async () => {
testBed = await setupOverviewPage({
privileges: {
hasAllPrivileges: true,
missingPrivileges: {
index: [DEPRECATION_LOGS_INDEX],
},
},
});
});

const { component } = testBed;

component.update();
});

test('warns the user of missing index privileges', () => {
const { exists } = testBed;

expect(exists('missingPrivilegesCallout')).toBe(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*/

export { FixDeprecationLogs } from './fix_deprecation_logs';
export { useDeprecationLogging } from './use_deprecation_logging';
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*/

export { EsDeprecationLogs } from './es_deprecation_logs';
export { useDeprecationLogging } from './fix_deprecation_logs';
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

import React, { FunctionComponent, useState, useEffect } from 'react';

import { EuiText, EuiFlexItem, EuiFlexGroup, EuiSpacer, EuiLink } from '@elastic/eui';
import { EuiText, EuiFlexItem, EuiFlexGroup, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import type { EuiStepProps } from '@elastic/eui/src/components/steps/step';

import { DEPRECATION_LOGS_INDEX } from '../../../../../common/constants';
import { WithPrivileges } from '../../../../shared_imports';
import type { OverviewStepProps } from '../../types';
import { EsDeprecationIssuesPanel, KibanaDeprecationIssuesPanel } from './components';

Expand Down Expand Up @@ -51,48 +49,10 @@ const FixIssuesStep: FunctionComponent<Props> = ({ setIsComplete }) => {
);
};

interface CustomProps {
navigateToEsDeprecationLogs: () => void;
}

const AccessDeprecationLogsMessage = ({ navigateToEsDeprecationLogs }: CustomProps) => {
return (
<WithPrivileges privileges={`index.${DEPRECATION_LOGS_INDEX}`}>
{({ hasPrivileges, isLoading }) => {
if (isLoading || !hasPrivileges) {
// Don't show the message with the link to access deprecation logs
// to users who can't access the UI anyways.
return null;
}

return (
<FormattedMessage
id="xpack.upgradeAssistant.overview.accessEsDeprecationLogsLabel"
defaultMessage="If you have application code that calls Elasticsearch APIs, review the {esDeprecationLogsLink} to make sure you are not using deprecated APIs."
values={{
esDeprecationLogsLink: (
<EuiLink
onClick={navigateToEsDeprecationLogs}
data-test-subj="viewElasticsearchDeprecationLogs"
>
{i18n.translate('xpack.upgradeAssistant.overview.esDeprecationLogsLink', {
defaultMessage: 'Elasticsearch deprecation logs',
})}
</EuiLink>
),
}}
/>
);
}}
</WithPrivileges>
);
};

export const getFixIssuesStep = ({
isComplete,
setIsComplete,
navigateToEsDeprecationLogs,
}: OverviewStepProps & CustomProps): EuiStepProps => {
}: OverviewStepProps): EuiStepProps => {
const status = isComplete ? 'complete' : 'incomplete';

return {
Expand All @@ -105,14 +65,7 @@ export const getFixIssuesStep = ({
<p>
<FormattedMessage
id="xpack.upgradeAssistant.overview.fixIssuesStepDescription"
defaultMessage="You must resolve any critical Elasticsearch and Kibana configuration issues before upgrading to Elastic 8.x. Ignoring warnings might result in differences in behavior after you upgrade. {accessDeprecationLogsMessage}"
values={{
accessDeprecationLogsMessage: (
<AccessDeprecationLogsMessage
navigateToEsDeprecationLogs={navigateToEsDeprecationLogs}
/>
),
}}
defaultMessage="You must resolve any critical Elasticsearch and Kibana configuration issues before upgrading to Elastic 8.x. Ignoring warnings might result in differences in behavior after you upgrade."
/>
</p>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export { getLogsStep } from './logs_step';
Loading

0 comments on commit f4358d5

Please sign in to comment.