Skip to content

Commit

Permalink
[Ingest Manager] Use dockerized package registry in api integration t…
Browse files Browse the repository at this point in the history
…ests (#34)
  • Loading branch information
skh authored Jun 3, 2020
1 parent e59d7e8 commit b9074b0
Show file tree
Hide file tree
Showing 430 changed files with 14,906 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target
/x-pack/legacy/plugins/infra/public/graphql/types.ts
/x-pack/legacy/plugins/infra/server/graphql/types.ts
/x-pack/legacy/plugins/maps/public/vendor/**

/x-pack/test/epm_api_integration/apis/fixtures/**
# package overrides
/packages/eslint-config-kibana
/packages/kbn-interpreter/src/common/lib/grammar.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const dockerServerSchema = () =>
portInContainer: Joi.number().required(),
waitForLogLine: Joi.alternatives(Joi.object().type(RegExp), Joi.string()).optional(),
waitFor: Joi.func().optional(),
args: Joi.array()
.items(Joi.string())
.optional(),
})
.default();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export interface DockerServerSpec {
port: number;
image: string;
waitForLogLine?: RegExp | string;
/** a function that should return an obeservable that will allow the tests to execute as soon as it emits anything */
/** a function that should return an observable that will allow the tests to execute as soon as it emits anything */
waitFor?: (server: DockerServer, logLine$: Rx.Observable<string>) => Rx.Observable<unknown>;
/* additional command line arguments passed to docker run */
args?: string[];
}

export interface DockerServer extends DockerServerSpec {
Expand All @@ -37,6 +39,6 @@ export interface DockerServer extends DockerServerSpec {
* Helper that helps authors use the type definitions for the section of the FTR config
* under the `dockerServers` key.
*/
export function defineDockerServersConfig(config: { [name: string]: DockerServerSpec }) {
export function defineDockerServersConfig(config: { [name: string]: DockerServerSpec } | {}) {
return config;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ export class DockerServersService {
}

private async dockerRun(server: DockerServer) {
const { args } = server;
try {
this.log.info(`[docker:${server.name}] running image "${server.image}"`);

const res = await execa('docker', [
const dockerArgs = [
'run',
'-dit',
args || [],
'-p',
`${server.port}:${server.portInContainer}`,
server.image,
]);
].flat();
const res = await execa('docker', dockerArgs);

return res.stdout.trim();
} catch (error) {
Expand Down Expand Up @@ -117,8 +120,12 @@ export class DockerServersService {
lifecycle.cleanup.add(() => {
try {
execa.sync('docker', ['kill', containerId]);
execa.sync('docker', ['rm', containerId]);
} catch (error) {
if (error.message.includes(`Container ${containerId} is not running`)) {
if (
error.message.includes(`Container ${containerId} is not running`) ||
error.message.includes(`No such container: ${containerId}`)
) {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/dev/precommit_hook/casing_check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export const IGNORE_FILE_GLOBS = [
// filename required by api-extractor
'api-documenter.json',

// test cases come from elastic/package-storage repo, which uses
// nameing conventions from elastic/beats modules
'x-pack/test/epm_api_integration/apis/fixtures/**',

// TODO fix file names in APM to remove these
'x-pack/plugins/apm/public/**/*',
'x-pack/plugins/apm/scripts/**/*',
Expand Down
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Base package

This is installed in the background by EPM to setup the Elastic Stack.
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"template": {
"mappings": {
"_meta": {
},
"dynamic_templates": [
{
"strings_as_keyword": {
"mapping": {
"ignore_above": 1024,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"date_detection": false,
"properties": {
"@timestamp": {
"type": "date"
},
"stream": {
"properties": {
"type": {
"type": "constant_keyword"
},
"dataset": {
"type": "constant_keyword"
},
"namespace": {
"type": "constant_keyword"
}
}
},
"agent": {
"properties": {
"hostname": {
"ignore_above": 1024,
"type": "keyword"
},
"name": {
"ignore_above": 1024,
"type": "keyword"
},
"id": {
"ignore_above": 1024,
"type": "keyword"
},
"ephemeral_id": {
"ignore_above": 1024,
"type": "keyword"
},
"type": {
"ignore_above": 1024,
"type": "keyword"
},
"version": {
"ignore_above": 1024,
"type": "keyword"
}
}
},
"ecs": {
"properties": {
"version": {
"ignore_above": 1024,
"type": "keyword"
}
}
},
"host": {
"properties": {
"hostname": {
"ignore_above": 1024,
"type": "keyword"
},
"os": {
"properties": {
"build": {
"ignore_above": 1024,
"type": "keyword"
},
"kernel": {
"ignore_above": 1024,
"type": "keyword"
},
"codename": {
"ignore_above": 1024,
"type": "keyword"
},
"name": {
"ignore_above": 1024,
"type": "keyword"
},
"family": {
"ignore_above": 1024,
"type": "keyword"
},
"version": {
"ignore_above": 1024,
"type": "keyword"
},
"platform": {
"ignore_above": 1024,
"type": "keyword"
},
"full": {
"ignore_above": 1024,
"type": "keyword"
}
}
},
"ip": {
"type": "ip"
},
"containerized": {
"type": "boolean"
},
"name": {
"ignore_above": 1024,
"type": "keyword"
},
"id": {
"ignore_above": 1024,
"type": "keyword"
},
"type": {
"ignore_above": 1024,
"type": "keyword"
},
"mac": {
"ignore_above": 1024,
"type": "keyword"
},
"architecture": {
"ignore_above": 1024,
"type": "keyword"
}
}
},
"message": {
"type": "text"
}
}
},
"aliases": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"template": {
"settings": {
"index": {
"lifecycle": {
"name": "events-default"
},
"codec": "best_compression",
"refresh_interval": "5s",
"number_of_shards": "1",
"query": {
"default_field": [
"message"
]
},
"number_of_routing_shards": "30"
}
},
"aliases": {}
}
}
Loading

0 comments on commit b9074b0

Please sign in to comment.