From ae6c0957e3d0ed3812b720d86411e83411f30e5f Mon Sep 17 00:00:00 2001 From: Palak Bhojani Date: Mon, 7 Jan 2019 11:55:06 -0800 Subject: [PATCH] Remove plugin bundles that don't match the protoboards --- ui/mocks/dummyData.ts | 21 ++++++++---- ui/src/onboarding/constants/pluginConfigs.ts | 33 +++---------------- .../onboarding/reducers/dataLoaders.test.ts | 24 +++++++------- .../__snapshots__/pluginConfigs.test.ts.snap | 3 ++ ui/src/onboarding/utils/pluginConfigs.test.ts | 22 +++---------- ui/src/types/v2/dataLoaders.ts | 9 ----- 6 files changed, 38 insertions(+), 74 deletions(-) create mode 100644 ui/src/onboarding/utils/__snapshots__/pluginConfigs.test.ts.snap diff --git a/ui/mocks/dummyData.ts b/ui/mocks/dummyData.ts index 02bc55a06d..e61ecc402c 100644 --- a/ui/mocks/dummyData.ts +++ b/ui/mocks/dummyData.ts @@ -17,12 +17,13 @@ import { TelegrafPluginInputCpu, TelegrafPluginInputRedis, TelegrafPluginInputDisk, - TelegrafPluginInputKernel, TelegrafPluginInputDiskio, TelegrafPluginInputMem, - TelegrafPluginInputSwap, TelegrafPluginInputSystem, TelegrafPluginInputProcesses, + TelegrafPluginInputNet, + TelegrafPluginInputProcstat, + TelegrafPluginInputDocker, } from 'src/api' export const links: Links = { @@ -328,9 +329,9 @@ export const diskioTelegrafPlugin = { configured: ConfigurationState.Configured, } -export const kernelTelegrafPlugin = { +export const netTelegrafPlugin = { ...telegrafPlugin, - name: TelegrafPluginInputKernel.NameEnum.Kernel, + name: TelegrafPluginInputNet.NameEnum.Net, configured: ConfigurationState.Configured, } @@ -346,10 +347,10 @@ export const processesTelegrafPlugin = { configured: ConfigurationState.Configured, } -export const swapTelegrafPlugin = { +export const procstatTelegrafPlugin = { ...telegrafPlugin, - name: TelegrafPluginInputSwap.NameEnum.Swap, - configured: ConfigurationState.Configured, + name: TelegrafPluginInputProcstat.NameEnum.Procstat, + configured: ConfigurationState.Unconfigured, } export const systemTelegrafPlugin = { @@ -372,6 +373,12 @@ export const redisPlugin = { }, } +export const dockerTelegrafPlugin = { + ...telegrafPlugin, + name: TelegrafPluginInputDocker.NameEnum.Docker, + configured: ConfigurationState.Configured, +} + export const influxDB2Plugin = { name: 'influxdb_v2', type: 'output', diff --git a/ui/src/onboarding/constants/pluginConfigs.ts b/ui/src/onboarding/constants/pluginConfigs.ts index a69572f989..2ed74c6d01 100644 --- a/ui/src/onboarding/constants/pluginConfigs.ts +++ b/ui/src/onboarding/constants/pluginConfigs.ts @@ -37,30 +37,16 @@ export const pluginsByBundle: PluginBundles = { TelegrafPluginInputCpu.NameEnum.Cpu, TelegrafPluginInputDisk.NameEnum.Disk, TelegrafPluginInputDiskio.NameEnum.Diskio, - TelegrafPluginInputKernel.NameEnum.Kernel, - TelegrafPluginInputMem.NameEnum.Mem, - TelegrafPluginInputProcesses.NameEnum.Processes, - TelegrafPluginInputSwap.NameEnum.Swap, TelegrafPluginInputSystem.NameEnum.System, - ], - [BundleName.Disk]: [ - TelegrafPluginInputDisk.NameEnum.Disk, - TelegrafPluginInputDiskio.NameEnum.Diskio, + TelegrafPluginInputMem.NameEnum.Mem, + TelegrafPluginInputNet.NameEnum.Net, + TelegrafPluginInputProcesses.NameEnum.Processes, + TelegrafPluginInputProcstat.NameEnum.Procstat, ], [BundleName.Docker]: [TelegrafPluginInputDocker.NameEnum.Docker], - [BundleName.File]: [TelegrafPluginInputFile.NameEnum.File], [BundleName.Kubernetes]: [TelegrafPluginInputKubernetes.NameEnum.Kubernetes], - [BundleName.Logparser]: [TelegrafPluginInputLogParser.NameEnum.Logparser], - [BundleName.Net]: [TelegrafPluginInputNet.NameEnum.Net], - [BundleName.NetResponse]: [ - TelegrafPluginInputNetResponse.NameEnum.NetResponse, - ], [BundleName.Ngnix]: [TelegrafPluginInputNgnix.NameEnum.Ngnix], - [BundleName.Procstat]: [TelegrafPluginInputProcstat.NameEnum.Procstat], - [BundleName.Prometheus]: [TelegrafPluginInputPrometheus.NameEnum.Prometheus], [BundleName.Redis]: [TelegrafPluginInputRedis.NameEnum.Redis], - [BundleName.Syslog]: [TelegrafPluginInputSyslog.NameEnum.Syslog], - [BundleName.Tail]: [TelegrafPluginInputTail.NameEnum.Tail], } export const telegrafPluginsInfo: TelegrafPluginInfo = { @@ -272,7 +258,6 @@ import { LogoDocker, LogoKubernetes, LogoNginx, - LogoPrometheus, LogoRedis, } from 'src/onboarding/graphics' @@ -281,23 +266,13 @@ export const BUNDLE_LOGOS = { [BundleName.Docker]: LogoDocker, [BundleName.Kubernetes]: LogoKubernetes, [BundleName.Ngnix]: LogoNginx, - [BundleName.Prometheus]: LogoPrometheus, [BundleName.Redis]: LogoRedis, } export const PLUGIN_BUNDLE_OPTIONS: BundleName[] = [ BundleName.System, - BundleName.Disk, BundleName.Docker, - BundleName.File, BundleName.Kubernetes, - BundleName.Logparser, - BundleName.Net, - BundleName.NetResponse, BundleName.Ngnix, - BundleName.Procstat, - BundleName.Prometheus, BundleName.Redis, - BundleName.Syslog, - BundleName.Tail, ] diff --git a/ui/src/onboarding/reducers/dataLoaders.test.ts b/ui/src/onboarding/reducers/dataLoaders.test.ts index a32b9a319c..c4ec1b53d5 100644 --- a/ui/src/onboarding/reducers/dataLoaders.test.ts +++ b/ui/src/onboarding/reducers/dataLoaders.test.ts @@ -28,14 +28,15 @@ import { cpuTelegrafPlugin, diskTelegrafPlugin, diskioTelegrafPlugin, - kernelTelegrafPlugin, + netTelegrafPlugin, memTelegrafPlugin, processesTelegrafPlugin, - swapTelegrafPlugin, + procstatTelegrafPlugin, systemTelegrafPlugin, redisTelegrafPlugin, token, telegrafConfig, + dockerTelegrafPlugin, } from 'mocks/dummyData' // Types @@ -374,16 +375,17 @@ describe('dataLoader reducer', () => { const actual = dataLoadersReducer( { ...INITIAL_STATE, - pluginBundles: [BundleName.Disk, BundleName.System], + pluginBundles: [BundleName.Docker, BundleName.System], telegrafPlugins: [ cpuTelegrafPlugin, diskTelegrafPlugin, diskioTelegrafPlugin, - kernelTelegrafPlugin, + netTelegrafPlugin, memTelegrafPlugin, processesTelegrafPlugin, - swapTelegrafPlugin, + procstatTelegrafPlugin, systemTelegrafPlugin, + dockerTelegrafPlugin, ], }, removeBundlePlugins(BundleName.System) @@ -391,8 +393,8 @@ describe('dataLoader reducer', () => { const expected = { ...INITIAL_STATE, - pluginBundles: [BundleName.Disk, BundleName.System], - telegrafPlugins: [diskTelegrafPlugin, diskioTelegrafPlugin], + pluginBundles: [BundleName.Docker, BundleName.System], + telegrafPlugins: [dockerTelegrafPlugin], } expect(actual).toEqual(expected) @@ -430,11 +432,11 @@ describe('dataLoader reducer', () => { cpuTelegrafPlugin, diskTelegrafPlugin, diskioTelegrafPlugin, - kernelTelegrafPlugin, - memTelegrafPlugin, - processesTelegrafPlugin, - swapTelegrafPlugin, systemTelegrafPlugin, + memTelegrafPlugin, + netTelegrafPlugin, + processesTelegrafPlugin, + procstatTelegrafPlugin, ]) ) }) diff --git a/ui/src/onboarding/utils/__snapshots__/pluginConfigs.test.ts.snap b/ui/src/onboarding/utils/__snapshots__/pluginConfigs.test.ts.snap new file mode 100644 index 0000000000..b21ed4c123 --- /dev/null +++ b/ui/src/onboarding/utils/__snapshots__/pluginConfigs.test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Onboarding.Utils.PluginConfig if plugin is found in only one bundle isPluginUniqueToBundle returns true 1`] = `true`; diff --git a/ui/src/onboarding/utils/pluginConfigs.test.ts b/ui/src/onboarding/utils/pluginConfigs.test.ts index 3abc9d69d6..88cdc90ef5 100644 --- a/ui/src/onboarding/utils/pluginConfigs.test.ts +++ b/ui/src/onboarding/utils/pluginConfigs.test.ts @@ -6,39 +6,25 @@ import { // Types import {BundleName} from 'src/types/v2/dataLoaders' -import { - TelegrafPluginInputCpu, - TelegrafPluginInputDisk, - TelegrafPluginInputSystem, -} from 'src/api' +import {TelegrafPluginInputCpu, TelegrafPluginInputSystem} from 'src/api' describe('Onboarding.Utils.PluginConfig', () => { describe('if plugin is found in only one bundle', () => { it('isPluginUniqueToBundle returns true', () => { const telegrafPlugin = TelegrafPluginInputCpu.NameEnum.Cpu const bundle = BundleName.System - const bundles = [BundleName.System, BundleName.Disk] + const bundles = [BundleName.System, BundleName.Docker] const actual = isPluginUniqueToBundle(telegrafPlugin, bundle, bundles) expect(actual).toBe(true) - }) - }) - describe('if plugin is found in multiple bundles', () => { - it('isPluginUniqueToBundle returns false', () => { - const telegrafPlugin = TelegrafPluginInputDisk.NameEnum.Disk - const bundle = BundleName.System - const bundles = [BundleName.System, BundleName.Disk] - - const actual = isPluginUniqueToBundle(telegrafPlugin, bundle, bundles) - - expect(actual).toBe(false) + expect(actual).toMatchSnapshot() }) }) describe('if plugin is not in bundle', () => { it('isPluginInBundle returns false', () => { const telegrafPlugin = TelegrafPluginInputSystem.NameEnum.System - const bundle = BundleName.Disk + const bundle = BundleName.Docker const actual = isPluginInBundle(telegrafPlugin, bundle) diff --git a/ui/src/types/v2/dataLoaders.ts b/ui/src/types/v2/dataLoaders.ts index 9a6941bfae..f5f8f78478 100644 --- a/ui/src/types/v2/dataLoaders.ts +++ b/ui/src/types/v2/dataLoaders.ts @@ -107,19 +107,10 @@ export interface TelegrafPlugin { export enum BundleName { System = 'System', - Disk = 'Disk', Docker = 'Docker', - File = 'File', Kubernetes = 'Kubernetes', - Logparser = 'LogParser', - Net = 'Net', - NetResponse = 'NetResponse', Ngnix = 'NGNIX', - Procstat = 'Procstat', - Prometheus = 'Prometheus', Redis = 'Redis', - Syslog = 'Syslog', - Tail = 'Tail', } export type TelegrafPluginName =