-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Observability solution] [SLO] Run burn rate api tests in serverless & ess using mocha tagging #183113
[Observability solution] [SLO] Run burn rate api tests in serverless & ess using mocha tagging #183113
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
…n_api_integration folder
265b687
to
0c04a91
Compare
…olution_api_integration
8028171
to
8c0c86e
Compare
a0040d7
to
5f4ec82
Compare
5f4ec82
to
b8237fc
Compare
); | ||
|
||
const svlSharedConfig = await readConfigFile( | ||
require.resolve('../../../../test_serverless/shared/config.base.ts') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I import shared services from test_serverless, since I want to reuse the sloApi
and alertingApi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dangerous approach. Services from the test_serverless
area are not guaranteed to work in stateful / ESS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I can understand this. In our case the exact same service works for both ESS and Serveless. What is the recommended approach here? Before doing this, I had the slo_api
and alerting_api
services within the new folder. Each configuration then (ess & serverless) can decide from where to get the service. Would this be a better approach?
I think we need to see which services can be reused in both environments and clean up/restructure them while we start migrating more tests into this kind of deployment agnostic solution. I would like to further discuss this with you. I'll arrange something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pheyos As per our discussion I moved these 2 services under deployment agnostic services in this commit and tests still work fine! Does it look better this way?
...test/observability_solution_api_integration/test_suites/alerting/burn_rate/burn_rate_rule.ts
Show resolved
Hide resolved
x-pack/test_serverless/api_integration/test_suites/observability/index.ts
Show resolved
Hide resolved
This PR makes it possible to write deployment agnostic tests using Mocha tagging. I tested it locally by running the scripts I added to the new package.json. Not sure whose area is this (appex-qa or kibana-operations), but my question here is what else needs to be done to make these tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments in the code.
While this approach can work short-term, there are some things to consider.
@ess
: Runs in an ESS environment (on-prem installation) as part of the CI validation on PRs.
@serverless
: Runs in the first quality gate and in the periodic pipeline.
With this PR you're going your own route when it comes to tagging and configuring serverless tests, which we do not support in the platform tooling. So while your new configs are included in regular local CI runs, you don't get ESS or MKI tests for free. You would have to set up your own pipeline, where you create ESS or MKI projects, point the test runner to it and perform the tests. If you want to run these tests in the Kibana serverless quality gates, you will have to meet some additional criteria for your pipeline before we can include it there.
Another important thing to consider is that teams have to move away from running tests with operator privileges in serverless (details in #183512) in the short term. With this current approach, how would you make sure to do that? As we discussed in zoom, authentication is quite different in stateful and serverless, which is the main reason why separate test directories have been introduced in the first place.
); | ||
|
||
const svlSharedConfig = await readConfigFile( | ||
require.resolve('../../../../test_serverless/shared/config.base.ts') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dangerous approach. Services from the test_serverless
area are not guaranteed to work in stateful / ESS.
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import type { FtrProviderContext } from '../../test_serverless/api_integration/ftr_provider_context'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the serverless ftr_provider_context
here can lead to issues with non-serverless tests (e.g. they might pick the wrong version of an overloaded test service).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at this file, where services are loaded from test_serverless
, but I totally get the point. That was my concern as well and I was expecting a comment from you regarding this. Let's address this topic in our chat next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...test/observability_solution_api_integration/test_suites/alerting/burn_rate/burn_rate_rule.ts
Show resolved
Hide resolved
@elasticmachine merge upstream |
@pheyos Thanks a lot for taking the time to review this PR. You are absolutely right, this PR only runs the tests in a local simulated environment. This PR is only the first step. We are aware that extra things need to be set up, so that tests can run in a real MKI environemnt. We would need guidance on how we can setup our own pipeline. Do you have any documentation? @MadameSheema After merging this initial PR, what were the next steps you did to make your tests run in an MKI environment? Do you have any link to a PR that we could take a look at?
Let's further discuss a few things on a Zoom call next week. |
I'm putting here an EXCELLENT list of PRs @MadameSheema compiled for us! Thanks a tons! Such a great help! This is all the work the Security team has done regarding having tests executed in MKI projects and integrated in buildkite. They have a periodic pipeline that executes all the tests marked as @serverless and they don't have the @skipServerlessInMKI
Here are a few more resources |
@dominiqueclarke Do you have an idea how we can fix this |
449297a
to
4d21820
Compare
💔 Build Failed
Failed CI Steps
Test Failures
Metrics [docs]Canvas Sharable Runtime
History
To update your PR or re-run it, just comment with: cc @mgiota |
Here's an update regarding the deployment agnostic tests and this POC. FTR tests already make use of the That being said I am going to close this PR and open a new one using Adding following in the config files: serverless config
ess config
and then adding for example |
@pheyos Before moving on with the new branch that will contain in its history only the necessary changes (suiteTags and nothing related to mochaOps) I wanted to check what are the conflicts of this branch with main. These conflicts are related to the operator privilege issue. We need to sync up on how to approach this. |
@pheyos Here's what I tried and looks like it works. The idea is that I have only one sloApi service defined within As you can see below in case of ess it creates all the predefined roles and users, where as on serverless it only creates an api key. serverless What do you think? Would this approach work for you? |
I am closing this POC, in favor of #187924, where I use |
Addresses #179549 Relates to #183113 ## Update Since the Appex QA team has taken on deployment agnostic tests, a lot of the original implementation of this PR has changed. Now that the Appex QA team has provided a current directly to write deployment agnostic tests, the burn rate rule tests have been moved here. To finish onboarding the burn rate rule test to this new framework, the following was done. 1. Add an `oblt.stateful.config.ts` file to complement the existing `oblt.serverless.config.ts` file to ensure the tests are run in CI 2. Ensure our test config is added to the buildkite pipepline 3. Add the alerting service to the new `deployment_agnostic/services` directory. 4. Port the tests over to the new `deployment_agnostic` directory 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="Burn rate 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="Burn rate rule" ``` For context, I've kept the history from the original PR description below. ## 🍒 History A new type of config file will be allowed for API integration and functional tests within the `x-pack/test` folder, using a pattern of `*.serverless.config.ts` — these config files will specify configuration needed to run a set of tests in a serverless deployment context. FTR tests already make use of the `it.tags(['my-tag-1', 'my-tag-2'])` pattern, and so we would like to stay with that pattern rather than introducing a new type of mocha tag in the it block's "description" as it was introduced in this [POC](#183113). The difference with the previous PR in terms of tagging is that we use `suiteTags` instead of `mochaOps` Adding following in the config files: **serverless config** ``` suiteTags: { include: ['serverless'], }, ``` **ess config** ``` suiteTags: { include: ['ess'], }, ``` and then adding `this.tags(['serverless', 'ess'])` in the test suite instructs the test runner to run the same test suite in both environments. In order to keep things simple, we stay with the current skip approach, which means that flaky tests will be skipped for all environments by appending .skip() to the suite or to specific test cases. ## Description - This PR uses `suiteTags` for tagging the tests appropriately. We decide through following labels in which environment the tests are going to be executed: - **@ess**: Runs in an ESS environment (on-prem installation) as part of the CI validation on PRs. - **@serverless**: Runs in a serverless environment. - It introduces a new folder `x-pack/test/observability_solution_api_integration` which will serve as a centralized location for all tests by obs-ux-management team that must be run in Serverless and ESS environments. A list of all tests can be found in the R&D [issue](#179549) - Within this folder, there is a "**config**" subdirectory that stores base configurations specific to both the Serverless and ESS environments. These configurations build upon the base configuration provided by test_serverless and api_integration, incorporating additional settings such as environment variables and tagging options. - The file `x-pack/test/observability_solution_api_integration/test_suites/alerting/burn_rate/burn_rate_rule.ts` is functional in both Serverless and ESS - It removes the existing burn rate rule from `x-pack/test_serverless/api_integration/test_suites/observability/alerting/burn_rate/burn_rate_rule.ts` - The `alertingApi` and `sloApi` services are moved to `test/api_integration` servers In the screenshot below you can see the `test_suites` folder structure, after having migrated the current slo burn rate rule. We recommend having an `alerting` and `slo` subfolders. Rest observability apps could be added as another subfolder under test_suites. As part of this PR, the `alerting > burn_rate` subfolders are created. <img width="376" alt="Screenshot 2024-05-13 at 09 21 28" src="https://github.com/elastic/kibana/assets/2852703/3ccaf0a5-1443-4bad-ad06-daa347488bf1"> ## How to run locally You can navigate into the new `observability_solution_api_integration` folder and use following commands to run the tests in serverless and ess environments accordingly. You can find more information in the README file of the observability_solution_api_integration folder. ``` cd x-pack/test/observability_solution_api_integration // SERVERLESS npm run alerting_burn_rate:server:serverless npm run alerting_burn_rate:runner:serverless // ESS npm run alerting_burn_rate:server:ess npm run alerting_burn_rate:runner:ess ``` ## CI - It includes a new entry in the `ftr_configs.yml` to execute the newly added tests in the pipeline. - It involves the addition of `suiteTags` in both serverless/config.base.ts and ess/config.base.ts. In the case of serverless, it includes **@serverless** while excluding **@skipInServerless**. Similarly, for ess, it includes **@ess** and excludes **@skipInEss**. ## Quality Gates and MKI pipeline The Platform team will support config files within `x-pack/test` folder with a pattern of `*.serverless.config.ts`, so these tests will be included in Kibana's Quality gates and will be run against a real MKI environment. --------- Co-authored-by: Dominique Belcher <[email protected]> Co-authored-by: Dominique Clarke <[email protected]> Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Dzmitry Lemechko <[email protected]> Co-authored-by: Robert Oskamp <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Addresses #179549
Relates to #166755
🆕 PR #187924
Summary
This POC is the outcome of this R&D issue for having deployment agnostic tests for SLO and o11y alerting features. We based our work on the
Mocha tagging
approach of the Security Solution and applied it to the slo burn rate rule type. We plan to migrate all our existing API tests listed in the R&D issue in follow up PRs.The idea is that a) we are going to write our api integration tests in a new location
observability_solution_api_integration
shared by b)ess & serverless configurations
. Each configuration will read from a specific location and load the corresponding services. Tests will be written only once and should be tagged with labels depending on which environments they need to be run.Description
x-pack/test/observability_solution_api_integration
which will serve as a centralized location for all tests by obs-ux-management team that must be run in Serverless and ESS environments. A list of all tests can be found in the R&D issuex-pack/test/observability_solution_api_integration/test_suites/alerting/burn_rate/burn_rate_rule.ts
is functional in both Serverless and ESSx-pack/test_serverless/api_integration/test_suites/observability/alerting/burn_rate/burn_rate_rule.ts
alertingApi
andsloApi
services are imported fromtest_serverless
In the screenshot below you can see the
test_suites
folder structure, after having migrated the current alerting and slo features. We recommend having analerting
andslo
subfolders. Rest observability apps could be added as another subfolder under test_suites. As part of this PR, thealerting > burn_rate
subfolders are created.How to run locally
You can navigate into the new
observability_solution_api_integration
folder and use following commands to run the tests in serverless and ess environments accordingly. You can find more information in the README file of the observability_solution_api_integration folder.CI
ftr_configs.yml
to execute the newly added tests in the pipeline.mochaOptions
in both serverless/config.base.ts and ess/config.base.ts. In the case of serverless, it includes @serverless while excluding @skipInServerless. Similarly, for ess, it includes @ess and excludes @skipInEss.Quality Gates and periodic pipelines
The first quality gate is the execution of the tests as part of the PR check process. Tests are executed on a mocked serverless enviroment (not MKI). Failures are not blocking a release but are blocking PRs to be merged.
The serverless tests executed as part of the PR check, use a stateless Elasticsearch. The periodic pipeline, which is executed every 4 hours is the health check of our tests in MKI environments.
TODO:
currently ess is broken, will be fixed once alerting api is in the common place)