From b90b3d474cee0cf0baa0acdf2205d5d27d180619 Mon Sep 17 00:00:00 2001 From: kurilova Date: Fri, 5 Apr 2024 12:38:19 +0000 Subject: [PATCH 1/2] Extend timeout when testrun is stopping --- .../src/app/interceptors/error.interceptor.ts | 20 ++++++++++++++----- .../ui/src/app/services/test-run.service.ts | 9 +++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/modules/ui/src/app/interceptors/error.interceptor.ts b/modules/ui/src/app/interceptors/error.interceptor.ts index 8fe5d0c23..9df4074ae 100644 --- a/modules/ui/src/app/interceptors/error.interceptor.ts +++ b/modules/ui/src/app/interceptors/error.interceptor.ts @@ -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 = 30 * 1000; @Injectable() export class ErrorInterceptor implements HttpInterceptor { + private isTestrunStop = false; constructor(private notificationService: NotificationService) {} - intercept( request: HttpRequest, next: HttpHandler, timeoutMs = DEFAULT_TIMEOUT_MS ): Observable> { - 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) => { @@ -66,6 +71,11 @@ export class ErrorInterceptor implements HttpInterceptor { } } return throwError(error); + }), + finalize(() => { + if (request.url.includes(SYSTEM_STOP)) { + this.isTestrunStop = false; + } }) ); } diff --git a/modules/ui/src/app/services/test-run.service.ts b/modules/ui/src/app/services/test-run.service.ts index 0fcb584fe..c7155357f 100644 --- a/modules/ui/src/app/services/test-run.service.ts +++ b/modules/ui/src/app/services/test-run.service.ts @@ -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(`${API_URL}/system/status`) - .subscribe((res: TestrunStatus) => { + this.http.get(`${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 { From f6d663f8687cdc8589ee2e9f484cd9d3915f470e Mon Sep 17 00:00:00 2001 From: kurilova Date: Wed, 10 Apr 2024 11:17:40 +0000 Subject: [PATCH 2/2] Increase interval --- modules/ui/src/app/interceptors/error.interceptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/src/app/interceptors/error.interceptor.ts b/modules/ui/src/app/interceptors/error.interceptor.ts index 9df4074ae..924cbde02 100644 --- a/modules/ui/src/app/interceptors/error.interceptor.ts +++ b/modules/ui/src/app/interceptors/error.interceptor.ts @@ -34,7 +34,7 @@ import { SYSTEM_STOP } from '../services/test-run.service'; import { finalize } from 'rxjs/operators'; const DEFAULT_TIMEOUT_MS = 5000; -const SYSTEM_STOP_TIMEOUT_MS = 30 * 1000; +const SYSTEM_STOP_TIMEOUT_MS = 60 * 1000; @Injectable() export class ErrorInterceptor implements HttpInterceptor {