69 lines
2.8 KiB
Gherkin
69 lines
2.8 KiB
Gherkin
Feature: Retry Patterns Implementation
|
|
As a developer
|
|
I want retry patterns implemented with tenacity
|
|
So that operations can be resilient to transient failures
|
|
|
|
Background:
|
|
Given I have the retry patterns module imported
|
|
|
|
Scenario: Basic exponential backoff retry works
|
|
Given I have a function that fails 2 times then succeeds
|
|
When I apply exponential backoff retry with max 3 attempts
|
|
Then the function should eventually succeed
|
|
And the function should be called 3 times
|
|
|
|
Scenario: Async exponential backoff retry works
|
|
Given I have an async function that fails 2 times then succeeds
|
|
When I apply async exponential backoff retry with max 3 attempts
|
|
Then the async function should eventually succeed
|
|
And the function should be called 3 times
|
|
|
|
Scenario: Network operation retry handles connection errors
|
|
Given I have a function that raises NetworkError twice
|
|
When I apply network retry pattern
|
|
Then the function should retry on NetworkError
|
|
And the function should be called 3 times maximum
|
|
|
|
Scenario: Provider operation retry handles rate limits
|
|
Given I have a function that raises RateLimitError
|
|
When I apply provider retry pattern
|
|
Then the function should retry with exponential jitter
|
|
And the function should respect rate limit backoff
|
|
|
|
Scenario: Circuit breaker opens after threshold
|
|
Given I have a circuit breaker with threshold 3
|
|
When a function fails 3 times
|
|
Then the circuit breaker should open
|
|
And subsequent calls should fail immediately
|
|
|
|
Scenario: Circuit breaker resets after timeout
|
|
Given I have an open circuit breaker
|
|
When the recovery timeout expires
|
|
Then the circuit breaker should enter half-open state
|
|
And successful calls should close the circuit
|
|
|
|
Scenario: Retry context tracks attempts
|
|
Given I have a retry context for "test operation"
|
|
When I execute a function that fails twice
|
|
Then the retry context should track 3 attempts
|
|
And the errors should be recorded
|
|
|
|
Scenario: Retry with jitter prevents thundering herd
|
|
Given I have multiple concurrent operations
|
|
When I apply retry with jitter
|
|
Then the retries should have random delays
|
|
And operations should not retry simultaneously
|
|
|
|
Scenario: Auto-debug retry pattern works
|
|
Given I have a function that fails with errors
|
|
And I have a debug callback that fixes issues
|
|
When I apply auto-debug retry
|
|
Then the function should retry with debug fixes
|
|
And eventually succeed after debugging
|
|
|
|
Scenario: Retry categories have correct configurations
|
|
Given I have the retry categories defined
|
|
Then network operations should retry 5 times
|
|
And provider operations should retry 3 times
|
|
And database operations should retry 3 times
|
|
And file operations should retry 3 times |