From 035a4337e3512bc244b0c8212d671a96cf147593 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 5 Oct 2022 07:56:49 -0400 Subject: [PATCH] Removing esArchiver from bulkCreate (#142676) --- .../common/suites/bulk_create.ts | 43 +++++++++++++------ .../security_and_spaces/apis/bulk_create.ts | 7 +-- .../spaces_only/apis/bulk_create.ts | 7 +-- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts index 7779c604472e1..bb0bd27ce85d9 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/bulk_create.ts @@ -6,7 +6,6 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; import { SavedObjectsErrorHelpers } from '@kbn/core/server'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES, ALL_SPACES_ID } from '../lib/spaces'; @@ -17,6 +16,8 @@ import { getRedactedNamespaces, } from '../lib/saved_object_test_utils'; import { ExpectResponseBody, TestCase, TestDefinition, TestSuite, TestUser } from '../lib/types'; +import { FtrProviderContext } from '../ftr_provider_context'; +import { getTestDataLoader, SPACE_1, SPACE_2 } from '../../../common/lib/test_data_loader'; const { DEFAULT: { spaceId: DEFAULT_SPACE_ID }, @@ -85,7 +86,10 @@ const createRequest = ({ type, id, initialNamespaces }: BulkCreateTestCase) => ( ...(initialNamespaces && { initialNamespaces }), }); -export function bulkCreateTestSuiteFactory(esArchiver: any, supertest: SuperTest) { +export function bulkCreateTestSuiteFactory(context: FtrProviderContext) { + const testDataLoader = getTestDataLoader(context); + const supertest = context.getService('supertestWithoutAuth'); + const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_create'); const expectResponseBody = ( @@ -193,16 +197,31 @@ export function bulkCreateTestSuiteFactory(esArchiver: any, supertest: SuperTest const { user, spaceId = SPACES.DEFAULT.spaceId, tests } = definition; describeFn(description, () => { - before(() => - esArchiver.load( - 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' - ) - ); - after(() => - esArchiver.unload( - 'x-pack/test/saved_object_api_integration/common/fixtures/es_archiver/saved_objects/spaces' - ) - ); + before(async () => { + await testDataLoader.createFtrSpaces(); + await testDataLoader.createFtrSavedObjectsData([ + { + spaceName: null, + dataUrl: + 'x-pack/test/saved_object_api_integration/common/fixtures/kbn_archiver/default_space.json', + }, + { + spaceName: SPACE_1.id, + dataUrl: + 'x-pack/test/saved_object_api_integration/common/fixtures/kbn_archiver/space_1.json', + }, + { + spaceName: SPACE_2.id, + dataUrl: + 'x-pack/test/saved_object_api_integration/common/fixtures/kbn_archiver/space_2.json', + }, + ]); + }); + + after(async () => { + await testDataLoader.deleteFtrSpaces(); + await testDataLoader.deleteFtrSavedObjectsData(); + }); const attrs = { attributes: { [NEW_ATTRIBUTE_KEY]: NEW_ATTRIBUTE_VAL } }; diff --git a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_create.ts b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_create.ts index 2d8ca1c303bd4..4176b6707b124 100644 --- a/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/security_and_spaces/apis/bulk_create.ts @@ -113,12 +113,9 @@ const createTestCases = (overwrite: boolean, spaceId: string) => { return { normalTypes, crossNamespace, hiddenType, allTypes }; }; -export default function ({ getService }: FtrProviderContext) { - const supertest = getService('supertestWithoutAuth'); - const esArchiver = getService('esArchiver'); - +export default function (context: FtrProviderContext) { const { addTests, createTestDefinitions, expectSavedObjectForbidden } = - bulkCreateTestSuiteFactory(esArchiver, supertest); + bulkCreateTestSuiteFactory(context); const createTests = (overwrite: boolean, spaceId: string, user: TestUser) => { const { normalTypes, crossNamespace, hiddenType, allTypes } = createTestCases( overwrite, diff --git a/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts b/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts index 34e18b76088f1..bccc55403ba79 100644 --- a/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts +++ b/x-pack/test/saved_object_api_integration/spaces_only/apis/bulk_create.ts @@ -103,11 +103,8 @@ const createTestCases = (overwrite: boolean, spaceId: string) => { ]; }; -export default function ({ getService }: FtrProviderContext) { - const supertest = getService('supertest'); - const esArchiver = getService('esArchiver'); - - const { addTests, createTestDefinitions } = bulkCreateTestSuiteFactory(esArchiver, supertest); +export default function (context: FtrProviderContext) { + const { addTests, createTestDefinitions } = bulkCreateTestSuiteFactory(context); const createTests = (overwrite: boolean, spaceId: string) => { const testCases = createTestCases(overwrite, spaceId); return createTestDefinitions(testCases, false, overwrite, {