-
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.
[EPM] Data source integration tests (#52542)
* Add fixtures for data source integration test. * Move test setup to beforeEach * Add test for datasource creation * Handle pipelines in yml format. * Make integration test for adding a data source pass.
- Loading branch information
Showing
5 changed files
with
166 additions
and
1 deletion.
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