Files
zeekay 10e6fec4c0 debrand: the brand token is INSIGHTS_, and a wrong one stops the container
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO
split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live
pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the
container entrypoint, so the misspelling does not degrade a feature -- it runs
migrate --check against a database whose history this tree does not share and
the container never starts.

Both replacements are measured against the shipped tree rather than chosen:
every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL ->
INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12
determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_
tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of
the bad rule and cannot collide with an upstream name.

The rule is fixed for the next convergence, and the tree it already produced is
repaired in the same commit -- the codemod is idempotent against its own output,
so it cannot undo this itself.
2026-08-01 17:42:28 -07:00

95 lines
2.6 KiB
Python
Executable File

#!/usr/bin/env python3
"""Main test runner for Insights acceptance tests."""
import sys
import logging
import subprocess
from pathlib import Path
# Configure logging for the test runner
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s", datefmt="%H:%M:%S")
logger = logging.getLogger(__name__)
def run_tests():
"""Run the acceptance test suite."""
test_dir = Path(__file__).parent
# Use virtual environment if it exists
venv_python = test_dir / ".venv" / "bin" / "python"
if venv_python.exists():
python_cmd = str(venv_python)
else:
python_cmd = sys.executable
# Run pytest on all test files
# -v: verbose
# -s: no capture, show print statements
# --tb=short: short traceback format
# --log-cli-level=DEBUG: show debug logs in console
# --log-cli-format: format for console logs
result = subprocess.run(
[
python_cmd,
"-m",
"pytest",
"-v",
"-s",
"--tb=short",
"--log-cli-level=DEBUG",
"--log-cli-format=%(asctime)s [%(levelname)s] %(name)s: %(message)s",
"--log-cli-date-format=%H:%M:%S",
"--numprocesses=1",
],
cwd=test_dir,
stdout=sys.stdout,
stderr=sys.stderr,
)
return result.returncode
def main():
"""Main entry point for the test runner."""
logger.info("=" * 60)
logger.info("Insights Acceptance Tests")
logger.info("=" * 60)
# Log environment info
import os
logger.info("Environment:")
logger.info(
" INSIGHTS_TEST_BASE_URL: %s", os.environ.get("INSIGHTS_TEST_BASE_URL", "http://localhost:8010 (default)")
)
# nosemgrep: python.lang.security.audit.logging.logger-credential-leak.python-logger-credential-disclosure
logger.info(" INSIGHTS_PERSONAL_API_KEY: %s", "SET" if os.environ.get("INSIGHTS_PERSONAL_API_KEY") else "NOT SET")
exit_code = 1
try:
# Run the tests
logger.info("Running acceptance tests...")
logger.info("-" * 60)
exit_code = run_tests()
logger.info("-" * 60)
if exit_code == 0:
logger.info("✓ All tests passed!")
else:
logger.error("✗ Tests failed with exit code %s", exit_code)
except KeyboardInterrupt:
logger.info("Interrupted by user")
exit_code = 130
except Exception as e:
logger.exception("✗ Error: %s", e)
exit_code = 1
logger.info("Done.")
return exit_code
if __name__ == "__main__":
sys.exit(main())