nixosTests.nixos-test-driver.node-name: init

This commit is contained in:
Robert Hensing 2023-04-25 12:21:38 +02:00
parent 3ec3d283c5
commit e207f4a116
2 changed files with 34 additions and 0 deletions

View File

@ -70,6 +70,7 @@ in {
# Testing the test driver
nixos-test-driver = {
extra-python-packages = handleTest ./nixos-test-driver/extra-python-packages.nix {};
node-name = runTest ./nixos-test-driver/node-name.nix;
};
# NixOS vm tests and non-vm unit tests

View File

@ -0,0 +1,33 @@
{
name = "nixos-test-driver.node-name";
nodes = {
"ok" = { };
# Valid node name, but not a great host name.
"one_two" = { };
# Valid node name, good host name
"a-b" = { };
# TODO: would be nice to test these eval failures
# Not allowed by lib/testing/network.nix (yet?)
# "foo.bar" = { };
# Not allowed.
# "not ok" = { }; # not ok
};
testScript = ''
start_all()
with subtest("python vars exist and machines are reachable through test backdoor"):
ok.succeed("true")
one_two.succeed("true")
a_b.succeed("true")
with subtest("hostname is derived from the node name"):
ok.succeed("hostname | tee /dev/stderr | grep '^ok$'")
one_two.succeed("hostname | tee /dev/stderr | grep '^onetwo$'")
a_b.succeed("hostname | tee /dev/stderr | grep '^a-b$'")
'';
}