Closed
Description
openedon May 14, 2024
Part of #183263
🍒 Summary
As part of this PR we introduced a way to write deployment agnostic tests using the deployment agnostic framework from Appex QA team. We want to migrate the existing metric threshold rule tests to the new agnostic framework.
Existing tests
Test | Type | ESS | Serverless | Notes |
---|---|---|---|---|
Metric threshold rule type | Alerting | ✅ | ❌ | ESS: x-pack/test/alerting_api_integration/observability/metric_threshold_rule.ts |
File structure
How to migrate
In this PR oblt.stateful.config.ts
and oblt.serverless.config.ts
were added, so no need to create any config file.
Existing metric threshold rule tests use a few alerting helpers. In the SLO burn rate rule PR the alerting API was migrated to the deployment agnostic folder. As part of the migration we should use the migrating alerting api.
Here's what you have to do:
- Move metric threshold rule tests from
x-pack/test/alerting_api_integration/observability/metric_threshold_rule.ts
withinx-pack/test/api_integration/deployment_agnostic/apis/observability/alerting
folder - Add the metric threshold rule test in this file
loadTestFile(require.resolve('./metric_threshold_rule'));
- Delete the metric threshold rule test from the old alerting_api_integration location
- Use the
DeploymentAgnosticFtrProviderContext
- use a combination of
supertestWithoutAuth
andsamlAuth
to generate an API key for user roles and make API calls
const samlAuth = getService('samlAuth');
const supertestWithoutAuth = getService('supertestWithoutAuth');
- Use the config service to decide on the
expected consumer
const config = getService('config');
const isServerless = config.get('serverless');
const expectedConsumer = isServerless ? 'observability' : 'infrastructure';
- Update the metric threshold rule tests to use the deployment agnostic alerting api
How to run
To run 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="Metric threshold rule"
To run 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="Metric threshold rule"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment