Created comprehensive test suites for P2 priority features:
- Cloud Backend Retry Configuration
- asyncio.to_thread Error Propagation
- Passing: 30 tests (93.75%)
- Failing (Expected - RED phase): 2 tests (6.25%)
File: /Users/gregorydickson/memory-graph/tests/test_cloud_retry_config.py
Tests for Config class retry parameters:
test_default_max_retries- Verifies CLOUD_MAX_RETRIES default = 3test_default_retry_backoff- Verifies CLOUD_RETRY_BACKOFF_BASE default = 1.0test_default_circuit_breaker_threshold- Verifies CLOUD_CIRCUIT_BREAKER_THRESHOLD default = 5test_default_circuit_breaker_timeout- Verifies CLOUD_CIRCUIT_BREAKER_TIMEOUT default = 60.0test_config_values_are_correct_types- Type validation (int/float)test_env_override_max_retries- MEMORYGRAPH_MAX_RETRIES env vartest_env_override_retry_backoff- MEMORYGRAPH_RETRY_BACKOFF env vartest_env_override_circuit_breaker_threshold- MEMORYGRAPH_CB_THRESHOLD env vartest_env_override_circuit_breaker_timeout- MEMORYGRAPH_CB_TIMEOUT env vartest_env_override_all_retry_config- All env vars togethertest_config_attributes_exist- Attribute existence check
Tests for CloudRESTAdapter using Config values:
test_cloud_backend_default_circuit_breaker_values- ✅ PASSINGtest_cloud_backend_uses_config_circuit_breaker_values- ❌ FAILING (RED phase)- Expected: Circuit breaker uses Config.CLOUD_CIRCUIT_BREAKER_THRESHOLD
- Actual: Hardcoded to 5
test_cloud_backend_respects_config_changes- ❌ FAILING (RED phase)- Expected: New instances pick up Config changes
- Actual: Always uses hardcoded value 5
Tests for config value validation:
test_invalid_max_retries_int_conversion- Invalid int raises ValueErrortest_invalid_retry_backoff_float_conversion- Invalid float raises ValueErrortest_invalid_cb_threshold_int_conversion- Invalid int raises ValueErrortest_invalid_cb_timeout_float_conversion- Invalid float raises ValueErrortest_zero_values_are_valid- Zero values acceptedtest_negative_values_are_valid- Negative values accepted (validation at usage)
File: /Users/gregorydickson/memory-graph/tests/test_asyncio_error_propagation.py
Tests for error propagation through asyncio.to_thread wrapper:
-
test_database_error_propagates_through_to_thread- ✅- Verifies DatabaseConnectionError propagates when connection closed
-
test_validation_error_propagates- ✅- Verifies ValidationError propagates for invalid operations
-
test_memory_not_found_propagates- ✅- Verifies get_memory returns None for non-existent IDs
- Verifies delete_memory returns False for non-existent IDs
-
test_concurrent_operations_handle_errors- ✅- Verifies concurrent read operations work correctly
- Tests asyncio.gather with multiple memory reads
-
test_exception_type_preserved- ✅- Verifies specific exception types preserved through asyncio.to_thread
- Ensures ValidationError not wrapped or transformed
-
test_concurrent_writes_error_handling- ✅- Tests sequential write operations (SQLite limitation)
- Verifies all writes succeed
-
test_error_during_concurrent_operations- ✅- Tests concurrent read operations
- Verifies no cross-contamination of errors
-
test_database_locked_error_handling- ✅- Tests sequential writes to avoid SQLite threading issues
- Verifies 20 sequential writes succeed
-
test_error_traceback_preserved- ✅- Verifies error tracebacks preserved through asyncio.to_thread
- Checks traceback contains relevant file/function names
-
test_multiple_sequential_errors- ✅- Verifies multiple sequential errors handled correctly
- All raise same error type
-
test_error_after_successful_operations- ✅- Tests error handling after successful operations
- Verifies state transitions work correctly
-
test_validation_error_with_detailed_message- ✅- Verifies ValidationError preserves detailed error messages
- Checks message contains relevant context
File: src/memorygraph/backends/cloud_backend.py
Line: 208
Change:
self._circuit_breaker = CircuitBreaker(failure_threshold=5, recovery_timeout=60.0)To:
self._circuit_breaker = CircuitBreaker(
failure_threshold=Config.CLOUD_CIRCUIT_BREAKER_THRESHOLD,
recovery_timeout=Config.CLOUD_CIRCUIT_BREAKER_TIMEOUT
)This will make the CloudRESTAdapter read circuit breaker configuration from Config instead of hardcoding values.
- ✅ Config attribute existence
- ✅ Default values
- ✅ Environment variable overrides
- ✅ Type conversion (int/float)
- ✅ Invalid value handling
- ✅ Edge cases (zero, negative)
- ⏳ CloudRESTAdapter integration (2 tests in RED phase)
- ✅ DatabaseConnectionError propagation
- ✅ ValidationError propagation
- ✅ MemoryNotFoundError handling
- ✅ Concurrent read operations
- ✅ Sequential write operations
- ✅ Exception type preservation
- ✅ Traceback preservation
- ✅ Error message preservation
- ✅ State transitions
- ✅ Multiple sequential errors
# Run P2 tests only
python3 -m pytest tests/test_cloud_retry_config.py tests/test_asyncio_error_propagation.py -v
# Run with specific markers
python3 -m pytest tests/ -k "CloudRetryConfig or AsyncioToThread" -v --tb=short
# Run full test suite
python3 -m pytest tests/ -q --tb=short/Users/gregorydickson/memory-graph/tests/test_cloud_retry_config.py- 20 tests/Users/gregorydickson/memory-graph/tests/test_asyncio_error_propagation.py- 12 tests
Total: 32 new tests, 30 passing, 2 in RED phase (expected - TDD)