Skip to content

Commit

Permalink
[7.5] [FTR] expose new es client service (#51066) (#51176)
Browse files Browse the repository at this point in the history
* always extend all common config and expose new es client service

* replace `es` service with `legacyEs`

# Conflicts:
#	test/api_integration/apis/saved_objects/bulk_update.js
#	x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js
#	x-pack/test/functional/apps/rollup_job/rollup_jobs.js
#	x-pack/test/functional/services/transform_ui/api.ts
  • Loading branch information
Spencer authored Nov 20, 2019
1 parent b6c40ee commit cfa8232
Show file tree
Hide file tree
Showing 104 changed files with 140 additions and 110 deletions.
2 changes: 1 addition & 1 deletion test/api_integration/apis/home/sample_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');

const MILLISECOND_IN_WEEK = 1000 * 60 * 60 * 24 * 7;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
} from './lib';

export default function ({ getService }) {
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('index_patterns/* error handler', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/kql_telemetry/kql_telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { get } from 'lodash';
export default function ({ getService }) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const es = getService('es');
const es = getService('legacyEs');

describe('telemetry API', () => {
before(() => esArchiver.load('saved_objects/basic'));
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/management/saved_objects/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import expect from '@kbn/expect';

export default function ({ getService }) {
const es = getService('es');
const es = getService('legacyEs');
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/bulk_create.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

const BULK_REQUESTS = [
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/bulk_get.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

const BULK_REQUESTS = [
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('create', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('delete', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('export', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('find', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('get', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { SavedObjectsSerializer } from '../../../../src/core/server/saved_object
import { SavedObjectsSchema } from '../../../../src/core/server/saved_objects/schema';

export default ({ getService }) => {
const es = getService('es');
const es = getService('legacyEs');
const callCluster = (path, ...args) => _.get(es, path).call(es, ...args);

describe('Kibana index migration', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/saved_objects/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('update', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/api_integration/apis/ui_metric/ui_metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ReportManager, METRIC_TYPE } from '@kbn/analytics';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');

const createStatsMetric = (eventName) => ({
key: ReportManager.createMetricKey({ appName: 'myApp', type: METRIC_TYPE.CLICK, eventName }),
Expand Down
5 changes: 1 addition & 4 deletions test/api_integration/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ import { services as commonServices } from '../../common/services';
import { KibanaSupertestProvider, ElasticsearchSupertestProvider } from './supertest';

export const services = {
es: commonServices.es,
esArchiver: commonServices.esArchiver,
retry: commonServices.retry,
...commonServices,
supertest: KibanaSupertestProvider,
esSupertest: ElasticsearchSupertestProvider,
randomness: commonServices.randomness,
};
33 changes: 33 additions & 0 deletions test/common/services/elasticsearch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { format as formatUrl } from 'url';

import { Client } from '@elastic/elasticsearch';

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

export function ElasticsearchProvider({ getService }: FtrProviderContext) {
const config = getService('config');

return new Client({
nodes: [formatUrl(config.get('servers.elasticsearch'))],
requestTimeout: config.get('timeouts.esRequestTimeout'),
});
}
2 changes: 1 addition & 1 deletion test/common/services/es_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import * as KibanaServer from './kibana_server';

export function EsArchiverProvider({ getService, hasService }: FtrProviderContext): EsArchiver {
const config = getService('config');
const client = getService('es');
const client = getService('legacyEs');
const log = getService('log');

if (!config.get('esArchiver')) {
Expand Down
4 changes: 3 additions & 1 deletion test/common/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
*/

import { LegacyEsProvider } from './legacy_es';
import { ElasticsearchProvider } from './elasticsearch';
import { EsArchiverProvider } from './es_archiver';
import { KibanaServerProvider } from './kibana_server';
import { RetryProvider } from './retry';
import { RandomnessProvider } from './randomness';

export const services = {
es: LegacyEsProvider,
legacyEs: LegacyEsProvider,
es: ElasticsearchProvider,
esArchiver: EsArchiverProvider,
kibanaServer: KibanaServerProvider,
retry: RetryProvider,
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/management/_handle_alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import expect from '@kbn/expect';

export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const es = getService('es');
const es = getService('legacyEs');
const retry = getService('retry');
const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import expect from '@kbn/expect';
export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const browser = getService('browser');
const es = getService('es');
const es = getService('legacyEs');
const retry = getService('retry');
const scriptedFiledName = 'versionConflictScript';
const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'header']);
Expand Down
4 changes: 1 addition & 3 deletions test/server_integration/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export default async function ({ readConfigFile }) {

return {
services: {
es: commonConfig.get('services.es'),
esArchiver: commonConfig.get('services.esArchiver'),
retry: commonConfig.get('services.retry'),
...commonConfig.get('services'),
supertest: KibanaSupertestProvider,
supertestWithoutAuth: KibanaSupertestWithoutAuthProvider,
esSupertest: ElasticsearchSupertestProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ES_TEST_INDEX_NAME = 'functional-test-actions-index';

// eslint-disable-next-line import/no-default-export
export default function indexTest({ getService }: FtrProviderContext) {
const es = getService('es');
const es = getService('legacyEs');
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
export default function({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const es = getService('es');
const es = getService('legacyEs');
const retry = getService('retry');
const esTestIndexTool = new ESTestIndexTool(es, retry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
// eslint-disable-next-line import/no-default-export
export default function alertTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const retry = getService('retry');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const esTestIndexTool = new ESTestIndexTool(es, retry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function createAlertTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const supertestWithoutAuth = getService('supertestWithoutAuth');

describe('create', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function createDeleteTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const supertestWithoutAuth = getService('supertestWithoutAuth');

describe('delete', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function createDisableAlertTests({ getService }: FtrProviderContext) {
const es = getService('es');
const es = getService('legacyEs');
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function createEnableAlertTests({ getService }: FtrProviderContext) {
const es = getService('es');
const es = getService('legacyEs');
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ES_TEST_INDEX_NAME = 'functional-test-actions-index';

// eslint-disable-next-line import/no-default-export
export default function indexTest({ getService }: FtrProviderContext) {
const es = getService('es');
const es = getService('legacyEs');
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');
const retry = getService('retry');
const esTestIndexTool = new ESTestIndexTool(es, retry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
// eslint-disable-next-line import/no-default-export
export default function alertTests({ getService }: FtrProviderContext) {
const supertestWithoutAuth = getService('supertestWithoutAuth');
const es = getService('es');
const es = getService('legacyEs');
const retry = getService('retry');
const esTestIndexTool = new ESTestIndexTool(es, retry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function createAlertTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');

describe('create', () => {
const objectRemover = new ObjectRemover(supertest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function createDeleteTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');

describe('delete', () => {
const objectRemover = new ObjectRemover(supertest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function createDisableAlertTests({ getService }: FtrProviderContext) {
const es = getService('es');
const es = getService('legacyEs');
const supertestWithoutAuth = getService('supertestWithoutAuth');

describe('disable', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function createEnableAlertTests({ getService }: FtrProviderContext) {
const es = getService('es');
const es = getService('legacyEs');
const supertestWithoutAuth = getService('supertestWithoutAuth');

describe('enable', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ES_INDEX_NAME } from './constants';
export default function ({ getService }) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const es = getService('es');
const es = getService('legacyEs');
const randomness = getService('randomness');

describe('assign_tags_to_beats', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ES_INDEX_NAME } from './constants';

export default function ({ getService }) {
const supertest = getService('supertest');
const es = getService('es');
const es = getService('legacyEs');

describe('create_enrollment_token', () => {
it('should create one token by default', async () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/beats/enroll_beat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ES_INDEX_NAME } from './constants';
export default function ({ getService }) {
const supertest = getService('supertest');
const randomness = getService('randomness');
const es = getService('es');
const es = getService('legacyEs');

describe('enroll_beat', () => {
let validEnrollmentToken;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/beats/get_beat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ES_INDEX_NAME } from './constants';
export default function ({ getService }) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const es = getService('es');
const es = getService('legacyEs');

describe('get_beat_configuration', () => {
const archive = 'beats/list';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/beats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { ES_INDEX_NAME } from './constants';

export default function ({ getService, loadTestFile }) {
const es = getService('es');
const es = getService('legacyEs');

describe('beats', () => {
const cleanup = () =>
Expand Down
Loading

0 comments on commit cfa8232

Please sign in to comment.