diff --git a/tests/Serval.E2ETests/ServalClientHelper.cs b/tests/Serval.E2ETests/ServalClientHelper.cs index 0eb0a0b8..6a944910 100644 --- a/tests/Serval.E2ETests/ServalClientHelper.cs +++ b/tests/Serval.E2ETests/ServalClientHelper.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; public class ServalClientHelper @@ -20,7 +21,7 @@ public ServalClientHelper(string audience, string prefix = "SCE_", bool ignoreSS else _httpClient = new HttpClient(); _httpClient.BaseAddress = new Uri(env["hostUrl"]); - _httpClient.Timeout = TimeSpan.FromSeconds(10); + _httpClient.Timeout = TimeSpan.FromSeconds(60); dataFilesClient = new DataFilesClient(_httpClient); translationEnginesClient = new TranslationEnginesClient(_httpClient); _httpClient.DefaultRequestHeaders.Add( @@ -112,20 +113,28 @@ public async Task StartBuildAsync(string engineId) public async Task BuildEngine(string engineId) { var newJob = await StartBuildAsync(engineId); + int revision = newJob.Revision; await translationEnginesClient.GetBuildAsync(engineId, newJob.Id, newJob.Revision); - int pollIntervalMs = 500; // start throttle at 0.5 seconds while (true) { - var result = await translationEnginesClient.GetBuildAsync(engineId, newJob.Id); - if (!(result.State == JobState.Active || result.State == JobState.Pending)) + try { - // build completed - break; + var result = await translationEnginesClient.GetBuildAsync(engineId, newJob.Id, revision + 1); + if (!(result.State == JobState.Active || result.State == JobState.Pending)) + { + // build completed + break; + } + revision = result.Revision; + } + catch (ServalApiException e) + { + if (e.StatusCode != 408) + throw; + + // Throttle requests + await Task.Delay(500); } - // Throttle requests - await Task.Delay(pollIntervalMs); - // increase throttle exponentially to 10 seconds - pollIntervalMs = (int)Math.Min(pollIntervalMs * 1.2, 10_000); } }