From 3e678e2b0c9828d31cf75f58cbf046c255045f14 Mon Sep 17 00:00:00 2001 From: Mat Schaffer Date: Tue, 8 Mar 2022 13:21:53 +0900 Subject: [PATCH 1/4] Add common nodesCount guard to EnterpriseSearchPanel --- .../cluster/overview/enterprise_search_panel.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/monitoring/public/components/cluster/overview/enterprise_search_panel.js b/x-pack/plugins/monitoring/public/components/cluster/overview/enterprise_search_panel.js index 1459ccb2ecac6..b8ff05213c1c0 100644 --- a/x-pack/plugins/monitoring/public/components/cluster/overview/enterprise_search_panel.js +++ b/x-pack/plugins/monitoring/public/components/cluster/overview/enterprise_search_panel.js @@ -31,6 +31,12 @@ import { getSafeForExternalLink } from '../../../lib/get_safe_for_external_link' export function EnterpriseSearchPanel(props) { const { setupMode } = props; const setupModeData = get(setupMode.data, 'enterprise_search'); + const nodesCount = props.stats.totalInstances || 0; + + // Do not show if we are not in setup mode + if (!nodesCount && !setupMode.enabled) { + return null; + } return ( From 599b647a5663a4b888997bb0da899f336c1b300e Mon Sep 17 00:00:00 2001 From: Mat Schaffer Date: Tue, 8 Mar 2022 13:36:37 +0900 Subject: [PATCH 2/4] Combine overview negative tests into one function Also include enterprise search negative check. --- .../functional/apps/monitoring/cluster/overview.js | 12 +++--------- .../services/monitoring/cluster_overview.js | 3 +++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/x-pack/test/functional/apps/monitoring/cluster/overview.js b/x-pack/test/functional/apps/monitoring/cluster/overview.js index 25e52535a39b2..1910c76d88492 100644 --- a/x-pack/test/functional/apps/monitoring/cluster/overview.js +++ b/x-pack/test/functional/apps/monitoring/cluster/overview.js @@ -112,13 +112,9 @@ export default function ({ getService, getPageObjects }) { expect(await overview.getKbnConnections()).to.be('174'); expect(await overview.getKbnMemoryUsage()).to.be('15.33%\n219.6 MB / 1.4 GB'); }); - - it('does not show logstash panel', async () => { - expect(await overview.doesLsPanelExist()).to.be(false); - }); }); - describe('for Yellow cluster with Basic license and no Kibana and Logstash', () => { + describe('for Yellow cluster with Basic license and no other stack components', () => { const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects); before(async () => { @@ -156,12 +152,10 @@ export default function ({ getService, getPageObjects }) { expect(await overview.getEsReplicaShards()).to.be('0'); }); - it('shows kibana panel', async () => { + it('shows no other component panels', async () => { expect(await overview.doesKbnPanelExist()).to.be(false); - }); - - it('does not show logstash panel', async () => { expect(await overview.doesLsPanelExist()).to.be(false); + expect(await overview.doesEntSearchPanelExist()).to.be(false); }); }); diff --git a/x-pack/test/functional/services/monitoring/cluster_overview.js b/x-pack/test/functional/services/monitoring/cluster_overview.js index e6c58ba4eac03..b3cae2d4b947b 100644 --- a/x-pack/test/functional/services/monitoring/cluster_overview.js +++ b/x-pack/test/functional/services/monitoring/cluster_overview.js @@ -232,6 +232,9 @@ export function MonitoringClusterOverviewProvider({ getService }) { return testSubjects.click(SUBJ_BEATS_LISTING); } + doesEntSearchPanelExist() { + return testSubjects.exists(SUBJ_ENT_SEARCH_PANEL); + } getEntSearchTotalNodes() { return testSubjects.getVisibleText(SUBJ_ENT_SEARCH_TOTAL_NODES); } From af622a2d0709cd61397e19fadb9f01e2b2eb610f Mon Sep 17 00:00:00 2001 From: Mat Schaffer Date: Tue, 8 Mar 2022 14:12:40 +0900 Subject: [PATCH 3/4] Use positive panel testing instead This should help ensure we don't have the same problem again of a non-hidden stack component. --- .../apps/monitoring/cluster/overview.js | 6 ++--- .../services/monitoring/cluster_overview.js | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/x-pack/test/functional/apps/monitoring/cluster/overview.js b/x-pack/test/functional/apps/monitoring/cluster/overview.js index 1910c76d88492..d4c646d48b92d 100644 --- a/x-pack/test/functional/apps/monitoring/cluster/overview.js +++ b/x-pack/test/functional/apps/monitoring/cluster/overview.js @@ -152,10 +152,8 @@ export default function ({ getService, getPageObjects }) { expect(await overview.getEsReplicaShards()).to.be('0'); }); - it('shows no other component panels', async () => { - expect(await overview.doesKbnPanelExist()).to.be(false); - expect(await overview.doesLsPanelExist()).to.be(false); - expect(await overview.doesEntSearchPanelExist()).to.be(false); + it('shows only elasticsearch panel', async () => { + expect(await overview.getPresentPanels()).to.eql(['Elasticsearch']); }); }); diff --git a/x-pack/test/functional/services/monitoring/cluster_overview.js b/x-pack/test/functional/services/monitoring/cluster_overview.js index b3cae2d4b947b..4e9f54cc00977 100644 --- a/x-pack/test/functional/services/monitoring/cluster_overview.js +++ b/x-pack/test/functional/services/monitoring/cluster_overview.js @@ -10,11 +10,14 @@ import expect from '@kbn/expect'; export function MonitoringClusterOverviewProvider({ getService }) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); + const find = getService('find'); const SUBJ_CLUSTER_ALERTS = `clusterAlertsContainer`; const SUBJ_CLUSTER_NAME = `overviewTabsclusterName`; - const SUBJ_ES_PANEL = `clusterItemContainerElasticsearch`; + const SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX = `clusterItemContainer`; + + const SUBJ_ES_PANEL = `${SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX}Elasticsearch`; const SUBJ_ES_STATUS = `${SUBJ_ES_PANEL} > statusIcon`; const SUBJ_ES_VERSION = `${SUBJ_ES_PANEL} > esVersion`; const SUBJ_ES_UPTIME = `${SUBJ_ES_PANEL} > esUptime`; @@ -29,7 +32,7 @@ export function MonitoringClusterOverviewProvider({ getService }) { const SUBJ_ES_REPLICA_SHARDS = `${SUBJ_ES_PANEL} > esReplicaShards`; const SUBJ_ES_ML_JOBS = `${SUBJ_ES_PANEL} > esMlJobs`; - const SUBJ_KBN_PANEL = `clusterItemContainerKibana`; + const SUBJ_KBN_PANEL = `${SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX}Kibana`; const SUBJ_KBN_STATUS = `${SUBJ_KBN_PANEL} > statusIcon`; const SUBJ_KBN_REQUESTS = `${SUBJ_KBN_PANEL} > kbnRequests`; const SUBJ_KBN_MAX_RESPONSE_TIME = `${SUBJ_KBN_PANEL} > kbnMaxResponseTime`; @@ -38,7 +41,7 @@ export function MonitoringClusterOverviewProvider({ getService }) { const SUBJ_KBN_OVERVIEW = `${SUBJ_KBN_PANEL} > kbnOverview`; const SUBJ_KBN_INSTANCES = `${SUBJ_KBN_PANEL} > kbnInstances`; - const SUBJ_LS_PANEL = `clusterItemContainerLogstash`; + const SUBJ_LS_PANEL = `${SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX}Logstash`; const SUBJ_LS_EVENTS_RECEIVED = `${SUBJ_LS_PANEL} > lsEventsReceived`; const SUBJ_LS_EVENTS_EMITTED = `${SUBJ_LS_PANEL} > lsEventsEmitted`; const SUBJ_LS_NODES = `${SUBJ_LS_PANEL} > lsNodes`; @@ -47,14 +50,14 @@ export function MonitoringClusterOverviewProvider({ getService }) { const SUBJ_LS_PIPELINES = `${SUBJ_LS_PANEL} > lsPipelines`; const SUBJ_LS_OVERVIEW = `${SUBJ_LS_PANEL} > lsOverview`; - const SUBJ_BEATS_PANEL = `clusterItemContainerBeats`; + const SUBJ_BEATS_PANEL = `${SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX}Beats`; const SUBJ_BEATS_OVERVIEW = `${SUBJ_BEATS_PANEL} > beatsOverview`; const SUBJ_BEATS_TOTAL_EVENTS = `${SUBJ_BEATS_PANEL} > beatsTotalEvents`; const SUBJ_BEATS_BYTES_SENT = `${SUBJ_BEATS_PANEL} > beatsBytesSent`; const SUBJ_BEATS_LISTING = `${SUBJ_BEATS_PANEL} > beatsListing`; const SUBJ_BEATS_TYPES_COUNTS = `${SUBJ_BEATS_PANEL} > beatTypeCount`; - const SUBJ_ENT_SEARCH_PANEL = `clusterItemContainerEnterprise Search`; + const SUBJ_ENT_SEARCH_PANEL = `${SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX}Enterprise Search`; const SUBJ_ENT_SEARCH_TOTAL_NODES = `${SUBJ_ENT_SEARCH_PANEL} > entSearchTotalNodes`; const SUBJ_ENT_SEARCH_OVERVIEW = `${SUBJ_ENT_SEARCH_PANEL} > entSearchOverview`; const SUBJ_ENT_SEARCH_ENGINES = `${SUBJ_ENT_SEARCH_PANEL} > appSearchEngines`; @@ -89,6 +92,16 @@ export function MonitoringClusterOverviewProvider({ getService }) { return testSubjects.click('alerts-modal-button'); } + async getPresentPanels() { + const panelElements = await find.allByCssSelector( + `[data-test-subj^="${SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX}"]` + ); + const panelTestSubjects = await Promise.all( + panelElements.map((e) => e.getAttribute('data-test-subj')) + ); + return panelTestSubjects.map((e) => e.replace(SUBJ_CLUSTER_ITEM_CONTAINER_PREFIX, '')); + } + getEsStatus() { return testSubjects.getVisibleText(SUBJ_ES_STATUS); } From f7f112743f1eb5d0bc70c4a20658bf8ddf786df2 Mon Sep 17 00:00:00 2001 From: Mat Schaffer Date: Tue, 8 Mar 2022 14:16:43 +0900 Subject: [PATCH 4/4] Remove unused does*PanelExist checks --- .../functional/services/monitoring/cluster_overview.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/x-pack/test/functional/services/monitoring/cluster_overview.js b/x-pack/test/functional/services/monitoring/cluster_overview.js index 4e9f54cc00977..ff146c94de732 100644 --- a/x-pack/test/functional/services/monitoring/cluster_overview.js +++ b/x-pack/test/functional/services/monitoring/cluster_overview.js @@ -153,9 +153,6 @@ export function MonitoringClusterOverviewProvider({ getService }) { return testSubjects.getVisibleText(SUBJ_ES_ML_JOBS); } - doesKbnPanelExist() { - return testSubjects.exists(SUBJ_KBN_PANEL); - } getKbnStatus() { return testSubjects.getVisibleText(SUBJ_KBN_STATUS); } @@ -181,9 +178,6 @@ export function MonitoringClusterOverviewProvider({ getService }) { return testSubjects.click(SUBJ_KBN_INSTANCES); } - doesLsPanelExist() { - return testSubjects.exists(SUBJ_LS_PANEL); - } getLsEventsReceived() { return testSubjects.getVisibleText(SUBJ_LS_EVENTS_RECEIVED); } @@ -245,9 +239,6 @@ export function MonitoringClusterOverviewProvider({ getService }) { return testSubjects.click(SUBJ_BEATS_LISTING); } - doesEntSearchPanelExist() { - return testSubjects.exists(SUBJ_ENT_SEARCH_PANEL); - } getEntSearchTotalNodes() { return testSubjects.getVisibleText(SUBJ_ENT_SEARCH_TOTAL_NODES); }