Skip to content

Commit

Permalink
[Ingest Manager] Fix failing test conflict error (#72149) (#72276)
Browse files Browse the repository at this point in the history
* 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 <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
neptunian and elasticmachine authored Jul 17, 2020
1 parent f803d39 commit c634729
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SavedObjectsBulkCreateObject> & { type: AssetType };
export type ArchiveAsset = Pick<
Expand Down Expand Up @@ -49,7 +53,7 @@ export async function installKibanaAssets(options: {
pkgName: string;
paths: string[];
isUpdate: boolean;
}): Promise<AssetReference[]> {
}): Promise<KibanaAssetReference[]> {
const { savedObjectsClient, paths, pkgName, isUpdate } = options;

if (isUpdate) {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions x-pack/test/api_integration/apis/fleet/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
3 changes: 1 addition & 2 deletions x-pack/test/api_integration/apis/fleet/unenroll_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c634729

Please sign in to comment.