Skip to content

[dotnet-sdk-10.0.100-preview.7.25351.101] Unit test case failed for Ocelot application #117316

Closed
@Junjun-zhao

Description

@Junjun-zhao

Description

When running the 3rd party applications with dotnet-sdk-preview.7.25351.101, Ocelot app Unit Test failed 2 test cases.

Reproduction Steps

App Repro steps :
The repro machine only has dotnet-sdk-10.0.100-preview.7.25351.101 installed and set DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX as 2.

  1. Copy \***\BugRepro_Share\2521603\OcelotTest03 to local machine.
  2. Update "Ocelot.AcceptanceTests.runtimeconfig.json" file to let the app run against with dotnet-sdk-10.0.100-preview.7.25351.101:
  "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "10.0.0-preview.7.25351.101"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "10.0.0-preview.7.25351.101"
      }
    ],
  1. Open command prompt and navigate to \OcelotTest03 folder.
  2. Input command “dotnet vstest Ocelot.AcceptanceTests.dll”.
  3. Press "Enter" to run the command.

Expected behavior

Total 278 test cases are all passes.

Image

Actual behavior

There are 2 test cases are failed with below error:

[xUnit.net 00:00:27.76]     Ocelot.AcceptanceTests.WebSocketTests.ShouldProxyWebsocketInputToDownstreamServiceAndUseLoadBalancer [FAIL]
  Failed Ocelot.AcceptanceTests.WebSocketTests.ShouldProxyWebsocketInputToDownstreamServiceAndUseLoadBalancer [564 ms]
  Error Message:
   System.Net.WebSockets.WebSocketException : The server returned status code '500' when status code '101' was expected.
  Stack Trace:
     at System.Net.WebSockets.WebSocketHandle.ValidateResponse(HttpResponseMessage response, String secValue)
   at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options)
   at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken)
   at Ocelot.AcceptanceTests.WebSocketTests.StartClient(String url) in C:\Users\v-gwei\Downloads\Ocelot-develop\test\Ocelot.AcceptanceTests\WebSocketTests.cs:line 130
   at Ocelot.AcceptanceTests.WebSocketTests.WhenIStartTheClients() in C:\Users\v-gwei\Downloads\Ocelot-develop\test\Ocelot.AcceptanceTests\WebSocketTests.cs:line 123
   at TestStack.BDDfy.Processors.AsyncTestRunner.Run(Func`1 performStep)
   at TestStack.BDDfy.Processors.ScenarioExecutor.ExecuteStep(Step step)
   at TestStack.BDDfy.Processors.ExceptionProcessor.Process(Story story)
   at TestStack.BDDfy.Engine.Run()
   at TestStack.BDDfy.BDDfyExtensions.BDDfy(Object testObject, String scenarioTitle, String caller)
   at Ocelot.AcceptanceTests.WebSocketTests.ShouldProxyWebsocketInputToDownstreamServiceAndUseLoadBalancer() in C:\Users\v-gwei\Downloads\Ocelot-develop\test\Ocelot.AcceptanceTests\WebSocketTests.cs:line 93
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:01:24.54]     Ocelot.AcceptanceTests.LoadBalancerTests.Should_load_balance_request_with_round_robin [FAIL]
  Failed Ocelot.AcceptanceTests.LoadBalancerTests.Should_load_balance_request_with_round_robin [127 ms]
  Error Message:
   Shouldly.ShouldAssertException : Shouldly uses your source code to generate its great error messages, build your test project with full debug information to get better error messages
The provided expression
    should be
50
    but was
0
  Stack Trace:
     at TestStack.BDDfy.StepActionFactory.<>c__DisplayClass1_0`1.<GetStepAction>b__0(Object o)
   at TestStack.BDDfy.StepExecutor.Execute(Step step, Object testObject)
   at TestStack.BDDfy.Processors.ScenarioExecutor.<>c__DisplayClass3_0.<ExecuteStep>b__0()
   at TestStack.BDDfy.Processors.AsyncTestRunner.Run(Func`1 performStep)
   at TestStack.BDDfy.Processors.ScenarioExecutor.ExecuteStep(Step step)

Failed!  - Failed:     2, Passed:   276, Skipped:     0, Total:   278, Duration: 1 m 47 s - Ocelot.AcceptanceTests.dll (net8.0)

Image

Regression?

yes

Verify Scenarios:

  1. Windows 11 24H2 x64 + dotnet-sdk-8.0.411: Pass
  2. Windows 11 24H2 x64 + dotnet-sdk-10.0.100-preview.6.25326.107: Pass
  3. Windows 11 24H2 x64 + dotnet-sdk-10.0.100-preview.7.25351.101: Fail

Known Workarounds

No response

Configuration

Application Name: Ocelot
OS: Windows 11 24H2
CPU: X64
.NET Build Number: 10.0.100-preview.7.25351.101
Shared App & App Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2521603
Github Link:https://github.com/ThreeMammals/Ocelot

Other information

Debug Repro Steps (debug steps gif attached):
The repro machine has Visual Studio 2022 Preview and dotnet-sdk-10.0.100-preview.7.25351.101 installed.

  1. Copy ***\BugRepro_Share\2521603\OcelotSourceCode\Ocelot] source code to local machine.
  2. Open Ocelot.sln with Visual Studio 2022 Preview.
  3. Switch Ocelot.UnitTests project to Framework 8.0 from Visual Studio.Image
  4. Build the Ocelot.AcceptanceTests.csproj test project.
  5. Update "Ocelot.AcceptanceTests.runtimeconfig.json" file underbin\Debug\net8.0 folder to let the app run against with dotnet-sdk-10.0.100-preview.7.25351.101:
 "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "10.0.0-preview.7.25351.101"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "10.0.0-preview.7.25351.101"
      }
    ],
  1. Open Test > Test Explorer window from Visual Studio.
  2. Find "Should_load_balance_request_with_round_robin" test method under Ocelot.AcceptanceTest(net8.0) > Ocelot.AcceptanceTests > LoadBalancerTests.
  3. Right click on the test case and select Debug to start debugging the test case.

Expected Result:
The selected test case will pass without any exception thrown.

Actual Result:
The selected test case will throw "System.ArgumentNullException: 'Value cannot be null. (Parameter 'key')'" exception from source code.

Image

Findings:
When debugging into the source code, we found the failed test cases are all caused by the _serviceName parameter that passed into TryScanNext() method in RoundRobin.cs become null when running with dotnet-sdk-preview.7.25351.101, which will throw "System.ArgumentNullException: 'Value cannot be null. (Parameter 'key')'":

Image

In previous version, it is an empty string:

Image

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions