From 41b820e66b308aeec15cb5bc7d833a8b1729aaea Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Wed, 2 Aug 2023 16:09:25 -0700 Subject: [PATCH 1/4] Fix VPC type Signed-off-by: Simeon Widdis --- .../__data__/repository/aws_vpc_flow/aws_vpc_flow-1.0.0.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/adaptors/integrations/__data__/repository/aws_vpc_flow/aws_vpc_flow-1.0.0.json b/server/adaptors/integrations/__data__/repository/aws_vpc_flow/aws_vpc_flow-1.0.0.json index f665c9cc2..86e8a9b03 100644 --- a/server/adaptors/integrations/__data__/repository/aws_vpc_flow/aws_vpc_flow-1.0.0.json +++ b/server/adaptors/integrations/__data__/repository/aws_vpc_flow/aws_vpc_flow-1.0.0.json @@ -4,7 +4,7 @@ "displayName": "AWS VPC Flow", "description": "AWS VPC Flow log collector", "license": "Apache-2.0", - "type": "logs", + "type": "logs_vpc", "author": "Haidong Wang", "sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_vpc_flow/info", "statics": { From 8c7d57c815284a690ecbe140e7e1e08ce0d240c7 Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Wed, 2 Aug 2023 16:17:09 -0700 Subject: [PATCH 2/4] Add a test case Signed-off-by: Simeon Widdis --- .../__test__/local_repository.test.ts | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/server/adaptors/integrations/__test__/local_repository.test.ts b/server/adaptors/integrations/__test__/local_repository.test.ts index bfe3ce583..246aa7e82 100644 --- a/server/adaptors/integrations/__test__/local_repository.test.ts +++ b/server/adaptors/integrations/__test__/local_repository.test.ts @@ -7,16 +7,26 @@ import { Repository } from '../repository/repository'; import { Integration } from '../repository/integration'; import path from 'path'; -describe("The local repository", () => { - it("Should pass shallow validation for all local integrations.", async () => { - let repository: Repository = new Repository(path.join(__dirname, '../__data__/repository')); - let integrations: Integration[] = await repository.getIntegrationList(); - await Promise.all(integrations.map(i => expect(i.check()).resolves.toBeTruthy())); - }); +describe('The local repository', () => { + it('Should pass shallow validation for all local integrations.', async () => { + const repository: Repository = new Repository(path.join(__dirname, '../__data__/repository')); + const integrations: Integration[] = await repository.getIntegrationList(); + await Promise.all(integrations.map((i) => expect(i.check()).resolves.toBeTruthy())); + }); - it("Should pass deep validation for all local integrations.", async () => { - let repository: Repository = new Repository(path.join(__dirname, '../__data__/repository')); - let integrations: Integration[] = await repository.getIntegrationList(); - await Promise.all(integrations.map(i => expect(i.deepCheck()).resolves.toBeTruthy())); - }); + it('Should pass deep validation for all local integrations.', async () => { + const repository: Repository = new Repository(path.join(__dirname, '../__data__/repository')); + const integrations: Integration[] = await repository.getIntegrationList(); + await Promise.all(integrations.map((i) => expect(i.deepCheck()).resolves.toBeTruthy())); + }); + + it('Should not have a type that is not imported in the config', async () => { + const repository: Repository = new Repository(path.join(__dirname, '../__data__/repository')); + const integrations: Integration[] = await repository.getIntegrationList(); + for (const integration of integrations) { + const config = await integration.getConfig(); + const components = config!.components.map((x) => x.name); + expect(components).toContain(config!.type); + } + }); }); From f2ec20ddee7b4bc24deb570673a031e91ceb63aa Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Wed, 2 Aug 2023 15:02:58 -0700 Subject: [PATCH 3/4] Re-apply link fix and update test Signed-off-by: Simeon Widdis --- .../repository/nginx/nginx-1.0.0.json | 1 - .../__test__/local_repository.test.ts | 20 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json b/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json index 2f7af3fee..421032f78 100644 --- a/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json +++ b/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json @@ -5,7 +5,6 @@ "description": "Nginx HTTP server collector", "license": "Apache-2.0", "type": "logs", - "link": "https://www.nginx.com/", "author": "OpenSearch", "sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/nginx/info", "statics": { diff --git a/server/adaptors/integrations/__test__/local_repository.test.ts b/server/adaptors/integrations/__test__/local_repository.test.ts index 246aa7e82..722711710 100644 --- a/server/adaptors/integrations/__test__/local_repository.test.ts +++ b/server/adaptors/integrations/__test__/local_repository.test.ts @@ -6,12 +6,24 @@ import { Repository } from '../repository/repository'; import { Integration } from '../repository/integration'; import path from 'path'; +import * as fs from 'fs/promises'; describe('The local repository', () => { - it('Should pass shallow validation for all local integrations.', async () => { - const repository: Repository = new Repository(path.join(__dirname, '../__data__/repository')); - const integrations: Integration[] = await repository.getIntegrationList(); - await Promise.all(integrations.map((i) => expect(i.check()).resolves.toBeTruthy())); + it('Should only contain valid integration directories or files.', async () => { + const directory = path.join(__dirname, '../__data__/repository'); + const folders = await fs.readdir(directory); + await Promise.all( + folders.map(async (folder) => { + const integPath = path.join(directory, folder); + if (!(await fs.lstat(integPath)).isDirectory()) { + // If it's not a directory (e.g. a README), skip it + return Promise.resolve(null); + } + // Otherwise, all directories must be integrations + const integ = new Integration(integPath); + await expect(integ.check()).resolves.toBe(true); + }) + ); }); it('Should pass deep validation for all local integrations.', async () => { From 93388d62b855413bb1a8fdc8f844fc3c8a483d75 Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Wed, 2 Aug 2023 16:25:25 -0700 Subject: [PATCH 4/4] Revert "Re-apply link fix and update test" This reverts commit f2ec20ddee7b4bc24deb570673a031e91ceb63aa. Signed-off-by: Simeon Widdis --- .../repository/nginx/nginx-1.0.0.json | 1 + .../__test__/local_repository.test.ts | 20 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json b/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json index 421032f78..2f7af3fee 100644 --- a/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json +++ b/server/adaptors/integrations/__data__/repository/nginx/nginx-1.0.0.json @@ -5,6 +5,7 @@ "description": "Nginx HTTP server collector", "license": "Apache-2.0", "type": "logs", + "link": "https://www.nginx.com/", "author": "OpenSearch", "sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/nginx/info", "statics": { diff --git a/server/adaptors/integrations/__test__/local_repository.test.ts b/server/adaptors/integrations/__test__/local_repository.test.ts index 722711710..246aa7e82 100644 --- a/server/adaptors/integrations/__test__/local_repository.test.ts +++ b/server/adaptors/integrations/__test__/local_repository.test.ts @@ -6,24 +6,12 @@ import { Repository } from '../repository/repository'; import { Integration } from '../repository/integration'; import path from 'path'; -import * as fs from 'fs/promises'; describe('The local repository', () => { - it('Should only contain valid integration directories or files.', async () => { - const directory = path.join(__dirname, '../__data__/repository'); - const folders = await fs.readdir(directory); - await Promise.all( - folders.map(async (folder) => { - const integPath = path.join(directory, folder); - if (!(await fs.lstat(integPath)).isDirectory()) { - // If it's not a directory (e.g. a README), skip it - return Promise.resolve(null); - } - // Otherwise, all directories must be integrations - const integ = new Integration(integPath); - await expect(integ.check()).resolves.toBe(true); - }) - ); + it('Should pass shallow validation for all local integrations.', async () => { + const repository: Repository = new Repository(path.join(__dirname, '../__data__/repository')); + const integrations: Integration[] = await repository.getIntegrationList(); + await Promise.all(integrations.map((i) => expect(i.check()).resolves.toBeTruthy())); }); it('Should pass deep validation for all local integrations.', async () => {