Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions modules/ui/src/app/interceptors/error.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,27 @@ import {
import { NotificationService } from '../services/notification.service';

import { SYSTEM_STOP } from '../services/test-run.service';
import { finalize } from 'rxjs/operators';

const DEFAULT_TIMEOUT_MS = 5000;
const SYSTEM_STOP_TIMEOUT_MS = 10000;
const SYSTEM_STOP_TIMEOUT_MS = 60 * 1000;

@Injectable()
export class ErrorInterceptor implements HttpInterceptor {
private isTestrunStop = false;
constructor(private notificationService: NotificationService) {}

intercept(
request: HttpRequest<unknown>,
next: HttpHandler,
timeoutMs = DEFAULT_TIMEOUT_MS
): Observable<HttpEvent<unknown>> {
const timeoutValue = request.url.includes(SYSTEM_STOP)
? SYSTEM_STOP_TIMEOUT_MS
: timeoutMs;
const timeoutValue =
request.url.includes(SYSTEM_STOP) || this.isTestrunStop
? SYSTEM_STOP_TIMEOUT_MS
: timeoutMs;
if (request.url.includes(SYSTEM_STOP)) {
this.isTestrunStop = true;
}
return next.handle(request).pipe(
timeout(timeoutValue),
catchError((error: HttpErrorResponse | TimeoutError) => {
Expand All @@ -66,6 +71,11 @@ export class ErrorInterceptor implements HttpInterceptor {
}
}
return throwError(error);
}),
finalize(() => {
if (request.url.includes(SYSTEM_STOP)) {
this.isTestrunStop = false;
}
})
);
}
Expand Down
9 changes: 5 additions & 4 deletions modules/ui/src/app/services/test-run.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ export class TestRunService {
* @param isCancelling - indicates if status should be overridden with Cancelling value
*/
getSystemStatus(isCancelling?: boolean): void {
this.http
.get<TestrunStatus>(`${API_URL}/system/status`)
.subscribe((res: TestrunStatus) => {
this.http.get<TestrunStatus>(`${API_URL}/system/status`).subscribe(
(res: TestrunStatus) => {
if (isCancelling && res.status !== StatusOfTestrun.Cancelled) {
res.status = StatusOfTestrun.Cancelling;
}
this.setSystemStatus(res);
});
},
err => console.error('HTTP Error', err)
);
}

stopTestrun(): Observable<boolean> {
Expand Down