From dd9b52fd41396287693223fd5050ca811a99ade7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Fri, 18 Feb 2022 12:05:29 +0100 Subject: [PATCH] log-volume: adjust request-id to avoid conflicts (#45511) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * log-volume: adjust request-id to avoid conflicts * added unit test * simplify test Co-authored-by: Piotr Jamróz * added missing import Co-authored-by: Piotr Jamróz --- .../app/features/explore/state/query.test.ts | 20 +++++++++++++++++++ public/app/features/explore/state/query.ts | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/public/app/features/explore/state/query.test.ts b/public/app/features/explore/state/query.test.ts index 2accb2fa55b..9aa8bcad2ac 100644 --- a/public/app/features/explore/state/query.test.ts +++ b/public/app/features/explore/state/query.test.ts @@ -21,6 +21,7 @@ import { DataQueryResponse, DataSourceApi, DataSourceJsonData, + DataSourceWithLogsVolumeSupport, DefaultTimeZone, LoadingState, MutableDataFrame, @@ -54,6 +55,7 @@ const defaultInitialState = { datasourceInstance: { query: jest.fn(), getRef: jest.fn(), + getLogsVolumeDataProvider: jest.fn(), meta: { id: 'something', }, @@ -101,6 +103,24 @@ describe('runQueries', () => { expect(getState().explore[ExploreId.left].graphResult).toBeDefined(); }); + it('should modify the request-id for log-volume queries', async () => { + setTimeSrv({ init() {} } as any); + const { dispatch, getState } = configureStore({ + ...(defaultInitialState as any), + }); + setupQueryResponse(getState()); + await dispatch(runQueries(ExploreId.left)); + + const state = getState().explore[ExploreId.left]; + expect(state.queryResponse.request?.requestId).toBe('explore_left'); + const datasource = state.datasourceInstance as any as DataSourceWithLogsVolumeSupport; + expect(datasource.getLogsVolumeDataProvider).toBeCalledWith( + expect.objectContaining({ + requestId: 'explore_left_log_volume', + }) + ); + }); + it('should set state to done if query completes without emitting', async () => { setTimeSrv({ init() {} } as any); const { dispatch, getState } = configureStore({ diff --git a/public/app/features/explore/state/query.ts b/public/app/features/explore/state/query.ts index 9825a6a1dfc..730d81177a7 100644 --- a/public/app/features/explore/state/query.ts +++ b/public/app/features/explore/state/query.ts @@ -497,7 +497,11 @@ export const runQueries = ( ); dispatch(cleanLogsVolumeAction({ exploreId })); } else if (hasLogsVolumeSupport(datasourceInstance)) { - const logsVolumeDataProvider = datasourceInstance.getLogsVolumeDataProvider(transaction.request); + const sourceRequest = { + ...transaction.request, + requestId: transaction.request.requestId + '_log_volume', + }; + const logsVolumeDataProvider = datasourceInstance.getLogsVolumeDataProvider(sourceRequest); dispatch( storeLogsVolumeDataProviderAction({ exploreId,