-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
# Backport This will backport the following commits from `main` to `8.15`: - [Integration assistant generate readme (#192887)](#192887) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Hanna Tamoudi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-17T16:31:18Z","message":"Integration assistant generate readme (#192887)\n\n## Summary\r\n\r\n- Create an integration `README` when using the Integration Assistant so\r\nthat it is displayed when opening the newly created integration.\r\n- Increase code coverage for the Integration Assistant plugin.","sha":"e360963065ab783c9cf265869fb43b2f73f74368","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["enhancement","release_note:skip","v9.0.0","backport:prev-major","v8.16.0","Team:Security-Scalability","v8.15.2","Feature:AutomaticImport"],"title":"Integration assistant generate readme","number":192887,"url":"https://github.com/elastic/kibana/pull/192887","mergeCommit":{"message":"Integration assistant generate readme (#192887)\n\n## Summary\r\n\r\n- Create an integration `README` when using the Integration Assistant so\r\nthat it is displayed when opening the newly created integration.\r\n- Increase code coverage for the Integration Assistant plugin.","sha":"e360963065ab783c9cf265869fb43b2f73f74368"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.15"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192887","number":192887,"mergeCommit":{"message":"Integration assistant generate readme (#192887)\n\n## Summary\r\n\r\n- Create an integration `README` when using the Integration Assistant so\r\nthat it is displayed when opening the newly created integration.\r\n- Increase code coverage for the Integration Assistant plugin.","sha":"e360963065ab783c9cf265869fb43b2f73f74368"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.15","label":"v8.15.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Hanna Tamoudi <[email protected]>
- Loading branch information
1 parent
e68e2a9
commit 657f5f0
Showing
6 changed files
with
488 additions
and
1 deletion.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
x-pack/plugins/integration_assistant/server/integration_builder/agent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as Utils from '../util'; | ||
import { createAgentInput } from './agent'; | ||
import { InputType } from '../../common'; | ||
|
||
jest.mock('../util', () => ({ | ||
...jest.requireActual('../util'), | ||
createSync: jest.fn(), | ||
ensureDirSync: jest.fn(), | ||
})); | ||
|
||
describe('createAgentInput', () => { | ||
const dataStreamPath = 'path'; | ||
|
||
beforeEach(async () => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('Should create expected files', async () => { | ||
const inputTypes: InputType[] = ['aws-s3', 'filestream']; | ||
|
||
createAgentInput(dataStreamPath, inputTypes); | ||
|
||
expect(Utils.ensureDirSync).toHaveBeenCalledWith(`${dataStreamPath}/agent/stream`); | ||
|
||
expect(Utils.createSync).toHaveBeenCalledWith( | ||
`${dataStreamPath}/agent/stream/aws-s3.yml.hbs`, | ||
expect.any(String) | ||
); | ||
expect(Utils.createSync).toHaveBeenCalledWith( | ||
`${dataStreamPath}/agent/stream/filestream.yml.hbs`, | ||
expect.any(String) | ||
); | ||
}); | ||
|
||
it('Should not create agent files if there are no input types', async () => { | ||
createAgentInput(dataStreamPath, []); | ||
|
||
expect(Utils.ensureDirSync).toHaveBeenCalledWith(`${dataStreamPath}/agent/stream`); | ||
expect(Utils.createSync).not.toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
x-pack/plugins/integration_assistant/server/integration_builder/data_stream.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as Utils from '../util'; | ||
import { DataStream, Docs, InputType, Pipeline } from '../../common'; | ||
import { createDataStream } from './data_stream'; | ||
import * as nunjucks from 'nunjucks'; | ||
|
||
jest.mock('nunjucks'); | ||
|
||
jest.mock('../util', () => ({ | ||
...jest.requireActual('../util'), | ||
removeDirSync: jest.fn(), | ||
ensureDirSync: jest.fn(), | ||
createSync: jest.fn(), | ||
copySync: jest.fn(), | ||
generateUniqueId: jest.fn(), | ||
generateFields: jest.fn(), | ||
})); | ||
|
||
describe('createDataStream', () => { | ||
const packageName = 'package'; | ||
const dataStreamPath = 'path'; | ||
const firstDatastreamName = 'datastream_1'; | ||
const firstDataStreamInputTypes: InputType[] = ['filestream', 'azure-eventhub']; | ||
const firstDataStreamDocs: Docs = [ | ||
{ | ||
key: 'foo', | ||
anotherKey: 'bar', | ||
}, | ||
]; | ||
const firstDataStreamPipeline: Pipeline = { | ||
processors: [ | ||
{ | ||
set: { | ||
field: 'ecs.version', | ||
value: '8.11.0', | ||
}, | ||
}, | ||
], | ||
}; | ||
const samples = '{"test1": "test1"}'; | ||
const firstDataStream: DataStream = { | ||
name: firstDatastreamName, | ||
title: 'Datastream_1', | ||
description: 'Datastream_1 description', | ||
inputTypes: firstDataStreamInputTypes, | ||
docs: firstDataStreamDocs, | ||
rawSamples: [samples], | ||
pipeline: firstDataStreamPipeline, | ||
samplesFormat: { name: 'ndjson', multiline: false }, | ||
}; | ||
|
||
it('Should create expected directories and files', async () => { | ||
createDataStream(packageName, dataStreamPath, firstDataStream); | ||
|
||
// pipeline | ||
expect(Utils.ensureDirSync).toHaveBeenCalledWith(dataStreamPath); | ||
expect(Utils.ensureDirSync).toHaveBeenCalledWith( | ||
`${dataStreamPath}/elasticsearch/ingest_pipeline` | ||
); | ||
|
||
// dataStream files | ||
expect(Utils.copySync).toHaveBeenCalledWith(expect.any(String), `${dataStreamPath}/fields`); | ||
|
||
// test files | ||
expect(Utils.ensureDirSync).toHaveBeenCalledWith(`${dataStreamPath}/_dev/test/pipeline`); | ||
expect(Utils.copySync).toHaveBeenCalledWith( | ||
expect.any(String), | ||
`${dataStreamPath}/_dev/test/pipeline/test-common-config.yml` | ||
); | ||
expect(Utils.createSync).toHaveBeenCalledWith( | ||
`${dataStreamPath}/_dev/test/pipeline/test-${packageName}-datastream-1.log`, | ||
samples | ||
); | ||
|
||
// // Manifest files | ||
expect(Utils.createSync).toHaveBeenCalledWith(`${dataStreamPath}/manifest.yml`, undefined); | ||
expect(nunjucks.render).toHaveBeenCalledWith(`filestream_manifest.yml.njk`, expect.anything()); | ||
expect(nunjucks.render).toHaveBeenCalledWith( | ||
`azure_eventhub_manifest.yml.njk`, | ||
expect.anything() | ||
); | ||
}); | ||
}); |
Oops, something went wrong.