Skip to content

Commit

Permalink
[TSVB] Remove vis_type_timeseries_enhanced plugin (elastic#89274)
Browse files Browse the repository at this point in the history
* [TSVB] get rid of vis_type_timeseries_enhanced

* add search strategy should be called from setup hook

* remove vis_type_timeseries_enhanced from CODEOWNERS

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	.github/CODEOWNERS
  • Loading branch information
alexwizp committed Jan 28, 2021
1 parent 983e2e4 commit 9719f5e
Show file tree
Hide file tree
Showing 31 changed files with 127 additions and 198 deletions.
4 changes: 0 additions & 4 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,6 @@ in their infrastructure.
|NOTE: This plugin contains implementation of URL drilldown. For drilldowns infrastructure code refer to ui_actions_enhanced plugin.
|{kib-repo}blob/{branch}/x-pack/plugins/vis_type_timeseries_enhanced/README.md[visTypeTimeseriesEnhanced]
|The vis_type_timeseries_enhanced plugin is the x-pack counterpart to the OSS vis_type_timeseries plugin.
|{kib-repo}blob/{branch}/x-pack/plugins/watcher/README.md[watcher]
|This plugins adopts some conventions in addition to or in place of conventions in Kibana (at the time of the plugin's creation):
Expand Down
9 changes: 0 additions & 9 deletions src/plugins/vis_type_timeseries/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ export const config: PluginConfigDescriptor<VisTypeTimeseriesConfig> = {
schema: configSchema,
};

export {
AbstractSearchStrategy,
ReqFacade,
} from './lib/search_strategies/strategies/abstract_search_strategy';

export { VisPayload } from '../common/types';

export { DefaultSearchCapabilities } from './lib/search_strategies/default_search_capabilities';

export function plugin(initializerContext: PluginInitializerContext) {
return new VisTypeTimeseriesPlugin(initializerContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { DefaultSearchCapabilities } from './default_search_capabilities';
import { ReqFacade } from './strategies/abstract_search_strategy';
import { VisPayload } from '../../../common/types';
import type { ReqFacade } from '../strategies/abstract_search_strategy';
import type { VisPayload } from '../../../../common/types';

describe('DefaultSearchCapabilities', () => {
let defaultSearchCapabilities: DefaultSearchCapabilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
convertIntervalToUnit,
parseInterval,
getSuitableUnit,
} from '../vis_data/helpers/unit_to_seconds';
import { RESTRICTIONS_KEYS } from '../../../common/ui_restrictions';
import { ReqFacade } from './strategies/abstract_search_strategy';
import { VisPayload } from '../../../common/types';
} from '../../vis_data/helpers/unit_to_seconds';
import { RESTRICTIONS_KEYS } from '../../../../common/ui_restrictions';
import type { ReqFacade } from '../strategies/abstract_search_strategy';
import type { VisPayload } from '../../../../common/types';

const getTimezoneFromRequest = (request: ReqFacade<VisPayload>) => {
return request.payload.timerange.timezone;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +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;
* you may not use this file except in compliance with the Elastic License.
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import { Unit } from '@elastic/datemath';
import { RollupSearchCapabilities } from './rollup_search_capabilities';

import { ReqFacade, VisPayload } from '../../../../../src/plugins/vis_type_timeseries/server';
import type { VisPayload } from '../../../../common/types';
import type { ReqFacade } from '../strategies/abstract_search_strategy';

describe('Rollup Search Capabilities', () => {
const testTimeZone = 'time_zone';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import { get, has } from 'lodash';
import { leastCommonInterval, isCalendarInterval } from './lib/interval_helper';
import { leastCommonInterval, isCalendarInterval } from '../lib/interval_helper';

import { DefaultSearchCapabilities } from './default_search_capabilities';

import {
ReqFacade,
DefaultSearchCapabilities,
VisPayload,
} from '../../../../../src/plugins/vis_type_timeseries/server';
import type { VisPayload } from '../../../../common/types';
import type { ReqFacade } from '../strategies/abstract_search_strategy';

export class RollupSearchCapabilities extends DefaultSearchCapabilities {
rollupIndex: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@
*/

export { SearchStrategyRegistry } from './search_strategy_registry';
export { DefaultSearchCapabilities } from './capabilities/default_search_capabilities';

export {
AbstractSearchStrategy,
ReqFacade,
RollupSearchStrategy,
DefaultSearchStrategy,
} from './strategies';
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import { isCalendarInterval, leastCommonInterval } from './interval_helper';

describe('interval_helper', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import dateMath from '@elastic/datemath';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/
import { get } from 'lodash';
import { RequestFacade, SearchStrategyRegistry } from './search_strategy_registry';
import { AbstractSearchStrategy, DefaultSearchStrategy } from './strategies';
import { DefaultSearchCapabilities } from './capabilities/default_search_capabilities';

import { SearchStrategyRegistry } from './search_strategy_registry';
// @ts-ignore
import { AbstractSearchStrategy } from './strategies/abstract_search_strategy';
// @ts-ignore
import { DefaultSearchStrategy } from './strategies/default_search_strategy';
// @ts-ignore
import { DefaultSearchCapabilities } from './default_search_capabilities';
const getPrivateField = <T>(registry: SearchStrategyRegistry, field: string) =>
get(registry, field) as T;

class MockSearchStrategy extends AbstractSearchStrategy {
checkForViability() {
Expand All @@ -28,23 +27,21 @@ describe('SearchStrategyRegister', () => {

beforeAll(() => {
registry = new SearchStrategyRegistry();
registry.addStrategy(new DefaultSearchStrategy());
});

test('should init strategies register', () => {
expect(
registry.addStrategy({} as AbstractSearchStrategy)[0] instanceof DefaultSearchStrategy
).toBe(true);
expect(getPrivateField(registry, 'strategies')).toHaveLength(1);
});

test('should not add a strategy if it is not an instance of AbstractSearchStrategy', () => {
const addedStrategies = registry.addStrategy({} as AbstractSearchStrategy);

expect(addedStrategies.length).toEqual(1);
expect(addedStrategies[0] instanceof DefaultSearchStrategy).toBe(true);
});

test('should return a DefaultSearchStrategy instance', async () => {
const req = {};
const req = {} as RequestFacade;
const indexPattern = '*';

const { searchStrategy, capabilities } = (await registry.getViableStrategy(req, indexPattern))!;
Expand All @@ -62,7 +59,7 @@ describe('SearchStrategyRegister', () => {
});

test('should return a MockSearchStrategy instance', async () => {
const req = {};
const req = {} as RequestFacade;
const indexPattern = '*';
const anotherSearchStrategy = new MockSearchStrategy();
registry.addStrategy(anotherSearchStrategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,15 @@
* Public License, v 1.
*/

import { AbstractSearchStrategy } from './strategies/abstract_search_strategy';
// @ts-ignore
import { DefaultSearchStrategy } from './strategies/default_search_strategy';
// @ts-ignore
import { extractIndexPatterns } from '../../../common/extract_index_patterns';

export type RequestFacade = any;

import { PanelSchema } from '../../../common/types';
import { AbstractSearchStrategy, ReqFacade } from './strategies';

export type RequestFacade = ReqFacade<any>;

export class SearchStrategyRegistry {
private strategies: AbstractSearchStrategy[] = [];

constructor() {
this.addStrategy(new DefaultSearchStrategy());
}

public addStrategy(searchStrategy: AbstractSearchStrategy) {
if (searchStrategy instanceof AbstractSearchStrategy) {
this.strategies.unshift(searchStrategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,35 @@
*/

import { from } from 'rxjs';
import { AbstractSearchStrategy } from './abstract_search_strategy';
import { AbstractSearchStrategy, ReqFacade } from './abstract_search_strategy';
import type { VisPayload } from '../../../../common/types';
import type { IFieldType } from '../../../../../data/common';

class FooSearchStrategy extends AbstractSearchStrategy {}

describe('AbstractSearchStrategy', () => {
let abstractSearchStrategy;
let req;
let mockedFields;
let indexPattern;
let abstractSearchStrategy: AbstractSearchStrategy;
let req: ReqFacade;
let mockedFields: IFieldType[];
let indexPattern: string;

beforeEach(() => {
mockedFields = [];
req = {
req = ({
payload: {},
pre: {
indexPatternsFetcher: {
getFieldsForWildcard: jest.fn().mockReturnValue(mockedFields),
},
},
getIndexPatternsService: jest.fn(() => ({
find: jest.fn(() => []),
})),
};
getIndexPatternsService: jest.fn(() =>
Promise.resolve({
find: jest.fn(() => []),
})
),
} as unknown) as ReqFacade<VisPayload>;

abstractSearchStrategy = new AbstractSearchStrategy();
abstractSearchStrategy = new FooSearchStrategy();
});

test('should init an AbstractSearchStrategy instance', () => {
Expand All @@ -42,7 +48,7 @@ describe('AbstractSearchStrategy', () => {
const fields = await abstractSearchStrategy.getFieldsForWildcard(req, indexPattern);

expect(fields).toEqual(mockedFields);
expect(req.pre.indexPatternsFetcher.getFieldsForWildcard).toHaveBeenCalledWith({
expect(req.pre.indexPatternsFetcher!.getFieldsForWildcard).toHaveBeenCalledWith({
pattern: indexPattern,
metaFields: [],
fieldCapsOptions: { allow_no_indices: true },
Expand All @@ -54,7 +60,7 @@ describe('AbstractSearchStrategy', () => {
const searchFn = jest.fn().mockReturnValue(from(Promise.resolve({})));

const responses = await abstractSearchStrategy.search(
{
({
payload: {
searchSession: {
sessionId: '1',
Expand All @@ -65,7 +71,7 @@ describe('AbstractSearchStrategy', () => {
requestContext: {
search: { search: searchFn },
},
},
} as unknown) as ReqFacade<VisPayload>,
searches
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

import type { FakeRequest, IUiSettingsClient, SavedObjectsClientContract } from 'kibana/server';

import { indexPatterns } from '../../../../../data/server';

import type { Framework } from '../../../plugin';
import type { IndexPatternsFetcher, IFieldType } from '../../../../../data/server';
import type { VisPayload } from '../../../../common/types';
import type { IndexPatternsService } from '../../../../../data/common';
import { indexPatterns } from '../../../../../data/server';
import { SanitizedFieldType } from '../../../../common/types';
import type { SanitizedFieldType } from '../../../../common/types';
import type { VisTypeTimeseriesRequestHandlerContext } from '../../../types';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { DefaultSearchStrategy } from './default_search_strategy';
import { ReqFacade } from './abstract_search_strategy';
import { VisPayload } from '../../../../common/types';
import type { ReqFacade } from './abstract_search_strategy';
import type { VisPayload } from '../../../../common/types';

describe('DefaultSearchStrategy', () => {
let defaultSearchStrategy: DefaultSearchStrategy;
Expand All @@ -20,7 +20,6 @@ describe('DefaultSearchStrategy', () => {
});

test('should init an DefaultSearchStrategy instance', () => {
expect(defaultSearchStrategy.name).toBe('default');
expect(defaultSearchStrategy.checkForViability).toBeDefined();
expect(defaultSearchStrategy.search).toBeDefined();
expect(defaultSearchStrategy.getFieldsForWildcard).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
*/

import { AbstractSearchStrategy, ReqFacade } from './abstract_search_strategy';
import { DefaultSearchCapabilities } from '../default_search_capabilities';
import { DefaultSearchCapabilities } from '../capabilities/default_search_capabilities';
import { VisPayload } from '../../../../common/types';

export class DefaultSearchStrategy extends AbstractSearchStrategy {
name = 'default';

checkForViability(req: ReqFacade<VisPayload>) {
return Promise.resolve({
isViable: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

export { AbstractSearchStrategy, ReqFacade } from './abstract_search_strategy';
export { DefaultSearchStrategy } from './default_search_strategy';
export { RollupSearchStrategy } from './rollup_search_strategy';
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import { RollupSearchStrategy } from './rollup_search_strategy';
import type { ReqFacade, VisPayload } from '../../../../../src/plugins/vis_type_timeseries/server';

jest.mock('../../../../../src/plugins/vis_type_timeseries/server', () => {
const actual = jest.requireActual('../../../../../src/plugins/vis_type_timeseries/server');
import type { VisPayload } from '../../../../common/types';
import type { ReqFacade } from './abstract_search_strategy';

jest.mock('./abstract_search_strategy', () => {
class AbstractSearchStrategyMock {
getFieldsForWildcard() {
return [
Expand All @@ -23,7 +27,6 @@ jest.mock('../../../../../src/plugins/vis_type_timeseries/server', () => {
}

return {
...actual,
AbstractSearchStrategy: AbstractSearchStrategyMock,
};
});
Expand Down Expand Up @@ -52,7 +55,7 @@ describe('Rollup Search Strategy', () => {
test('should create instance of RollupSearchRequest', () => {
const rollupSearchStrategy = new RollupSearchStrategy();

expect(rollupSearchStrategy.name).toBe('rollup');
expect(rollupSearchStrategy).toBeDefined();
});

describe('checkForViability', () => {
Expand Down
Loading

0 comments on commit 9719f5e

Please sign in to comment.