aspnet / HttpSysServer

[Archived] A web server for ASP.NET Core based on the Windows Http Server API. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
106 stars 39 forks source link

Add diagnostics to debug flaky tests #470

Closed Tratcher closed 6 years ago

Tratcher commented 6 years ago

457 This series of tests runs the client and server inline asynchronously. Some of them have been flaky and we added timeouts to prevent them from hanging. However that timeout doesn't explain why it failed. One theory is that the client encountered an error before the request reached the server, but we time out before we await that task so the error goes unreported.

I've added an extension that surfaces the error details if the request fails before the server receives it.

/cc: @ryanbrandenburg

Tratcher commented 6 years ago

AppVeyor failures captured with the new tracing:

[xUnit.net 00:00:15.78]     Microsoft.AspNetCore.Server.HttpSys.Listener.ResponseCachingTests.Caching_VariousUnsupportedRequestMethods_NotCached(method: "UNKNOWN") [FAIL]
  Failed   Microsoft.AspNetCore.Server.HttpSys.Listener.ResponseCachingTests.Caching_VariousUnsupportedRequestMethods_NotCached(method: "UNKNOWN")
  Error Message:
   System.InvalidOperationException : The response completed prematurely: StatusCode: 503, ReasonPhrase: 'Service Unavailable', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:
  {
    Server: Microsoft-HTTPAPI/2.0
    Date: Fri, 03 Aug 2018 22:50:48 GMT
    Connection: close
    Content-Type: text/html; charset=us-ascii
    Content-Length: 326
  }
  Stack Trace:
     at Microsoft.AspNetCore.Server.HttpSys.Listener.Utilities.Before[T](Task`1 acceptTask, Task`1 responseTask) in /_/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs:line 123
     at Microsoft.AspNetCore.Server.HttpSys.Listener.ResponseCachingTests.Caching_VariousUnsupportedRequestMethods_NotCached(String method) in /_/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseCachingTests.cs:line 623
  --- End of stack trace from previous location where exception was thrown ---
  Results File: C:\projects\httpsysserver\artifacts\logs\UnitTests-netcoreapp2.2-t000.trx
Microsoft.AspNetCore.Server.HttpSys.Listener.ResponseHeaderTests.AddingControlCharactersToHeadersThrows(key: "\r\nServer", value: "Data") [FAIL]
  Failed   Microsoft.AspNetCore.Server.HttpSys.Listener.ResponseHeaderTests.AddingControlCharactersToHeadersThrows(key: "\r\nServer", value: "Data")
  Error Message:
   System.InvalidOperationException : The response completed prematurely: StatusCode: 503, ReasonPhrase: 'Service Unavailable', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
  {
    Connection: close
    Date: Fri, 03 Aug 2018 22:51:21 GMT
    Server: Microsoft-HTTPAPI/2.0
    Content-Length: 326
    Content-Type: text/html; charset=us-ascii
  }
  Stack Trace:
     at Microsoft.AspNetCore.Server.HttpSys.Listener.Utilities.<Before>d__15`1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.AspNetCore.Server.HttpSys.Listener.ResponseHeaderTests.<AddingControlCharactersToHeadersThrows>d__18.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)