AWS Integration Test Fixes Summary
Overview
This document summarizes the fixes implemented to resolve the AWS integration test issues, specifically the hanging tests and intermittent failures when using FakeCloud endpoints.
Issues Fixed
1. State Lock Conflicts
Problem: Tests were using shared state file paths causing conflicts when running in parallel with pytest-xdist.
Solution: Added temporary directory fixtures in conftest.py to isolate each test:
- test_output_dir fixture provides unique temp directory for each test
- state_file_path fixture provides unique state file path
- Tests automatically change to temp directory and restore original cwd
2. "a set is required" Error
Problem: AWS provider expects endpoints to be a SET type, but the cty_msgpack encoder was treating SET as LIST.
Solution: Fixed in cty_msgpack.py:
- Updated _build_element_type to handle SET nesting mode (value 3)
- Updated _infer_type to detect Python sets and encode as SET type
- Added schema-driven normalization helper to ensure endpoints formatting aligns with provider expectations
3. ApplyResourceChange Hanging
Problem: Tests with endpoints configuration would hang during ApplyResourceChange RPC call.
Root Cause: The actual issue was not hanging but provider state corruption between test runs. When tests alternated between configurations with and without endpoints, the provider's internal state became inconsistent.
Solutions Implemented:
1. Provider Lifecycle Management (provider_lifecycle.py):
- Tracks all active provider processes
- Ensures clean shutdown between test runs
- Registers cleanup handlers for graceful termination
- Timeout Protection in
provider_protocol.py: - Added 5-minute timeout to ApplyResourceChange RPC
-
Provides clear error message when timeout occurs
-
Environment Variable Workaround:
- Use AWS_ENDPOINT_URL_* environment variables instead of endpoints parameter
- This avoids the provider state corruption issue entirely
Test Results
Working Configuration (Environment Variables)
# Set environment variables
os.environ["AWS_ENDPOINT_URL_S3"] = "http://localhost:4566"
os.environ["AWS_ENDPOINT_URL_STS"] = "http://localhost:4566"
# Provider WITHOUT endpoints parameter
provider = AwsProvider(nf_id="aws", region="us-east-1", access_key="test", secret_key="test", skip_credentials_validation=True, skip_requesting_account_id=True, skip_metadata_api_check="true", s3_use_path_style=True)
This configuration successfully: - ✓ Plans resources - ✓ Creates resources in FakeCloud - ✓ Works with multiple resources concurrently
Known Issues
-
Destroy Phase Provider Configuration: The destroy phase fails with "Provider not configured" error. This is a separate issue related to provider lifecycle management during destroy operations.
-
Direct Endpoints Parameter: Using the
endpointsparameter directly still causes intermittent issues due to provider state corruption. The environment variable workaround is recommended.
Files Modified
/libs/netherframe.core/netherframe/core/cty_msgpack.py- Fixed SET type encoding/libs/netherframe.core/netherframe/core/config/config_normalization.py- Schema-aware normalization for provider inputs/libs/netherframe.core/netherframe/core/provider_protocol.py- Added timeout and endpoints fix/libs/netherframe.core/netherframe/core/provider_lifecycle.py- Provider lifecycle management/libs/netherframe.core/tests/integration/aws/conftest.py- Test isolation fixtures- All integration test files - Updated to use temp directory fixtures
Recommendations
-
Use Environment Variables: For FakeCloud testing, use AWS_ENDPOINT_URL_* environment variables instead of the endpoints parameter.
-
Test Isolation: Always use the temp directory fixtures to ensure test isolation.
-
Provider Cleanup: The provider lifecycle manager helps but may need further improvements for the destroy phase.
-
Future Work:
- Fix the destroy phase provider configuration issue
- Investigate why direct endpoints parameter causes state corruption
- Consider implementing provider pooling to avoid frequent start/stop cycles