Unparser.cs Usability Test issue

Hi,
the test test_post_for_different_urls_should_return_http_200 seems to run in parallel via [Parallelizable(ParallelScope.All)].

This seems to sometimes throw an error as the httpclient is shared and the “x-forwarded-for” header is already added in a different thread.

Hi @hendrik.zahn, will investigate and get back to you.

H Hendrik, I ran your app and it looks failing the usability test:

 Failed test_post_for_different_urls_should_return_http_200("http://a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.com") [20 ms]
  Error Message:
     Expected: OK
  But was:  BadRequest

  Stack Trace:
     at program.Tests.programUsabilityTest.test_post_for_different_urls_should_return_http_200(String url) in /app/test/programUsabilityTest.cs:line 115
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

I also ran the original repo, a few times and it passed the usability tests each time.

Have you tried to run this challenge using docker? make test ? this ensure that your local environment is identical to server-side testing.

You can also try to reset your repo. Stop the challenge and start it but check “delete my repo” during start to get a fresh copy of the challenge.

Hi,
thanks for investigating.

I work with Podman using the Dockerfile but i tried CDE and local checkout too and all are the same for me.

The error you see is exactly what im describing. That test shouldnt fail.
If you remove the [Parallelizable(ParallelScope.All)] that test should pass.

The real failure should be in “test_post_invalid_url_should_return_http_400”.

Using a debugger i found that the test will try to add to httpclient.DefaultRequestHeaders from two different threads at same time. As its a simple collection this will throw an exception and fail the test because the key already exists.

Why this happens now? I guess its a timing thing and the Uri.TryCreate might be slowing it down enough to matter.

I have removed [Parallelizable(ParallelScope.All)] from the server side tests, please make a new commit to kick of server-side test. Please let me know if that resolve the issue.

Hi,
yes its getting past that test now, thanks :slight_smile:

1 Like