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

[FTR] Support for deployment agnostic e2e tests #161574

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,5 @@ enabled:
- x-pack/performance/journeys/apm_service_inventory.ts
- x-pack/test/custom_branding/config.ts
- x-pack/test/profiling_api_integration/cloud/config.ts
- x-pack/test/api_integration/apis/all_deployments/config.ts
- x-pack/test/functional/apps/all_deployments/config.ts
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const DEV_PATTERNS = [
...DEV_FILE_PATTERNS.map((file) => `{packages,src,x-pack}/**/${file}`),
'packages/kbn-interpreter/tasks/**/*',
'src/dev/**/*',
'x-pack/{dev-tools,tasks,test,test_serverless,build_chromium}/**/*',
'x-pack/{dev-tools,tasks,test,test_all_deployments,test_serverless,build_chromium}/**/*',
'x-pack/performance/**/*',
'src/setup_node_env/index.js',
'src/cli/dev.js',
Expand Down Expand Up @@ -603,6 +603,7 @@ module.exports = {
'x-pack/test/ui_capabilities/*/tests/**/*',
'x-pack/test/performance/**/*.ts',
'**/cypress.config.{js,ts}',
'x-pack/test_all_deployments/*/test_suites/**/*',
'x-pack/test_serverless/**/config*.ts',
'x-pack/test_serverless/*/test_suites/**/*',
'x-pack/test/profiling_api_integration/**/*.ts',
Expand Down
25 changes: 25 additions & 0 deletions x-pack/test/api_integration/apis/all_deployments/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrConfigProviderContext } from '@kbn/test';

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const baseIntegrationTestsConfig = await readConfigFile(require.resolve('../../config.ts'));

return {
...baseIntegrationTestsConfig.getAll(),
testFiles: [
require.resolve('../../../../test_all_deployments/api_integration/test_suites/common'),
require.resolve('../../../../test_all_deployments/api_integration/test_suites/observability'),
require.resolve('../../../../test_all_deployments/api_integration/test_suites/search'),
require.resolve('../../../../test_all_deployments/api_integration/test_suites/security'),
],
junit: {
reportName: 'X-Pack API Integration Tests - all deployments tests',
},
};
}
31 changes: 31 additions & 0 deletions x-pack/test/common/services/common_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';

import { FtrProviderContext } from '../ftr_provider_context';

const COMMON_REQUEST_HEADERS = {
'kbn-xsrf': 'some-xsrf-token',
};

export function CommonApiServiceProvider({}: FtrProviderContext) {
return {
getCommonRequestHeader() {
return COMMON_REQUEST_HEADERS;
},

assertResponseStatusCode(expectedStatus: number, actualStatus: number, responseBody: object) {
expect(actualStatus).to.eql(
expectedStatus,
`Expected status code ${expectedStatus}, got ${actualStatus} with body '${JSON.stringify(
responseBody
)}'`
);
},
};
}
2 changes: 2 additions & 0 deletions x-pack/test/common/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import { services as kibanaCommonServices } from '../../../../test/common/servic
import { InfraLogViewsServiceProvider } from './infra_log_views';
import { SpacesServiceProvider } from './spaces';
import { BsearchSecureService } from './bsearch_secure';
import { CommonApiServiceProvider } from './common_api';

export const services = {
...kibanaCommonServices,
infraLogViews: InfraLogViewsServiceProvider,
supertest: kibanaApiIntegrationServices.supertest,
spaces: SpacesServiceProvider,
secureBsearch: BsearchSecureService,
commonApi: CommonApiServiceProvider,
};
25 changes: 25 additions & 0 deletions x-pack/test/functional/apps/all_deployments/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrConfigProviderContext } from '@kbn/test';

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const baseIntegrationTestsConfig = await readConfigFile(require.resolve('../../config.base.js'));

return {
...baseIntegrationTestsConfig.getAll(),
testFiles: [
require.resolve('../../../../test_all_deployments/functional/test_suites/common'),
require.resolve('../../../../test_all_deployments/functional/test_suites/observability'),
require.resolve('../../../../test_all_deployments/functional/test_suites/search'),
require.resolve('../../../../test_all_deployments/functional/test_suites/security'),
],
junit: {
reportName: 'Chrome X-Pack UI Functional Tests - all deployments tests',
},
};
}
5 changes: 5 additions & 0 deletions x-pack/test_all_deployments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Kibana tests for all deployments

TBD, structure and additional explanations, e.g.
* no dedicated config
* no dedicated services / page objects - only x-pack version available (no serverless)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { GenericFtrProviderContext } from '@kbn/test';

// eslint-disable-next-line @kbn/imports/no_boundary_crossing
import { services } from '../../test/api_integration/services';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, {}>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('all deployments common API', function () {
loadTestFile(require.resolve('./status'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const commonApi = getService('commonApi');
const supertest = getService('supertest');

describe('Status API', function () {
it('gets the status', async () => {
const { body, status } = await supertest
.get(`/api/status`)
.set(commonApi.getCommonRequestHeader());

commonApi.assertResponseStatusCode(200, status, body);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('all deployments observability API', function () {
loadTestFile(require.resolve('./status'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const commonApi = getService('commonApi');
const supertest = getService('supertest');

// This is a dummy test. Replace with something useful!
describe('Status API', function () {
it('gets the status', async () => {
const { body, status } = await supertest
.get(`/api/status`)
.set(commonApi.getCommonRequestHeader());

commonApi.assertResponseStatusCode(200, status, body);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('all deployments search API', function () {
loadTestFile(require.resolve('./status'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const commonApi = getService('commonApi');
const supertest = getService('supertest');

// This is a dummy test. Replace with something useful!
describe('Status API', function () {
it('gets the status', async () => {
const { body, status } = await supertest
.get(`/api/status`)
.set(commonApi.getCommonRequestHeader());

commonApi.assertResponseStatusCode(200, status, body);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('all deployments security API', function () {
loadTestFile(require.resolve('./status'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const commonApi = getService('commonApi');
const supertest = getService('supertest');

// This is a dummy test. Replace with something useful!
describe('Status API', function () {
it('gets the status', async () => {
const { body, status } = await supertest
.get(`/api/status`)
.set(commonApi.getCommonRequestHeader());

commonApi.assertResponseStatusCode(200, status, body);
});
});
}
16 changes: 16 additions & 0 deletions x-pack/test_all_deployments/functional/ftr_provider_context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { GenericFtrProviderContext } from '@kbn/test';

// eslint-disable-next-line @kbn/imports/no_boundary_crossing
import { services } from '../../test/functional/page_objects';

// eslint-disable-next-line @kbn/imports/no_boundary_crossing
import { services } from '../../test/functional/services';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getPageObject, getService }: FtrProviderContext) {
const commonPage = getPageObject('common');
const testSubjects = getService('testSubjects');

describe('home page', function () {
it('navigates to home page', async () => {
await commonPage.navigateToApp('home');
await testSubjects.existOrFail('homeApp', { timeout: 2000 });
});
});
}
14 changes: 14 additions & 0 deletions x-pack/test_all_deployments/functional/test_suites/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('all deployments common UI', function () {
loadTestFile(require.resolve('./home_page'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getPageObject, getService }: FtrProviderContext) {
const commonPage = getPageObject('common');
const testSubjects = getService('testSubjects');

// This is a dummy test. Replace with something useful!
describe('home page', function () {
it('navigates to home page', async () => {
await commonPage.navigateToApp('home');
await testSubjects.existOrFail('homeApp', { timeout: 2000 });
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('all deployments observability UI', function () {
loadTestFile(require.resolve('./home_page'));
});
}
Loading