Skip to content

New User Struggling To Understand Why WebApplicationFactory:CreateClient() Blocking In Docker-Compose Environment On Remote GitLab.com CI Server #27988

Answered by dcs3spp
dcs3spp asked this question in Q&A
Discussion options

You must be logged in to vote

After reading this aspnetcore issue discovered that the problem was with the implementation
of my IHostedService implementation.

The StartAsync method was performing the task, running until the request completed. By design this method is meant to be fire and forget, i.e. start the task and then continue. Updated my KafkaAdmin service to be a BackgroundService, overriding ExecuteAsync method, as listed below.
Subsequently, tests no longer blocks.

using System;
using System.Threading;
using System.Threading.Tasks;

using Confluent.Kafka;
using Confluent.Kafka.Admin;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

using KafkaAdmin.K…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dcs3spp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant