#!/usr/bin/env python3 """Run matched HIL workloads through the persistent local soak logger.""" import argparse from concurrent.futures import ThreadPoolExecutor import json from pathlib import Path import socket import subprocess import time ROOT=Path.home()/'hwtest/runs/s3-memory-soak' DEVICES=('indicator','v4') CONFIG=None def rpc(**request): if CONFIG and CONFIG.get('control_tcp_port'): request['token']=CONFIG['control_token'] stream=socket.create_connection(('127.0.0.1',CONFIG['control_tcp_port']),timeout=40) else: stream=socket.socket(socket.AF_UNIX) stream.settimeout(40);stream.connect(str(ROOT/'control.sock')) with stream: stream.sendall(json.dumps(request).encode()+b'\n') response=json.loads(stream.makefile('rb').readline()) if not response['ok']: raise RuntimeError(response.get('error','RPC failed')) return response['result'] def command(device,value): return rpc(device=device,command=value,timeout=25)['reply'] def sample(device): value=rpc(operation='sample',device=device) if value['uptime_decreased']: raise AssertionError(device+' unexpected reset') return value def healthy(device,timeout=360): end=time.monotonic()+timeout while time.monotonic()