dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.34k stars 9.99k forks source link

Quarantine WebApplicationFactory #58442

Open contione opened 1 day ago

contione commented 1 day ago

Failing Test(s)

Error Message

  1. System.ObjectDisposedException : Cannot access a disposed object. Object name: 'IServiceProvider'.
  2. System.InvalidOperationException : The entry point exited without ever building an IHost.
  3. An unhandled exception has occurred while executing the request. System.NullReferenceException: Object reference not set to an instance of an object.
  4. System.Net.Http.HttpRequestException : Error while copying content to a stream.

Stacktrace

```text 1. HostingListener.CreateHost() <>c__DisplayClass10_0.b__0(String[] args) DeferredHostBuilder.Build() WebApplicationFactory`1.CreateHost(IHostBuilder builder) WebApplicationFactory`1.ConfigureHostBuilder(IHostBuilder hostBuilder) WebApplicationFactory`1.EnsureServer() WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers) WebApplicationFactory`1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers) WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options) WebApplicationFactory`1.CreateClient() 2. ThrowHelper.ThrowObjectDisposedException() ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope) ServiceProvider.GetService(Type serviceType) ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) WebApplicationFactory`1.ConfigureHostBuilder(IHostBuilder hostBuilder) WebApplicationFactory`1.EnsureServer() WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers) WebApplicationFactory`1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers) WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options) WebApplicationFactory`1.CreateClient() 3. An unhandled exception has occurred while executing the request. System.NullReferenceException: Object reference not set to an instance of an object. at Serilog.Extensions.Logging.SerilogLogger..ctor(SerilogLoggerProvider provider, ILogger logger, String name) in /_/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs:line 51 at Serilog.Extensions.Logging.SerilogLoggerProvider.CreateLogger(String name) in /_/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerProvider.cs:line 47 at Serilog.Extensions.Logging.SerilogLoggerFactory.CreateLogger(String categoryName) in /_/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerFactory.cs:line 59 at Microsoft.Extensions.Logging.Logger`1..ctor(ILoggerFactory factory) at Microsoft.Extensions.Logging.LoggerFactoryExtensions.CreateLogger[T](ILoggerFactory factory) at Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder.Build() at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher.CreateMatcher(IReadOnlyList`1 endpoints) at Microsoft.AspNetCore.Routing.DataSourceDependentCache`1.Initialize() at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func`1 matcherBuilderFactory) at Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.g__AwaitMatcher|10_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task`1 matcherTask) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context) Method Get_EndpointReturnSuccessAndTraceId failed on attempt 7 with exception: Response status code does not indicate success: 500 (Internal Server Error). 4. ---- System.IO.IOException : -------- System.NullReferenceException : Object reference not set to an instance of an object. Stack Trace: at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Tests.Configures.WebApplicationTests.Get_SwaggerUIEndpointsReturnSuccessAndCorrectContentType() in /agent/_work/1/s/src/Tests/Configures/TransferWebApplicationTests.cs:line 48 --- End of stack trace from previous location --- ```

Build

Currently, we are unable to provide the build link.

contione commented 1 day ago

Note: We are experiencing frequent exceptions when running tests on Azure DevOps using the WebApplicationFactory framework. These issues are difficult to reproduce in local testing environments.