release: bump version to 0.74.4
This commit is contained in:
1 parent
a54fcdbeed
commit
58671e7bc3
71 files changed
+2999
-791
No files matched your search
@@ -8,6 +8,7 @@ from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
@@ -43,6 +44,163 @@ def run_shell(functions: list[str], setup: str, action: str) -> subprocess.Compl
|
||||
|
||||
|
||||
class DatabaseLifecycleTests(unittest.TestCase):
|
||||
def test_ai_start_uses_host_readiness_without_waiting_for_docker_probe_schedule(self) -> None:
|
||||
for recreate in (0, 1):
|
||||
with self.subTest(recreate=recreate):
|
||||
result = run_shell(
|
||||
["start_ai_provider_service"],
|
||||
f"""
|
||||
AI_PROVIDER_RECREATE_REQUIRED={recreate}
|
||||
AI_PROVIDER_START_MAX_RETRIES=1
|
||||
AI_PROVIDER_HEALTH_CHECK_ATTEMPTS=10
|
||||
AI_PROVIDER_HEALTH_CHECK_INTERVAL=2
|
||||
AI_PROVIDER_CONTAINER_NAME=planet_aiprovider
|
||||
for fn in set_wait_detail write_ai_provider_runtime_env_file \
|
||||
ensure_ai_provider_image_current recreate_ai_provider_container docker; do
|
||||
functions[$fn]='return 0'
|
||||
done
|
||||
wait_for_container_health() {{ echo WAIT_FOR_DOCKER_SCHEDULE; return 1; }}
|
||||
wait_for_http() {{ echo "HOST_CHECK $1"; return 0; }}
|
||||
log_error() {{ :; }}
|
||||
""",
|
||||
"start_ai_provider_service 18010",
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertIn("HOST_CHECK http://localhost:18010/health", result.stdout)
|
||||
self.assertNotIn("WAIT_FOR_DOCKER_SCHEDULE", result.stdout)
|
||||
|
||||
def test_fatal_backend_startup_does_not_launch_three_identical_attempts(self) -> None:
|
||||
result = run_shell(
|
||||
["start_backend_with_retry"],
|
||||
f"""
|
||||
SCRIPT_DIR={ROOT}
|
||||
BACKEND_LOG_FILE=/dev/null
|
||||
BACKEND_PID_FILE=/dev/null
|
||||
BACKEND_MAX_RETRIES=3
|
||||
BACKEND_HEALTH_CHECK_ATTEMPTS=60
|
||||
BACKEND_HEALTH_CHECK_INTERVAL=2
|
||||
VERBOSE=0
|
||||
cleanup_backend_processes() {{ :; }}
|
||||
start_detached_command() {{ echo STARTED >&2; echo 42; }}
|
||||
write_pid_file() {{ :; }}
|
||||
wait_for_http() {{ return 2; }}
|
||||
kill() {{ :; }}
|
||||
backend_log_indicates_port_conflict() {{ return 1; }}
|
||||
animate_wait_spinner() {{ echo WAITED; }}
|
||||
log_error() {{ :; }}
|
||||
""",
|
||||
"start_backend_with_retry 8000",
|
||||
)
|
||||
self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
|
||||
self.assertEqual(result.stderr.count("STARTED"), 1)
|
||||
self.assertNotIn("WAITED", result.stdout)
|
||||
|
||||
def test_start_keeps_stopped_containers_available_for_reuse(self) -> None:
|
||||
result = run_shell(
|
||||
["start"],
|
||||
"""
|
||||
BACKEND_PORT=8000
|
||||
FRONTEND_PORT=3000
|
||||
AI_PROVIDER_PORT=8010
|
||||
BACKEND_PORT_REQUESTED=0
|
||||
FRONTEND_PORT_REQUESTED=0
|
||||
FRONTEND_LAN_ENABLED=0
|
||||
MOTION_AGENT_REQUESTED=0
|
||||
for fn in parse_service_args prepare_allow_lan_public_ports print_splash \
|
||||
start_backend_service start_frontend_service write_port_state \
|
||||
verify_allow_lan_access log_success log_note; do
|
||||
functions[$fn]='return 0'
|
||||
done
|
||||
current_frontend_scheme() { echo http; }
|
||||
cleanup_exit_containers() { echo DELETED_STOPPED_CONTAINERS; }
|
||||
""",
|
||||
"start --non-motion-agent",
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertNotIn("DELETED_STOPPED_CONTAINERS", result.stdout)
|
||||
|
||||
def test_start_checks_database_before_preparing_ai_and_starting_backend(self) -> None:
|
||||
for connection_status in (0, 1):
|
||||
with self.subTest(connection_status=connection_status):
|
||||
result = run_shell(
|
||||
["start_backend_service"],
|
||||
f"""
|
||||
BACKEND_MAX_RETRIES=3
|
||||
BACKEND_LOG_FILE=/dev/null
|
||||
for fn in set_wait_detail log_success log_note log_error; do
|
||||
functions[$fn]='return 0'
|
||||
done
|
||||
ensure_uv_backend_deps() {{ echo DEPS; }}
|
||||
ensure_database_services_healthy() {{ echo CONTAINERS; }}
|
||||
verify_backend_database_connection() {{ echo DB_CHECK; return {connection_status}; }}
|
||||
ai_provider_service_healthy() {{ return 1; }}
|
||||
start_ai_provider_service() {{ echo AI_STARTED; }}
|
||||
start_backend_with_retry() {{ echo BACKEND_STARTED; }}
|
||||
""",
|
||||
"start_backend_service 8000 0 8010",
|
||||
)
|
||||
self.assertIn("DB_CHECK", result.stdout)
|
||||
if connection_status:
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertNotIn("AI_STARTED", result.stdout)
|
||||
self.assertNotIn("BACKEND_STARTED", result.stdout)
|
||||
else:
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertLess(result.stdout.index("DB_CHECK"), result.stdout.index("AI_STARTED"))
|
||||
self.assertEqual(result.stdout.count("DEPS"), 1)
|
||||
|
||||
def test_backend_fatal_startup_log_stops_waiting_while_reloader_is_alive(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
log_file = Path(directory) / "backend.log"
|
||||
log_file.write_text("Application startup failed. Exiting.\n")
|
||||
result = run_shell(
|
||||
["wait_for_http", "backend_startup_failed", "log_matches"],
|
||||
f"""
|
||||
BACKEND_PID=$$
|
||||
BACKEND_LOG_FILE={log_file}
|
||||
set_wait_detail() {{ :; }}
|
||||
clear_wait_spinner() {{ :; }}
|
||||
http_ok() {{ echo HTTP_PROBE; return 1; }}
|
||||
animate_wait_spinner() {{ echo WAIT; }}
|
||||
""",
|
||||
"wait_for_http http://localhost:8000/health 60 2 backend backend_startup_failed",
|
||||
)
|
||||
self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
|
||||
self.assertNotIn("WAIT", result.stdout)
|
||||
self.assertNotIn("HTTP_PROBE", result.stdout)
|
||||
|
||||
def test_readiness_without_failure_probe_still_waits_for_slow_healthy_services(self) -> None:
|
||||
result = run_shell(
|
||||
["wait_for_http"],
|
||||
"""
|
||||
probes=0
|
||||
set_wait_detail() { :; }
|
||||
clear_wait_spinner() { :; }
|
||||
finish_wait_spinner() { :; }
|
||||
format_wait_elapsed_seconds() { echo 0; }
|
||||
http_ok() { probes=$((probes + 1)); [ $probes -eq 3 ]; }
|
||||
animate_wait_spinner() { echo WAIT; }
|
||||
""",
|
||||
"wait_for_http http://localhost:8010/health 10 2 provider",
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertEqual(result.stdout.count("WAIT"), 2)
|
||||
|
||||
def test_backend_worker_import_failure_is_distinct_from_optional_collector_errors(self) -> None:
|
||||
for contents, expected_status in (
|
||||
("Process SpawnProcess-1:\nModuleNotFoundError: missing_app\n", 0),
|
||||
("Collector unavailable\nImportError: optional_dependency\n", 1),
|
||||
):
|
||||
with self.subTest(contents=contents), tempfile.TemporaryDirectory() as directory:
|
||||
log_file = Path(directory) / "backend.log"
|
||||
log_file.write_text(contents)
|
||||
result = run_shell(
|
||||
["backend_startup_failed", "log_matches"],
|
||||
f"BACKEND_PID=$$\nBACKEND_LOG_FILE={log_file}",
|
||||
"backend_startup_failed",
|
||||
)
|
||||
self.assertEqual(result.returncode, expected_status, result.stderr)
|
||||
|
||||
def test_existing_container_gets_current_compose_configuration(self) -> None:
|
||||
for function in ("start_database_services", "start_postgres_service"):
|
||||
with self.subTest(function=function):
|
||||
|
||||
Reference in new issue
Block a user