[Ingest Manager] Use DockerServers service in integration tests. (#69822)

* Partially disable test files.

* Use DockerServers in EPM tests.

* Only run tests when DockerServers have been set up

* Reenable ingest manager API integration tests

* Pass new test_packages to registry container

* Enable DockerServers tests in CI.

* Correctly serve filetest package for file tests.

* Add helper to skip test and log warning.

* Reenable further file tests.

* Add developer documentation about Docker in Kibana CI.

* Document use of yarn test:ftr

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Sonja Krause-Harder 2020-06-29 15:24:11 +02:00 committed by GitHub
parent 8e57db696a
commit e91594aeb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 474 additions and 343 deletions

View file

@ -21,6 +21,7 @@ def functionalTestProcess(String name, Closure closure) {
def kibanaPort = "61${processNumber}1"
def esPort = "61${processNumber}2"
def esTransportPort = "61${processNumber}3"
def ingestManagementPackageRegistryPort = "61${processNumber}4"
withEnv([
"CI_PARALLEL_PROCESS_NUMBER=${processNumber}",
@ -29,6 +30,7 @@ def functionalTestProcess(String name, Closure closure) {
"TEST_KIBANA_URL=http://elastic:changeme@localhost:${kibanaPort}",
"TEST_ES_URL=http://elastic:changeme@localhost:${esPort}",
"TEST_ES_TRANSPORT_PORT=${esTransportPort}",
"INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=${ingestManagementPackageRegistryPort}",
"IS_PIPELINE_JOB=1",
"JOB=${name}",
"KBN_NP_PLUGINS_BUILT=true",

View file

@ -0,0 +1,113 @@
# API integration tests
Many API integration tests for Ingest Manager trigger at some point a connection to the package registry, and retrieval of some packages. If these connections are made to a package registry deployment outside of Kibana CI, these tests can fail at any time for two reasons:
* the deployed registry is temporarily unavailable
* the packages served by the registry do not match the expectation of the code under test
For that reason, we run a dockerized version of the package registry in Kibana CI. For this to work, our tests must run against a custom test configuration and be kept in a custom directory, `x-pack/test/ingest_manager_api_integration`.
## How to run the tests locally
Usually, having the test server and the test runner in two different shells is most efficient, as it is possible to keep the server running and only rerun the test runner as often as needed. To do so, in one shell in the main `kibana` directory, run:
```
$ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr:server --config x-pack/test/ingest_manager_api_integration/config.ts
```
In another shell in the same directory, run
```
$ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr:runner --config x-pack/test/ingest_manager_api_integration/config.ts
```
However, it is also possible to **alternatively** run everything in one go, again from the main `kibana` directory:
```
$ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr --config x-pack/test/ingest_manager_api_integration/config.ts
```
Port `12345` is used as an example here, it can be anything, but the environment variable has to be present for the tests to run at all.
## DockerServers service setup
We use the `DockerServers` service provided by `kbn-test`. The documentation for this functionality can be found here:
https://github.com/elastic/kibana/blob/master/packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md
The main configuration for the `DockerServers` service for our tests can be found in `x-pack/test/ingest_manager_api_integration/config.ts`:
### Specify the arguments to pass to `docker run`:
```
const dockerArgs: string[] = [
'-v',
`${path.join(
path.dirname(__filename),
'./apis/fixtures/package_registry_config.yml'
)}:/registry/config.yml`,
'-v',
`${path.join(
path.dirname(__filename),
'./apis/fixtures/test_packages'
)}:/registry/packages/test-packages`,
];
```
`-v` mounts local paths into the docker image. The first one puts a custom configuration file into the correct place in the docker container, the second one mounts a directory containing additional packages.
### Specify the docker image to use
```
image: 'docker.elastic.co/package-registry/package-registry:kibana-testing-1'
```
This image contains the content of `docker.elastic.co/package-registry/package-registry:master` on June 26 2020. The image used here should be stable, i.e. using `master` would defeat the purpose of having a stable set of packages to be used in Kibana CI.
### Packages available for testing
The containerized package registry contains a set of packages which should be sufficient to run tests against all parts of Ingest Manager. The list of the packages are logged to the console when the docker container is initialized during testing, or when the container is started manually with
```
docker run -p 8080:8080 docker.elastic.co/package-registry/package-registry:kibana-testing-1
```
Additional packages for testing certain corner cases or error conditions can be put into `x-pack/test/ingest_manager_api_integration/apis/fixtures/test_packages`. A package `filetest` has been added there as an example.
## Some DockerServers background
For the `DockerServers` servers to run correctly in CI, the `INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT` environment variable needs to be under control of the CI environment. The reason behind this: it is possible that several versions of our tests are run in parallel on the same worker in Jenkins, and if we used a hard-coded port number here, those tests would run into port conflicts. (This is also the case for a few other ports, and the setup happens in `vars/kibanaPipeline.groovy`).
Also, not every developer has `docker` installed on their workstation, so it must be possible to run the testsuite as a whole without `docker`, and preferably this should be the default behaviour. Therefore, our `DockerServers` service is only enabled when `INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT` is set. This needs to be checked in every test like this:
```
it('fetches a .json search file', async function () {
if (server.enabled) {
await supertest
.get('/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/search/sample_search.json')
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
} else {
warnAndSkipTest(this, log);
}
});
```
If the tests are skipped in this way, they are marked in the test summary as `pending` and a warning is logged:
```
└-: EPM Endpoints
└-> "before all" hook
└-: list
└-> "before all" hook
└-> lists all packages from the registry
└-> "before each" hook: global before each
│ warn disabling tests because DockerServers service is not enabled, set INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT to run them
└-> lists all packages from the registry
└-> "after all" hook
[...]
│1 passing (233ms)
│6 pending
```

View file

@ -52,6 +52,7 @@ const onlyNotInCoverageTests = [
require.resolve('../test/endpoint_api_integration_no_ingest/config.ts'),
require.resolve('../test/reporting_api_integration/config.js'),
require.resolve('../test/functional_embedded/config.ts'),
require.resolve('../test/ingest_manager_api_integration/config.ts'),
];
require('@kbn/plugin-helpers').babelRegister();

View file

@ -1,151 +0,0 @@
/*
* 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.
*/
import ServerMock from 'mock-http-server';
import { FtrProviderContext } from '../../api_integration/ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
describe('package file', () => {
const server = new ServerMock({ host: 'localhost', port: 6666 });
beforeEach(() => {
server.start(() => {});
});
afterEach(() => {
server.stop(() => {});
});
it('fetches a .png screenshot image', async () => {
server.on({
method: 'GET',
path: '/package/auditd/2.0.4/img/screenshots/auditbeat-file-integrity-dashboard.png',
reply: {
headers: { 'content-type': 'image/png' },
},
});
const supertest = getService('supertest');
await supertest
.get(
'/api/ingest_manager/epm/packages/auditd/2.0.4/img/screenshots/auditbeat-file-integrity-dashboard.png'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'image/png')
.expect(200);
});
it('fetches an .svg icon image', async () => {
server.on({
method: 'GET',
path: '/package/auditd/2.0.4/img/icon.svg',
reply: {
headers: { 'content-type': 'image/svg' },
},
});
const supertest = getService('supertest');
await supertest
.get('/api/ingest_manager/epm/packages/auditd/2.0.4/img/icon.svg')
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'image/svg');
});
it('fetches an auditbeat .conf rule file', async () => {
server.on({
method: 'GET',
path: '/package/auditd/2.0.4/auditbeat/rules/sample-rules-linux-32bit.conf',
});
const supertest = getService('supertest');
await supertest
.get(
'/api/ingest_manager/epm/packages/auditd/2.0.4/auditbeat/rules/sample-rules-linux-32bit.conf'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
});
it('fetches an auditbeat .yml config file', async () => {
server.on({
method: 'GET',
path: '/package/auditd/2.0.4/auditbeat/config/config.yml',
reply: {
headers: { 'content-type': 'text/yaml; charset=UTF-8' },
},
});
const supertest = getService('supertest');
await supertest
.get('/api/ingest_manager/epm/packages/auditd/2.0.4/auditbeat/config/config.yml')
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'text/yaml; charset=UTF-8')
.expect(200);
});
it('fetches a .json kibana visualization file', async () => {
server.on({
method: 'GET',
path:
'/package/auditd/2.0.4/kibana/visualization/b21e0c70-c252-11e7-8692-232bd1143e8a-ecs.json',
});
const supertest = getService('supertest');
await supertest
.get(
'/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/visualization/b21e0c70-c252-11e7-8692-232bd1143e8a-ecs.json'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
});
it('fetches a .json kibana dashboard file', async () => {
server.on({
method: 'GET',
path:
'/package/auditd/2.0.4/kibana/dashboard/7de391b0-c1ca-11e7-8995-936807a28b16-ecs.json',
});
const supertest = getService('supertest');
await supertest
.get(
'/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/dashboard/7de391b0-c1ca-11e7-8995-936807a28b16-ecs.json'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
});
it('fetches an .json index pattern file', async () => {
server.on({
method: 'GET',
path: '/package/auditd/2.0.4/kibana/index-pattern/auditbeat-*.json',
});
const supertest = getService('supertest');
await supertest
.get('/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/index-pattern/auditbeat-*.json')
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
});
it('fetches a .json search file', async () => {
server.on({
method: 'GET',
path: '/package/auditd/2.0.4/kibana/search/0f10c430-c1c3-11e7-8995-936807a28b16-ecs.json',
});
const supertest = getService('supertest');
await supertest
.get(
'/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/search/0f10c430-c1c3-11e7-8995-936807a28b16-ecs.json'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
});
});
}

View file

@ -1,32 +0,0 @@
{
"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"
}

View file

@ -1,124 +0,0 @@
/*
* 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.
*/
import expect from '@kbn/expect';
import ServerMock from 'mock-http-server';
import { FtrProviderContext } from '../../api_integration/ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
describe('list', () => {
const server = new ServerMock({ host: 'localhost', port: 6666 });
beforeEach(() => {
server.start(() => {});
});
afterEach(() => {
server.stop(() => {});
});
it('lists all packages from the registry', async () => {
const searchResponse = [
{
description: 'First integration package',
download: '/package/first-1.0.1.tar.gz',
name: 'first',
title: 'First',
type: 'integration',
version: '1.0.1',
},
{
description: 'Second integration package',
download: '/package/second-2.0.4.tar.gz',
icons: [
{
src: '/package/second-2.0.4/img/icon.svg',
type: 'image/svg+xml',
},
],
name: 'second',
title: 'Second',
type: 'integration',
version: '2.0.4',
},
];
server.on({
method: 'GET',
path: '/search',
reply: {
status: 200,
headers: { 'content-type': 'application/json' },
body: JSON.stringify(searchResponse),
},
});
const supertest = getService('supertest');
const fetchPackageList = async () => {
const response = await supertest
.get('/api/ingest_manager/epm/packages')
.set('kbn-xsrf', 'xxx')
.expect(200);
return response.body;
};
const listResponse = await fetchPackageList();
expect(listResponse.response.length).to.be(2);
expect(listResponse.response[0]).to.eql({ ...searchResponse[0], status: 'not_installed' });
expect(listResponse.response[1]).to.eql({ ...searchResponse[1], status: 'not_installed' });
});
it('sorts the packages even if the registry sends them unsorted', async () => {
const searchResponse = [
{
description: 'BBB integration package',
download: '/package/bbb-1.0.1.tar.gz',
name: 'bbb',
title: 'BBB',
type: 'integration',
version: '1.0.1',
},
{
description: 'CCC integration package',
download: '/package/ccc-2.0.4.tar.gz',
name: 'ccc',
title: 'CCC',
type: 'integration',
version: '2.0.4',
},
{
description: 'AAA integration package',
download: '/package/aaa-0.0.1.tar.gz',
name: 'aaa',
title: 'AAA',
type: 'integration',
version: '0.0.1',
},
];
server.on({
method: 'GET',
path: '/search',
reply: {
status: 200,
headers: { 'content-type': 'application/json' },
body: JSON.stringify(searchResponse),
},
});
const supertest = getService('supertest');
const fetchPackageList = async () => {
const response = await supertest
.get('/api/ingest_manager/epm/packages')
.set('kbn-xsrf', 'xxx')
.expect(200);
return response.body;
};
const listResponse = await fetchPackageList();
expect(listResponse.response.length).to.be(3);
expect(listResponse.response[0].name).to.eql('aaa');
expect(listResponse.response[1].name).to.eql('bbb');
expect(listResponse.response[2].name).to.eql('ccc');
});
});
}

View file

@ -1,35 +0,0 @@
/*
* 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.
*/
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const xPackAPITestsConfig = await readConfigFile(require.resolve('../api_integration/config.ts'));
return {
testFiles: [require.resolve('./apis')],
servers: xPackAPITestsConfig.get('servers'),
services: {
supertest: xPackAPITestsConfig.get('services.supertest'),
es: xPackAPITestsConfig.get('services.es'),
},
junit: {
reportName: 'X-Pack EPM API Integration Tests',
},
esTestCluster: {
...xPackAPITestsConfig.get('esTestCluster'),
},
kbnTestServer: {
...xPackAPITestsConfig.get('kbnTestServer'),
serverArgs: [
...xPackAPITestsConfig.get('kbnTestServer.serverArgs'),
'--xpack.ingestManager.epm.registryUrl=http://localhost:6666',
],
},
};
}

View file

@ -0,0 +1,96 @@
/*
* 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.
*/
import { FtrProviderContext } from '../../api_integration/ftr_provider_context';
import { warnAndSkipTest } from '../helpers';
export default function ({ getService }: FtrProviderContext) {
const log = getService('log');
const supertest = getService('supertest');
const dockerServers = getService('dockerServers');
const server = dockerServers.get('registry');
describe('package file', () => {
it('fetches a .png screenshot image', async function () {
if (server.enabled) {
await supertest
.get(
'/api/ingest_manager/epm/packages/filetest/0.1.0/img/screenshots/metricbeat_dashboard.png'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'image/png')
.expect(200);
} else {
warnAndSkipTest(this, log);
}
});
it('fetches an .svg icon image', async function () {
if (server.enabled) {
await supertest
.get('/api/ingest_manager/epm/packages/filetest/0.1.0/img/logo.svg')
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'image/svg+xml')
.expect(200);
} else {
warnAndSkipTest(this, log);
}
});
it('fetches a .json kibana visualization file', async function () {
if (server.enabled) {
await supertest
.get(
'/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/visualization/sample_visualization.json'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
} else {
warnAndSkipTest(this, log);
}
});
it('fetches a .json kibana dashboard file', async function () {
if (server.enabled) {
await supertest
.get(
'/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/dashboard/sample_dashboard.json'
)
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
} else {
warnAndSkipTest(this, log);
}
});
it('fetches a .json search file', async function () {
if (server.enabled) {
await supertest
.get('/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/search/sample_search.json')
.set('kbn-xsrf', 'xxx')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(200);
} else {
warnAndSkipTest(this, log);
}
});
});
// Disabled for now as we don't serve prebuilt index patterns in current packages.
// it('fetches an .json index pattern file', async function () {
// if (server.enabled) {
// await supertest
// .get('/api/ingest_manager/epm/packages/filetest/0.1.0/kibana/index-pattern/sample-*.json')
// .set('kbn-xsrf', 'xxx')
// .expect('Content-Type', 'application/json; charset=utf-8')
// .expect(200);
// } else {
// warnAndSkipTest(this, log);
// }
// });
}

View file

@ -0,0 +1,3 @@
package_paths:
- /registry/packages/package-storage
- /registry/packages/test-packages

View file

@ -0,0 +1,5 @@
# filetest
This package contains randomly collected files from other packages to be used in API integration tests.
It also serves as an example how to serve a package from the fixtures directory with the package registry docker container. For this, also see the `x-pack/test/ingest_manager_api_integration/config.ts` how the `test_packages` directory is mounted into the docker container, and `x-pack/test/ingest_manager_api_integration/apis/fixtures/package_registry_config.yml` how to pass the directory to the registry.

View file

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
<g fill="none" fill-rule="evenodd">
<path fill="#F04E98" d="M29,32.0001 L15.935,9.4321 C13.48,5.1941 7,6.9351 7,11.8321 L7,52.1681 C7,57.0651 13.48,58.8061 15.935,54.5671 L29,32.0001 Z"/>
<path fill="#FA744E" d="M34.7773,32.0001 L33.3273,34.5051 L20.2613,57.0731 C19.8473,57.7871 19.3533,58.4271 18.8023,59.0001 L34.9273,59.0001 C38.7073,59.0001 42.2213,57.0601 44.2363,53.8611 L58.0003,32.0001 L34.7773,32.0001 Z"/>
<path fill="#343741" d="M44.2363,10.1392 C42.2213,6.9402 38.7073,5.0002 34.9273,5.0002 L18.8023,5.0002 C19.3533,5.5732 19.8473,6.2122 20.2613,6.9272 L33.3273,29.4942 L34.7773,32.0002 L58.0003,32.0002 L44.2363,10.1392 Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 750 B

View file

@ -0,0 +1,38 @@
{
"attributes": {
"description": "Logs Kafka integration dashboard",
"hits": 0,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[],\"highlightAll\":true,\"query\":{\"language\":\"kuery\",\"query\":\"\"},\"version\":true}"
},
"optionsJSON": "{\"darkTheme\":false}",
"panelsJSON": "[{\"embeddableConfig\":{},\"gridData\":{\"h\":12,\"i\":\"1\",\"w\":24,\"x\":0,\"y\":0},\"panelIndex\":\"1\",\"panelRefName\":\"panel_0\",\"version\":\"7.3.0\"},{\"embeddableConfig\":{\"columns\":[\"kafka.log.class\",\"kafka.log.trace.class\",\"kafka.log.trace.full\"],\"sort\":[\"@timestamp\",\"desc\"]},\"gridData\":{\"h\":12,\"i\":\"2\",\"w\":24,\"x\":24,\"y\":0},\"panelIndex\":\"2\",\"panelRefName\":\"panel_1\",\"version\":\"7.3.0\"},{\"embeddableConfig\":{\"columns\":[\"log.level\",\"kafka.log.component\",\"message\"],\"sort\":[\"@timestamp\",\"desc\"]},\"gridData\":{\"h\":20,\"i\":\"3\",\"w\":48,\"x\":0,\"y\":20},\"panelIndex\":\"3\",\"panelRefName\":\"panel_2\",\"version\":\"7.3.0\"},{\"embeddableConfig\":{},\"gridData\":{\"h\":8,\"i\":\"4\",\"w\":48,\"x\":0,\"y\":12},\"panelIndex\":\"4\",\"panelRefName\":\"panel_3\",\"version\":\"7.3.0\"}]",
"timeRestore": false,
"title": "[Logs Kafka] Overview ECS",
"version": 1
},
"id": "sample_dashboard",
"references": [
{
"id": "number-of-kafka-stracktraces-by-class-ecs",
"name": "panel_0",
"type": "visualization"
},
{
"id": "Kafka stacktraces-ecs",
"name": "panel_1",
"type": "search"
},
{
"id": "sample_search",
"name": "panel_2",
"type": "search"
},
{
"id": "sample_visualization",
"name": "panel_3",
"type": "visualization"
}
],
"type": "dashboard"
}

View file

@ -0,0 +1,36 @@
{
"attributes": {
"columns": [
"log.level",
"kafka.log.component",
"message"
],
"description": "",
"hits": 0,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[{\"$state\":{\"store\":\"appState\"},\"meta\":{\"alias\":null,\"disabled\":false,\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\",\"key\":\"dataset.name\",\"negate\":false,\"params\":{\"query\":\"kafka.log\",\"type\":\"phrase\"},\"type\":\"phrase\",\"value\":\"log\"},\"query\":{\"match\":{\"dataset.name\":{\"query\":\"kafka.log\",\"type\":\"phrase\"}}}}],\"highlightAll\":true,\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\",\"query\":{\"language\":\"kuery\",\"query\":\"\"},\"version\":true}"
},
"sort": [
[
"@timestamp",
"desc"
]
],
"title": "All logs [Logs Kafka] ECS",
"version": 1
},
"id": "All Kafka logs-ecs",
"references": [
{
"id": "logs-*",
"name": "kibanaSavedObjectMeta.searchSourceJSON.index",
"type": "index-pattern"
},
{
"id": "logs-*",
"name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index",
"type": "index-pattern"
}
],
"type": "search"
}

View file

@ -0,0 +1,22 @@
{
"attributes": {
"description": "",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[]}"
},
"savedSearchRefName": "search_0",
"title": "Log levels over time [Logs Kafka] ECS",
"uiStateJSON": "{}",
"version": 1,
"visState": "{\"aggs\":[{\"enabled\":true,\"id\":\"1\",\"params\":{},\"schema\":\"metric\",\"type\":\"count\"},{\"enabled\":true,\"id\":\"2\",\"params\":{\"extended_bounds\":{},\"field\":\"@timestamp\",\"interval\":\"auto\",\"min_doc_count\":1},\"schema\":\"segment\",\"type\":\"date_histogram\"},{\"enabled\":true,\"id\":\"3\",\"params\":{\"customLabel\":\"Log Level\",\"field\":\"log.level\",\"order\":\"desc\",\"orderBy\":\"1\",\"size\":5},\"schema\":\"group\",\"type\":\"terms\"}],\"params\":{\"addLegend\":true,\"addTimeMarker\":false,\"addTooltip\":true,\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"labels\":{\"show\":true,\"truncate\":100},\"position\":\"bottom\",\"scale\":{\"type\":\"linear\"},\"show\":true,\"style\":{},\"title\":{\"text\":\"@timestamp per day\"},\"type\":\"category\"}],\"grid\":{\"categoryLines\":false,\"style\":{\"color\":\"#eee\"}},\"legendPosition\":\"right\",\"seriesParams\":[{\"data\":{\"id\":\"1\",\"label\":\"Count\"},\"drawLinesBetweenPoints\":true,\"mode\":\"stacked\",\"show\":\"true\",\"showCircles\":true,\"type\":\"histogram\",\"valueAxis\":\"ValueAxis-1\"}],\"times\":[],\"type\":\"histogram\",\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"labels\":{\"filter\":false,\"rotate\":0,\"show\":true,\"truncate\":100},\"name\":\"LeftAxis-1\",\"position\":\"left\",\"scale\":{\"mode\":\"normal\",\"type\":\"linear\"},\"show\":true,\"style\":{},\"title\":{\"text\":\"Count\"},\"type\":\"value\"}]},\"title\":\"Log levels over time [Logs Kafka] ECS\",\"type\":\"histogram\"}"
},
"id": "sample_visualization",
"references": [
{
"id": "All Kafka logs-ecs",
"name": "search_0",
"type": "search"
}
],
"type": "visualization"
}

View file

@ -0,0 +1,30 @@
format_version: 1.0.0
name: filetest
title: For File Tests
description: This is a package.
version: 0.1.0
categories: []
# Options are experimental, beta, ga
release: beta
# The package type. The options for now are [integration, solution], more type might be added in the future.
# The default type is integration and will be set if empty.
type: integration
license: basic
# This package can be removed
removable: true
requirement:
elasticsearch:
versions: ">7.7.0"
kibana:
versions: ">7.7.0"
screenshots:
- src: "/img/screenshots/metricbeat_dashboard.png"
title: "metricbeat dashboard"
size: "1855x949"
type: "image/png"
icons:
- src: "/img/logo.svg"
size: "16x16"
type: "image/svg+xml"

View file

@ -9,7 +9,7 @@ export default function ({ loadTestFile }) {
this.tags('ciGroup7');
loadTestFile(require.resolve('./list'));
loadTestFile(require.resolve('./file'));
loadTestFile(require.resolve('./template'));
//loadTestFile(require.resolve('./template'));
loadTestFile(require.resolve('./ilm'));
});
}

