rust/capture/docs/llma-acceptance-test-suite.md
This document describes the Python acceptance test suite for the LLM Analytics pipeline. These tests validate end-to-end functionality that requires real PostHog infrastructure: database, S3 storage, Kafka, authentication services, and the full ingestion pipeline.
Implementation Requirement: Each phase in the implementation plan must pass its corresponding acceptance tests before proceeding to the next phase. This ensures incremental validation and prevents regression as new features are added.
/i/v0/ai endpoint$ai_trace, $ai_span, $ai_generation, $ai_embedding, $ai_metric, $ai_feedbackapplication/json, text/plain, application/octet-streamPhase Completion Requirement: All acceptance tests for a phase must pass before implementation can proceed to the next phase. This gate ensures quality and prevents compound issues from multiple incomplete features.
test_basic_ai_generation_event: Full end-to-end event processingtest_all_accepted_ai_event_types: Verify all six supported AI event types are accepted and storedtest_ai_endpoint_invalid_auth_returns_401: Invalid token validationThe acceptance test suite is implemented in Python using pytest to test against full PostHog infrastructure.
common/ingestion/acceptance_tests/test_llm_analytics.pyrequests for HTTP client operationsboto3 for S3 client operations (when needed)/i/v0/ai endpoint enabled# PostHog Instance (defaults to http://localhost:8010 if not set)
export POSTHOG_TEST_BASE_URL="http://localhost:8010"
# Personal API Key (required - no default)
export POSTHOG_PERSONAL_API_KEY="your_personal_api_key_here"
Creating a Personal API Key:
http://localhost:8010)POSTHOG_PERSONAL_API_KEYNote: The test suite automatically creates temporary organizations and projects for each test class and cleans them up after tests complete. S3 configuration is handled by the PostHog instance itself.
# Run all acceptance tests using the test runner
cd common/ingestion/acceptance_tests
python run_tests.py
# Or run pytest directly for specific tests
pytest test_llm_analytics.py::TestLLMAnalytics::test_basic_ai_generation_event -v
# Run specific test class
pytest test_llm_analytics.py::TestLLMAnalytics -v
The run_tests.py script automatically:
--numprocesses=auto for faster executionEach test phase will include common utilities for: