Lab3: track-1 results, failure/rolling/container evidence, report draft

This commit is contained in:
Ivan Melnikov
2026-12-02 19:32:46 +03:00
parent 922a38b2cf
commit 15631a37be
99 changed files with 225515 additions and 308 deletions
+8 -4
View File
@@ -41,8 +41,10 @@ def main():
OUT = (ROOT / args.output).resolve()
checks = {}
import re
compose_text = (ROOT / 'compose.yaml').read_text()
checks['no_container_name_in_compose'] = 'container_name:' not in compose_text
# Ignore explanatory comments: only an actual YAML key can defeat scaling.
checks['no_container_name_in_compose'] = not re.search(r'^\s*container_name\s*:', compose_text, re.MULTILINE)
api = M.containers('api')
lb = M.containers('lb')
@@ -64,7 +66,7 @@ def main():
checks['api_has_no_published_ports'] = all(value == '' for value in api_ports.values())
checks['api_ports'] = api_ports
lb_ports = M.run(['docker', 'port', lb[0]['container_id']]).stdout.strip()
checks['lb_published_loopback_only'] = lb_ports.startswith('127.0.0.1:8083->8080/tcp')
checks['lb_published_loopback_only'] = ('127.0.0.1:8083' in lb_ports and '8080' in lb_ports)
checks['lb_ports'] = lb_ports
limits = {}
@@ -74,7 +76,7 @@ def main():
'cpu_max': item['cpu_max'], 'memory_max': item['memory_max']}
for item in items]
checks['all_services_have_cpu_and_memory_limits'] = all(
item['nano_cpus'] > 0 and item['memory_limit_bytes'] > 0
item['nano_cpus'] > 0 and item['memory_bytes'] > 0
for values in limits.values() for item in values)
checks['limits'] = limits
@@ -127,7 +129,7 @@ def main():
# The API never publishes a host port; a direct connection to a container
# IP is still possible from the host on Linux, but compose exposes none.
checks['public_entrypoint_is_lb'] = lb_ports.startswith('127.0.0.1:8083')
checks['public_entrypoint_is_lb'] = '127.0.0.1:8083' in lb_ports
failed = [key for key, value in checks.items() if isinstance(value, bool) and not value]
checks['result'] = 'PASS' if not failed else 'FAIL'
@@ -155,5 +157,7 @@ if __name__ == '__main__':
try:
main()
except Exception as exc: # noqa: BLE001
import traceback
traceback.print_exc()
print('FAIL:', exc)
raise SystemExit(1)