Skip to content

Commit

Permalink
Revert "[FTR] Use importExport for saved_object/basic archive (#100244)"
Browse files Browse the repository at this point in the history
This reverts commit 0f9debe.
  • Loading branch information
tylersmalley authored Jun 2, 2021
1 parent 2dfda12 commit 2956993
Show file tree
Hide file tree
Showing 43 changed files with 6,863 additions and 2,232 deletions.
11 changes: 4 additions & 7 deletions packages/kbn-test/src/kbn_client/kbn_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

import { ToolingLog } from '@kbn/dev-utils';

import { KbnClientImportExport } from './kbn_client_import_export';
import { KbnClientPlugins } from './kbn_client_plugins';
import { KbnClientRequester, ReqOptions } from './kbn_client_requester';
import { KbnClientSavedObjects } from './kbn_client_saved_objects';
import { KbnClientSpaces } from './kbn_client_spaces';
import { KbnClientStatus } from './kbn_client_status';
import { KbnClientUiSettings, UiSettingValues } from './kbn_client_ui_settings';
import { KbnClientPlugins } from './kbn_client_plugins';
import { KbnClientVersion } from './kbn_client_version';
import { KbnClientSavedObjects } from './kbn_client_saved_objects';
import { KbnClientUiSettings, UiSettingValues } from './kbn_client_ui_settings';
import { KbnClientImportExport } from './kbn_client_import_export';

