[Security Solution][QA] Fix Serverless grep in api integration config (#188291)

**Issue**
The regular expression used to grep tests for serverless execution is
too loose. Tests marked as `@skipInServerlessMKI` are not executed in
the regular serverless PR pipeline as expected.

**Expected Behavior**
Tests tagged with `@skipInServerlessMKI` should only be skipped in the
MKI environment. For example, a test tagged `@ess @serverless
@skipInServerlessMKI` should run in the ESS and regular Serverless
pipelines (PR, `main`) but should be skipped in the MKI environment.

**Current Behavior**
Tests with the tag `@ess @serverless @skipInServerlessMKI` are not being
executed in the regular serverless pipelines, nor in the MKI environment
where they are expected to be skipped.

**Reason**
The regular expression`'/^(?!.*@skipInServerless).*@serverless.*/'` is
too broad. It incorrectly excludes tests tagged with
`@skipInServerlessMKI` because it matches the common `@skipInServerless`
part.

**Solution**
Refine the grep pattern to match the whole word `@skipInServerless` at
the beginning or end of a string, or surrounded by whitespace
`'/^(?!.*(^|\\s)@skipInServerless(\\s|$)).*@serverless.*/'`

**Example**
Tests not executed in PR pipelines due to the `@skipInServerlessMKI`
tag:
1.
`detections_response/detection_engine/actions/trial_license_complete_tier/update_actions.ts`
 * Total test cases: 7
 *  Expected to execute in serverless: 7
 * Tests with @skipInServerlessMKI tag: 4
* [Actually executed in serverless environment:
3](https://buildkite.com/elastic/kibana-pull-request/builds/221346#0190b59a-76c0-4c8d-976c-a5de1070fb2d/1988-2280)
* [Executed with change in regexp:
7](https://buildkite.com/elastic/kibana-pull-request/builds/221386#0190b5fe-fd96-487a-a902-bd21db2bec3a/1981-2269)
2.
`detections_response/detection_engine/alerts/trial_license_complete_tier/assignments/assignments_serverless.ts`
 * Total test cases: 7
 *  Expected to execute in serverless: 7
 * Tests with @skipInServerlessMKI tag: 7
* [Actually executed in serverless environment:
0](https://buildkite.com/elastic/kibana-pull-request/builds/221346#0190b59a-764c-426f-a8b0-384eebf4c438/2621-2890)
* [Executed with change in regexp:
7](https://buildkite.com/elastic/kibana-pull-request/builds/221386#0190b5fe-fd56-445e-93cf-58c980c34228/3807-4146)
3.
`entity_analytics/risk_engine/trial_license_complete_tier/risk_scoring_task/task_execution.ts`
  * Total test cases: 7
 *  Expected to execute in serverless: 6
 * Tests with @skipInServerlessMKI tag: 6
* [Actually executed in serverless environment:
1](https://buildkite.com/elastic/kibana-pull-request/builds/221346#0190b59a-7670-4721-8984-778486b85c35/1625-2045)
* [Executed with change in regexp:
6](https://buildkite.com/elastic/kibana-pull-request/builds/221386#0190b5fe-fd56-445e-93cf-58c980c34228/3807-4146)
This commit is contained in:
Konrad Szwarc 2024-07-26 15:13:17 +02:00 committed by GitHub
parent 7bb17aefc3
commit 6b4a58a163
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 9 additions and 9 deletions

View file

@ -43,7 +43,7 @@ export function createTestConfig(options: CreateTestConfigOptions) {
mochaOpts: {
...svlSharedConfig.get('mochaOpts'),
grep: '/^(?!.*@skipInServerless).*@serverless.*/',
grep: '/^(?!.*(^|\\s)@skipInServerless(\\s|$)).*@serverless.*/',
},
};
};

View file

@ -296,7 +296,7 @@ export default ({ getService }: FtrProviderContext): void => {
});
});
describe('schedule manual rule run action', () => {
describe('@skipInServerless @skipInServerlessMKI schedule manual rule run action', () => {
it('should return all existing and enabled rules as succeeded', async () => {
const intervalInMinutes = 25;
const interval = `${intervalInMinutes}m`;

View file

@ -921,7 +921,7 @@ export default ({ getService }: FtrProviderContext): void => {
});
});
describe('migrate pre-8.0 action connector ids', () => {
describe('@skipInServerless migrate pre-8.0 action connector ids', () => {
const defaultSpaceActionConnectorId = '61b17790-544e-11ec-a349-11361cc441c4';
const space714ActionConnectorId = '51b17790-544e-11ec-a349-11361cc441c4';
@ -1376,7 +1376,7 @@ export default ({ getService }: FtrProviderContext): void => {
});
});
it('should resolve exception references that include comments', async () => {
it('@skipInServerless should resolve exception references that include comments', async () => {
// So importing a rule that references an exception list
// Keep in mind, no exception lists or rules exist yet
const ndjson = combineToNdJson(

View file

@ -202,7 +202,7 @@ export default ({ getService }: FtrProviderContext) => {
enableAssetCriticalityAdvancedSetting(kibanaServer, log);
});
it('should return the first 10 asset criticality records if no args provided', async () => {
it('@skipInServerless should return the first 10 asset criticality records if no args provided', async () => {
await createRecords();
const { body } = await assetCriticalityRoutes.list();
@ -237,7 +237,7 @@ export default ({ getService }: FtrProviderContext) => {
);
});
it('should only return 1 asset criticality record if per_page=1', async () => {
it('@skipInServerless should only return 1 asset criticality record if per_page=1', async () => {
await createRecords();
const { body } = await assetCriticalityRoutes.list({ per_page: 1 });
@ -251,7 +251,7 @@ export default ({ getService }: FtrProviderContext) => {
expect(body.records[0].id_value).to.eql(records[0].id_value);
});
it('should return the next 10 asset criticality records if page=2', async () => {
it('@skipInServerless should return the next 10 asset criticality records if page=2', async () => {
await createRecords();
const { body } = await assetCriticalityRoutes.list({ page: 2 });

View file

@ -145,7 +145,7 @@ export default ({ getService }: FtrProviderContext) => {
});
// https://github.com/elastic/kibana/issues/183247
describe('@serverless @skipInServerlessMKI Asset Criticality Privileges API', () => {
describe('@skipInServerless @skipInServerlessMKI Asset Criticality Privileges API', () => {
const supertestWithoutAuth = getService('supertestWithoutAuth');
const assetCriticalityRoutesNoAuth =
assetCriticalityRouteHelpersFactoryNoAuth(supertestWithoutAuth);

View file

@ -104,7 +104,7 @@ export default ({ getService }: FtrProviderContext): void => {
);
});
it('@skipInServerlessMKI starts the latest transform', async () => {
it('@skipInServerlessMKI @skipInServerless starts the latest transform', async () => {
await waitForRiskScoresToBePresent({ es, log, scoreCount: 10 });
const transformStats = await es.transform.getTransformStats({