Skip to content

Commit ae37590

Browse files
committed
Remove the accounts created by deployment smoke tests
The production smoke test and post-deploy probes each registered an account on the live service. A data migration deletes exactly those five accounts by email, and everything they own cascades with them; on any other database none of the addresses exist and it does nothing.
1 parent eed5ac1 commit ae37590

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""remove deployment test accounts
2+
3+
The production smoke tests and post-deploy probes of 2026-10-01 and 2026-10-02 each registered
4+
an account to exercise the live service end to end. This deletes exactly those accounts, by
5+
email, together with everything they own (their documents, branches, edits and sessions cascade).
6+
Elsewhere none of these addresses exist, so this does nothing.
7+
8+
Revision ID: 8cbbb2f048f7
9+
Revises: b48a71d073f4
10+
Create Date: 2026-10-02 20:41:07.513946
11+
"""
12+
13+
from collections.abc import Sequence
14+
15+
import sqlalchemy as sa
16+
from alembic import op
17+
18+
revision: str = "8cbbb2f048f7"
19+
down_revision: str | None = "b48a71d073f4"
20+
branch_labels: str | Sequence[str] | None = None
21+
depends_on: str | Sequence[str] | None = None
22+
23+
TEST_ACCOUNTS = (
24+
"smoke-alice-47d4b5ba@example.com",
25+
"smoke-bob-605e929c@example.com",
26+
"probe-heartbeat-1634a3f7@example.com",
27+
"probe-phase3-fc90e04d@example.com",
28+
"probe-phase7-5d1c2e@example.com",
29+
)
30+
31+
32+
def upgrade() -> None:
33+
op.get_bind().execute(
34+
sa.text("DELETE FROM users WHERE email IN :emails").bindparams(
35+
sa.bindparam("emails", expanding=True)
36+
),
37+
{"emails": list(TEST_ACCOUNTS)},
38+
)
39+
40+
41+
def downgrade() -> None:
42+
pass # deleted data cannot come back, and nothing depends on it

‎apps/api/tests/test_migrations.py‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,48 @@ async def test_search_text_is_backfilled_for_documents_edited_before_search(
8585
await engine.dispose()
8686

8787
assert rows == {"Old doc": "Written before search existed", "Never opened": ""}
88+
89+
90+
async def test_deployment_test_accounts_are_removed_and_nothing_else(database_url: str) -> None:
91+
from sqlalchemy import text
92+
93+
config = alembic_config(database_url)
94+
await asyncio.to_thread(command.downgrade, config, "b48a71d073f4")
95+
engine = create_engine(database_url)
96+
try:
97+
async with engine.begin() as conn:
98+
await conn.execute(text("TRUNCATE users, documents CASCADE"))
99+
await conn.execute(
100+
text(
101+
"INSERT INTO users (id, email, name, password_hash) VALUES"
102+
" ('01900000-0000-7000-8000-00000000000a', 'smoke-bob-605e929c@example.com',"
103+
" 'Smoke Bob', 'x'),"
104+
" ('01900000-0000-7000-8000-00000000000b', 'real@example.com', 'Real', 'x')"
105+
)
106+
)
107+
await conn.execute(
108+
text(
109+
"INSERT INTO documents (id, owner_id, title) VALUES"
110+
" ('01900000-0000-7000-8000-00000000000c',"
111+
" '01900000-0000-7000-8000-00000000000a', 'Smoke test'),"
112+
" ('01900000-0000-7000-8000-00000000000d',"
113+
" '01900000-0000-7000-8000-00000000000b', 'Real work')"
114+
)
115+
)
116+
117+
await asyncio.to_thread(command.upgrade, config, "head")
118+
119+
async with engine.connect() as conn:
120+
emails: list[str] = list(
121+
(await conn.execute(text("SELECT email FROM users"))).scalars()
122+
)
123+
titles: list[str] = list(
124+
(await conn.execute(text("SELECT title FROM documents"))).scalars()
125+
)
126+
await conn.execute(text("TRUNCATE users, documents CASCADE"))
127+
await conn.commit()
128+
finally:
129+
await engine.dispose()
130+
131+
assert emails == ["real@example.com"]
132+
assert titles == ["Real work"] # the test account's document went with it

0 commit comments

Comments
 (0)