-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80b767c
commit fc7611f
Showing
21 changed files
with
553 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
frontend/packages/dev-console/src/components/pipelineruns/logs/LogSnippetBlock.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
...tend/packages/dev-console/src/components/pipelineruns/logs/PipelineRunDetailsErrorLog.tsx
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
frontend/packages/dev-console/src/components/pipelineruns/logs/RunDetailsErrorLog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as React from 'react'; | ||
import LogSnippetBlock from './LogSnippetBlock'; | ||
import { CombinedErrorDetails } from './log-snippet-types'; | ||
|
||
type RunDetailErrorLogProps = { | ||
logDetails: CombinedErrorDetails; | ||
namespace: string; | ||
}; | ||
|
||
const RunDetailsErrorLog: React.FC<RunDetailErrorLogProps> = ({ logDetails, namespace }) => { | ||
if (!logDetails) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<dl> | ||
<dt>Message</dt> | ||
<dd>{logDetails.title}</dd> | ||
</dl> | ||
<dl> | ||
<dt>Log Snippet</dt> | ||
<dd> | ||
<LogSnippetBlock logDetails={logDetails} namespace={namespace}> | ||
{(logSnippet: string) => <pre>{logSnippet}</pre>} | ||
</LogSnippetBlock> | ||
</dd> | ||
</dl> | ||
</> | ||
); | ||
}; | ||
|
||
export default RunDetailsErrorLog; |
201 changes: 201 additions & 0 deletions
201
.../packages/dev-console/src/components/pipelineruns/logs/__tests__/log-snippet-test-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
import { PipelineRun } from 'packages/dev-console/src/utils/pipeline-augment'; | ||
import { TaskRunData } from '../log-snippet-types'; | ||
|
||
export const LogSnippetTaskData: TaskRunData[] = [ | ||
{ | ||
kind: 'TaskRun', | ||
metadata: { name: 'taskrun1-abhi', namespace: 'abhi' }, | ||
status: { | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'True', | ||
type: 'Failed', | ||
}, | ||
], | ||
}, | ||
spec: {}, | ||
}, | ||
{ | ||
kind: 'TaskRun', | ||
metadata: { name: 'taskrun1-abhi', namespace: 'abhi' }, | ||
status: { | ||
podName: 'pod1', | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'True', | ||
type: 'Failed', | ||
}, | ||
], | ||
}, | ||
spec: {}, | ||
}, | ||
{ | ||
kind: 'TaskRun', | ||
metadata: { name: 'taskrun1-abhi', namespace: 'abhi' }, | ||
status: { | ||
podName: 'pod1', | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'SUCCEEDED', | ||
status: 'True', | ||
type: 'SUCCEEDED', | ||
}, | ||
], | ||
}, | ||
spec: {}, | ||
}, | ||
]; | ||
|
||
export const PipelineRunMock: PipelineRun[] = [ | ||
{ | ||
apiVersion: 'tekton.dev/v1alpha1', | ||
kind: 'PipelineRun', | ||
metadata: { | ||
name: 'simple-pipeline-failed', | ||
namespace: 'tekton-pipelines', | ||
}, | ||
spec: { | ||
pipelineRef: { | ||
name: 'simple-pipeline', | ||
}, | ||
}, | ||
status: { | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Succeeded', | ||
status: 'True', | ||
type: 'Succeeded', | ||
}, | ||
], | ||
startTime: '2019-10-29T11:56:40Z', | ||
taskRuns: { | ||
task1: { | ||
status: { | ||
startTime: '2019-10-29T11:57:53Z', | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Succeeded', | ||
status: 'True', | ||
type: 'Succeeded', | ||
}, | ||
], | ||
podName: 'p1', | ||
}, | ||
pipelineTaskName: 'task1', | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
apiVersion: 'tekton.dev/v1alpha1', | ||
kind: 'PipelineRun', | ||
metadata: { | ||
name: 'simple-pipeline-failed', | ||
namespace: 'tekton-pipelines', | ||
}, | ||
spec: { | ||
pipelineRef: { | ||
name: 'simple-pipeline', | ||
}, | ||
}, | ||
status: { | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'False', | ||
type: 'Succeeded', | ||
}, | ||
], | ||
startTime: '2019-10-29T11:56:40Z', | ||
taskRuns: { | ||
task1: { | ||
status: { | ||
startTime: '2019-10-29T11:57:53Z', | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'False', | ||
type: 'Succeeded', | ||
}, | ||
], | ||
podName: 'pod1', | ||
steps: [ | ||
{ | ||
container: 'container1', | ||
imageID: 'a', | ||
name: 'step1', | ||
terminated: { | ||
containerID: 'b', | ||
exitCode: 1, | ||
finishedAt: 'x', | ||
reason: 'FAILED INTENTIONALLY', | ||
startedAt: 'c', | ||
}, | ||
}, | ||
], | ||
}, | ||
pipelineTaskName: 'task1', | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
apiVersion: 'tekton.dev/v1alpha1', | ||
kind: 'PipelineRun', | ||
metadata: { | ||
name: 'simple-pipeline-failed-2', | ||
namespace: 'tekton-pipelines', | ||
}, | ||
spec: { | ||
pipelineRef: { | ||
name: 'simple-pipeline', | ||
}, | ||
}, | ||
status: { | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'False', | ||
type: 'Succeeded', | ||
}, | ||
], | ||
startTime: '2019-10-29T11:56:40Z', | ||
taskRuns: { | ||
task1: { | ||
status: { | ||
startTime: '2019-10-29T11:57:53Z', | ||
completionTime: '2019-10-29T11:57:53Z', | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-10-29T11:57:53Z', | ||
reason: 'Failed', | ||
status: 'False', | ||
type: 'Succeeded', | ||
}, | ||
], | ||
podName: 'pod1', | ||
}, | ||
pipelineTaskName: 'task1', | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; |
44 changes: 44 additions & 0 deletions
44
...packages/dev-console/src/components/pipelineruns/logs/__tests__/log-snippet-utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { taskRunSnippetMessage } from '../log-snippet-utils'; | ||
import { ErrorDetailsWithLogName, ErrorDetailsWithStaticLog } from '../log-snippet-types'; | ||
import { LogSnippetTaskData } from './log-snippet-test-data'; | ||
|
||
const testContainer = 'container-B'; | ||
|
||
describe('LogSnippet utils test', () => { | ||
it('should return title and static message for no container', () => { | ||
const { title, staticMessage } = taskRunSnippetMessage( | ||
LogSnippetTaskData[0].metadata.name, | ||
LogSnippetTaskData[0].status, | ||
null, | ||
) as ErrorDetailsWithStaticLog; | ||
expect(title).toEqual( | ||
`Failure on task ${LogSnippetTaskData[0].metadata.name} - check logs for details.`, | ||
); | ||
expect(staticMessage).toEqual('Unknown failure condition'); | ||
}); | ||
|
||
it('should return title and static message for no pod', () => { | ||
const { title, staticMessage } = taskRunSnippetMessage( | ||
LogSnippetTaskData[0].metadata.name, | ||
LogSnippetTaskData[0].status, | ||
testContainer, | ||
) as ErrorDetailsWithStaticLog; | ||
expect(title).toEqual( | ||
`Failure on task ${LogSnippetTaskData[0].metadata.name} - check logs for details.`, | ||
); | ||
expect(staticMessage).toEqual('Unknown failure condition'); | ||
}); | ||
|
||
it('should return title from task metadata, pod and container', () => { | ||
const { title, podName, containerName } = taskRunSnippetMessage( | ||
LogSnippetTaskData[1].metadata.name, | ||
LogSnippetTaskData[1].status, | ||
testContainer, | ||
) as ErrorDetailsWithLogName; | ||
expect(title).toEqual( | ||
`Failure on task ${LogSnippetTaskData[1].metadata.name} - check logs for details.`, | ||
); | ||
expect(podName).toEqual(LogSnippetTaskData[1].status.podName); | ||
expect(containerName).toEqual(testContainer); | ||
}); | ||
}); |
Oops, something went wrong.