|
|
@ -1,10 +1,18 @@ |
|
|
|
import { interval, lastValueFrom, of } from 'rxjs'; |
|
|
|
import { interval, lastValueFrom, of } from 'rxjs'; |
|
|
|
|
|
|
|
|
|
|
|
import { LogRowModel, MutableDataFrame, FieldType, LogLevel, dataFrameToJSON, DataQueryErrorType } from '@grafana/data'; |
|
|
|
import { |
|
|
|
|
|
|
|
dataFrameToJSON, |
|
|
|
|
|
|
|
DataQueryErrorType, |
|
|
|
|
|
|
|
DataQueryRequest, |
|
|
|
|
|
|
|
FieldType, |
|
|
|
|
|
|
|
LogLevel, |
|
|
|
|
|
|
|
LogRowModel, |
|
|
|
|
|
|
|
MutableDataFrame, |
|
|
|
|
|
|
|
} from '@grafana/data'; |
|
|
|
|
|
|
|
|
|
|
|
import { genMockFrames, setupMockedLogsQueryRunner } from '../__mocks__/LogsQueryRunner'; |
|
|
|
import { genMockFrames, setupMockedLogsQueryRunner } from '../__mocks__/LogsQueryRunner'; |
|
|
|
import { validLogsQuery } from '../__mocks__/queries'; |
|
|
|
import { validLogsQuery } from '../__mocks__/queries'; |
|
|
|
import { LogAction } from '../types'; |
|
|
|
import { CloudWatchQuery, LogAction } from '../types'; |
|
|
|
import * as rxjsUtils from '../utils/rxjs/increasingInterval'; |
|
|
|
import * as rxjsUtils from '../utils/rxjs/increasingInterval'; |
|
|
|
|
|
|
|
|
|
|
|
import { LOG_IDENTIFIER_INTERNAL, LOGSTREAM_IDENTIFIER_INTERNAL } from './CloudWatchLogsQueryRunner'; |
|
|
|
import { LOG_IDENTIFIER_INTERNAL, LOGSTREAM_IDENTIFIER_INTERNAL } from './CloudWatchLogsQueryRunner'; |
|
|
@ -213,4 +221,32 @@ describe('CloudWatchLogsQueryRunner', () => { |
|
|
|
expect(i).toBe(3); |
|
|
|
expect(i).toBe(3); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('handleLogQueries', () => { |
|
|
|
|
|
|
|
it('should return error message when missing query string', async () => { |
|
|
|
|
|
|
|
const { runner } = setupMockedLogsQueryRunner(); |
|
|
|
|
|
|
|
const response = await lastValueFrom( |
|
|
|
|
|
|
|
runner.handleLogQueries( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
datasource: { type: 'cloudwatch', uid: 'Zne6OZIVk' }, |
|
|
|
|
|
|
|
id: '', |
|
|
|
|
|
|
|
logGroups: [{ label: '', text: '', value: '' }], |
|
|
|
|
|
|
|
queryMode: 'Logs', |
|
|
|
|
|
|
|
refId: 'A', |
|
|
|
|
|
|
|
region: 'default', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
{ scopedVars: {} } as DataQueryRequest<CloudWatchQuery> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(response).toEqual({ |
|
|
|
|
|
|
|
data: [], |
|
|
|
|
|
|
|
error: { |
|
|
|
|
|
|
|
message: 'Query is required', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|