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

NETOBSERV-230 topology view #97

Merged
merged 6 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions web/locales/en/plugin__network-observability-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"None": "None",
"Cola": "Cola",
"ColaNoForce": "ColaNoForce",
"Concentric": "Concentric",
"Dagre": "Dagre",
"Force": "Force",
"Grid": "Grid",
Expand Down Expand Up @@ -114,9 +115,8 @@
"Unable to get flows": "Unable to get flows",
"No results found": "No results found",
"Clear all filters and try again.": "Clear all filters and try again.",
"More options": "More options",
"Unable to get topology": "Unable to get topology",
"TODO": "TODO",
"Show options": "Show options",
"Options": "Options",
"Display": "Display",
"Groups": "Groups",
Expand All @@ -128,6 +128,8 @@
"Labels on edges are hidden": "Labels on edges are hidden",
"Badges are displayed": "Badges are displayed",
"Badges are hidden": "Badges are hidden",
"Long labels are truncated": "Long labels are truncated",
"Whole labels are displayed": "Whole labels are displayed",
"Flow Table": "Flow Table",
"Topology": "Topology",
"Column management": "Column management",
Expand Down
1,969 changes: 1,802 additions & 167 deletions web/package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
"fix-imports": "eslint --no-eslintrc --no-inline-config --parser '@typescript-eslint/parser' --plugin 'unused-imports' --plugin 'react-hooks' --rule 'unused-imports/no-unused-imports:error' --fix \"./src/**/*.{ts,tsx}\""
},
"devDependencies": {
"@openshift-console/dynamic-plugin-sdk": "0.0.3",
"@openshift-console/dynamic-plugin-sdk-webpack": "0.0.4",
"@patternfly/react-core": "4.175.4",
"@openshift-console/dynamic-plugin-sdk": "0.0.6",
"@openshift-console/dynamic-plugin-sdk-webpack": "0.0.6",
"@patternfly/react-core": "^4.202.5",
"@patternfly/react-table": "4.44.4",
"@patternfly/react-topology": "4.49.5",
"@testing-library/react": "^12.1.2",
"@types/copy-webpack-plugin": "8.0.1",
"@types/enzyme": "3.10.x",
"@types/jest": "27.0.3",
"@types/jsdom": "^16.2.13",
"@types/lodash": "^4.14.178",
"@types/port-numbers": "^5.0.0",
"@types/react": "16.14.21",
"@types/react-dom": "16.9.14",
"@types/react": "^17.0.1",
"@types/react-dom": "^17.0.1",
"@types/react-router-dom": "^5.3.3",
"@types/react-transition-group": "^4.4.4",
"@types/webpack-dev-server": "^4.5.0",
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/dropdowns/layout-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const LayoutDropdown: React.FC<{
return t('Cola');
case LayoutName.ColaNoForce:
return t('ColaNoForce');
case LayoutName.Concentric:
return t('Concentric');
case LayoutName.Dagre:
return t('Dagre');
case LayoutName.Force:
Expand Down
277 changes: 277 additions & 0 deletions web/src/components/netflow-topology/__tests-data__/metrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
export const response = {
status: 'success',
data: {
resultType: 'matrix',
result: [
{
metric: {
DstAddr: '10.129.0.15',
DstK8S_Name: 'loki-distributor-loki-76598c8449-csmh2',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'loki-distributor-loki',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '10.131.0.18',
SrcK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
SrcK8S_Namespace: 'network-observability',
SrcK8S_OwnerName: 'flowlogs-pipeline',
SrcK8S_OwnerType: 'Deployment',
SrcK8S_Type: 'Pod'
},
values: [
[1647965100, '2210400'],
[1647965400, '919800'],
[1647965700, '3517100']
]
},
{
metric: {
DstAddr: '10.130.0.15',
DstK8S_Name: 'loki-distributor-loki-76598c8449-ngp4d',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'loki-distributor-loki',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '10.131.0.18',
SrcK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
SrcK8S_Namespace: 'network-observability',
SrcK8S_OwnerName: 'flowlogs-pipeline',
SrcK8S_OwnerType: 'Deployment',
SrcK8S_Type: 'Pod'
},
values: [
[1647965100, '1491100'],
[1647965400, '1611400'],
[1647965700, '858100']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '10.129.0.15',
SrcK8S_Name: 'loki-distributor-loki-76598c8449-csmh2',
SrcK8S_Namespace: 'network-observability',
SrcK8S_OwnerName: 'loki-distributor-loki',
SrcK8S_OwnerType: 'Deployment',
SrcK8S_Type: 'Pod'
},
values: [
[1647965100, '128300'],
[1647965400, '105300'],
[1647965700, '52000']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '10.130.0.15',
SrcK8S_Name: 'loki-distributor-loki-76598c8449-ngp4d',
SrcK8S_Namespace: 'network-observability',
SrcK8S_OwnerName: 'loki-distributor-loki',
SrcK8S_OwnerType: 'Deployment',
SrcK8S_Type: 'Pod'
},
values: [
[1647965100, '104700'],
[1647965400, '47600'],
[1647965700, '46300']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '10.131.0.7',
SrcK8S_Name: 'dns-default-klz8q',
SrcK8S_Namespace: 'openshift-dns',
SrcK8S_OwnerName: 'dns-default',
SrcK8S_OwnerType: 'DaemonSet',
SrcK8S_Type: 'Pod'
},
values: [
[1647965100, '20500'],
[1647965400, '42100'],
[1647965700, '43200']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '100.64.0.2'
},
values: [
[1647965100, '801800'],
[1647965400, '891300'],
[1647965700, '1089700']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '100.64.0.3'
},
values: [
[1647965100, '1304200'],
[1647965400, '1932100'],
[1647965700, '1336400']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '100.64.0.4'
},
values: [
[1647965100, '1428500'],
[1647965400, '1330400'],
[1647965700, '949100']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '172.30.0.10',
SrcK8S_Name: 'dns-default',
SrcK8S_Namespace: 'openshift-dns',
SrcK8S_OwnerName: 'dns-default',
SrcK8S_OwnerType: 'Service',
SrcK8S_Type: 'Service'
},
values: [
[1647965100, '63700'],
[1647965400, '168400'],
[1647965700, '85300']
]
},
{
metric: {
DstAddr: '10.131.0.18',
DstK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'flowlogs-pipeline',
DstK8S_OwnerType: 'Deployment',
DstK8S_Type: 'Pod',
SrcAddr: '172.30.116.84',
SrcK8S_Name: 'loki-distributor-http-loki',
SrcK8S_Namespace: 'network-observability',
SrcK8S_OwnerName: 'loki-distributor-http-loki',
SrcK8S_OwnerType: 'Service',
SrcK8S_Type: 'Service'
},
values: [
[1647965100, '55900'],
[1647965400, '47100'],
[1647965700, '88100']
]
},
{
metric: {
DstAddr: '172.30.0.10',
DstK8S_Name: 'dns-default',
DstK8S_Namespace: 'openshift-dns',
DstK8S_OwnerName: 'dns-default',
DstK8S_OwnerType: 'Service',
DstK8S_Type: 'Service',
SrcAddr: '10.131.0.18',
SrcK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
SrcK8S_Namespace: 'network-observability',
SrcK8S_OwnerName: 'flowlogs-pipeline',
SrcK8S_OwnerType: 'Deployment',
SrcK8S_Type: 'Pod'
},
values: [
[1647965100, '22400'],
[1647965400, '33600'],
[1647965700, '22400']
]
},
{
metric: {
DstAddr: '172.30.116.84',
DstK8S_Name: 'loki-distributor-http-loki',
DstK8S_Namespace: 'network-observability',
DstK8S_OwnerName: 'loki-distributor-http-loki',
DstK8S_OwnerType: 'Service',
DstK8S_Type: 'Service',
SrcAddr: '10.131.0.18',
SrcK8S_Name: 'flowlogs-pipeline-69b6669d59-f76sh',
SrcK8S_Namespace: 'network-observability',
SrcK8S_OwnerName: 'flowlogs-pipeline',
SrcK8S_OwnerType: 'Deployment',
SrcK8S_Type: 'Pod'
},
values: [
[1647965100, '458800'],
[1647965400, '1789200'],
[1647965700, '932000']
]
}
],
stats: {
summary: {
bytesProcessedPerSecond: 105976603,
linesProcessedPerSecond: 100026,
totalBytesProcessed: 24590613,
totalLinesProcessed: 23210,
execTime: 0.23203813
},
store: {
totalChunksRef: 74,
totalChunksDownloaded: 74,
chunksDownloadTime: 0.000732113,
headChunkBytes: 0,
headChunkLines: 0,
decompressedBytes: 1664739,
decompressedLines: 1564,
compressedBytes: 186000,
totalDuplicates: 0
},
ingester: {
totalReached: 1,
totalChunksMatched: 687,
totalBatches: 1,
totalLinesSent: 289,
headChunkBytes: 12768113,
headChunkLines: 12263,
decompressedBytes: 10157761,
decompressedLines: 9383,
compressedBytes: 968090,
totalDuplicates: 0
}
}
}
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
import { EmptyState, EmptyStateBody, Spinner } from '@patternfly/react-core';
import { shallow } from 'enzyme';
import * as React from 'react';
import { TopologyMetrics } from '../../../api/loki';
import { DefaultOptions, LayoutName } from '../../../model/topology';
import { DEFAULT_TIME_RANGE } from '../../../utils/router';
import NetflowTopology from '../netflow-topology';

describe('<NetflowTopology />', () => {
const mocks = {
error: undefined as string | undefined,
loading: false,
range: DEFAULT_TIME_RANGE,
metrics: [] as TopologyMetrics[],
layout: LayoutName.Cola,
options: DefaultOptions,
lowScale: 0.3,
medScale: 0.5,
filters: [],
toggleTopologyOptions: jest.fn()
};

it('should render component', async () => {
const wrapper = shallow(<NetflowTopology />);
const wrapper = shallow(<NetflowTopology {...mocks} />);
expect(wrapper.find(NetflowTopology)).toBeTruthy();
});

it('should render loading', async () => {
mocks.loading = true;
const wrapper = shallow(<NetflowTopology {...mocks} />);
expect(wrapper.find(Spinner)).toHaveLength(1);
});

it('should render error', async () => {
mocks.error = 'test error message';
const wrapper = shallow(<NetflowTopology {...mocks} />);
expect(wrapper.find(EmptyState)).toHaveLength(1);
expect(wrapper.find(EmptyStateBody)).toHaveLength(1);
});
});
Loading