Preserve distributed job context and expose grade 4 operational signals
This commit is contained in:
@@ -6,6 +6,7 @@ import sys
|
||||
from collections.abc import AsyncIterator
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
@@ -15,6 +16,7 @@ from alembic.migration import MigrationContext
|
||||
from alembic.script import ScriptDirectory
|
||||
from alembic.util import CommandError
|
||||
from sqlalchemy import MetaData, Table, case, func, insert, inspect, literal, make_url, select, text
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy.pool import NullPool
|
||||
@@ -44,6 +46,7 @@ VERSIONS = [
|
||||
"0004_jobs",
|
||||
"0005_failed_registry",
|
||||
"0006_attachment_quarantine",
|
||||
"0007_trace_context",
|
||||
]
|
||||
TABLES = [
|
||||
UserRow,
|
||||
@@ -247,13 +250,15 @@ async def contents(dsn: str) -> dict:
|
||||
table = await connection.run_sync(
|
||||
lambda sync, name=model.__tablename__: Table(name, MetaData(), autoload_with=sync)
|
||||
)
|
||||
missing = {}
|
||||
missing: dict[str, Any] = {}
|
||||
if model is AttachmentRow and "published_version" not in table.c:
|
||||
missing = {
|
||||
"original_key": case((table.c.status == "ready", table.c.object_key)),
|
||||
"staging_key": case((table.c.status == "pending", table.c.object_key)),
|
||||
"published_version": case((table.c.status == "ready", 1), else_=0),
|
||||
}
|
||||
if model in (JobRow, OutboxRow):
|
||||
missing["trace_context"] = literal({}, type_=JSONB)
|
||||
columns = [
|
||||
table.c[col.name]
|
||||
if col.name in table.c
|
||||
@@ -449,7 +454,7 @@ async def test_failed_revision_rolls_back_ddl_and_version(
|
||||
"from alembic import op\n"
|
||||
"import sqlalchemy as sa\n"
|
||||
"revision = '0003_failure'\n"
|
||||
"down_revision = '0006_attachment_quarantine'\n"
|
||||
"down_revision = '0007_trace_context'\n"
|
||||
"def upgrade():\n"
|
||||
" op.create_table('must_rollback', sa.Column('id', sa.Integer, primary_key=True))\n"
|
||||
" raise RuntimeError('migration failed')\n"
|
||||
|
||||
Reference in New Issue
Block a user