Conformance Testing Strategy¶
This document outlines the architecture for the TofuSoup conformance testing suite.
๐ค AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
Testing Philosophy: souptest vs. pytest¶
A core distinction in this project is the separation of concerns in testing:
- Conformance Tests (souptest_*.py): These tests, located in tofusoup/conformance/, are for verifying cross-language compatibility. They compare the behavior of Python implementations against the canonical Go harnesses. They are run via the soup test command.
- Internal Tests (test_*.py): These are standard unit and integration tests for the tofusoup tool itself. They are located in tofusoup/tests/ and are run using pytest directly.
Directory Structure¶
The conformance test suite is organized by component and test type:
conformance/
โโโ conftest.py # Global fixtures and configurations
โโโ utils/ # Shared test utilities
โ
โโโ cty/ # CTY conformance tests
โ โโโ souptest_cty_python_vs_go.py # Cross-language CTY compatibility
โ โโโ conftest.py # CTY-specific fixtures
โ
โโโ hcl/ # HCL conformance tests
โ โโโ souptest_hcl_python_vs_go.py # Cross-language HCL compatibility
โ โโโ testdata/ # HCL test fixtures
โ โโโ conftest.py # HCL-specific fixtures
โ
โโโ wire/ # Wire protocol conformance tests
โ โโโ souptest_wire_python_vs_go.py # Wire protocol compatibility
โ โโโ conftest.py # Wire-specific fixtures
โ
โโโ rpc/ # RPC conformance tests
โ โโโ souptest_rpc_matrix.py # Cross-language RPC matrix testing
โ โโโ souptest_rpc_kv.py # KV service tests
โ โโโ certs/ # Test certificates
โ โโโ conftest.py # RPC-specific fixtures
โ
โโโ cli_verification/ # CLI harness verification tests
โ โโโ souptest_cty_cli.py # CTY CLI tests
โ โโโ souptest_hcl_cli.py # HCL CLI tests
โ โโโ souptest_wire_cli.py # Wire CLI tests
โ
โโโ equivalence/ # Terraform equivalence testing
โ โโโ tests/ # Equivalence test cases
โ โโโ tfcoremock/ # Terraform mock infrastructure
โ
โโโ tf/ # Terraform integration tests
โโโ http_api/ # HTTP backend tests
โโโ nested/ # Nested module tests
Test Organization¶
Component Tests¶
Each component has dedicated conformance tests that validate cross-language compatibility:
- CTY Tests: Verify that Python CTY encoding/decoding produces identical results to Go
- HCL Tests: Ensure HCL parsing produces identical AST representations
- Wire Tests: Validate binary-level equivalence in wire protocol encoding
- RPC Tests: Test cross-language RPC communication (Python โ Go)
CLI Verification Tests¶
CLI verification tests validate that harness command-line interfaces work correctly: - Execute harness binaries with various inputs - Verify exit codes and output formats - Ensure consistent behavior across language implementations
Integration Tests¶
Integration tests in equivalence/ and tf/ directories validate:
- Full Terraform workflows
- Provider lifecycle operations
- State management
- Backend operations
Running Tests¶
Run All Conformance Tests¶
Run Component-Specific Tests¶
soup test cty # CTY conformance tests
soup test hcl # HCL conformance tests
soup test wire # Wire protocol tests
soup test rpc # RPC tests
Run with Pytest Directly¶
# All conformance tests
pytest conformance/
# Specific component
pytest conformance/cty/ -v
# With markers
pytest conformance/ -m "not slow"
Test Design Principles¶
- Cross-Language Validation: Every test compares Python and Go implementations
- Binary-Level Equivalence: Wire protocol tests verify byte-for-byte output matching
- Shared Fixtures: Common test data defined in
conftest.pyfiles - Clear Test Naming:
souptest_*prefix identifies conformance tests - Harness Integration: Tests use actual harness binaries, not mocked implementations