fix(api): skip bootstrap ddl statement timeout
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m7s
CD Pipeline / build-and-deploy (push) Successful in 5m1s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 0s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 57s
CD Pipeline / post-deploy-checks (push) Successful in 3m23s
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m7s
CD Pipeline / build-and-deploy (push) Successful in 5m1s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 0s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 57s
CD Pipeline / post-deploy-checks (push) Successful in 3m23s
This commit is contained in:
@@ -12,6 +12,7 @@ from collections.abc import Awaitable
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.exc import DBAPIError
|
||||
|
||||
|
||||
class _FakeScalarResult:
|
||||
@@ -190,6 +191,29 @@ async def test_init_db_releases_bootstrap_lock_when_ddl_times_out(monkeypatch):
|
||||
assert any("pg_advisory_unlock" in stmt for stmt in fake_engine.lock_conn.statements)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_init_db_skips_bootstrap_when_postgres_statement_timeout(monkeypatch):
|
||||
from src.db import base as db_base
|
||||
|
||||
fake_engine = _FakeEngine()
|
||||
|
||||
async def fake_run_init_db_ddl(_engine: object) -> None:
|
||||
raise DBAPIError(
|
||||
"ALTER TABLE approval_records ADD COLUMN IF NOT EXISTS telegram_message_id",
|
||||
{},
|
||||
Exception("canceling statement due to statement timeout"),
|
||||
)
|
||||
|
||||
monkeypatch.setattr(db_base, "get_engine", lambda: fake_engine)
|
||||
monkeypatch.setattr(db_base, "_run_init_db_ddl", fake_run_init_db_ddl)
|
||||
|
||||
await db_base.init_db()
|
||||
|
||||
assert "pg_try_advisory_lock" in fake_engine.lock_conn.statements[0]
|
||||
assert any("pg_advisory_unlock" in stmt for stmt in fake_engine.lock_conn.statements)
|
||||
assert "COMMIT" in fake_engine.lock_conn.statements
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_signal_worker_initializes_worker_redis_pool_before_tasks(monkeypatch):
|
||||
from src.workers import signal_worker
|
||||
|
||||
Reference in New Issue
Block a user