export interface KbnClientOptions {
url: string;
Expand All @@ -30,7 +29,6 @@ export class KbnClient {
readonly plugins: KbnClientPlugins;
readonly version: KbnClientVersion;
readonly savedObjects: KbnClientSavedObjects;
readonly spaces: KbnClientSpaces;
readonly uiSettings: KbnClientUiSettings;
readonly importExport: KbnClientImportExport;

Expand Down Expand Up @@ -61,7 +59,6 @@ export class KbnClient {
this.plugins = new KbnClientPlugins(this.status);
this.version = new KbnClientVersion(this.status);
this.savedObjects = new KbnClientSavedObjects(this.log, this.requester);
this.spaces = new KbnClientSpaces(this.requester);
this.uiSettings = new KbnClientUiSettings(this.log, this.requester, this.uiSettingDefaults);
this.importExport = new KbnClientImportExport(
this.log,
Expand Down
2 changes: 0 additions & 2 deletions packages/kbn-test/src/kbn_client/kbn_client_requester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ export class KbnClientRequester {
responseType: options.responseType,
// work around https://github.com/axios/axios/issues/2791
transformResponse: options.responseType === 'text' ? [(x) => x] : undefined,
maxContentLength: 30000000,
maxBodyLength: 30000000,
paramsSerializer: (params) => Qs.stringify(params),
});

Expand Down
67 changes: 0 additions & 67 deletions packages/kbn-test/src/kbn_client/kbn_client_spaces.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/dev/precommit_hook/casing_check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const IGNORE_FILE_GLOBS = [
'.ci/pipeline-library/**/*',
'packages/kbn-test/jest-preset.js',
'test/package/Vagrantfile',
'**/test/**/fixtures/**/*',

// filename must match language code which requires capital letters
'**/translations/*.json',
Expand All @@ -62,6 +61,8 @@ export const IGNORE_FILE_GLOBS = [
'x-pack/plugins/apm/e2e/**/*',

'x-pack/plugins/maps/server/fonts/**/*',
// packages for the ingest manager's api integration tests could be valid semver which has dashes
'x-pack/test/fleet_api_integration/apis/fixtures/test_packages/**/*',

// Bazel default files
'**/WORKSPACE.bazel',
Expand Down Expand Up @@ -97,6 +98,7 @@ export const IGNORE_DIRECTORY_GLOBS = [
...KEBAB_CASE_DIRECTORY_GLOBS,
'src/babel-*',
'packages/*',
'test/functional/fixtures/es_archiver/visualize_source-filters',
'packages/kbn-pm/src/utils/__fixtures__/*',
'x-pack/dev-tools',
'packages/kbn-optimizer/src/__fixtures__/mock_repo/x-pack',
Expand Down
6 changes: 3 additions & 3 deletions test/api_integration/apis/kql_telemetry/kql_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const es = getService('es');

describe('telemetry API', () => {
before(() => kibanaServer.importExport.load('saved_objects/basic'));
after(() => kibanaServer.importExport.unload('saved_objects/basic'));
before(() => esArchiver.load('saved_objects/basic'));
after(() => esArchiver.unload('saved_objects/basic'));

it('should increment the opt *in* counter in the .kibana/kql-telemetry document', async () => {
await supertest
Expand Down
137 changes: 89 additions & 48 deletions test/api_integration/apis/saved_objects/bulk_create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { getKibanaVersion } from './lib/saved_objects_test_utils';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const kibanaServer = getService('kibanaServer');
const SPACE_ID = 'ftr-so-bulk-create';
const esArchiver = getService('esArchiver');
const esDeleteAllIndices = getService('esDeleteAllIndices');

const BULK_REQUESTS = [
{
Expand All @@ -38,58 +38,99 @@ export default function ({ getService }: FtrProviderContext) {

before(async () => {
KIBANA_VERSION = await getKibanaVersion(getService);
await kibanaServer.spaces.create({ id: SPACE_ID, name: SPACE_ID });
await kibanaServer.importExport.load('saved_objects/basic', { space: SPACE_ID });
});

after(() => kibanaServer.spaces.delete(SPACE_ID));
describe('with kibana index', () => {
before(() => esArchiver.load('saved_objects/basic'));
after(() => esArchiver.unload('saved_objects/basic'));

it('should return 200 with individual responses', async () =>
await supertest
.post(`/s/${SPACE_ID}/api/saved_objects/_bulk_create`)
.send(BULK_REQUESTS)
.expect(200)
.then((resp) => {
expect(resp.body).to.eql({
saved_objects: [
{
type: 'visualization',
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
error: {
error: 'Conflict',
message:
'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] conflict',
statusCode: 409,
it('should return 200 with individual responses', async () =>
await supertest
.post(`/api/saved_objects/_bulk_create`)
.send(BULK_REQUESTS)
.expect(200)
.then((resp) => {
expect(resp.body).to.eql({
saved_objects: [
{
type: 'visualization',
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
error: {
error: 'Conflict',
message:
'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] conflict',
statusCode: 409,
},
},
},
{
type: 'dashboard',
id: 'a01b2f57-fcfd-4864-b735-09e28f0d815e',
updated_at: resp.body.saved_objects[1].updated_at,
version: resp.body.saved_objects[1].version,
attributes: {
title: 'A great new dashboard',
{
type: 'dashboard',
id: 'a01b2f57-fcfd-4864-b735-09e28f0d815e',
updated_at: resp.body.saved_objects[1].updated_at,
version: resp.body.saved_objects[1].version,
attributes: {
title: 'A great new dashboard',
},
migrationVersion: {
dashboard: resp.body.saved_objects[1].migrationVersion.dashboard,
},
coreMigrationVersion: KIBANA_VERSION,
references: [],
namespaces: ['default'],
},
migrationVersion: {
dashboard: resp.body.saved_objects[1].migrationVersion.dashboard,
],
});
}));

it('should not return raw id when object id is unspecified', async () =>
await supertest
.post(`/api/saved_objects/_bulk_create`)
.send(BULK_REQUESTS.map(({ id, ...rest }) => rest))
.expect(200)
.then((resp) => {
resp.body.saved_objects.map(({ id }: { id: string }) =>
expect(id).not.match(/visualization|dashboard/)
);
}));
});

describe('without kibana index', () => {
before(
async () =>
// just in case the kibana server has recreated it
await esDeleteAllIndices('.kibana*')
);

it('should return 200 with errors', async () => {
await new Promise((resolve) => setTimeout(resolve, 2000));
await supertest
.post('/api/saved_objects/_bulk_create')
.send(BULK_REQUESTS)
.expect(200)
.then((resp) => {
expect(resp.body).to.eql({
saved_objects: [
{
id: BULK_REQUESTS[0].id,
type: BULK_REQUESTS[0].type,
error: {
error: 'Internal Server Error',
message: 'An internal server error occurred',
statusCode: 500,
},
},
coreMigrationVersion: KIBANA_VERSION,
references: [],
namespaces: [SPACE_ID],
},
],
{
id: BULK_REQUESTS[1].id,
type: BULK_REQUESTS[1].type,
error: {
error: 'Internal Server Error',
message: 'An internal server error occurred',
statusCode: 500,
},
},
],
});
});
}));

it('should not return raw id when object id is unspecified', async () =>
await supertest
.post(`/s/${SPACE_ID}/api/saved_objects/_bulk_create`)
.send(BULK_REQUESTS.map(({ id, ...rest }) => rest))
.expect(200)
.then((resp) => {
resp.body.saved_objects.map(({ id }: { id: string }) =>
expect(id).not.match(/visualization|dashboard/)
);
}));
});
});
});
}
Loading

0 comments on commit 2956993

Please sign in to comment.