@sailboat-computer/data-storage
Version:
Shared data storage library for sailboat computer v3
51 lines (37 loc) • 1.68 kB
Markdown
# Resilience Tests for Data Storage Package
This directory contains tests that verify the resilience features of the data storage package. These tests focus on ensuring the system can handle failures gracefully and recover properly.
## Test Categories
1. **Provider Unavailability Tests**
- Tests behavior when storage providers are unavailable
- Verifies fallback to local storage
- Ensures operations continue to work
2. **Recovery Tests**
- Tests recovery when providers become available again
- Verifies synchronization of locally stored data
- Ensures system returns to normal operation
3. **Graceful Degradation Tests**
- Tests behavior when all remote providers are unavailable
- Verifies system continues to function with reduced capabilities
- Ensures critical operations still work
4. **Circuit Breaker Tests**
- Tests circuit breaker opening and closing
- Verifies half-open state behavior
- Ensures proper failure counting and reset
5. **Timeout Tests**
- Tests behavior when operations time out
- Verifies timeout handling and recovery
- Ensures system remains responsive
## Running the Tests
```bash
# Run all resilience tests
npm test -- --testPathPattern=tests/resilience
# Run specific test category
npm test -- --testPathPattern=tests/resilience/provider-unavailability.test.ts
```
## Adding New Tests
When adding new resilience tests, follow these guidelines:
1. Group related tests in a single file
2. Use descriptive test names that explain the scenario
3. Include both failure and recovery scenarios
4. Mock external dependencies to simulate failures
5. Verify both functional behavior and metrics