Skip to content

Commit

Permalink
[SecuritySolution] [8.11] Fix fleet_integration.ts API integration te…
Browse files Browse the repository at this point in the history
…st flake (elastic#170510)

Fixes: elastic#167056

**See
[comment](elastic#167056 (comment))
in ticket.**
**This is only the fix for 8.11.**

## Summary

- Changes the installation of the `security_detection_engine` package
from the current Fleet bulk install packages endpoint to use the
endpoint that installs a single package, in order to get to a more
stable test
- Notice that the errors reported that Kibana machine are socket
hangups/timeouts and are solved on retry, so they do not block any
pipelines)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
jpdjere authored Nov 7, 2023
1 parent 19e5f24 commit 4ee1728
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getPrebuiltRulesAndTimelinesStatus,
} from '../../utils';
import { deleteAllPrebuiltRuleAssets } from '../../utils/prebuilt_rules/delete_all_prebuilt_rule_assets';
import { installPrebuiltRulesFleetPackage } from '../../utils/prebuilt_rules/install_prebuilt_rules_fleet_package';
import { installPrebuiltRulesPackageViaFleetAPI } from '../../utils/prebuilt_rules/install_fleet_package_by_url';
import { installPrebuiltRulesAndTimelines } from '../../utils/prebuilt_rules/install_prebuilt_rules_and_timelines';
import { deletePrebuiltRulesFleetPackage } from '../../utils/prebuilt_rules/delete_prebuilt_rules_fleet_package';

Expand Down Expand Up @@ -41,11 +41,7 @@ export default ({ getService }: FtrProviderContext): void => {
expect(statusBeforePackageInstallation.rules_not_installed).toBe(0);
expect(statusBeforePackageInstallation.rules_not_updated).toBe(0);

await installPrebuiltRulesFleetPackage({
es,
supertest,
overrideExistingPackage: true,
});
await installPrebuiltRulesPackageViaFleetAPI(es, supertest);

// Verify that status is updated after package installation
const statusAfterPackageInstallation = await getPrebuiltRulesAndTimelinesStatus(supertest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ export * from './prebuilt_rules/install_prebuilt_rules';
export * from './prebuilt_rules/upgrade_prebuilt_rules';
export * from './prebuilt_rules/install_mock_prebuilt_rules';
export * from './prebuilt_rules/install_prebuilt_rules_and_timelines';
export * from './prebuilt_rules/get_prebuilt_rules_and_timelines_status';
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@ import { ALL_SAVED_OBJECT_INDICES } from '@kbn/core-saved-objects-server';
import { InstallPackageResponse } from '@kbn/fleet-plugin/common/types';

/**
* Installs prebuilt rules package `security_detection_engine` by version.
* Installs latest available non-prerelease prebuilt rules package `security_detection_engine`.
*
* @param es Elasticsearch client
* @param supertest SuperTest instance
* @param version Semver version of the `security_detection_engine` package to install
* @returns Fleet install package response
*/

export const installPrebuiltRulesPackageByVersion = async (
export const installPrebuiltRulesPackageViaFleetAPI = async (
es: Client,
supertest: SuperTest.SuperTest<SuperTest.Test>,
version: string
supertest: SuperTest.SuperTest<SuperTest.Test>
): Promise<InstallPackageResponse> => {
const fleetResponse = await supertest
.post(`/api/fleet/epm/packages/security_detection_engine/${version}`)
.post(`/api/fleet/epm/packages/security_detection_engine`)
.set('kbn-xsrf', 'xxxx')
.type('application/json')
.send({ force: true })
Expand All @@ -48,3 +47,29 @@ export const installPrebuiltRulesPackageByVersion = async (

return fleetResponse.body as InstallPackageResponse;
};
/**
* Installs prebuilt rules package `security_detection_engine`, passing in the version
* of the package as a parameter to the utl.
*
* @param es Elasticsearch client
* @param supertest SuperTest instance
* @param version Semver version of the `security_detection_engine` package to install
* @returns Fleet install package response
*/

export const installPrebuiltRulesPackageByVersion = async (
es: Client,
supertest: SuperTest.SuperTest<SuperTest.Test>,
version: string
): Promise<InstallPackageResponse> => {
const fleetResponse = await supertest
.post(`/api/fleet/epm/packages/security_detection_engine/${version}`)
.set('kbn-xsrf', 'xxxx')
.type('application/json')
.send({ force: true })
.expect(200);

await es.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES });

return fleetResponse.body as InstallPackageResponse;
};

0 comments on commit 4ee1728

Please sign in to comment.