Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks,
scenario scripts and the CI job from the lab 5 solution commit 64d5c67,
keep the lab 5 Makefile targets on top of the unchanged skeleton
targets, and append the lab 5 solution variables to the skeleton
.env.example. The package and the application follow the contract
version 1.6.0, and the image, the throwaway test containers and the
broker vhost description are tagged lab6 so they do not collide with a
lab 5 stand on the same host.
This is the starting point of the lab 6 cycle: lint, own tests and the
offline skeleton check pass before any lab 6 change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
import asyncio
|
|
import os
|
|
import sys
|
|
|
|
from messenger.attachments.application.pipeline import STALL_AFTER_CLAIM, TRANSIENT_ERROR
|
|
from messenger.shared.application.errors import Unavailable
|
|
from messenger.shared.application.ports import Logger
|
|
|
|
CRASH_EXIT_CODE = 137
|
|
|
|
|
|
class EnvironmentFaults:
|
|
__slots__ = ("_logger", "_point", "_stall_seconds")
|
|
|
|
def __init__(self, point: str, logger: Logger, stall_seconds: float = 0.0) -> None:
|
|
self._point = point
|
|
self._logger = logger
|
|
self._stall_seconds = stall_seconds
|
|
|
|
async def reach(self, point: str) -> None:
|
|
if not self._point or point != self._point:
|
|
return
|
|
self._logger.warning("fault.injected", reason=point)
|
|
if point == TRANSIENT_ERROR:
|
|
raise Unavailable("внедрённая временная ошибка")
|
|
if point == STALL_AFTER_CLAIM:
|
|
self._point = ""
|
|
await asyncio.sleep(self._stall_seconds)
|
|
return
|
|
sys.stdout.flush()
|
|
sys.stderr.flush()
|
|
os._exit(CRASH_EXIT_CODE)
|