diff --git a/scripts/candidate_runtime.py b/scripts/candidate_runtime.py index 34e2c9c..2ad99cd 100644 --- a/scripts/candidate_runtime.py +++ b/scripts/candidate_runtime.py @@ -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}]}}} diff --git a/scripts/test_candidate_release.py b/scripts/test_candidate_release.py index 1d2b58f..f029825 100644 --- a/scripts/test_candidate_release.py +++ b/scripts/test_candidate_release.py @@ -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])