Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657"""Run a command under CPU and disk load, to reproduce a flaky test.
Every flaky test is treated as a product bug until shown otherwise, and mostonly fail when the machine is busy. This keeps two cores hashing and oneprocess rewriting and fsyncing a 1 MiB file while the command runs:
python3 test/manual/stress.py python3 test/e2e/run.py acp:AcpLoadTests
With no command it runs the Python e2e suite. It exits with the command's code."""
import hashlibimport multiprocessingimport osimport subprocessimport sysimport tempfilefrom multiprocessing.synchronize import Event
BLOCK = b"x" * 1_048_576
def burn(stop: Event) -> None: while not stop.is_set(): hashlib.sha256(BLOCK).digest()
def sync(stop: Event) -> None: with tempfile.TemporaryFile() as handle: while not stop.is_set(): handle.seek(0) handle.write(BLOCK) handle.flush() os.fsync(handle.fileno())
def main(command: list[str]) -> int: stop = multiprocessing.Event() load = [ multiprocessing.Process(target=task, args=(stop,)) for task in (burn, burn, sync) ] for process in load: process.start() try: return subprocess.run(command or [sys.executable, "test/e2e/run.py"]).returncode finally: stop.set() for process in load: process.join(5) if process.is_alive(): process.kill()
if __name__ == "__main__": sys.exit(main(sys.argv[1:]))