Skip to content

Commit

Permalink
Merge branch 'main' into fix-flaky-metering-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenIdo authored Oct 28, 2024
2 parents 00c60a0 + a8048dd commit cf39df3
Show file tree
Hide file tree
Showing 117 changed files with 460 additions and 341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ const maxDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -1035,7 +1035,7 @@ const minDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -1491,7 +1491,7 @@ const topDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics'],
Expand Down Expand Up @@ -1590,7 +1590,7 @@ const valuesDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ const coalesceDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
minParams: 1,
},
{
Expand All @@ -957,7 +957,7 @@ const coalesceDefinition: FunctionDefinition = {
optional: true,
},
],
returnType: 'text',
returnType: 'keyword',
minParams: 1,
},
{
Expand Down Expand Up @@ -1973,7 +1973,7 @@ const greatestDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
minParams: 1,
},
{
Expand All @@ -1989,7 +1989,7 @@ const greatestDefinition: FunctionDefinition = {
optional: true,
},
],
returnType: 'text',
returnType: 'keyword',
minParams: 1,
},
{
Expand Down Expand Up @@ -2484,7 +2484,7 @@ const leastDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
minParams: 1,
},
{
Expand All @@ -2500,7 +2500,7 @@ const leastDefinition: FunctionDefinition = {
optional: true,
},
],
returnType: 'text',
returnType: 'keyword',
minParams: 1,
},
{
Expand Down Expand Up @@ -3198,7 +3198,7 @@ const ltrimDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
Expand Down Expand Up @@ -3475,7 +3475,7 @@ const mvAppendDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -3920,7 +3920,7 @@ const mvDedupeDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -4067,7 +4067,7 @@ const mvFirstDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -4224,7 +4224,7 @@ const mvLastDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -4341,7 +4341,7 @@ const mvMaxDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -4583,7 +4583,7 @@ const mvMinDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -5054,7 +5054,7 @@ const mvSliceDefinition: FunctionDefinition = {
optional: true,
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -5221,7 +5221,7 @@ const mvSortDefinition: FunctionDefinition = {
acceptedValues: ['asc', 'desc'],
},
],
returnType: 'text',
returnType: 'keyword',
},
{
params: [
Expand Down Expand Up @@ -6131,7 +6131,7 @@ const reverseDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
Expand Down Expand Up @@ -6323,7 +6323,7 @@ const rtrimDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
Expand Down Expand Up @@ -8597,7 +8597,7 @@ const toLowerDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
Expand Down Expand Up @@ -8995,7 +8995,7 @@ const toUpperDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
Expand Down Expand Up @@ -9077,7 +9077,7 @@ const trimDefinition: FunctionDefinition = {
optional: false,
},
],
returnType: 'text',
returnType: 'keyword',
},
],
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useKibana } from '../../../common/lib/kibana';

