-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[EPM] Data source integration tests #52542
Merged
skh
merged 5 commits into
elastic:feature-ingest
from
skh:52483-data-source-integration-tests
Dec 11, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a1a638
Add fixtures for data source integration test.
skh e77e8f3
Move test setup to beforeEach
skh 32b3484
Add test for datasource creation
skh b24f3f1
Handle pipelines in yml format.
skh c8fa5e8
Make integration test for adding a data source pass.
skh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
/* eslint-disable no-console */ | ||
/* tslint:disable */ | ||
|
||
import { readFileSync } from 'fs'; | ||
import path from 'path'; | ||
import expect from '@kbn/expect'; | ||
import ServerMock from 'mock-http-server'; | ||
import { FtrProviderContext } from '../../api_integration/ftr_provider_context'; | ||
|
||
export default function({ getService }: FtrProviderContext) { | ||
const supertest = getService('supertest'); | ||
describe('data source installation', () => { | ||
const registryMock = new ServerMock({ host: 'localhost', port: 6666 }); | ||
beforeEach(async () => { | ||
registryMock.start(() => {}); | ||
const packageResponse = readFileSync( | ||
path.join(__dirname, '/fixtures/packages/package/yamlpipeline_1.0.0') | ||
).toString(); | ||
const fileResponse = readFileSync( | ||
path.join(__dirname, '/fixtures/packages/epr/yamlpipeline_1.0.0.tar.gz') | ||
); | ||
registryMock.on({ | ||
method: 'GET', | ||
path: '/package/yamlpipeline-1.0.0', | ||
reply: { | ||
status: 200, | ||
headers: { 'content-type': 'application/json' }, | ||
body: packageResponse, | ||
}, | ||
}); | ||
|
||
registryMock.on({ | ||
method: 'GET', | ||
path: '/epr/yamlpipeline/yamlpipeline-1.0.0.tar.gz', | ||
reply: { | ||
status: 200, | ||
headers: { 'content-type': 'application/gzip' }, | ||
body: fileResponse, | ||
}, | ||
}); | ||
|
||
const installPackage = async () => { | ||
const response = await supertest | ||
.get('/api/epm/install/yamlpipeline-1.0.0') | ||
.set('kbn-xsrf', 'xxx') | ||
.expect(200); | ||
return response.body; | ||
}; | ||
// commment for debugging | ||
await installPackage(); | ||
|
||
// uncomment for debugging | ||
// const packageInstallResponse = await installPackage(); | ||
// console.log('packageInstallResponse is: ', packageInstallResponse); | ||
// console.log( | ||
// 'requests are', | ||
// registryMock.requests().map(r => r.url) | ||
// ); | ||
}); | ||
afterEach(() => { | ||
registryMock.stop(() => {}); | ||
}); | ||
it('test setup works', async () => { | ||
const readPackageSavedObject = async () => { | ||
const response = await supertest | ||
.get('/api/saved_objects/epm-package/yamlpipeline-1.0.0') | ||
.expect(200); | ||
return response.body; | ||
}; | ||
const savedObjectResponse = await readPackageSavedObject(); | ||
expect(savedObjectResponse.id).to.be('yamlpipeline-1.0.0'); | ||
}); | ||
it('works with a package containing only yml format ingest pipelines', async () => { | ||
const createDataSource = async () => { | ||
const response = await supertest | ||
.get('/api/epm/datasource/install/yamlpipeline-1.0.0') | ||
.expect(200); | ||
return response.body; | ||
}; | ||
|
||
const readDataSourceSavedObject = async () => { | ||
const response = await supertest | ||
.get('/api/saved_objects/epm-datasource/yamlpipeline-1.0.0') | ||
.expect(200); | ||
return response.body; | ||
}; | ||
|
||
// comment for debugging | ||
await createDataSource(); | ||
|
||
// uncomment for debugging | ||
// const createDataSourceResponse = await createDataSource(); | ||
// console.log('createDataSourceResponse is ', createDataSourceResponse); | ||
|
||
const readDataSourceSavedObjectResponse = await readDataSourceSavedObject(); | ||
expect(readDataSourceSavedObjectResponse.id).to.be('yamlpipeline-1.0.0'); | ||
}); | ||
}); | ||
} |
Binary file added
BIN
+1.95 KB
x-pack/test/epm_api_integration/apis/fixtures/packages/epr/yamlpipeline_1.0.0.tar.gz
Binary file not shown.
32 changes: 32 additions & 0 deletions
32
x-pack/test/epm_api_integration/apis/fixtures/packages/package/yamlpipeline_1.0.0
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,32 @@ | ||
{ | ||
"name": "yamlpipeline", | ||
"title": "Yaml Pipeline package", | ||
"version": "1.0.0", | ||
"description": "This package contains a yaml pipeline.\n", | ||
"type": "integration", | ||
"categories": [ | ||
"logs" | ||
], | ||
"requirement": { | ||
"kibana": {} | ||
}, | ||
"assets": [ | ||
"/package/yamlpipeline-1.0.0/manifest.yml", | ||
"/package/yamlpipeline-1.0.0/dataset/log/manifest.yml", | ||
"/package/yamlpipeline-1.0.0/dataset/log/elasticsearch/ingest-pipeline/pipeline-entry.yml", | ||
"/package/yamlpipeline-1.0.0/dataset/log/elasticsearch/ingest-pipeline/pipeline-json.yml", | ||
"/package/yamlpipeline-1.0.0/dataset/log/elasticsearch/ingest-pipeline/pipeline-plaintext.yml" | ||
], | ||
"format_version": "1.0.0", | ||
"datasets": [ | ||
{ | ||
"title": "Log Yaml pipeline", | ||
"name": "log", | ||
"release": "", | ||
"type": "logs", | ||
"ingest_pipeline": "" | ||
} | ||
], | ||
"download": "/epr/yamlpipeline/yamlpipeline-1.0.0.tar.gz", | ||
"path": "/package/yamlpipeline-1.0.0" | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pity that it is not supported. @delvedor Does the new client support this?