grab warnings from correct key + test (#12977)

This commit is contained in:
Vadim Ogievetsky 2022-08-25 18:47:33 -07:00
parent 4937017e6f
commit 2af68b6edc
9 changed files with 2323 additions and 50 deletions

View File

@ -123,6 +123,7 @@ export const EXECUTION_INGEST_COMPLETE = Execution.fromTaskPayloadAndReport(
{ {
multiStageQuery: { multiStageQuery: {
type: 'multiStageQuery',
taskId: 'query-32ced762-7679-4a25-9220-3915c5976961', taskId: 'query-32ced762-7679-4a25-9220-3915c5976961',
payload: { payload: {
status: { status: 'SUCCESS', startTime: '2022-08-22T20:12:51.391Z', durationMs: 25097 }, status: { status: 'SUCCESS', startTime: '2022-08-22T20:12:51.391Z', durationMs: 25097 },

File diff suppressed because one or more lines are too long

View File

@ -211,14 +211,14 @@ export class Execution {
static fromTaskPayloadAndReport( static fromTaskPayloadAndReport(
taskPayload: { payload: any; task: string }, taskPayload: { payload: any; task: string },
taskReport: { taskReport: {
multiStageQuery: { payload: any; taskId: string }; multiStageQuery: { type: string; payload: any; taskId: string };
error?: any; error?: any;
}, },
): Execution { ): Execution {
// Must have status set for a valid report // Must have status set for a valid report
const id = deepGet(taskReport, 'multiStageQuery.taskId'); const id = deepGet(taskReport, 'multiStageQuery.taskId');
const status = deepGet(taskReport, 'multiStageQuery.payload.status.status'); const status = deepGet(taskReport, 'multiStageQuery.payload.status.status');
const warnings = deepGet(taskReport, 'multiStageQuery.payload.status.warningReports'); const warnings = deepGet(taskReport, 'multiStageQuery.payload.status.warnings');
if (typeof id !== 'string' || !Execution.validTaskStatus(status)) { if (typeof id !== 'string' || !Execution.validTaskStatus(status)) {
throw new Error('Invalid payload'); throw new Error('Invalid payload');

View File

@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { shallow } from 'enzyme';
import React from 'react';
import { EXECUTION_INGEST_ERROR } from '../../../druid-models/execution/execution-ingest-error.mock';
import { ExecutionDetailsPane } from './execution-details-pane';
describe('ExecutionDetailsPane', () => {
it('matches snapshot no init tab', () => {
const comp = shallow(
<ExecutionDetailsPane execution={EXECUTION_INGEST_ERROR} goToIngestion={() => {}} />,
);
expect(comp).toMatchSnapshot();
});
it('matches snapshot with init tab', () => {
const comp = shallow(
<ExecutionDetailsPane
execution={EXECUTION_INGEST_ERROR}
initTab="warnings"
goToIngestion={() => {}}
/>,
);
expect(comp).toMatchSnapshot();
});
});

View File

@ -8,23 +8,17 @@ exports[`ExecutionErrorPane matches snapshot 1`] = `
<p <p
className="error-message-text" className="error-message-text"
> >
UnknownError: TooManyWarnings:
java.lang.RuntimeException: java.lang.RuntimeException: Error occured while trying to read uri: https://static.imply.io/example-data/kttm-v2/kttm-v2-2019-08-25.json.gz_ Too many warnings of type CannotParseExternalData generated (max = 10)
<a
onClick={[Function]}
>
(Stack trace)
</a>
</p> </p>
<div> <div>
Failed task ID: Failed task ID:
<Memo(ClickToCopy) <Memo(ClickToCopy)
text="query-0cf1a40a-aaef-4d17-bda4-5afa7edf07e7-worker0" text="query-c6bffa9d-43c4-45a0-95f8-0c8c453655fb"
/> />
(on host: (on host:
<Memo(ClickToCopy) <Memo(ClickToCopy)
text="localhost:8101" text="localhost"
/> />
) )
</div> </div>

View File

@ -353,7 +353,7 @@ export const HelperQuery = React.memo(function HelperQuery(props: HelperQueryPro
) : execution.isSuccessfulInsert() ? ( ) : execution.isSuccessfulInsert() ? (
<IngestSuccessPane <IngestSuccessPane
execution={execution} execution={execution}
onDetails={() => onDetails(statsTaskId!)} onDetails={onDetails}
onQueryTab={onQueryTab} onQueryTab={onQueryTab}
/> />
) : execution.error ? ( ) : execution.error ? (

View File

@ -21,12 +21,13 @@ import React from 'react';
import { Execution, WorkbenchQuery } from '../../../druid-models'; import { Execution, WorkbenchQuery } from '../../../druid-models';
import { formatDuration, pluralIfNeeded } from '../../../utils'; import { formatDuration, pluralIfNeeded } from '../../../utils';
import { ExecutionDetailsTab } from '../execution-details-pane/execution-details-pane';
import './ingest-success-pane.scss'; import './ingest-success-pane.scss';
export interface IngestSuccessPaneProps { export interface IngestSuccessPaneProps {
execution: Execution; execution: Execution;
onDetails(): void; onDetails(id: string, initTab?: ExecutionDetailsTab): void;
onQueryTab?(newQuery: WorkbenchQuery, tabName?: string): void; onQueryTab?(newQuery: WorkbenchQuery, tabName?: string): void;
} }
@ -54,12 +55,20 @@ export const IngestSuccessPane = React.memo(function IngestSuccessPane(
return ( return (
<div className="ingest-success-pane"> <div className="ingest-success-pane">
<p> <p>
{`${rows < 0 ? 'Data' : pluralIfNeeded(rows, 'row')} inserted into '${datasource}'.` + {`${rows < 0 ? 'Data' : pluralIfNeeded(rows, 'row')} inserted into '${datasource}'.`}
(warnings > 0 ? ` ${pluralIfNeeded(warnings, 'warning')} generated.` : '')} {warnings > 0 && (
<>
{' '}
<span className="action" onClick={() => onDetails(execution.id, 'warnings')}>
{pluralIfNeeded(warnings, 'warning')}
</span>{' '}
recorded.
</>
)}
</p> </p>
<p> <p>
{duration ? `Insert query took ${formatDuration(duration)}. ` : `Insert query completed. `} {duration ? `Insert query took ${formatDuration(duration)}. ` : `Insert query completed. `}
<span className="action" onClick={onDetails}> <span className="action" onClick={() => onDetails(execution.id)}>
Show details Show details
</span> </span>
</p> </p>

View File

@ -403,7 +403,7 @@ export const QueryTab = React.memo(function QueryTab(props: QueryTabProps) {
) : execution.isSuccessfulInsert() ? ( ) : execution.isSuccessfulInsert() ? (
<IngestSuccessPane <IngestSuccessPane
execution={execution} execution={execution}
onDetails={() => onDetails(statsTaskId!)} onDetails={onDetails}
onQueryTab={onQueryTab} onQueryTab={onQueryTab}
/> />
) : execution.error ? ( ) : execution.error ? (