From 3f5e2077ba4b0ac4644be75641dfd8ae904227b9 Mon Sep 17 00:00:00 2001 From: Sandra Gonzales Date: Fri, 17 Jul 2020 11:11:46 -0400 Subject: [PATCH] [Ingest Manager] Fix failing test conflict error (#72149) (#72275) * save kibana installation references after other updates have completed to avoid conflict error * unskip tests * uncomment out line * add back await to not change things * unskip fleet_unenroll_agent Co-authored-by: Elastic Machine Co-authored-by: Elastic Machine --- .../services/epm/kibana/assets/install.ts | 22 ++++++++++--------- .../server/services/epm/packages/install.ts | 9 +++++--- .../test/api_integration/apis/fleet/setup.ts | 3 +-- .../apis/fleet/unenroll_agent.ts | 3 +-- .../apis/epm/install.ts | 3 +-- .../apps/endpoint/policy_details.ts | 3 +-- .../apps/endpoint/policy_list.ts | 3 +-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/x-pack/plugins/ingest_manager/server/services/epm/kibana/assets/install.ts b/x-pack/plugins/ingest_manager/server/services/epm/kibana/assets/install.ts index 2a743f244e64d..a3fe444b19b1a 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/kibana/assets/install.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/kibana/assets/install.ts @@ -11,10 +11,14 @@ import { } from 'src/core/server'; import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../../../common'; import * as Registry from '../../registry'; -import { AssetType, KibanaAssetType, AssetReference } from '../../../../types'; +import { + AssetType, + KibanaAssetType, + AssetReference, + KibanaAssetReference, +} from '../../../../types'; import { deleteKibanaSavedObjectsAssets } from '../../packages/remove'; import { getInstallationObject, savedObjectTypes } from '../../packages'; -import { saveInstalledKibanaRefs } from '../../packages/install'; type SavedObjectToBe = Required & { type: AssetType }; export type ArchiveAsset = Pick< @@ -49,7 +53,7 @@ export async function installKibanaAssets(options: { pkgName: string; paths: string[]; isUpdate: boolean; -}): Promise { +}): Promise { const { savedObjectsClient, paths, pkgName, isUpdate } = options; if (isUpdate) { @@ -65,16 +69,14 @@ export async function installKibanaAssets(options: { // install the new assets and save installation references const kibanaAssetTypes = Object.values(KibanaAssetType); - const installationPromises = kibanaAssetTypes.map((assetType) => - installKibanaSavedObjects({ savedObjectsClient, assetType, paths }) + const installedAssets = await Promise.all( + kibanaAssetTypes.map((assetType) => + installKibanaSavedObjects({ savedObjectsClient, assetType, paths }) + ) ); // installKibanaSavedObjects returns AssetReference[], so .map creates AssetReference[][] // call .flat to flatten into one dimensional array - const newInstalledKibanaAssets = await Promise.all(installationPromises).then((results) => - results.flat() - ); - await saveInstalledKibanaRefs(savedObjectsClient, pkgName, newInstalledKibanaAssets); - return newInstalledKibanaAssets; + return installedAssets.flat(); } export const deleteKibanaInstalledRefs = async ( savedObjectsClient: SavedObjectsClientContract, diff --git a/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts b/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts index cd4259a0c30d7..a69daae6e0410 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts @@ -169,17 +169,20 @@ export async function installPackage(options: { ); } - // update to newly installed version when all assets are successfully installed - if (isUpdate) await updateVersion(savedObjectsClient, pkgName, pkgVersion); // get template refs to save const installedTemplateRefs = installedTemplates.map((template) => ({ id: template.templateName, type: ElasticsearchAssetType.indexTemplate, })); + const [installedKibanaAssets] = await Promise.all([ installKibanaAssetsPromise, installIndexPatternPromise, ]); + + await saveInstalledKibanaRefs(savedObjectsClient, pkgName, installedKibanaAssets); + // update to newly installed version when all assets are successfully installed + if (isUpdate) await updateVersion(savedObjectsClient, pkgName, pkgVersion); return [...installedKibanaAssets, ...installedPipelines, ...installedTemplateRefs]; } const updateVersion = async ( @@ -230,7 +233,7 @@ export async function createInstallation(options: { export const saveInstalledKibanaRefs = async ( savedObjectsClient: SavedObjectsClientContract, pkgName: string, - installedAssets: AssetReference[] + installedAssets: KibanaAssetReference[] ) => { await savedObjectsClient.update(PACKAGES_SAVED_OBJECT_TYPE, pkgName, { installed_kibana: installedAssets, diff --git a/x-pack/test/api_integration/apis/fleet/setup.ts b/x-pack/test/api_integration/apis/fleet/setup.ts index 82e494b0ab28c..4fcf39886e202 100644 --- a/x-pack/test/api_integration/apis/fleet/setup.ts +++ b/x-pack/test/api_integration/apis/fleet/setup.ts @@ -11,8 +11,7 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('es'); - // FLAKY: https://github.com/elastic/kibana/issues/72053 - describe.skip('fleet_setup', () => { + describe('fleet_setup', () => { beforeEach(async () => { try { await es.security.deleteUser({ diff --git a/x-pack/test/api_integration/apis/fleet/unenroll_agent.ts b/x-pack/test/api_integration/apis/fleet/unenroll_agent.ts index 4e1443ad1fc68..bc6c44e590cc4 100644 --- a/x-pack/test/api_integration/apis/fleet/unenroll_agent.ts +++ b/x-pack/test/api_integration/apis/fleet/unenroll_agent.ts @@ -16,8 +16,7 @@ export default function (providerContext: FtrProviderContext) { const supertest = getService('supertest'); const esClient = getService('es'); - // FLAKY: https://github.com/elastic/kibana/issues/64696 - describe.skip('fleet_unenroll_agent', () => { + describe('fleet_unenroll_agent', () => { let accessAPIKeyId: string; let outputAPIKeyId: string; before(async () => { diff --git a/x-pack/test/ingest_manager_api_integration/apis/epm/install.ts b/x-pack/test/ingest_manager_api_integration/apis/epm/install.ts index b6807b2fd3414..f73ba56c172c4 100644 --- a/x-pack/test/ingest_manager_api_integration/apis/epm/install.ts +++ b/x-pack/test/ingest_manager_api_integration/apis/epm/install.ts @@ -21,8 +21,7 @@ export default function ({ getService }: FtrProviderContext) { const mappingsPackage = 'overrides-0.1.0'; const server = dockerServers.get('registry'); - // FLAKY: https://github.com/elastic/kibana/issues/71939 - describe.skip('installs packages that include settings and mappings overrides', async () => { + describe('installs packages that include settings and mappings overrides', async () => { after(async () => { if (server.enabled) { // remove the package just in case it being installed will affect other tests diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts index d57bd32441454..cf76f297d83be 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts @@ -19,8 +19,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const policyTestResources = getService('policyTestResources'); - // FLAKY: https://github.com/elastic/kibana/issues/72102 - describe.skip('When on the Endpoint Policy Details Page', function () { + describe('When on the Endpoint Policy Details Page', function () { this.tags(['ciGroup7']); describe('with an invalid policy id', () => { diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts index b91f0647487ff..57321ab4cd911 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts @@ -19,8 +19,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const policyTestResources = getService('policyTestResources'); const RELATIVE_DATE_FORMAT = /\d (?:seconds|minutes) ago/i; - // FLAKY: https://github.com/elastic/kibana/issues/71951 - describe.skip('When on the Endpoint Policy List', function () { + describe('When on the Endpoint Policy List', function () { this.tags(['ciGroup7']); before(async () => { await pageObjects.policy.navigateToPolicyList();