Manually time out H2SpecTests (#6366)
This commit is contained in:
parent
236ceb73c1
commit
6a5c0cf189
|
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
@ -14,6 +15,8 @@ namespace Interop.FunctionalTests
|
||||||
{
|
{
|
||||||
public static class H2SpecCommands
|
public static class H2SpecCommands
|
||||||
{
|
{
|
||||||
|
private const int TimeoutSeconds = 15;
|
||||||
|
|
||||||
private static string GetToolLocation()
|
private static string GetToolLocation()
|
||||||
{
|
{
|
||||||
var root = Path.Combine(Environment.CurrentDirectory, "h2spec");
|
var root = Path.Combine(Environment.CurrentDirectory, "h2spec");
|
||||||
|
|
@ -166,14 +169,14 @@ namespace Interop.FunctionalTests
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RunTest(string testId, int port, bool https, ILogger logger)
|
public static async Task RunTest(string testId, int port, bool https, ILogger logger)
|
||||||
{
|
{
|
||||||
var tempFile = Path.GetTempPath() + Guid.NewGuid() + ".xml";
|
var tempFile = Path.GetTempPath() + Guid.NewGuid() + ".xml";
|
||||||
var processOptions = new ProcessStartInfo
|
var processOptions = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = GetToolLocation(),
|
FileName = GetToolLocation(),
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
Arguments = $"{testId} -p {port.ToString(CultureInfo.InvariantCulture)} --strict -j {tempFile} --timeout 15"
|
Arguments = $"{testId} -p {port.ToString(CultureInfo.InvariantCulture)} --strict -j {tempFile} --timeout {TimeoutSeconds}"
|
||||||
+ (https ? " --tls --insecure" : ""),
|
+ (https ? " --tls --insecure" : ""),
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
|
|
@ -181,7 +184,14 @@ namespace Interop.FunctionalTests
|
||||||
|
|
||||||
using (var process = Process.Start(processOptions))
|
using (var process = Process.Start(processOptions))
|
||||||
{
|
{
|
||||||
var data = process.StandardOutput.ReadToEnd();
|
var dataTask = process.StandardOutput.ReadToEndAsync();
|
||||||
|
|
||||||
|
if (await Task.WhenAny(dataTask, Task.Delay(TimeSpan.FromSeconds(TimeoutSeconds * 2))) != dataTask)
|
||||||
|
{
|
||||||
|
throw new TimeoutException($"h2spec didn't exit within {TimeoutSeconds * 2} seconds.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await dataTask;
|
||||||
logger.LogDebug(data);
|
logger.LogDebug(data);
|
||||||
|
|
||||||
var results = File.ReadAllText(tempFile);
|
var results = File.ReadAllText(tempFile);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Interop.FunctionalTests
|
||||||
{
|
{
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
|
|
||||||
H2SpecCommands.RunTest(testCase.Id, host.GetPort(), testCase.Https, Logger);
|
await H2SpecCommands.RunTest(testCase.Id, host.GetPort(), testCase.Https, Logger);
|
||||||
|
|
||||||
await host.StopAsync();
|
await host.StopAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue