Attempt fix Angular template flaky test (#17279)

* Attempt fix Angular template flaky test

* Increase timeout
This commit is contained in:
Ajay Bhargav Baaskaran 2019-11-21 15:10:09 -08:00 committed by GitHub
parent e2def80a0a
commit 877e5fafef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View File

@ -164,7 +164,7 @@ namespace Templates.Test.Helpers
{
if (!_process.HasExited)
{
throw new InvalidOperationException("Process has not finished running.");
throw new InvalidOperationException($"Process {_process.ProcessName} with pid: {_process.Id} has not finished running.");
}
return $"Process exited with code {_process.ExitCode}\nStdErr: {Error}\nStdOut: {Output}";
@ -174,12 +174,16 @@ namespace Templates.Test.Helpers
{
if(!timeSpan.HasValue)
{
timeSpan = TimeSpan.FromSeconds(480);
timeSpan = TimeSpan.FromSeconds(600);
}
Exited.Wait(timeSpan.Value);
if (assertSuccess && _process.ExitCode != 0)
var exited = Exited.Wait(timeSpan.Value);
if (!exited)
{
_output.WriteLine($"The process didn't exit within the allotted time ({timeSpan.Value.TotalSeconds} seconds).");
_process.Dispose();
}
else if (assertSuccess && _process.ExitCode != 0)
{
throw new Exception($"Process exited with code {_process.ExitCode}\nStdErr: {Error}\nStdOut: {Output}");
}

View File

@ -242,7 +242,7 @@ namespace Templates.Test.Helpers
do
{
restoreResult = await RestoreAsync(output, workingDirectory);
if (restoreResult.ExitCode == 0)
if (restoreResult.HasExited && restoreResult.ExitCode == 0)
{
return restoreResult;
}

View File

@ -212,7 +212,7 @@ namespace Templates.Test.SpaTemplateTest
catch (HttpRequestException ex) when (ex.Message.StartsWith("The SSL connection could not be established"))
{
}
await Task.Delay(TimeSpan.FromSeconds(5 * attempt));
await Task.Delay(TimeSpan.FromSeconds(10 * attempt));
} while (attempt < maxAttempts);
}
@ -306,10 +306,12 @@ namespace Templates.Test.SpaTemplateTest
var entries = logs.GetLog(logKind);
var badEntries = entries.Where(e => new LogLevel[] { LogLevel.Warning, LogLevel.Severe }.Contains(e.Level));
// Based on https://github.com/webpack/webpack-dev-server/issues/2134
badEntries = badEntries.Where(e =>
!e.Message.Contains("failed: WebSocket is closed before the connection is established.")
&& !e.Message.Contains("[WDS] Disconnected!")
&& !e.Message.Contains("Timed out connecting to Chrome, retrying"));
&& !e.Message.Contains("Timed out connecting to Chrome, retrying")
&& !(e.Message.Contains("jsonp?c=") && e.Message.Contains("Uncaught TypeError:") && e.Message.Contains("is not a function")));
Assert.True(badEntries.Count() == 0, "There were Warnings or Errors from the browser." + Environment.NewLine + string.Join(Environment.NewLine, badEntries));
}