ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.31k stars 1.63k forks source link

fixed PollyQoSTests AcceptanceTests #1909

Closed brikibsw closed 8 months ago

brikibsw commented 8 months ago

Fixes / New Feature #

The most significant changes involve updates to the OcelotBuilderExtensions and PollyQoSResiliencePipelineProvider classes, as well as modifications to the PollyQoSTests class.

In the OcelotBuilderExtensions class, the GetDelegatingHandler method is now used instead of GetDelegatingHandlerV7 in the AddPolly methods. The AddPolly method without parameters has been simplified using a lambda expression. The GetDelegatingHandler method now returns a new instance of PollyResiliencePipelineDelegatingHandler instead of PollyPoliciesDelegatingHandler.

In the PollyQoSResiliencePipelineProvider class, a comment has been added suggesting the use of ResiliencePipelineRegistry<TKey>.GetOrAddPipeline due to its thread-safe nature. The MinimumThroughput property in circuitBreakerStrategyOptions now uses the value from route.QosOptions.ExceptionsAllowedBeforeBreaking.

In the PollyQoSTests class, the QoSOptions used in the test configurations have been updated. Two tests, Should_open_circuit_breaker_then_close and Open_circuit_should_not_effect_different_route, have been modified to repeat the same request as the minimum ExceptionsAllowedBeforeBreaking is now 2. The GivenThereIsAPossiblyBrokenServiceRunningOn method now delays for 2.1 seconds when the request count is 2, to ensure the circuit is open.

Proposed Changes

  1. OcelotBuilderExtensions class updated to use GetDelegatingHandler method.
  2. AddPolly methods in OcelotBuilderExtensions class simplified.
  3. GetDelegatingHandler method in OcelotBuilderExtensions class now returns a new instance of PollyResiliencePipelineDelegatingHandler.
  4. Comment added in PollyQoSResiliencePipelineProvider class suggesting the use of ResiliencePipelineRegistry<TKey>.GetOrAddPipeline.
  5. MinimumThroughput property in circuitBreakerStrategyOptions updated to use value from route.QosOptions.ExceptionsAllowedBeforeBreaking.
  6. QoSOptions in PollyQoSTests class updated.
  7. Should_open_circuit_breaker_then_close and Open_circuit_should_not_effect_different_route tests in PollyQoSTests class updated.
  8. GivenThereIsAPossiblyBrokenServiceRunningOn method in PollyQoSTests class updated to delay for 2.1 seconds when request count is 2.