fix(qa): 为候选库验收预留连接容量
build / build (push) Successful in 2m9s

This commit is contained in:
姚章浩
2026-11-25 01:09:01 +08:00
parent bb57a9835c
commit 7926c8e8b9
2 changed files with 21 additions and 0 deletions
+11
View File
@@ -49,6 +49,12 @@ def qa_database(path):
return url, cert
def qa_process_command(role):
if role not in ('api', 'worker'):
raise ValueError('unexpected QA process')
return ['/bin/sh', '-ec', 'export DATABASE_URL="$${DATABASE_URL}&pool_max_conns=2"; exec /app/' + role]
def ready(directory, bundle, test_database=None):
bundle = bundle.resolve()
manifest = cd.read_json(bundle / 'release.json')
@@ -99,6 +105,11 @@ def ready(directory, bundle, test_database=None):
if test_database is None:
services['api']['depends_on'] = {'postgres': {'condition': 'service_healthy'}}
services['worker'].update(command=['/app/worker'], depends_on={'api': {'condition': 'service_healthy'}})
if test_database is not None:
# Apply the pgx budget to the application process. The independent libpq
# migration probe reads the original, TLS-verified DSN from Docker exec.
for role in ('api', 'worker'):
services[role]['command'] = qa_process_command(role)
services['web'].update(ports=['127.0.0.1::8080'], depends_on={'api': {'condition': 'service_healthy'}})
internal_subnet = isolated_subnet()
networks = {'default': {'internal': test_database is None, 'ipam': {'config': [{'subnet': internal_subnet}]}}}
+10
View File
@@ -23,6 +23,16 @@ class CandidateReleaseTest(unittest.TestCase):
for n, sha in ((20, A), (21, B))}
self.report = {'actor': {'id': OWNER}, 'createdAt': '2026-11-01T11:00:00Z', 'id': OWNER}
def test_qa_application_budget_is_process_local(self):
import os
key = 'DATABASE' + '_URL'
for role in ('api', 'worker'):
shell, flags, body = runtime.qa_process_command(role)
self.assertTrue(body.endswith('exec /app/' + role))
rendered = body.replace('$$', '$').replace('exec /app/' + role, 'printenv ' + key)
value = subprocess.check_output([shell, flags, rendered], env={**os.environ, key: 'qa?sslmode=verify-full'}, text=True)
self.assertEqual(value.strip(), 'qa?sslmode=verify-full&pool_max_conns=2')
def test_one_requirement_owns_its_own_release(self):
plan = dict(self.plan, items=[{'task': TASK, 'commit': B}], extra=[A])
candidate.check_scope(plan, self.prs.__getitem__, [A, B])