Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarantine WebApplicationFactory #58442

Open
contione opened this issue Oct 15, 2024 · 1 comment
Open

Quarantine WebApplicationFactory #58442

contione opened this issue Oct 15, 2024 · 1 comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Comments

@contione
Copy link

contione commented Oct 15, 2024

Failing Test(s)

  • Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory

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

1. 
  HostingListener.CreateHost()
   <>c__DisplayClass10_0.<ResolveHostFactory>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.<Invoke>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.<SendAsync>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.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Oct 15, 2024
@contione contione changed the title Quarantine <WebApplicationFactory> Quarantine WebApplicationFactory Oct 15, 2024
@contione contione changed the title Quarantine WebApplicationFactory Quarantine <WebApplicationFactory> Oct 15, 2024
@contione contione changed the title Quarantine <WebApplicationFactory> Quarantine WebApplicationFactory Oct 15, 2024
@contione
Copy link
Author

contione commented Oct 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

No branches or pull requests

2 participants