fix(stage): stream Redis snapshot with native stdout support
Stage author bootstrap (dedicated repair) / bootstrap (push) Failing after 49s
Stage author bootstrap (dedicated repair) / bootstrap (push) Failing after 49s
This commit is contained in:
1 parent
2408bafc49
commit
5c93517b9e
3 files changed
+18
-2
No files matched your search
@@ -161,7 +161,7 @@ def rehearse(d, backup, sql, backend_image, env_file, token, owned, evidence):
|
||||
if redis_info.get('Name') != '/canino_redis_stage' or not redis_info.get('State', {}).get('Running'):
|
||||
raise ValueError('Stage session validator unavailable')
|
||||
rdb = d.run(['exec', 'canino_redis_stage', 'sh', '-c',
|
||||
'export REDISCLI_AUTH="$REDIS_PASSWORD"; exec redis-cli --rdb /dev/stdout'], timeout=120)
|
||||
'if [ -n "$REDIS_PASSWORD" ]; then export REDISCLI_AUTH="$REDIS_PASSWORD"; else unset REDISCLI_AUTH; fi; exec redis-cli --rdb -'], timeout=120)
|
||||
if not rdb.startswith(b'REDIS'): raise ValueError('Invalid Stage blacklist snapshot')
|
||||
redis = d.run(['create', '--pull=never', '--network=container:' + cid,
|
||||
redis_info['Image'], 'redis-server', '--bind', '127.0.0.1',
|
||||
|
||||
@@ -96,6 +96,22 @@ class WorkflowTests(unittest.TestCase):
|
||||
|
||||
|
||||
class MaintenanceTests(unittest.TestCase):
|
||||
def test_snapshot_stream_auth_matches_existing_configuration(self):
|
||||
import os
|
||||
text = (HERE / 'operation.py').read_text()
|
||||
command = next(line.strip().split("'", 2)[1] for line in text.splitlines()
|
||||
if 'if [ -n "$REDIS_PASSWORD" ]' in line)
|
||||
self.assertIn('exec redis-cli --rdb -', command)
|
||||
with tempfile.TemporaryDirectory(dir='/opt/data/cache/scratch') as tmp:
|
||||
cli = Path(tmp) / 'redis-cli'
|
||||
cli.write_text('#!/bin/sh\nprintf "%s:%s:%s" "${REDISCLI_AUTH-unset}" "$1" "$2"\n')
|
||||
cli.chmod(0o700)
|
||||
for password, expected in [('', 'unset:--rdb:-'), ('fixture', 'fixture:--rdb:-')]:
|
||||
env = dict(os.environ, PATH=tmp+':'+os.environ['PATH'],
|
||||
REDIS_PASSWORD=password, REDISCLI_AUTH='stale-fixture')
|
||||
result = subprocess.run(['sh','-c',command], env=env, capture_output=True, text=True, check=True)
|
||||
self.assertEqual(result.stdout, expected)
|
||||
|
||||
def test_no_published_port_real_validator_and_single_post(self):
|
||||
op=ci.op
|
||||
calls=[]
|
||||
|
||||
@@ -33,7 +33,7 @@ class RecoveryTests(unittest.TestCase):
|
||||
return b'[{"Name":"/canino_redis_stage","State":{"Running":true},"Image":"redis"}]'
|
||||
if args[:2] == ['inspect', '-f']: return b'true'
|
||||
if args[0] == 'create': return ('b'*64).encode()
|
||||
if '--rdb /dev/stdout' in ' '.join(args): return b'REDISsnapshot'
|
||||
if '--rdb -' in ' '.join(args): return b'REDISsnapshot'
|
||||
if 'PING' in args: return b'PONG'
|
||||
if args[0] == 'run': return ('a'*64).encode()
|
||||
if 'pg_restore' in args:
|
||||
|
||||
Reference in new issue
Block a user