Skip to content

Commit

Permalink
Enable execution logs for tasks executing on platform != default (#1926)
Browse files Browse the repository at this point in the history
* Fetch link on task execution resource

* Up model

* Up clean fields

* Enable test on logs for task executions

* schemaTarget on task exeuction model

* Up check

* Up

* Up test

* Up parameters

* Cleanup field

* Cleanup

* Polish test
  • Loading branch information
claudiahub authored Aug 9, 2023
1 parent 13f73a4 commit 215c316
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
7 changes: 5 additions & 2 deletions ui/src/app/shared/api/task.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,15 @@ describe('shared/api/task.service.ts', () => {
taskService.getExecutionLogs(
TaskExecution.parse({
externalExecutionId: 'foo',
arguments: ['--spring.cloud.data.flow.platformname=bar']
schemaTarget: 'boot3',
arguments: [
'--spring.cloud.data.flow.platformname=bar'
]
})
);
const httpUri = mockHttp.get.calls.mostRecent().args[0];
const headerArgs = mockHttp.get.calls.mostRecent().args[1].headers;
expect(httpUri).toEqual('/tasks/logs/foo?platformName=bar');
expect(httpUri).toEqual('/tasks/logs/foo?platformName=bar&schemaTarget=boot3');
expect(headerArgs.get('Content-Type')).toEqual('application/json');
expect(headerArgs.get('Accept')).toEqual('application/json');
});
Expand Down
15 changes: 7 additions & 8 deletions ui/src/app/shared/api/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,15 @@ export class TaskService {
}
});
}
const url = taskExecution?._links && taskExecution?._links['tasks/logs'] !== undefined
? taskExecution?._links['tasks/logs'].href :
UrlUtilities.calculateBaseApiUrl() + `tasks/logs/${taskExecution.externalExecutionId}?platformName=${platformName}&schemaTarget=${taskExecution.schemaTarget}`;
const params = new HttpParams({encoder: new DataflowEncoder()});
return this.httpClient
.get<any>(
UrlUtilities.calculateBaseApiUrl() +
`tasks/logs/${taskExecution.externalExecutionId}?platformName=${platformName}`,
{
headers,
params
}
)
.get<any>(url, {
headers,
params
})
.pipe(catchError(ErrorUtils.catchError));
}

Expand Down
13 changes: 12 additions & 1 deletion ui/src/app/shared/model/task-execution.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import {DateTime} from 'luxon';
import {Page} from './page.model';

interface hrefObj {
href: string;
}

interface TaskExecutionLinks {
'tasks/logs': hrefObj;
}

export class LaunchResponse {
executionId: number;
schemaTarget: string;
Expand All @@ -23,13 +31,14 @@ export class TaskExecution {
arguments: string[];
jobExecutionIds: number[];
errorMessage: string;
schemaTarget: string;
externalExecutionId: string;
taskExecutionStatus: string;
parentExecutionId: number;
resourceUrl: string;
appProperties: any;
schemaTarget: string;
deploymentProperties: {[key: string]: string};
_links: TaskExecutionLinks;

static parse(input: any): TaskExecution {
const execution = new TaskExecution();
Expand All @@ -41,6 +50,7 @@ export class TaskExecution {
execution.endTime = input?.endTime ? DateTime.fromISO(input.endTime) : null;
execution.exitMessage = input?.exitMessage;
execution.arguments = input?.arguments || [];
execution.schemaTarget = input?.schemaTarget || 'boot2';
execution.jobExecutionIds = input?.jobExecutionIds || [];
execution.errorMessage = input?.errorMessage;
execution.taskExecutionStatus = input?.taskExecutionStatus;
Expand All @@ -49,6 +59,7 @@ export class TaskExecution {
execution.resourceUrl = input?.resourceUrl;
execution.appProperties = input?.appProperties;
execution.deploymentProperties = input?.deploymentProperties;
execution._links = input?._links;
execution.schemaTarget = input?.schemaTarget;
return execution;
}
Expand Down

0 comments on commit 215c316

Please sign in to comment.