created tasks for grade 4
This commit is contained in:
+14
-5
@@ -137,20 +137,23 @@ def verify():
|
||||
import time
|
||||
|
||||
project_name = os.getenv('TEST_PROJECT', 'messenger-test')
|
||||
if any(inventory([project_name]).values()):
|
||||
raise RuntimeError(f'Choose an unused TEST_PROJECT; {project_name} already has resources')
|
||||
os.environ.update(COMPOSE_PROJECT_NAME=project_name,
|
||||
COMPOSE_FILE='compose.yaml:compose.test.yaml',
|
||||
GRAFANA_HOST_PORT='23000', LB_HOST_PORT='28080',
|
||||
DOCKER_TESTS='1')
|
||||
DOCKER_TESTS='1', OTEL_ENABLED='true')
|
||||
report = {'date_utc': datetime.now(timezone.utc).isoformat(), 'checks': [],
|
||||
'profile': {'single_stack': True, 'load_duration_seconds': 10,
|
||||
'load_requests_per_second': 10, 'load_concurrency': 2}}
|
||||
destination = ROOT / 'evidence/verification.json'
|
||||
destination.parent.mkdir(exist_ok=True)
|
||||
|
||||
def run(name, command, timeout=600):
|
||||
def run(name, command, timeout=600, *, env=None):
|
||||
print('RUN: ' + name, flush=True)
|
||||
started = time.monotonic()
|
||||
result = subprocess.run(command, cwd=ROOT, text=True, capture_output=True, timeout=timeout)
|
||||
result = subprocess.run(command, cwd=ROOT, text=True, capture_output=True, timeout=timeout,
|
||||
env={**os.environ, **(env or {})})
|
||||
executable = Path(command[0])
|
||||
display_command = [str(executable.relative_to(ROOT)) if executable.is_relative_to(ROOT)
|
||||
else command[0], *command[1:]]
|
||||
@@ -175,7 +178,9 @@ def verify():
|
||||
run('openapi', [sys.executable, 'scripts/validate_openapi.py'])
|
||||
run('compose', ['docker', 'compose', '--env-file', '.env', 'config', '--quiet'])
|
||||
run('startup', ['make', '--no-print-directory', 'test-stand-up'], timeout=600)
|
||||
run('regression', ['make', '--no-print-directory', 'test-unit'])
|
||||
# Локальные ASGI fixtures не находятся в сети Compose. Проверки SDK
|
||||
# используют exporters в памяти, интеграционный стенд экспортирует OTLP.
|
||||
run('regression', ['make', '--no-print-directory', 'test-unit'], env={'OTEL_ENABLED': 'false'})
|
||||
run('api', [sys.executable, 'tests/smoke.py', '--base-url', 'http://localhost:28080'])
|
||||
run('observability', [sys.executable, '-m', 'scripts.check_observability',
|
||||
'--base-url', 'http://localhost:28080',
|
||||
@@ -192,7 +197,11 @@ def verify():
|
||||
finally:
|
||||
try:
|
||||
print('RUN: cleanup', flush=True)
|
||||
report['cleanup'] = clean_stands(apply=True)
|
||||
ComposeProject().run('down', '--volumes', '--remove-orphans', timeout=120)
|
||||
remaining = inventory([project_name])
|
||||
if any(remaining.values()):
|
||||
raise RuntimeError('Verification project cleanup incomplete')
|
||||
report['cleanup'] = {'project': project_name, 'remaining': remaining, 'result': 'PASS'}
|
||||
print('PASS: cleanup', flush=True)
|
||||
finally:
|
||||
report['finished_at_utc'] = datetime.now(timezone.utc).isoformat()
|
||||
|
||||
Reference in New Issue
Block a user