-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Migrate inspect API tests to be deployment-agnostic (#199963)
### How to test Closes #198977 Part of #193245 This PR contains the changes to migrate `inspect` test folder to deployment-agnostic testing strategy. ### How to test - Serverless ``` node scripts/functional_tests_server --config x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts node scripts/functional_test_runner --config x-pack/test/api_integration/deployment_agnostic/configs/serverless/oblt.serverless.config.ts --grep="APM" ``` It's recommended to be run against [MKI](https://github.com/crespocarlos/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki) - Stateful ``` node scripts/functional_tests_server --config x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts node scripts/functional_test_runner --config x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.stateful.config.ts --grep="APM" ``` ## Checks - [ ] (OPTIONAL, only if a test has been unskipped) Run flaky test suite - [x] local run for serverless - [x] local run for stateful - [x] MKI run for serverless (cherry picked from commit bb68f92)
- Loading branch information
Showing
5 changed files
with
119 additions
and
64 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...api_integration/deployment_agnostic/apis/observability/apm/constants/archives_metadata.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,10 @@ | ||
/* | ||
* 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 archivesMetadata from '../../../../../../apm_api_integration/common/fixtures/es_archiver/archives_metadata'; | ||
|
||
export default archivesMetadata; |
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/apm/inspect/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('inspect', () => { | ||
loadTestFile(require.resolve('./inspect.spec.ts')); | ||
}); | ||
} |
94 changes: 94 additions & 0 deletions
94
...k/test/api_integration/deployment_agnostic/apis/observability/apm/inspect/inspect.spec.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,94 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
|
||
import { DeploymentAgnosticFtrProviderContext } from '../../../../ftr_provider_context'; | ||
import { ARCHIVER_ROUTES } from '../constants/archiver'; | ||
import archives_metadata from '../constants/archives_metadata'; | ||
|
||
export default function inspectFlagTests({ getService }: DeploymentAgnosticFtrProviderContext) { | ||
const apmApiClient = getService('apmApi'); | ||
const esArchiver = getService('esArchiver'); | ||
|
||
const archiveName = '8.0.0'; | ||
const metadata = archives_metadata['apm_8.0.0']; | ||
|
||
describe('Inspect feature', () => { | ||
before(async () => { | ||
await esArchiver.load(ARCHIVER_ROUTES[archiveName]); | ||
}); | ||
after(async () => { | ||
await esArchiver.unload(ARCHIVER_ROUTES[archiveName]); | ||
}); | ||
|
||
describe('when omitting `_inspect` query param', () => { | ||
it('returns response without `_inspect`', async () => { | ||
const { status, body } = await apmApiClient.readUser({ | ||
endpoint: 'GET /internal/apm/environments', | ||
params: { | ||
query: { | ||
start: metadata.start, | ||
end: metadata.end, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(status).to.be(200); | ||
expect(body._inspect).to.be(undefined); | ||
}); | ||
}); | ||
|
||
describe('when passing `_inspect` as query param', () => { | ||
describe('elasticsearch calls made with end-user auth are returned', () => { | ||
it('for environments', async () => { | ||
const { status, body } = await apmApiClient.readUser({ | ||
endpoint: 'GET /internal/apm/environments', | ||
params: { | ||
query: { | ||
start: metadata.start, | ||
end: metadata.end, | ||
_inspect: true, | ||
}, | ||
}, | ||
}); | ||
expect(status).to.be(200); | ||
expect(body._inspect).not.to.be.empty(); | ||
|
||
// @ts-expect-error | ||
expect(Object.keys(body._inspect[0])).to.eql([ | ||
'id', | ||
'json', | ||
'name', | ||
'response', | ||
'startTime', | ||
'stats', | ||
'status', | ||
]); | ||
}); | ||
}); | ||
|
||
describe('elasticsearch calls made with internal user should not leak internal queries', () => { | ||
it('for custom links', async () => { | ||
const { status, body } = await apmApiClient.readUser({ | ||
endpoint: 'GET /internal/apm/settings/custom_links', | ||
params: { | ||
query: { | ||
'service.name': 'opbeans-node', | ||
'transaction.type': 'request', | ||
_inspect: true, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(status).to.be(200); | ||
expect(body._inspect).to.eql([]); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
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