Skip to content

Commit

Permalink
Hide Enterprise search panel when no nodes are present (#127100)
Browse files Browse the repository at this point in the history
(cherry picked from commit fc3aedc)
  • Loading branch information
matschaffer committed Mar 8, 2022
1 parent 066d6a2 commit 73a993c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ClusterItemContainer
Expand Down Expand Up @@ -126,7 +132,7 @@ export function EnterpriseSearchPanel(props) {
id="xpack.monitoring.cluster.overview.entSearchPanel.nodesTotalLinkLabel"
defaultMessage="Nodes: {nodesTotal}"
values={{
nodesTotal: formatNumber(props.stats.totalInstances, 'int_commas'),
nodesTotal: formatNumber(nodesCount, 'int_commas'),
}}
/>
</h3>
Expand Down
14 changes: 3 additions & 11 deletions x-pack/test/functional/apps/monitoring/cluster/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -156,12 +152,8 @@ export default function ({ getService, getPageObjects }) {
expect(await overview.getEsReplicaShards()).to.be('0');
});

it('shows kibana panel', async () => {
expect(await overview.doesKbnPanelExist()).to.be(false);
});

it('does not show logstash panel', async () => {
expect(await overview.doesLsPanelExist()).to.be(false);
it('shows only elasticsearch panel', async () => {
expect(await overview.getPresentPanels()).to.eql(['Elasticsearch']);
});
});

Expand Down
29 changes: 18 additions & 11 deletions x-pack/test/functional/services/monitoring/cluster_overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -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`;
Expand All @@ -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`;
Expand All @@ -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`;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -140,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);
}
Expand All @@ -168,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);
}
Expand Down

0 comments on commit 73a993c

Please sign in to comment.