nixos/test-driver: use breakpointHook to debug tests with pdb & ssh; add dump() function#392117
nixos/test-driver: use breakpointHook to debug tests with pdb & ssh; add dump() function#392117Ma27 wants to merge 2 commits intoNixOS:masterfrom
dump() function#392117Conversation
There was a problem hiding this comment.
I'm not convinced by this new dump function, the print function is basically universal to print something out and I don't see the point of having it not have the 'provenance' prefix by default 🤔
I believe the default behavior should be to have the prefix.
And for special cases we could expose the non-prefix print as raw_print/direct_print/original_print ?
There was a problem hiding this comment.
So, on one hand I agree. OTOH I think it's kinda weird to override print() and give it special behavior (unless file= is set).
For me, this was the less intrusive/controversial change, but I'm very open to do what @bew suggested. What do the maintainers think?
faba8f4 to
e2d555e
Compare
e2d555e to
5ec80ef
Compare
This function prefixes each line of the string given to it and prints it
into the log. This is useful to make it clear where the output is
actually coming from which may is expected to be useful in long VM-tests
with `print()` statements in between.
I decided to not replace `print()` here since `print` has a `file=`
argument that allows it to write anywhere, so it's not necessarily a
replacement.
Essentially,
dump(machine.succeed("ip a"))
results in output like
machine: must succeed: ip a
machine: (finished: must succeed: ip a, in 0.01 seconds)
(test-script) 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
(test-script) [...]
(test-script) 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
(test-script) [...]
machine: ...
5ec80ef to
68e3527
Compare
This uses the `attach.sh` from our `breakpointHook` to allow getting
into the sandbox of the VM test. In there, it's now possible to do two
things:
* debugging the test script interactively with pdb[1] via
telnet 127.0.0.1 4444
* use the AF_VSOCK part to SSH into a VM.
[1] https://docs.python.org/3/library/pdb.html
68e3527 to
ed15e11
Compare
|
@tfc this would be the last round of the OceanSprint stuff, the more controversial one adding the breakpointHook (+pdb) to the sandbox for debugging inside it. I know that you had reservations about this addition, but I figured that having the breakpointHook thing as last resort is quite useful, also for VM tests. So here it is :) |
Right now it wrongly seems as if you can set `sshBackdoor.enable = true;` for each test and not only for debugging purposes. This is wrong however since you'd need to pass /dev/vhost-vsock into the sandbox for this (which is also a prerequisite for NixOS#392117). To make that clear, two things were changed: * add a warning to the manual to communicate this. * exit both interactive and non-interactive driver early if /dev/vhost-vsock is missing and the ssh backdoor is enabled. If that's the case, we pass a CLI flag to the driver already in the interactive case. This change also sets the flag for the non-interactive case. That way we also get a better error if somebody tries to enable this on a system that doesn't support that.
|
Superseded by #422066. |
Note: draft, depends on #392030, #390996 & #372979.
After a discussion with @tfc it was clear that the interactive part (#392030) is less controversial, so this is another PR on top. Only the last two commits are the relevant changes.
This uses the
attach.shfrom ourbreakpointHookto allow gettinginto the sandbox of the VM test. In there, it's now possible to do two
things:
debugging the test script interactively with pdb[1] via
telnet 127.0.0.1 4444
use the AF_VSOCK part to SSH into a VM.
Also, add a
dump()function that outputs stuff, but with a log prefix to make it clear where it's coming from.[1] https://docs.python.org/3/library/pdb.html
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.