|
|
|
@ -7,9 +7,12 @@ with import ../lib/testing-python.nix { inherit system pkgs; }; |
|
|
|
|
with pkgs.lib; |
|
|
|
|
|
|
|
|
|
let |
|
|
|
|
makeHostNameTest = hostName: domain: |
|
|
|
|
makeHostNameTest = hostName: domain: fqdnOrNull: |
|
|
|
|
let |
|
|
|
|
fqdn = hostName + (optionalString (domain != null) ".${domain}"); |
|
|
|
|
getStr = str: # maybeString2String |
|
|
|
|
let res = builtins.tryEval str; |
|
|
|
|
in if (res.success && res.value != null) then res.value else "null"; |
|
|
|
|
in |
|
|
|
|
makeTest { |
|
|
|
|
name = "hostname-${fqdn}"; |
|
|
|
@ -26,13 +29,16 @@ let |
|
|
|
|
]; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
testScript = '' |
|
|
|
|
testScript = { nodes, ... }: '' |
|
|
|
|
start_all() |
|
|
|
|
|
|
|
|
|
machine = ${hostName} |
|
|
|
|
|
|
|
|
|
machine.wait_for_unit("network-online.target") |
|
|
|
|
|
|
|
|
|
# Test if NixOS computes the correct FQDN (either a FQDN or an error/null): |
|
|
|
|
assert "${getStr nodes.machine.config.networking.fqdn}" == "${getStr fqdnOrNull}" |
|
|
|
|
|
|
|
|
|
# The FQDN, domain name, and hostname detection should work as expected: |
|
|
|
|
assert "${fqdn}" == machine.succeed("hostname --fqdn").strip() |
|
|
|
|
assert "${optionalString (domain != null) domain}" == machine.succeed("dnsdomainname").strip() |
|
|
|
@ -60,7 +66,7 @@ let |
|
|
|
|
|
|
|
|
|
in |
|
|
|
|
{ |
|
|
|
|
noExplicitDomain = makeHostNameTest "ahost" null; |
|
|
|
|
noExplicitDomain = makeHostNameTest "ahost" null null; |
|
|
|
|
|
|
|
|
|
explicitDomain = makeHostNameTest "ahost" "adomain"; |
|
|
|
|
explicitDomain = makeHostNameTest "ahost" "adomain" "ahost.adomain"; |
|
|
|
|
} |
|
|
|
|