forked from mtusi2026/mtusi2026lab7
lab7: безопасность, mTLS, OpenBao и PKI lifecycle
This commit is contained in:
@@ -4,23 +4,22 @@
|
||||
The stand must be running. The script temporarily recreates worker/relay with
|
||||
FAULTS_ENABLED=1 and targeted failpoints, then restores the normal services.
|
||||
|
||||
python3 student-tests/lab5_faults.py --base-url http://localhost:8080
|
||||
python3 student-tests/lab5_faults.py --base-url https://localhost:8443
|
||||
"""
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'scripts'))
|
||||
|
||||
from client import Client, Failure, arguments, check, run # noqa: E402
|
||||
from tests_helpers import compose, jobctl, psql # noqa: E402
|
||||
from lab7_http import BASE_URL, CA_FILE # noqa: E402
|
||||
|
||||
FIXTURE = Path(__file__).resolve().parents[1] / 'tests/fixtures/sample.png'
|
||||
WORKER = 'mtusi-messenger-lab6-worker-1'
|
||||
RELAY = 'mtusi-messenger-lab6-relay-1'
|
||||
|
||||
|
||||
def worker_with(**env):
|
||||
@@ -61,11 +60,8 @@ def wait_db(attachment_id, predicate, timeout=120, description=''):
|
||||
|
||||
|
||||
def queue_messages(name):
|
||||
project = 'mtusi-messenger-lab6'
|
||||
result = subprocess.run(
|
||||
['docker', 'exec', project + '-broker-1', 'rabbitmqctl', '-p', 'messenger', 'list_queues', 'name', 'messages'],
|
||||
capture_output=True, text=True, check=True,
|
||||
)
|
||||
result = compose('exec', '-T', 'broker', 'rabbitmqctl', '-p', 'messenger',
|
||||
'list_queues', 'name', 'messages')
|
||||
for line in result.stdout.splitlines():
|
||||
if line.startswith(name):
|
||||
return int(line.split()[1])
|
||||
@@ -222,9 +218,9 @@ def scenario_lease_takeover(client, alice, chat):
|
||||
)
|
||||
|
||||
wait_db(attached['id'], lambda s, e, a: s == 'processing', 20, 'processing claim')
|
||||
subprocess.run(['docker', 'pause', WORKER], check=True, capture_output=True)
|
||||
compose('pause', 'worker')
|
||||
wait_db(attached['id'], lambda s, e, a: s == 'queued' and a >= 2, 30, 'lease expiry requeue')
|
||||
subprocess.run(['docker', 'unpause', WORKER], check=True, capture_output=True)
|
||||
compose('unpause', 'worker')
|
||||
ready = client.wait_ready(alice, attached, wait_seconds=60)
|
||||
check(len(ready['variants']) == 3, 'lease takeover produced an incomplete variant set')
|
||||
print('lease expiry: paused worker, reaper requeued, stale attempt fenced, ready')
|
||||
@@ -296,7 +292,7 @@ def scenario_replay_older_version_refused(client, alice, chat):
|
||||
|
||||
def main():
|
||||
args = arguments('Lab5 level 4 fault injection')
|
||||
client = Client(args.base_url, args.ca_file)
|
||||
client = Client(args.base_url or BASE_URL, args.ca_file or CA_FILE)
|
||||
alice, _, _, chat = client.bootstrap()
|
||||
|
||||
scenarios = [
|
||||
|
||||
Reference in New Issue
Block a user