Skip to content

Commit

Permalink
[8.16] [Ingest Pipelines] Improve api integration tests (#196718) (#1…
Browse files Browse the repository at this point in the history
…96749)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Ingest Pipelines] Improve api integration tests
(#196718)](#196718)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-17T17:40:21Z","message":"[Ingest
Pipelines] Improve api integration tests (#196718)\n\nFollow-up to
https://github.com/elastic/kibana/pull/190830\r\n\r\n## Summary\r\n\r\nI
noticed that the api integration tests that have been added
with\r\nhttps://github.com//pull/190830 were not actually
included\r\nto run as part of the Management test suite. This PR adds
them and it\r\nalso adds some test cases for the `ipinfo` database
type.","sha":"727c19a78bf7831da150e84ffb06abf6db6878bc","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Kibana
Management","release_note:skip","test-api-integration","v9.0.0","Feature:Ingest
Node
Pipelines","backport:prev-minor","v8.16.0","v8.17.0"],"title":"[Ingest
Pipelines] Improve api integration
tests","number":196718,"url":"https://github.com/elastic/kibana/pull/196718","mergeCommit":{"message":"[Ingest
Pipelines] Improve api integration tests (#196718)\n\nFollow-up to
https://github.com/elastic/kibana/pull/190830\r\n\r\n## Summary\r\n\r\nI
noticed that the api integration tests that have been added
with\r\nhttps://github.com//pull/190830 were not actually
included\r\nto run as part of the Management test suite. This PR adds
them and it\r\nalso adds some test cases for the `ipinfo` database
type.","sha":"727c19a78bf7831da150e84ffb06abf6db6878bc"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196718","number":196718,"mergeCommit":{"message":"[Ingest
Pipelines] Improve api integration tests (#196718)\n\nFollow-up to
https://github.com/elastic/kibana/pull/190830\r\n\r\n## Summary\r\n\r\nI
noticed that the api integration tests that have been added
with\r\nhttps://github.com//pull/190830 were not actually
included\r\nto run as part of the Management test suite. This PR adds
them and it\r\nalso adds some test cases for the `ipinfo` database
type.","sha":"727c19a78bf7831da150e84ffb06abf6db6878bc"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[email protected]>
  • Loading branch information
kibanamachine and ElenaStoeva authored Oct 17, 2024
1 parent 95ae64b commit 5e1e8b0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions x-pack/test/api_integration/apis/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default function ({ loadTestFile }) {
loadTestFile(require.resolve('./index_management'));
loadTestFile(require.resolve('./index_lifecycle_management'));
loadTestFile(require.resolve('./snapshot_restore'));
loadTestFile(require.resolve('./ingest_pipelines'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,51 @@ export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const ingestPipelines = getService('ingestPipelines');
const url = `/api/ingest_pipelines/databases`;
const databaseName = 'GeoIP2-Anonymous-IP';
const normalizedDatabaseName = 'geoip2-anonymous-ip';
const maxmindDatabaseName = 'GeoIP2-Anonymous-IP';
const normalizedMaxmindDatabaseName = 'geoip2-anonymous-ip';
const ipinfoDatabaseName = 'asn';
const normalizedIpinfoDatabaseName = 'asn';

describe('Manage databases', function () {
after(async () => {
await ingestPipelines.api.deleteGeoipDatabases();
});

describe('Create', () => {
it('creates a geoip database when using a correct database name', async () => {
const database = { maxmind: '123456', databaseName };
it('creates a maxmind geoip database when using a correct database name', async () => {
const database = {
databaseType: 'maxmind',
databaseName: maxmindDatabaseName,
maxmind: '123456',
};
const { body } = await supertest
.post(url)
.set('kbn-xsrf', 'xxx')
.send(database)
.expect(200);

expect(body).to.eql({
name: databaseName,
id: normalizedDatabaseName,
name: maxmindDatabaseName,
id: normalizedMaxmindDatabaseName,
});
});

it('creates a geoip database when using an incorrect database name', async () => {
const database = { maxmind: '123456', databaseName: 'Test' };
it('creates an ipinfo geoip database when using a correct database name', async () => {
const database = { databaseType: 'ipinfo', databaseName: ipinfoDatabaseName };
const { body } = await supertest
.post(url)
.set('kbn-xsrf', 'xxx')
.send(database)
.expect(200);

expect(body).to.eql({
name: ipinfoDatabaseName,
id: normalizedIpinfoDatabaseName,
});
});

it('returns error when creating a geoip database with an incorrect database name', async () => {
const database = { databaseType: 'maxmind', databaseName: 'Test', maxmind: '123456' };
await supertest.post(url).set('kbn-xsrf', 'xxx').send(database).expect(400);
});
});
Expand All @@ -47,8 +67,13 @@ export default function ({ getService }: FtrProviderContext) {
const { body } = await supertest.get(url).set('kbn-xsrf', 'xxx').expect(200);
expect(body).to.eql([
{
id: normalizedDatabaseName,
name: databaseName,
id: normalizedIpinfoDatabaseName,
name: ipinfoDatabaseName,
type: 'ipinfo',
},
{
id: normalizedMaxmindDatabaseName,
name: maxmindDatabaseName,
type: 'maxmind',
},
]);
Expand All @@ -58,7 +83,12 @@ export default function ({ getService }: FtrProviderContext) {
describe('Delete', () => {
it('deletes a geoip database', async () => {
await supertest
.delete(`${url}/${normalizedDatabaseName}`)
.delete(`${url}/${normalizedMaxmindDatabaseName}`)
.set('kbn-xsrf', 'xxx')
.expect(200);

await supertest
.delete(`${url}/${normalizedIpinfoDatabaseName}`)
.set('kbn-xsrf', 'xxx')
.expect(200);
});
Expand Down

0 comments on commit 5e1e8b0

Please sign in to comment.