forked from mtusi2026/mtusi2026lab7
feat: completed tasks for grade 4
This commit is contained in:
@@ -28,12 +28,13 @@ class ComposeProject:
|
||||
self.config = json.loads(self.run("config", "--format", "json"))
|
||||
self.name = self.config["name"]
|
||||
|
||||
def docker(self, *args: str, timeout: int = 90, env=None) -> str:
|
||||
def docker(self, *args: str, timeout: int = 90, env=None, input_text=None) -> str:
|
||||
"""Выполняет Docker-команду с ограничением времени."""
|
||||
result = subprocess.run(
|
||||
["docker", *args],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
input=input_text,
|
||||
capture_output=True,
|
||||
timeout=timeout,
|
||||
env={**os.environ, **(env or {})},
|
||||
@@ -42,9 +43,9 @@ class ComposeProject:
|
||||
raise RuntimeError(result.stderr.strip() or result.stdout.strip())
|
||||
return result.stdout.strip()
|
||||
|
||||
def run(self, *args: str, timeout: int = 90, env=None) -> str:
|
||||
def run(self, *args: str, timeout: int = 90, env=None, input_text=None) -> str:
|
||||
"""Выполняет команду Compose с текущими overrides."""
|
||||
return self.docker(*self.command[1:], *args, timeout=timeout, env=env)
|
||||
return self.docker(*self.command[1:], *args, timeout=timeout, env=env, input_text=input_text)
|
||||
|
||||
def replicas(self) -> list[Replica]:
|
||||
"""Читает состояние API без окружения контейнеров."""
|
||||
@@ -170,7 +171,7 @@ def verify(*, keep_stand=False):
|
||||
summary = re.search(r'\d+ passed[^\n]*', result.stdout)
|
||||
if summary:
|
||||
entry['summary'] = summary.group(0)
|
||||
if name == 'security' and not result.returncode:
|
||||
if name in ('security', 'lifecycle') and not result.returncode:
|
||||
entry['summary'] = result.stdout.strip().splitlines()
|
||||
print(result.stdout.strip(), flush=True)
|
||||
if result.returncode:
|
||||
@@ -200,6 +201,8 @@ def verify(*, keep_stand=False):
|
||||
run('external-tls', [sys.executable, 'tests/security.py', '--base-url', 'https://localhost:28080'])
|
||||
run('security', [sys.executable, '-m', 'scripts.check_security',
|
||||
'--base-url', 'https://localhost:28080', '--bao-port', bao_port])
|
||||
run('lifecycle', [sys.executable, '-m', 'scripts.check_lifecycle',
|
||||
'--base-url', 'https://localhost:28080', '--bao-port', bao_port])
|
||||
run('failover', [sys.executable, 'tests/resilience.py', '--mode', 'failover',
|
||||
'--action-script', 'scripts/stop-one.sh', '--base-url', 'https://localhost:28080'])
|
||||
report['result'] = 'PASS'
|
||||
|
||||
Reference in New Issue
Block a user