From 1e9ac63e630293833ad924d048964b1cbcc79a2f Mon Sep 17 00:00:00 2001 From: Georgii Gorbachev Date: Fri, 20 Dec 2024 15:07:17 +0100 Subject: [PATCH] [Security Solution] Reduce flakiness in functions for installing Fleet package with prebuilt rules (#204823) **Fixes: https://github.com/elastic/kibana/issues/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: https://github.com/elastic/kibana/issues/204812#issuecomment-2552010657 ### 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 39091fc30ba274f155cb807ef5de4e98bcc1072f) --- .../rules/prebuilt_rules/install_fleet_package_by_url.ts | 6 +++--- .../prebuilt_rules/install_prebuilt_rules_fleet_package.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts index b88a848758a8f..c01968e17cd93 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_fleet_package_by_url.ts @@ -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`. @@ -46,7 +46,7 @@ export const installPrebuiltRulesPackageViaFleetAPI = async ( }, { retryCount: MAX_RETRIES, - timeout: ATTEMPT_TIMEOUT, + timeout: TOTAL_TIMEOUT, } ); @@ -87,7 +87,7 @@ export const installPrebuiltRulesPackageByVersion = async ( }, { retryCount: MAX_RETRIES, - timeout: ATTEMPT_TIMEOUT, + timeout: TOTAL_TIMEOUT, } ); diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts index f7a7337d40241..dc5def47abaee 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts @@ -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 @@ -60,7 +60,7 @@ export const installPrebuiltRulesFleetPackage = async ({ }, { retryCount: MAX_RETRIES, - timeout: ATTEMPT_TIMEOUT, + timeout: TOTAL_TIMEOUT, } ); @@ -94,7 +94,7 @@ export const installPrebuiltRulesFleetPackage = async ({ }, { retryCount: MAX_RETRIES, - timeout: ATTEMPT_TIMEOUT, + timeout: TOTAL_TIMEOUT, } );