mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
log-volume: adjust request-id to avoid conflicts (#45511)
* log-volume: adjust request-id to avoid conflicts * added unit test * simplify test Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * added missing import Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
@@ -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<DataQuery>;
|
||||
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({
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user