tag:help.appveyor.com,2012-11-13:/discussions/problems/17281-test-fails-on-appveyor-but-works-locally-and-elsewhereAppVeyor: Discussion 2019-06-27T05:24:12Ztag:help.appveyor.com,2012-11-13:Comment/461980932018-10-06T00:57:48Z2018-10-06T00:57:48ZTest fails on appveyor but works locally and elsewhere<div><p>There is a race condition somewhere. Maybe in in xunit or in Kestrel. I don't think in Mongo DB.</p>
<p>I forked your repo and was able to reproduce the problem. Enabling 4-core VMs fixed it. I am sure you local machine and "elsewhere" has more than 2 cores.</p>
<p>It reminds me <a href="https://help.appveyor.com/discussions/problems/15020-xunit-test-execution-hangs">this</a> case. However I was not able to workaround it with setting <a href="https://github.com/xunit/xunit/issues/1169#issuecomment-287521557">"parallelizeTestCollections": false</a> in your <code>xunit.runner.json</code>. However it still can be an xunit issue (see links to discussions and solution in the support thread I mention).</p>
<p>Another theory is that Web service exhausted connections. I am not very familiar with <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/web-host?view=aspnetcore-2.1">Kestrel</a>, but I would recommend try wrapping <a href="https://github.com/gldraphael/evlog/blob/refactor/integration-tests-to-use-webappfactory-and-seed-a-testdb/tests/Evlog.IntegrationTests/Pages/PublicPages_that_should.cs#L10">HttpClient</a> into <code>using</code> statement for it not to leave opened sessions. I am just speculating, but may be it can help.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/461980932018-10-08T06:31:03Z2018-10-08T06:43:01ZTest fails on appveyor but works locally and elsewhere<div><p>Hey, thank you for taking the time to investigate the issue.</p>
<blockquote>
<p>Another theory is that Web service exhausted connections. I am not very familiar with Kestrel, but I would recommend try wrapping HttpClient into using statement for it not to leave opened sessions. I am just speculating, but may be it can help.</p>
</blockquote>
<p>The http client is being disposed though. I've manually invoked client.Dispose() in the IDisposable fixture's Dispose(). xUnit invokes it like it should. EDIT: I tried using blocks but it still fails: <a href="https://ci.appveyor.com/project/Galdin/evlog/builds/19332526/tests">Link</a></p>
<blockquote>
<p>Enabling 4-core VMs fixed it. I am sure you local machine and "elsewhere" has more than 2 cores.</p>
</blockquote>
<p>I'm not entirely sure it's the cores -- the test pass on docker when the number of CPUs is set to 2. Number of CPU and cores mean the same thing, right?</p>
<p>I'll try running the docker build on appveyor to see if that passes.</p></div>gldraphael