Description
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.
- Copy \***\BugRepro_Share\2521603\OcelotTest03 to local machine.
- 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"
}
],
- Open command prompt and navigate to \OcelotTest03 folder.
- Input command “dotnet vstest Ocelot.AcceptanceTests.dll”.
- Press "Enter" to run the command.
Expected behavior
Total 278 test cases are all passes.
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)
Regression?
yes
Verify Scenarios:
- Windows 11 24H2 x64 + dotnet-sdk-8.0.411: Pass
- Windows 11 24H2 x64 + dotnet-sdk-10.0.100-preview.6.25326.107: Pass
- 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.
- Copy ***\BugRepro_Share\2521603\OcelotSourceCode\Ocelot] source code to local machine.
- Open Ocelot.sln with Visual Studio 2022 Preview.
- Switch Ocelot.UnitTests project to Framework 8.0 from Visual Studio.Image
- Build the Ocelot.AcceptanceTests.csproj test project.
- 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"
}
],
- Open Test > Test Explorer window from Visual Studio.
- Find "Should_load_balance_request_with_round_robin" test method under Ocelot.AcceptanceTest(net8.0) > Ocelot.AcceptanceTests > LoadBalancerTests.
- 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.
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')'":
In previous version, it is an empty string:
@dotnet-actwx-bot @dotnet/compat