Skip to content

Commit

Permalink
[Security Solution] Reduce flakiness in functions for installing Flee…
Browse files Browse the repository at this point in the history
…t package with prebuilt rules (elastic#204823)

**Fixes: elastic#204812

## Summary

This PR increases the total timeout for installing the prebuilt rules
package from the API integration tests from 2 minutes to 6 minutes,
where 6 minutes = 2 minutes * 3 attempts.

Logic before the fix:
- If the first attempt takes more than 2 minutes, it will continue to
run.
- If the first attempt takes less than 2 minutes, there will be a second
one.
- If the first attempt takes more than 2 minutes, there won't be a
second one.

Logic after the fix:
- If the first attempt takes more than 2 minutes, it will continue to
run.
- If the first attempt takes less than 2 minutes, there will be a second
one.
- If the first attempt takes more than 2 minutes but less than 6, there
will be a second one.
- If the first attempt takes more than 6 minutes, there won't be a
second one.

Context:
elastic#204812 (comment)

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

(cherry picked from commit 39091fc)
  • Loading branch information
banderror committed Dec 20, 2024
1 parent 6b9e6e2 commit 6decc62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import expect from 'expect';
import { refreshSavedObjectIndices } from '../../refresh_index';

const MAX_RETRIES = 2;
const ATTEMPT_TIMEOUT = 120000;
const TOTAL_TIMEOUT = 6 * 60000; // 6 mins, applies to all attempts (1 + MAX_RETRIES)

/**
* Installs latest available non-prerelease prebuilt rules package `security_detection_engine`.
Expand Down Expand Up @@ -46,7 +46,7 @@ export const installPrebuiltRulesPackageViaFleetAPI = async (
},
{
retryCount: MAX_RETRIES,
timeout: ATTEMPT_TIMEOUT,
timeout: TOTAL_TIMEOUT,
}
);

Expand Down Expand Up @@ -87,7 +87,7 @@ export const installPrebuiltRulesPackageByVersion = async (
},
{
retryCount: MAX_RETRIES,
timeout: ATTEMPT_TIMEOUT,
timeout: TOTAL_TIMEOUT,
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import expect from 'expect';
import { refreshSavedObjectIndices } from '../../refresh_index';

const MAX_RETRIES = 2;
const ATTEMPT_TIMEOUT = 120000;
const TOTAL_TIMEOUT = 6 * 60000; // 6 mins, applies to all attempts (1 + MAX_RETRIES)

/**
* Installs the `security_detection_engine` package via fleet API. This will
Expand Down Expand Up @@ -60,7 +60,7 @@ export const installPrebuiltRulesFleetPackage = async ({
},
{
retryCount: MAX_RETRIES,
timeout: ATTEMPT_TIMEOUT,
timeout: TOTAL_TIMEOUT,
}
);

Expand Down Expand Up @@ -94,7 +94,7 @@ export const installPrebuiltRulesFleetPackage = async ({
},
{
retryCount: MAX_RETRIES,
timeout: ATTEMPT_TIMEOUT,
timeout: TOTAL_TIMEOUT,
}
);

Expand Down

0 comments on commit 6decc62

Please sign in to comment.