fix(ops): reconcile CI backend wrapper and gate locked dependency image before swap
Deploy Backend / deploy (push) Successful in 1m17s
Deploy Backend / deploy (push) Successful in 1m17s
This commit is contained in:
1 parent
c2960c4ed0
commit
3fb1e417c6
5 files changed
+108
-2
No files matched your search
@@ -0,0 +1,50 @@
|
||||
"""Disposable deployment boundary tests. Never contacts Docker or production."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
class DeployBoundary(unittest.TestCase):
|
||||
def run_fixture(self, broken=False):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
p = Path(tmp)
|
||||
(p/'bin').mkdir()
|
||||
(p/'repo/ops').mkdir(parents=True)
|
||||
(p/'repo/ops/backend.compose.yml').write_text('services: {}\n')
|
||||
(p/'base.yml').write_text('services: {}\n')
|
||||
log = p/'calls'
|
||||
for name, body in {
|
||||
'git': 'if [ "$1" = rev-parse ]; then printf "%040d\\n" 1; fi',
|
||||
'docker': 'printf "%s\\n" "$*" >> "$CALLS"; if [ "$1" = run ] && [ "$BROKEN" = 1 ]; then exit 17; fi',
|
||||
'curl': 'printf 200',
|
||||
'sleep': ':',
|
||||
}.items():
|
||||
f = p/'bin'/name
|
||||
f.write_text('#!/bin/sh\n'+body+'\n')
|
||||
f.chmod(0o755)
|
||||
env = dict(os.environ, PATH=str(p/'bin')+':'+os.environ['PATH'],
|
||||
APP_DIR=str(p/'repo'), BASE_COMPOSE=str(p/'base.yml'),
|
||||
CALLS=str(log), BROKEN=str(int(broken)))
|
||||
result = subprocess.run(['bash', str(ROOT/'ops/deploy-backend.sh'), '0'*39+'1'], env=env, capture_output=True, text=True)
|
||||
return result, log.read_text() if log.exists() else ''
|
||||
|
||||
def test_missing_vendor_prevents_container_swap(self):
|
||||
r, calls = self.run_fixture(True)
|
||||
self.assertNotEqual(r.returncode, 0)
|
||||
self.assertIn('run --rm --network none --entrypoint php', calls)
|
||||
self.assertNotIn(' up ', calls)
|
||||
|
||||
def test_build_assertion_precedes_backend_only_swap(self):
|
||||
r, calls = self.run_fixture()
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertLess(calls.index(' build backend'), calls.index('run --rm'))
|
||||
self.assertLess(calls.index('run --rm'), calls.index(' up '))
|
||||
self.assertIn('up -d --no-deps --no-build backend', calls)
|
||||
self.assertNotIn('migrate', calls)
|
||||
self.assertNotIn('prune', calls)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user