Skip to content

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

soup test all

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

  1. Cross-Language Validation: Every test compares Python and Go implementations
  2. Binary-Level Equivalence: Wire protocol tests verify byte-for-byte output matching
  3. Shared Fixtures: Common test data defined in conftest.py files
  4. Clear Test Naming: souptest_* prefix identifies conformance tests
  5. Harness Integration: Tests use actual harness binaries, not mocked implementations