We have a lot of changes in the style of
def foo(
self,
new: dt.timedelta | None = None,
old: float | None = None,
)
which is OK for cases where the API is used as
foo(old=23.5)
however for named arguments that actually falls short in the `ty`-stage:
foo(23.5)
As a workaround I flipped the order of old/new and changed the type of
`old` to accept both a timedelta and the old type, i.e.
def foo(
self,
old: float | dt.timedelta | None = None,
new: dt.timedelta | None = None,
)
and only give a deprecation warning if `old` is not of type `dt.timedelta | None`.
That way, both
foo(old=23.5)
foo(23.5)
are still accepted, at the same time, both
foo(new=timedelta(...))
foo(timedelta(...))
are OK.
Apparently this wasn't the case before, but now it is
In [3]: machine.shell_interact()
??? Warning (DeprecationWarning): Use the SSH backdoor instead
File "<ipython-input-3-4e72ea6a987e>", line 1
Reviewing #512771 got me thinking and I'm not sure I see a good reason
to keep this method given the SSH backdoor functionality has a much
better UX.
I'd propose we deprecate it, await 26.11 to see if people complain and
remove it alltogether after that.
The nspawn test machine passes a driver-owned AF_UNIX SOCK_DGRAM socket as the
container's NOTIFY_SOCKET (systemd-nspawn --notify-ready=yes). The driver only
drained it while waiting for the initial READY=1 during boot.
A container's PID 1 re-sends READY=1 on every `systemctl daemon-reexec` (the
same Manager.Reexecute that switch-to-configuration issues whenever the systemd
package changed). With nothing draining the socket after boot, its receive
buffer fills and PID 1 blocks in sendmsg() to NOTIFY_SOCKET (wchan
unix_wait_for_peer) while re-executing, so it never finishes re-initializing.
From then on every in-container `systemctl` call hangs or fails with
'Transport endpoint is not connected', which hangs wait_for_unit /
switch-to-configuration for the full timeout. QEMU nodes have no such notify
socket and are unaffected.
Drain the notify socket in a dedicated daemon thread for the container's whole
lifetime so PID 1 never blocks on the re-exec READY=1 send. Readiness and the
leader PID are now read from that thread's state instead of polling the socket
inline during boot.
Assisted-by: Claude:claude-opus-4-8
Restore the ability to pass a test script on the command line through:
```
--test-script [PATH]
```
which was possible prior to its removal in: f1bcb61731
I have found the flag to be quite practical for NixOS test iteration and propose
hereby to reintroduce it again.
While it is still possible without this flag to pass an external test
script, it now needs to be done through the indirection of a `--config`
configuration file - which now has to have configuration which points towards
the test script, which adds enough friction as to not make it ergonomic anymore.
The `--test-script` flag overwrites the configuration from the test config.
Before this commit, `wait_for_console_text` would read one line every
900ms before trying again to read the next line.
This commit fixes that behavior by greedily reading all buffer that is
available for match trying to find a match rather than reading one per
retry iteration.
In effect this moves the loop inside the `console_matches` helper and
makes the behavior of `wait_for_console_text` with timeout behave the
same way as with timeout.
This also provides a test that showcases the problem.
TL;DR add `assert` to correct location for type-narrowing
typeshed recently updated their definition of `select` in bcb6399e15.
The result is that the members of the lists passed to `select` now
require an upper bound of `FileDescriptorLike`.
The `self.shell` variable is typed as `socket | None`, but previously
passed checking against typeshed due to the missing upper-bound.
Despite the source code including a type-narrowing `assert`, `ty` does
not make use of it within the inner function that `select` is used in,
meaning `self.shell` wasn't narrowed at the appropriate place.
Now that typeshed has added this upper-bound, type-checking starts to fail, as evidenced in
https://github.com/NixOS/nixpkgs/pull/523288#issuecomment-4529738483.
So the correct fix is just to add the `assert` into the inner function.
For backwards-compat reason it's legal to do
runTest {
nodes.foo = { /* ... */ };
testScript = ''
machine.start()
# do your thing
'';
}
This makes several places in the codebase unnecessarily complex and is
something people shouldn't be using anyways. Additionally, I was
reminded by people that this can actually be confusing when you expect
the variable to be named differently.
Hence, deprecate this behavior and kill it in a few releases down the
road.