#!/usr/bin/env python3 # Per-COMMAND auth variant (model A: "authenticate each time"). # Same daemon/ops as the persistent-connection harness, but every command # opens a FRESH connection, does a full signed-HELLO R4 handshake, sends the # command, reads the reply, then closes. This is what cubec one-shot / # stress.sh does. Unlike stress.sh, THIS harness tracks per-command errors # so we can compare the error rate head-to-head against auth-once. import os, sys, socket, struct, time, threading, csv, hmac, hashlib, subprocess, tempfile, shutil from collections import defaultdict import statistics as st REPO = os.environ.get("REPO", "/home/CUBELinux/CUBELinux-2") SRV = os.path.join(REPO, "target/release/cube-server") if not os.path.exists(SRV): sys.exit("cube-server release binary missing; build first") USERS = int(os.environ.get("USERS", "8")) DURATION = int(os.environ.get("DURATION", "150")) PSK = b"lan-shared-key-1234" WORK = "/root/cube-stress" os.makedirs(WORK, exist_ok=True) TMPD = tempfile.mkdtemp(prefix=f"{WORK}/run-percmd-") STORE = os.path.join(TMPD, f"store-{os.getpid()}.json") PSK_FILE = os.path.join(TMPD, "psk.txt") open(PSK_FILE, "w").write(PSK.decode()) SOCK = os.path.join(TMPD, "cube.sock") RUN_LOG = os.path.join(TMPD, "run.log") DAEMON_LOG = os.path.join(TMPD, "daemon.log") ERR_LOG = os.path.join(TMPD, "run-errors.log") CSV = os.path.join(TMPD, "cmds.csv") TENANTS = ["alpha","bravo","charlie","delta","echo","foxtrot","golf","hotel","india","juliet"] OWNERS = ["alice","bob","carol","dave","erin","frank","grace","heidi","ivan","judy"] def log(*a): with open(RUN_LOG, "a") as f: f.write(" ".join(map(str,a)) + "\n") log(f"USERS={USERS} DURATION={DURATION}s MODE=per-command-auth (fresh handshake every op)") def write_frame(sock, payload): b = payload.encode(); sock.sendall(struct.pack("