print the vm test's priv response and journal only on failure
This commit is contained in:
parent
2b4fd52b0a
commit
bbc2a83771
1 changed files with 6 additions and 4 deletions
|
|
@ -132,6 +132,9 @@ pkgs.testers.runNixOSTest {
|
||||||
def stop():
|
def stop():
|
||||||
host.succeed(f"nixos-container stop {MACHINE}")
|
host.succeed(f"nixos-container stop {MACHINE}")
|
||||||
|
|
||||||
|
def priv_journal():
|
||||||
|
return host.execute("journalctl -u hive-priv --no-pager | tail -n 30")[1]
|
||||||
|
|
||||||
def write_flags():
|
def write_flags():
|
||||||
"""What hive-c0re does before every start: one request to hive-priv."""
|
"""What hive-c0re does before every start: one request to hive-priv."""
|
||||||
req = json.dumps({
|
req = json.dumps({
|
||||||
|
|
@ -143,11 +146,10 @@ pkgs.testers.runNixOSTest {
|
||||||
# socat gives up 0.5s after its stdin ends unless told to wait; the
|
# socat gives up 0.5s after its stdin ends unless told to wait; the
|
||||||
# salvage copies a whole root, which takes longer.
|
# salvage copies a whole root, which takes longer.
|
||||||
out = host.succeed(f"echo '{req}' | socat -t 120 - UNIX-CONNECT:/run/hive/priv.sock")
|
out = host.succeed(f"echo '{req}' | socat -t 120 - UNIX-CONNECT:/run/hive/priv.sock")
|
||||||
print("hive-priv answered: " + repr(out))
|
|
||||||
print(host.execute("journalctl -u hive-priv --no-pager | tail -n 30")[1])
|
|
||||||
lines = out.strip().splitlines()
|
lines = out.strip().splitlines()
|
||||||
assert lines, "hive-priv sent no response"
|
# The journal is read only when the assert fires.
|
||||||
assert json.loads(lines[-1])["ok"] is True, out
|
assert lines, f"hive-priv sent no response; journal:\n{priv_journal()}"
|
||||||
|
assert json.loads(lines[-1])["ok"] is True, f"response={out!r}; journal:\n{priv_journal()}"
|
||||||
|
|
||||||
def conf():
|
def conf():
|
||||||
return host.succeed(f"cat /etc/nixos-containers/{MACHINE}.conf")
|
return host.succeed(f"cat /etc/nixos-containers/{MACHINE}.conf")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue