From 516b18fdacb9f8ad0c2dead20647d19e4610d02b Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 21 Sep 2022 11:39:50 -0400 Subject: [PATCH] Removing esArchiver and using new data loader (#140807) * Removing esArchiver and using new data loader * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Thomas Watson --- .../suites/resolve_copy_to_space_conflicts.ts | 38 ++++++------------- .../apis/resolve_copy_to_space_conflicts.ts | 8 +--- .../apis/resolve_copy_to_space_conflicts.ts | 10 ++--- 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts index f74434f72227e..58a434bd0ca91 100644 --- a/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts +++ b/x-pack/test/spaces_api_integration/common/suites/resolve_copy_to_space_conflicts.ts @@ -6,13 +6,13 @@ */ import expect from '@kbn/expect'; -import { SuperTest } from 'supertest'; -import { EsArchiver } from '@kbn/es-archiver'; import { SavedObject } from '@kbn/core/server'; import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common/constants'; import { CopyResponse } from '@kbn/spaces-plugin/server/lib/copy_to_spaces'; import { getUrlPrefix } from '../lib/space_test_utils'; import { DescribeFn, TestDefinitionAuthentication } from '../lib/types'; +import { FtrProviderContext } from '../ftr_provider_context'; +import { getTestDataLoader } from '../lib/test_data_loader'; type TestResponse = Record; @@ -51,11 +51,11 @@ const getDestinationSpace = (originSpaceId?: string) => { return DEFAULT_SPACE_ID; }; -export function resolveCopyToSpaceConflictsSuite( - esArchiver: EsArchiver, - supertestWithAuth: SuperTest, - supertestWithoutAuth: SuperTest -) { +export function resolveCopyToSpaceConflictsSuite(context: FtrProviderContext) { + const testDataLoader = getTestDataLoader(context); + const supertestWithAuth = context.getService('supertest'); + const supertestWithoutAuth = context.getService('supertestWithoutAuth'); + const getVisualizationAtSpace = async (spaceId: string): Promise> => { return supertestWithAuth .get(`${getUrlPrefix(spaceId)}/api/saved_objects/visualization/cts_vis_3_${spaceId}`) @@ -487,16 +487,8 @@ export function resolveCopyToSpaceConflictsSuite( }); describe('single-namespace types', () => { - beforeEach(() => - esArchiver.load( - 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' - ) - ); - afterEach(() => - esArchiver.unload( - 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' - ) - ); + beforeEach(async () => await testDataLoader.beforeEach()); + afterEach(async () => await testDataLoader.afterEach()); const dashboardObject = { type: 'dashboard', id: `cts_dashboard_${spaceId}` }; const visualizationObject = { type: 'visualization', id: `cts_vis_3_${spaceId}` }; @@ -638,16 +630,8 @@ export function resolveCopyToSpaceConflictsSuite( const includeReferences = false; const createNewCopies = false; describe(`multi-namespace types with "overwrite" retry`, () => { - before(() => - esArchiver.load( - 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' - ) - ); - after(() => - esArchiver.unload( - 'x-pack/test/spaces_api_integration/common/fixtures/es_archiver/saved_objects/spaces' - ) - ); + before(async () => await testDataLoader.beforeEach()); + after(async () => await testDataLoader.afterEach()); const testCases = tests.multiNamespaceTestCases(); testCases.forEach(({ testTitle, objects, retries, statusCode, response }) => { diff --git a/x-pack/test/spaces_api_integration/security_and_spaces/apis/resolve_copy_to_space_conflicts.ts b/x-pack/test/spaces_api_integration/security_and_spaces/apis/resolve_copy_to_space_conflicts.ts index 1b39cd5d77302..2f1788ae348f9 100644 --- a/x-pack/test/spaces_api_integration/security_and_spaces/apis/resolve_copy_to_space_conflicts.ts +++ b/x-pack/test/spaces_api_integration/security_and_spaces/apis/resolve_copy_to_space_conflicts.ts @@ -11,11 +11,7 @@ import { resolveCopyToSpaceConflictsSuite } from '../../common/suites/resolve_co import { FtrProviderContext } from '../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export -export default function resolveCopyToSpaceConflictsTestSuite({ getService }: FtrProviderContext) { - const supertestWithoutAuth = getService('supertestWithoutAuth'); - const supertestWithAuth = getService('supertest'); - const esArchiver = getService('esArchiver'); - +export default function resolveCopyToSpaceConflictsTestSuite(context: FtrProviderContext) { const { resolveCopyToSpaceConflictsTest, createExpectNonOverriddenResponseWithReferences, @@ -27,7 +23,7 @@ export default function resolveCopyToSpaceConflictsTestSuite({ getService }: Ftr createExpectUnauthorizedAtSpaceWithoutReferencesResult, createMultiNamespaceTestCases, NON_EXISTENT_SPACE_ID, - } = resolveCopyToSpaceConflictsSuite(esArchiver, supertestWithAuth, supertestWithoutAuth); + } = resolveCopyToSpaceConflictsSuite(context); describe('resolve copy to spaces conflicts', () => { [ diff --git a/x-pack/test/spaces_api_integration/spaces_only/apis/resolve_copy_to_space_conflicts.ts b/x-pack/test/spaces_api_integration/spaces_only/apis/resolve_copy_to_space_conflicts.ts index 454c49f9a6ca6..2248c67cd8219 100644 --- a/x-pack/test/spaces_api_integration/spaces_only/apis/resolve_copy_to_space_conflicts.ts +++ b/x-pack/test/spaces_api_integration/spaces_only/apis/resolve_copy_to_space_conflicts.ts @@ -5,15 +5,11 @@ * 2.0. */ -import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; +import { FtrProviderContext } from '../../common/ftr_provider_context'; import { resolveCopyToSpaceConflictsSuite } from '../../common/suites/resolve_copy_to_space_conflicts'; // eslint-disable-next-line import/no-default-export -export default function resolveCopyToSpaceConflictsTestSuite({ getService }: FtrProviderContext) { - const supertestWithoutAuth = getService('supertestWithoutAuth'); - const supertestWithAuth = getService('supertest'); - const esArchiver = getService('esArchiver'); - +export default function resolveCopyToSpaceConflictsTestSuite(context: FtrProviderContext) { const { resolveCopyToSpaceConflictsTest, createExpectNonOverriddenResponseWithReferences, @@ -23,7 +19,7 @@ export default function resolveCopyToSpaceConflictsTestSuite({ getService }: Ftr createMultiNamespaceTestCases, NON_EXISTENT_SPACE_ID, originSpaces, - } = resolveCopyToSpaceConflictsSuite(esArchiver, supertestWithAuth, supertestWithoutAuth); + } = resolveCopyToSpaceConflictsSuite(context); describe('resolve copy to spaces conflicts', () => { originSpaces.forEach((spaceId) => {