Skip to content

Commit

Permalink
Merge branch 'main' into add-api-test-es-function
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv authored Jul 5, 2024
2 parents efbd404 + 7968b14 commit 03f3732
Show file tree
Hide file tree
Showing 60 changed files with 470 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-operations-alerts'
allow_rebuilds: true
branch_configuration: main 8.14 7.17
branch_configuration: main 8.15 8.14 7.17
default_branch: main
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/artifacts.yml
Expand All @@ -49,6 +49,10 @@ spec:
cronline: 0 7 * * * America/New_York
message: Daily build
branch: main
Daily build (8.15):
cronline: 0 7 * * * America/New_York
message: Daily build
branch: '8.15'
Daily build (8.14):
cronline: 0 7 * * * America/New_York
message: Daily build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-operations-alerts'
allow_rebuilds: true
branch_configuration: 7.17 8.14
branch_configuration: 7.17 8.14 8.15
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/artifacts.yml
skip_intermediate_builds: false
Expand All @@ -45,6 +45,10 @@ spec:
kibana-tech-leads:
access_level: MANAGE_BUILD_AND_READ
schedules:
Daily build (8.15):
cronline: 0 7 * * * America/New_York
message: Daily build
branch: '8.15'
Daily build (8.14):
cronline: 0 7 * * * America/New_York
message: Daily build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-operations-alerts'
allow_rebuilds: true
branch_configuration: '8.14'
branch_configuration: 8.15 8.14
default_branch: main
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/artifacts_trigger.yml
Expand All @@ -46,6 +46,10 @@ spec:
kibana-tech-leads:
access_level: MANAGE_BUILD_AND_READ
schedules:
Daily build (8.15):
cronline: 0 */2 * * * America/New_York
message: Daily build
branch: '8.15'
Daily build (8.14):
cronline: 0 */2 * * * America/New_York
message: Daily build
Expand Down
10 changes: 7 additions & 3 deletions .buildkite/pipeline-resource-definitions/kibana-es-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-operations-alerts'
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
allow_rebuilds: true
branch_configuration: main 8.14 7.17
branch_configuration: main 8.15 8.14 7.17
default_branch: main
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/es_snapshots/build.yml
Expand All @@ -49,6 +49,10 @@ spec:
cronline: 0 9 * * * America/New_York
message: Daily build
branch: main
Daily build (8.15):
cronline: 0 9 * * * America/New_York
message: Daily build
branch: '8.15'
Daily build (8.14):
cronline: 0 9 * * * America/New_York
message: Daily build
Expand Down Expand Up @@ -82,7 +86,7 @@ spec:
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-operations-alerts'
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
allow_rebuilds: true
branch_configuration: main 8.14 7.17
branch_configuration: main 8.15 8.14 7.17
default_branch: main
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/es_snapshots/promote.yml
Expand Down Expand Up @@ -130,7 +134,7 @@ spec:
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
REPORT_FAILED_TESTS_TO_GITHUB: 'true'
allow_rebuilds: true
branch_configuration: main 8.14 7.17
branch_configuration: main 8.15 8.14 7.17
default_branch: main
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/es_snapshots/verify.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-unsupported-ftrs-alerts'
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
allow_rebuilds: true
branch_configuration: main 8.14 7.17
branch_configuration: main 8.15 8.14 7.17
default_branch: main
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/on_merge_unsupported_ftrs.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
REPORT_FAILED_TESTS_TO_GITHUB: 'true'
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true'
allow_rebuilds: true
branch_configuration: main 7.17 8.14
branch_configuration: main 7.17 8.14 8.15
default_branch: main
repository: elastic/kibana
pipeline_file: .buildkite/pipelines/on_merge.yml
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-check-mappings-update-cli/current_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@
"slug"
],
"usage-counter": [
"count",
"counterName",
"counterType",
"domainId",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3410,6 +3410,9 @@
"usage-counter": {
"dynamic": false,
"properties": {
"count": {
"type": "integer"
},
"counterName": {
"type": "keyword"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"uptime-dynamic-settings": "b6756ff71d6b5258971b1c8fd433d167affbde52",
"uptime-synthetics-api-key": "7ae976a461248f9dbd8442af14a179bdbc229eca",
"url": "c923a4a5002a09c0080c9095e958f07d518e6704",
"usage-counter": "3a104db0c9867da2d0436e20604a11dc5d0bb59e",
"usage-counter": "1690e9b642393c467e560fd14dd317dea24a14ee",
"usage-counters": "48782b3bcb6b5a23ba6f2bfe3a380d835e68890a",
"visualization": "93a3e73994ad836fe2b1dccbe208238f41f63da0",
"workplace_search_telemetry": "52b32b47ee576f554ac77cb1d5896dfbcfe9a1fb",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,11 @@ test('creates new embeddable with specified size if size is provided', async ()
expect(dashboard!.getState().explicitInput.panels.new_panel.gridData.h).toBe(1);
});

test('creates a control group from the control group factory and waits for it to be initialized', async () => {
test('creates a control group from the control group factory', async () => {
const mockControlGroupContainer = {
destroy: jest.fn(),
render: jest.fn(),
updateInput: jest.fn(),
untilInitialized: jest.fn(),
getInput: jest.fn().mockReturnValue({}),
getInput$: jest.fn().mockReturnValue(new Observable()),
getOutput: jest.fn().mockReturnValue({}),
Expand Down Expand Up @@ -532,7 +531,6 @@ test('creates a control group from the control group factory and waits for it to
undefined,
{ lastSavedInput: expect.objectContaining({ controlStyle: 'oneLine' }) }
);
expect(mockControlGroupContainer.untilInitialized).toHaveBeenCalled();
});

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ export const initializeDashboard = async ({
dashboardContainer.controlGroup = controlGroup;
startSyncingDashboardControlGroup.bind(dashboardContainer)();
});
await controlGroup.untilInitialized();
}

// --------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
import { dataViewComplexMock } from '../../../__mocks__/data_view_complex';
import { getDiscoverGlobalStateContainer } from './discover_global_state_container';
import { createKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';
import { VIEW_MODE } from '../../../../common/constants';
import { createSearchSourceMock } from '@kbn/data-plugin/common/search/search_source/mocks';

describe('DiscoverSavedSearchContainer', () => {
const savedSearch = savedSearchMock;
Expand Down Expand Up @@ -232,4 +234,57 @@ describe('DiscoverSavedSearchContainer', () => {
expect(savedSearchContainer.getHasChanged$().getValue()).toBe(false);
});
});

describe('isEqualSavedSearch', () => {
it('should return true for equal saved searches', () => {
const savedSearch1 = savedSearchMock;
const savedSearch2 = { ...savedSearchMock };
expect(isEqualSavedSearch(savedSearch1, savedSearch2)).toBe(true);
});

it('should return false for different saved searches', () => {
const savedSearch1 = savedSearchMock;
const savedSearch2 = { ...savedSearchMock, title: 'New title' };
expect(isEqualSavedSearch(savedSearch1, savedSearch2)).toBe(false);
});

it('should return true for saved searches with equal default values of viewMode and false otherwise', () => {
const savedSearch1 = { ...savedSearchMock, viewMode: undefined };
const savedSearch2 = { ...savedSearchMock, viewMode: VIEW_MODE.DOCUMENT_LEVEL };
const savedSearch3 = { ...savedSearchMock, viewMode: VIEW_MODE.AGGREGATED_LEVEL };
expect(isEqualSavedSearch(savedSearch1, savedSearch2)).toBe(true);
expect(isEqualSavedSearch(savedSearch2, savedSearch1)).toBe(true);
expect(isEqualSavedSearch(savedSearch1, savedSearch3)).toBe(false);
expect(isEqualSavedSearch(savedSearch2, savedSearch3)).toBe(false);
});

it('should return true for saved searches with equal default values of breakdownField and false otherwise', () => {
const savedSearch1 = { ...savedSearchMock, breakdownField: undefined };
const savedSearch2 = { ...savedSearchMock, breakdownField: '' };
const savedSearch3 = { ...savedSearchMock, breakdownField: 'test' };
expect(isEqualSavedSearch(savedSearch1, savedSearch2)).toBe(true);
expect(isEqualSavedSearch(savedSearch2, savedSearch1)).toBe(true);
expect(isEqualSavedSearch(savedSearch1, savedSearch3)).toBe(false);
expect(isEqualSavedSearch(savedSearch2, savedSearch3)).toBe(false);
});

it('should check searchSource fields', () => {
const savedSearch1 = {
...savedSearchMock,
searchSource: createSearchSourceMock({
index: savedSearchMock.searchSource.getField('index'),
}),
};
const savedSearch2 = {
...savedSearchMock,
searchSource: createSearchSourceMock({
index: savedSearchMock.searchSource.getField('index'),
}),
};
expect(isEqualSavedSearch(savedSearch1, savedSearch1)).toBe(true);
expect(isEqualSavedSearch(savedSearch1, savedSearch2)).toBe(true);
savedSearch2.searchSource.setField('query', { language: 'lucene', query: 'test' });
expect(isEqualSavedSearch(savedSearch1, savedSearch2)).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,7 @@ export function isEqualSavedSearch(savedSearchPrev: SavedSearch, savedSearchNext
const prevValue = getSavedSearchFieldForComparison(prevSavedSearch, key);
const nextValue = getSavedSearchFieldForComparison(nextSavedSearchWithoutSearchSource, key);

const isSame =
isEqual(prevValue, nextValue) ||
// By default, viewMode: undefined is equivalent to documents view
// So they should be treated as same
(key === 'viewMode' &&
(prevValue ?? VIEW_MODE.DOCUMENT_LEVEL) === (nextValue ?? VIEW_MODE.DOCUMENT_LEVEL));
const isSame = isEqual(prevValue, nextValue);

if (!isSame) {
addLog('[savedSearch] difference between initial and changed version', {
Expand Down Expand Up @@ -412,6 +407,12 @@ function getSavedSearchFieldForComparison(
return savedSearch.breakdownField || ''; // ignore the difference between an empty string and undefined
}

if (fieldName === 'viewMode') {
// By default, viewMode: undefined is equivalent to documents view
// So they should be treated as same
return savedSearch.viewMode ?? VIEW_MODE.DOCUMENT_LEVEL;
}

return savedSearch[fieldName];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import { FetchStatus } from '../../../types';
import { dataViewComplexMock } from '../../../../__mocks__/data_view_complex';
import { getDiscoverStateMock } from '../../../../__mocks__/discover_state.mock';
import { discoverServiceMock } from '../../../../__mocks__/services';
import { createDataViewDataSource } from '../../../../../common/data_sources';
import { createDataViewDataSource, DataSourceType } from '../../../../../common/data_sources';
import { VIEW_MODE } from '@kbn/saved-search-plugin/common';

describe('buildStateSubscribe', () => {
const savedSearch = savedSearchMock;
const stateContainer = getDiscoverStateMock({ savedSearch });
stateContainer.dataState.refetch$.next = jest.fn();
stateContainer.dataState.reset = jest.fn();
stateContainer.actions.setDataView = jest.fn();
stateContainer.savedSearchState.update = jest.fn();

const getSubscribeFn = () => {
return buildStateSubscribe({
Expand Down Expand Up @@ -51,6 +53,20 @@ describe('buildStateSubscribe', () => {
expect(stateContainer.dataState.refetch$.next).not.toHaveBeenCalled();
});

it('should not call refetch$ if viewMode changes', async () => {
await getSubscribeFn()({
...stateContainer.appState.getState(),
dataSource: {
type: DataSourceType.Esql,
},
viewMode: VIEW_MODE.AGGREGATED_LEVEL,
});

expect(stateContainer.dataState.refetch$.next).not.toHaveBeenCalled();
expect(stateContainer.dataState.reset).not.toHaveBeenCalled();
expect(stateContainer.savedSearchState.update).toHaveBeenCalled();
});

it('should call refetch$ if the chart is hidden', async () => {
await getSubscribeFn()({ hideChart: true });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ export const buildStateSubscribe =
const isEsqlMode = isDataSourceType(nextState.dataSource, DataSourceType.Esql);
const queryChanged = !isEqual(nextQuery, prevQuery) || !isEqual(nextQuery, prevState.query);

if (
isEsqlMode &&
isEqualState(prevState, nextState, ['dataSource', 'viewMode']) &&
!queryChanged
) {
// When there's a switch from data view to es|ql, this just leads to a cleanup of index and viewMode
if (isEsqlMode && prevState.viewMode !== nextState.viewMode && !queryChanged) {
savedSearchState.update({ nextState });
addLog('[appstate] subscribe $fetch ignored for es|ql', { prevState, nextState });
return;
}

if (isEsqlMode && isEqualState(prevState, nextState, ['dataSource']) && !queryChanged) {
// When there's a switch from data view to es|ql, this just leads to a cleanup of index
// And there's no subsequent action in this function required
addLog('[appstate] subscribe update ignored for es|ql', { prevState, nextState });
return;
Expand Down
Loading

0 comments on commit 03f3732

Please sign in to comment.