From a3bd8616677358419c3621a39ca9b10cdea340d3 Mon Sep 17 00:00:00 2001 From: Dennis Adjei-Baah Date: Thu, 16 Aug 2018 11:14:01 -0700 Subject: [PATCH] Add a meshed column to metrics tables in the web UI (#1466) Currently conduit stat outputs a column that shows the number of meshed pods in the resource being queried. The web UI does not have this information about meshed pod state. This commit adds a meshed column for better UI parity with the stat command. Signed-off-by: Dennis Adjei-Baah --- web/app/js/components/MetricsTable.jsx | 14 ++++++++++++++ web/app/js/components/util/MetricUtils.js | 7 ++++++- web/app/test/MetricUtilsTest.js | 1 + web/app/test/MetricsTableTest.js | 20 +++++++++++++++++--- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/web/app/js/components/MetricsTable.jsx b/web/app/js/components/MetricsTable.jsx index 2eada2b72..41c7bf896 100644 --- a/web/app/js/components/MetricsTable.jsx +++ b/web/app/js/components/MetricsTable.jsx @@ -43,6 +43,15 @@ const formatTitle = (title, tooltipText) => { }; +const meshedColumn = { + title: formatTitle("Meshed"), + dataIndex: "pods", + key: "pods", + className: "numeric", + sorter: (a, b) => numericSort(a.pods.totalPods, b.pods.totalPods), + render: p => p.meshedPods + "/" + p.totalPods +}; + const columnDefinitions = (resource, namespaces, onFilterClick, showNamespaceColumn, PrefixedLink, showGrafanaLink) => { let nsColumn = [ { @@ -142,6 +151,11 @@ const columnDefinitions = (resource, namespaces, onFilterClick, showNamespaceCol } ]; + // don't add the meshed column on a Authority MetricsTable + if (resource !== "authority") { + columns.splice(1, 0, meshedColumn); + } + if (!showNamespaceColumn) { return columns; } else { diff --git a/web/app/js/components/util/MetricUtils.js b/web/app/js/components/util/MetricUtils.js index 1f50fb448..157c80bab 100644 --- a/web/app/js/components/util/MetricUtils.js +++ b/web/app/js/components/util/MetricUtils.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -import Percentage from './Percentage'; +import Percentage from './Percentage.js'; import PropTypes from 'prop-types'; const getPodCategorization = pod => { @@ -118,6 +118,11 @@ const processStatTable = table => { latency: getLatency(row), tlsRequestPercent: getTlsRequestPercentage(row), added: row.meshedPodCount === row.runningPodCount, + pods: { + totalPods: row.runningPodCount, + meshedPods: row.meshedPodCount, + meshedPercentage: new Percentage(parseInt(row.meshedPodCount, 10), parseInt(row.runningPodCount, 10)) + }, errors: row.errorsByPod }; }) diff --git a/web/app/test/MetricUtilsTest.js b/web/app/test/MetricUtilsTest.js index f5ad3f76b..3a19c92d9 100644 --- a/web/app/test/MetricUtilsTest.js +++ b/web/app/test/MetricUtilsTest.js @@ -26,6 +26,7 @@ describe('MetricUtils', () => { P95: 2, P99: 7 }, + pods: {totalPods: "1", meshedPods: "1", meshedPercentage: new Percentage(1,1)}, added: true, errors: {} } diff --git a/web/app/test/MetricsTableTest.js b/web/app/test/MetricsTableTest.js index 511ae187d..814a1a54a 100644 --- a/web/app/test/MetricsTableTest.js +++ b/web/app/test/MetricsTableTest.js @@ -29,7 +29,7 @@ describe('Tests for ', () => { expect(table).to.have.length(1); expect(table.props().dataSource).to.have.length(1); - expect(table.props().columns).to.have.length(8); + expect(table.props().columns).to.have.length(9); }); it('omits the namespace column for the namespace resource', () => { @@ -43,7 +43,7 @@ describe('Tests for ', () => { const table = component.find(BaseTable); expect(table).to.have.length(1); - expect(table.props().columns).to.have.length(7); + expect(table.props().columns).to.have.length(8); }); it('omits the namespace column when showNamespaceColumn is false', () => { @@ -58,7 +58,21 @@ describe('Tests for ', () => { const table = component.find(BaseTable); expect(table).to.have.length(1); - expect(table.props().columns).to.have.length(7); + expect(table.props().columns).to.have.length(8); + }); + + it('omits meshed column for authority resource', () => { + const component = shallow( + + ); + + const table = component.find(BaseTable); + + expect(table).to.have.length(1); + expect(table.props().columns).to.have.length(8); }); });