View file

@ -0,0 +1,38 @@
/*
* 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.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../api_integration/ftr_provider_context';
import { warnAndSkipTest } from '../helpers';
export default function ({ getService }: FtrProviderContext) {
const log = getService('log');
const supertest = getService('supertest');
const dockerServers = getService('dockerServers');
const server = dockerServers.get('registry');
// use function () {} and not () => {} here
// because `this` has to point to the Mocha context
// see https://mochajs.org/#arrow-functions
describe('list', async function () {
it('lists all packages from the registry', async function () {
if (server.enabled) {
const fetchPackageList = async () => {
const response = await supertest
.get('/api/ingest_manager/epm/packages')
.set('kbn-xsrf', 'xxx')
.expect(200);
return response.body;
};
const listResponse = await fetchPackageList();
expect(listResponse.response.length).to.be(11);
} else {
warnAndSkipTest(this, log);
}
});
});
}

View file

@ -0,0 +1,67 @@
/*
* 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.
*/
import path from 'path';
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
import { defineDockerServersConfig } from '@kbn/test';
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const xPackAPITestsConfig = await readConfigFile(require.resolve('../api_integration/config.ts'));
const registryPort: string | undefined = process.env.INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT;
// mount the config file for the package registry as well as
// the directory containing additional packages into the container
const dockerArgs: string[] = [
'-v',
`${path.join(
path.dirname(__filename),
'./apis/fixtures/package_registry_config.yml'
)}:/registry/config.yml`,
'-v',
`${path.join(
path.dirname(__filename),
'./apis/fixtures/test_packages'
)}:/registry/packages/test-packages`,
];
return {
testFiles: [require.resolve('./apis')],
servers: xPackAPITestsConfig.get('servers'),
dockerServers: defineDockerServersConfig({
registry: {
enabled: !!registryPort,
image: 'docker.elastic.co/package-registry/package-registry:kibana-testing-1',
portInContainer: 8080,
port: registryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
},
}),
services: {
supertest: xPackAPITestsConfig.get('services.supertest'),
es: xPackAPITestsConfig.get('services.es'),
},
junit: {
reportName: 'X-Pack EPM API Integration Tests',
},
esTestCluster: {
...xPackAPITestsConfig.get('esTestCluster'),
},
kbnTestServer: {
...xPackAPITestsConfig.get('kbnTestServer'),
serverArgs: [
...xPackAPITestsConfig.get('kbnTestServer.serverArgs'),
...(registryPort
? [`--xpack.ingestManager.epm.registryUrl=http://localhost:${registryPort}`]
: []),
],
},
};
}

View file

@ -0,0 +1,15 @@
/*
* 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.
*/
import { Context } from 'mocha';
import { ToolingLog } from '@kbn/dev-utils';
export function warnAndSkipTest(mochaContext: Context, log: ToolingLog) {
log.warning(
'disabling tests because DockerServers service is not enabled, set INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT to run them'
);
mochaContext.skip();
}