export const TopValuesPopover = React.memo(() => {
const { pathname } = useLocation();
const { browserFields, indexPattern } = useSourcererDataView(getScopeFromPath(pathname));
const { browserFields, sourcererDataView } = useSourcererDataView(getScopeFromPath(pathname));
const {
services: { topValuesPopover },
} = useKibana();
Expand Down Expand Up @@ -44,7 +44,7 @@ export const TopValuesPopover = React.memo(() => {
showLegend
scopeId={data.scopeId}
toggleTopN={onClose}
indexPattern={indexPattern}
dataViewSpec={sourcererDataView}
browserFields={browserFields}
/>
</EuiWrappingPopover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ const StatefulEventsViewerComponent: React.FC<EventsViewerProps & PropsFromRedux
const {
browserFields,
dataViewId,
indexPattern,
sourcererDataView,
selectedPatterns,
sourcererDataView,
dataViewId: selectedDataViewId,
loading: isLoadingIndexPattern,
} = useSourcererDataView(sourcererScope);
Expand Down Expand Up @@ -271,12 +270,12 @@ const StatefulEventsViewerComponent: React.FC<EventsViewerProps & PropsFromRedux
dataProviders: [],
filters: globalFilters,
from: start,
indexPattern,
indexPattern: sourcererDataView,
kqlMode: 'filter',
kqlQuery: query,
to: end,
}),
[esQueryConfig, browserFields, globalFilters, start, indexPattern, query, end]
[esQueryConfig, browserFields, globalFilters, start, sourcererDataView, query, end]
);

const canQueryTimeline = useMemo(
Expand Down Expand Up @@ -318,7 +317,7 @@ const StatefulEventsViewerComponent: React.FC<EventsViewerProps & PropsFromRedux
id: tableId,
indexNames: indexNames ?? selectedPatterns,
limit: itemsPerPage,
runtimeMappings: sourcererDataView?.runtimeFieldMap as RunTimeMappings,
runtimeMappings: sourcererDataView.runtimeFieldMap as RunTimeMappings,
skip: !canQueryTimeline,
sort: sortField,
startDate: start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const InsightEditorComponent = ({
onCancel,
}: EuiMarkdownEditorUiPluginEditorProps<InsightComponentProps & { relativeTimerange: string }>) => {
const isEditMode = node != null;
const { indexPattern } = useSourcererDataView(SourcererScopeName.default);
const { sourcererDataView } = useSourcererDataView(SourcererScopeName.default);
const {
unifiedSearch: {
ui: { FiltersBuilderLazy },
Expand Down Expand Up @@ -400,7 +400,7 @@ const InsightEditorComponent = ({
);
}, [labelController.field.value, providers, dataView]);
const filtersStub = useMemo(() => {
const index = indexPattern && indexPattern.getName ? indexPattern.getName() : '*';
const index = sourcererDataView.name ?? '*';
return [
{
$state: {
Expand All @@ -414,7 +414,7 @@ const InsightEditorComponent = ({
},
},
];
}, [indexPattern]);
}, [sourcererDataView]);
const isPlatinum = useLicense().isAtLeast('platinum');

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const useInsightQuery = ({
}: UseInsightQuery): UseInsightQueryResult => {
const { uiSettings } = useKibana().services;
const esQueryConfig = useMemo(() => getEsQueryConfig(uiSettings), [uiSettings]);
const { browserFields, selectedPatterns, indexPattern, dataViewId } = useSourcererDataView(
const { browserFields, selectedPatterns, sourcererDataView, dataViewId } = useSourcererDataView(
SourcererScopeName.timeline
);
const [hasError, setHasError] = useState(false);
Expand All @@ -51,7 +51,7 @@ export const useInsightQuery = ({
const parsedCombinedQueries = combineQueries({
config: esQueryConfig,
dataProviders,
indexPattern,
indexPattern: sourcererDataView,
browserFields,
filters,
kqlQuery: {
Expand All @@ -66,7 +66,7 @@ export const useInsightQuery = ({
setHasError(true);
return null;
}
}, [browserFields, dataProviders, esQueryConfig, hasError, indexPattern, filters]);
}, [browserFields, dataProviders, esQueryConfig, hasError, sourcererDataView, filters]);

const [dataLoadingState, { events, totalCount }] = useTimelineEvents({
dataViewId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mount } from 'enzyme';
import React from 'react';
import { waitFor } from '@testing-library/react';
import { mockBrowserFields } from '../../containers/source/mock';
import { mockGlobalState, TestProviders, mockIndexPattern, createMockStore } from '../../mock';
import { mockGlobalState, TestProviders, createMockStore, mockDataViewSpec } from '../../mock';
import type { State } from '../../store';

import type { Props } from './top_n';
Expand Down Expand Up @@ -145,7 +145,7 @@ const store = createMockStore(state);
const testProps = {
browserFields: mockBrowserFields,
field,
indexPattern: mockIndexPattern,
indexPattern: mockDataViewSpec,
scopeId: TableId.hostsPageEvents,
toggleTopN: jest.fn(),
onFilterAdded: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import React, { useMemo } from 'react';
import type { ConnectedProps } from 'react-redux';
import { connect } from 'react-redux';

import type { DataViewBase, Filter, Query } from '@kbn/es-query';
import { getEsQueryConfig } from '@kbn/data-plugin/common';
import type { Filter, Query } from '@kbn/es-query';
import { type DataViewSpec, getEsQueryConfig } from '@kbn/data-plugin/common';
import { isActiveTimeline } from '../../../helpers';
import { InputsModelId } from '../../store/inputs/constants';
import { useGlobalTime } from '../../containers/use_global_time';
Expand Down Expand Up @@ -77,7 +77,7 @@ const connector = connect(makeMapStateToProps);
export interface OwnProps {
browserFields: BrowserFields;
field: string;
indexPattern: DataViewBase;
dataViewSpec?: DataViewSpec;
scopeId?: string;
toggleTopN: () => void;
onFilterAdded?: () => void;
Expand All @@ -97,7 +97,7 @@ const StatefulTopNComponent: React.FC<Props> = ({
browserFields,
dataProviders,
field,
indexPattern,
dataViewSpec: indexPattern,
globalFilters = EMPTY_FILTERS,
globalQuery = EMPTY_QUERY,
kqlMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mount } from 'enzyme';
import React from 'react';
import { waitFor } from '@testing-library/react';

import { TestProviders, mockIndexPattern } from '../../mock';
import { TestProviders, mockDataViewSpec } from '../../mock';

import { allEvents, defaultOptions } from './helpers';
import type { Props as TopNProps } from './top_n';
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('TopN', () => {
field,
filters: [],
from: '2020-04-14T00:31:47.695Z',
indexPattern: mockIndexPattern,
indexPattern: mockDataViewSpec,
options: defaultOptions,
query,
setAbsoluteRangeDatePickerTarget: InputsModelId.global,
Expand Down
Loading

0 comments on commit cf39df3

Please sign in to comment.