my-homelab-configs/tests/jeannie/test_searxng_pipeline.py

45 lines
1.9 KiB
Python

#!/usr/bin/env python3
import pathlib
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[2]
class SearxngPipelineTests(unittest.TestCase):
def test_compose_has_isolated_valkey_and_resource_limits(self):
compose = (ROOT / "infra/searxng/docker-compose.yml").read_text(encoding="utf-8")
self.assertIn("name: homelab-searxng", compose)
self.assertIn("valkey:", compose)
self.assertIn("mem_limit: 768m", compose)
self.assertIn("searxng:2026.12.3-44427d4a8", compose)
self.assertNotIn("valkey/valkey:latest", compose)
def test_settings_enable_limiter_and_json(self):
settings = (ROOT / "infra/searxng/settings.yml").read_text(encoding="utf-8")
self.assertIn("limiter: true", settings)
self.assertIn("url: valkey://valkey:6379/0", settings)
self.assertIn("- json", settings)
def test_edge_has_dedicated_route_not_generic_backend(self):
main = (ROOT / "bootstrap/edge/main.tf").read_text(encoding="utf-8")
nginx = (ROOT / "bootstrap/edge/templates/default.conf.tftpl").read_text(encoding="utf-8")
self.assertIn('searxng_server_name', main)
self.assertIn('"search.${var.server_name}"', main)
self.assertIn("server_name ${searxng_server_name};", nginx)
self.assertIn("zone=searxng_search", nginx)
self.assertIn("proxy_pass http://${searxng_backend_host}:${searxng_backend_port}", nginx)
def test_pipeline_preserves_secret_and_checks_health(self):
pipeline = (ROOT / "lib/jeannie/pipeline.sh").read_text(encoding="utf-8")
self.assertIn("deploy_searxng()", pipeline)
self.assertIn('"id": "searxng-deploy"', pipeline)
self.assertIn("SEARXNG_SECRET=//p", pipeline)
self.assertIn('openssl rand -hex 32', pipeline)
self.assertIn('${http_port}/healthz', pipeline)
if __name__ == "__main__":
unittest.main()