-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Dataset quality] Integrations agnostic-deployment api tests (#…
…193144) (#193939) # Backport This will backport the following commits from `main` to `8.x`: - [[Dataset quality] Integrations agnostic-deployment api tests (#193144)](#193144) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Yngrid Coello","email":"yngrid.coello@elastic.co"},"sourceCommit":{"committedDate":"2024-09-17T17:52:17Z","message":"[Dataset quality] Integrations agnostic-deployment api tests (#193144)\n\nRelates to #191980 PR aims to introduce deployment-agnostic configuration for dataset\r\nquality tests, specifically targeting `GET\r\n/internal/dataset_quality/integrations`.","sha":"45c71c5a6b8f53eeb2c82c4319dfac0205668a8c","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","v8.16.0"],"number":193144,"url":"#193144 quality] Integrations agnostic-deployment api tests (#193144)\n\nRelates to #191980 PR aims to introduce deployment-agnostic configuration for dataset\r\nquality tests, specifically targeting `GET\r\n/internal/dataset_quality/integrations`.","sha":"45c71c5a6b8f53eeb2c82c4319dfac0205668a8c"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"#193144 quality] Integrations agnostic-deployment api tests (#193144)\n\nRelates to #191980 PR aims to introduce deployment-agnostic configuration for dataset\r\nquality tests, specifically targeting `GET\r\n/internal/dataset_quality/integrations`.","sha":"45c71c5a6b8f53eeb2c82c4319dfac0205668a8c"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
- Loading branch information
Showing
13 changed files
with
325 additions
and
137 deletions.
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
14 changes: 14 additions & 0 deletions
14
x-pack/test/api_integration/deployment_agnostic/apis/observability/dataset_quality/index.ts
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,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { DeploymentAgnosticFtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
export default function ({ loadTestFile }: DeploymentAgnosticFtrProviderContext) { | ||
describe('Dataset quality', () => { | ||
loadTestFile(require.resolve('./integrations/integrations')); | ||
}); | ||
} |
137 changes: 137 additions & 0 deletions
137
...ation/deployment_agnostic/apis/observability/dataset_quality/integrations/integrations.ts
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,137 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { RoleCredentials, InternalRequestHeader } from '@kbn/ftr-common-functional-services'; | ||
import expect from '@kbn/expect'; | ||
import { APIReturnType } from '@kbn/dataset-quality-plugin/common/rest'; | ||
import { CustomIntegration } from '../../../../services/package_api'; | ||
import { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context'; | ||
|
||
export default function ({ getService }: DeploymentAgnosticFtrProviderContext) { | ||
const samlAuth = getService('samlAuth'); | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
const packageApi = getService('packageApi'); | ||
|
||
const endpoint = 'GET /internal/dataset_quality/integrations'; | ||
type Integration = APIReturnType<typeof endpoint>['integrations'][0]; | ||
|
||
const integrationPackages = ['system', 'synthetics']; | ||
const customIntegrations: CustomIntegration[] = [ | ||
{ | ||
integrationName: 'my.custom.integration', | ||
datasets: [ | ||
{ | ||
name: 'my.custom.integration', | ||
type: 'logs', | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
async function callApiAs({ | ||
roleAuthc, | ||
headers, | ||
}: { | ||
roleAuthc: RoleCredentials; | ||
headers: InternalRequestHeader; | ||
}): Promise<any> { | ||
const { body } = await supertestWithoutAuth | ||
.get('/internal/dataset_quality/integrations') | ||
.set(roleAuthc.apiKeyHeader) | ||
.set(headers); | ||
|
||
return body; | ||
} | ||
|
||
describe('Integrations', () => { | ||
let adminRoleAuthc: RoleCredentials; | ||
let internalHeaders: InternalRequestHeader; | ||
|
||
before(async () => { | ||
adminRoleAuthc = await samlAuth.createM2mApiKeyWithRoleScope('admin'); | ||
internalHeaders = samlAuth.getInternalRequestHeader(); | ||
}); | ||
|
||
after(async () => { | ||
await samlAuth.invalidateM2mApiKeyWithRoleScope(adminRoleAuthc); | ||
}); | ||
|
||
describe('gets the installed integrations', () => { | ||
before(async () => { | ||
await Promise.all( | ||
integrationPackages.map((pkg) => | ||
packageApi.installPackage({ | ||
roleAuthc: adminRoleAuthc, | ||
pkg, | ||
}) | ||
) | ||
); | ||
}); | ||
|
||
it('returns all installed integrations and its datasets map', async () => { | ||
const body = await callApiAs({ | ||
roleAuthc: adminRoleAuthc, | ||
headers: internalHeaders, | ||
}); | ||
|
||
expect(body.integrations.map((integration: Integration) => integration.name)).to.eql([ | ||
'synthetics', | ||
'system', | ||
]); | ||
|
||
expect(body.integrations[0].datasets).not.empty(); | ||
expect(body.integrations[1].datasets).not.empty(); | ||
}); | ||
|
||
after( | ||
async () => | ||
await Promise.all( | ||
integrationPackages.map((pkg) => | ||
packageApi.uninstallPackage({ roleAuthc: adminRoleAuthc, pkg }) | ||
) | ||
) | ||
); | ||
}); | ||
|
||
describe('gets the custom installed integrations', () => { | ||
before(async () => { | ||
await Promise.all( | ||
customIntegrations.map((customIntegration: CustomIntegration) => | ||
packageApi.installCustomIntegration({ roleAuthc: adminRoleAuthc, customIntegration }) | ||
) | ||
); | ||
}); | ||
|
||
it('returns custom integrations and its datasets map', async () => { | ||
const body = await callApiAs({ | ||
roleAuthc: adminRoleAuthc, | ||
headers: internalHeaders, | ||
}); | ||
|
||
expect(body.integrations.map((integration: Integration) => integration.name)).to.eql([ | ||
'my.custom.integration', | ||
]); | ||
|
||
expect(body.integrations[0].datasets).to.eql({ | ||
'my.custom.integration': 'My.custom.integration', | ||
}); | ||
}); | ||
|
||
after( | ||
async () => | ||
await Promise.all( | ||
customIntegrations.map((customIntegration: CustomIntegration) => | ||
packageApi.uninstallPackage({ | ||
roleAuthc: adminRoleAuthc, | ||
pkg: customIntegration.integrationName, | ||
}) | ||
) | ||
) | ||
); | ||
}); | ||
}); | ||
} |
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
2 changes: 2 additions & 0 deletions
2
.../api_integration/deployment_agnostic/default_configs/fixtures/package_registry_config.yml
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,2 @@ | ||
package_paths: | ||
- /packages/package-storage |
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
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
Oops, something went wrong.