nixos/tests/networking: test hostname via DHCP
This commit is contained in:
parent
bf1cf6bffc
commit
54a6949722
@ -284,7 +284,8 @@ in
|
|||||||
[
|
[
|
||||||
dhcpcd
|
dhcpcd
|
||||||
config.networking.resolvconf.package
|
config.networking.resolvconf.package
|
||||||
] ++ lib.optional cfg.setHostname (
|
]
|
||||||
|
++ lib.optional cfg.setHostname (
|
||||||
pkgs.writeShellScriptBin "hostname" ''
|
pkgs.writeShellScriptBin "hostname" ''
|
||||||
${lib.getExe' pkgs.systemd "hostnamectl"} set-hostname --transient $1
|
${lib.getExe' pkgs.systemd "hostnamectl"} set-hostname --transient $1
|
||||||
''
|
''
|
||||||
|
@ -178,6 +178,29 @@ let
|
|||||||
router.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::2")
|
router.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::2")
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
dhcpHostname = {
|
||||||
|
name = "hostnameDHCP";
|
||||||
|
nodes.router = router;
|
||||||
|
nodes.client = clientConfig {
|
||||||
|
# use the name given by the DHCP server
|
||||||
|
system.name = "client";
|
||||||
|
networking.hostName = lib.mkForce "";
|
||||||
|
security.polkit.enable = true;
|
||||||
|
virtualisation.interfaces.enp1s0.vlan = 1;
|
||||||
|
networking.interfaces.enp1s0.useDHCP = true;
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
router.start()
|
||||||
|
router.systemctl("start network-online.target")
|
||||||
|
router.wait_for_unit("network-online.target")
|
||||||
|
|
||||||
|
client.start()
|
||||||
|
client.wait_for_unit("network.target")
|
||||||
|
|
||||||
|
with subtest("Wait until we have received the hostname"):
|
||||||
|
client.wait_until_succeeds("hostname | grep -q 'client1'")
|
||||||
|
'';
|
||||||
|
};
|
||||||
dhcpOneIf = {
|
dhcpOneIf = {
|
||||||
name = "OneInterfaceDHCP";
|
name = "OneInterfaceDHCP";
|
||||||
nodes.router = router;
|
nodes.router = router;
|
||||||
|
@ -63,7 +63,12 @@ stdenv.mkDerivation rec {
|
|||||||
) "[ -e ${placeholder "out"}/lib/dhcpcd/dev/udev.so ]";
|
) "[ -e ${placeholder "out"}/lib/dhcpcd/dev/udev.so ]";
|
||||||
|
|
||||||
passthru.tests = {
|
passthru.tests = {
|
||||||
inherit (nixosTests.networking.scripted) macvlan dhcpSimple dhcpOneIf;
|
inherit (nixosTests.networking.scripted)
|
||||||
|
macvlan
|
||||||
|
dhcpSimple
|
||||||
|
dhcpHostname
|
||||||
|
dhcpOneIf
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user