Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [FTR][CI] Use default distribution for all tests (#94968) #99980

Merged
merged 6 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .ci/Jenkinsfile_flaky
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ def agentProcess(Map params = [:]) {
]) {
task {
if (config.needBuild) {
if (!config.isXpack) {
kibanaPipeline.buildOss()
} else {
kibanaPipeline.buildXpack()
}
kibanaPipeline.buildKibana()
}

for(def i = 0; i < config.agentExecutions; i++) {
Expand Down
2 changes: 1 addition & 1 deletion .ci/Jenkinsfile_security_cypress
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kibanaPipeline(timeoutMinutes: 180) {
def job = 'xpack-securityCypress'

workers.ci(name: job, size: 'l', ramDisk: true) {
kibanaPipeline.bash('test/scripts/jenkins_xpack_build_kibana.sh', 'Build Default Distributable')
kibanaPipeline.bash('test/scripts/jenkins_build_kibana.sh', 'Build Distributable')
kibanaPipeline.functionalTestProcess(job, 'test/scripts/jenkins_security_solution_cypress_chrome.sh')()
// Temporarily disabled to figure out test flake
// kibanaPipeline.functionalTestProcess(job, 'test/scripts/jenkins_security_solution_cypress_firefox.sh')()
Expand Down
6 changes: 1 addition & 5 deletions .ci/es-snapshots/Jenkinsfile_verify_es
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ kibanaPipeline(timeoutMinutes: 210) {
])

task {
kibanaPipeline.buildOss(6)
kibanaPipeline.buildKibana(16)
tasks.ossCiGroups()
}

task {
kibanaPipeline.buildXpack(10, true)
tasks.xpackCiGroups()
tasks.xpackCiGroupDocker()
}
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-es-archiver/src/lib/indices/kibana_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export async function createDefaultSpace({
index,
type: '_doc',
id: 'space:default',
refresh: 'wait_for',
body: {
type: 'space',
updated_at: new Date().toISOString(),
Expand Down
12 changes: 8 additions & 4 deletions packages/kbn-test/src/kbn_client/kbn_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

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

import { KbnClientRequester, ReqOptions } from './kbn_client_requester';
import { KbnClientStatus } from './kbn_client_status';
import { KbnClientImportExport } from './kbn_client_import_export';
import { KbnClientPlugins } from './kbn_client_plugins';
import { KbnClientVersion } from './kbn_client_version';
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 { KbnClientImportExport } from './kbn_client_import_export';
import { KbnClientVersion } from './kbn_client_version';

export interface KbnClientOptions {
url: string;
Expand All @@ -29,6 +30,7 @@ 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 @@ -59,11 +61,13 @@ 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,
this.requester,
this.savedObjects,
this.spaces,
options.importExportDir
);
}
Expand Down
15 changes: 15 additions & 0 deletions packages/kbn-test/src/kbn_client/kbn_client_import_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ToolingLog, isAxiosResponseError, createFailError } from '@kbn/dev-util

import { KbnClientRequester, uriencode, ReqOptions } from './kbn_client_requester';
import { KbnClientSavedObjects } from './kbn_client_saved_objects';
import { KbnClientSpaces } from './kbn_client_spaces';

interface ImportApiResponse {
success: boolean;
Expand All @@ -39,6 +40,7 @@ export class KbnClientImportExport {
public readonly log: ToolingLog,
public readonly requester: KbnClientRequester,
public readonly savedObjects: KbnClientSavedObjects,
private readonly spaces: KbnClientSpaces,
public readonly dir?: string
) {}

Expand Down Expand Up @@ -66,6 +68,19 @@ export class KbnClientImportExport {
const formData = new FormData();
formData.append('file', objects.map((obj) => JSON.stringify(obj)).join('\n'), 'import.ndjson');

if (options?.space) {
this.log.info('creating space', options.space);

try {
await this.spaces.create({
id: options.space,
name: options.space,
});
} catch (e) {
this.log.warning('creating space failed:', e.message);
}
}

// TODO: should we clear out the existing saved objects?
const resp = await this.req<ImportApiResponse>(options?.space, {
method: 'POST',
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-test/src/kbn_client/kbn_client_requester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ 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: 67 additions & 0 deletions packages/kbn-test/src/kbn_client/kbn_client_spaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { KbnClientRequester, uriencode } from './kbn_client_requester';

interface UpdateBody {
name: string;
description?: string;
disabledFeatures?: string | string[];
initials?: string;
color?: string;
imageUrl?: string;
}

interface CreateBody extends UpdateBody {
id: string;
}

export class KbnClientSpaces {
constructor(private readonly requester: KbnClientRequester) {}

async create(body: CreateBody) {
await this.requester.request({
method: 'POST',
path: '/api/spaces/space',
body,
});
}

async update(id: string, body: UpdateBody) {
await this.requester.request({
method: 'PUT',
path: uriencode`/api/spaces/space/${id}`,
body,
});
}

async get(id: string) {
const { data } = await this.requester.request({
method: 'GET',
path: uriencode`/api/spaces/space/${id}`,
});

return data;
}

async list() {
const { data } = await this.requester.request({
method: 'GET',
path: '/api/spaces/space',
});

return data;
}

async delete(id: string) {
await this.requester.request({
method: 'DELETE',
path: uriencode`/api/spaces/space/${id}`,
});
}
}
1 change: 1 addition & 0 deletions src/dev/precommit_hook/casing_check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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 Down
2 changes: 2 additions & 0 deletions test/accessibility/apps/dashboard_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('dashboard panel full screen', async () => {
const header = await dashboardPanelActions.getPanelHeading('[Flights] Airline Carrier');
await dashboardPanelActions.toggleContextMenu(header);
await dashboardPanelActions.clickContextMenuMoreItem();

await testSubjects.click('embeddablePanelAction-togglePanel');
await a11y.testAppSnapshot();
});
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/home/sample_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function ({ getService }: FtrProviderContext) {

expect(resp.body).to.eql({
elasticsearchIndicesCreated: { kibana_sample_data_flights: 13059 },
kibanaSavedObjectsLoaded: 20,
kibanaSavedObjectsLoaded: 23,
});
});

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 esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const es = getService('es');

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

it('should increment the opt *in* counter in the .kibana/kql-telemetry document', async () => {
await supertest
Expand Down
136 changes: 47 additions & 89 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 esArchiver = getService('esArchiver');
const esDeleteAllIndices = getService('esDeleteAllIndices');
const kibanaServer = getService('kibanaServer');
const SPACE_ID = 'ftr-so-bulk-create';

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

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

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

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,
},
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,
},
{
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'],
},
{
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',
},
],
});
}));

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,
},
migrationVersion: {
dashboard: resp.body.saved_objects[1].migrationVersion.dashboard,
},
{
id: BULK_REQUESTS[1].id,
type: BULK_REQUESTS[1].type,
error: {
error: 'Internal Server Error',
message: 'An internal server error occurred',
statusCode: 500,
},
},
],
});
coreMigrationVersion: KIBANA_VERSION,
references: [],
namespaces: [SPACE_ID],
},
],
});
});
});
}));

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