Unverified Commit 54a69497 authored by rnhmjoj's avatar rnhmjoj
Browse files

nixos/tests/networking: test hostname via DHCP

parent bf1cf6bf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -284,7 +284,8 @@ in
          [
            dhcpcd
            config.networking.resolvconf.package
          ] ++ lib.optional cfg.setHostname (
          ]
          ++ lib.optional cfg.setHostname (
            pkgs.writeShellScriptBin "hostname" ''
              ${lib.getExe' pkgs.systemd "hostnamectl"} set-hostname --transient $1
            ''
+23 −0
Original line number Diff line number Diff line
@@ -178,6 +178,29 @@ let
            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 = {
      name = "OneInterfaceDHCP";
      nodes.router = router;
+6 −1
Original line number Diff line number Diff line
@@ -63,7 +63,12 @@ stdenv.mkDerivation rec {
  ) "[ -e ${placeholder "out"}/lib/dhcpcd/dev/udev.so ]";

  passthru.tests = {
    inherit (nixosTests.networking.scripted) macvlan dhcpSimple dhcpOneIf;
    inherit (nixosTests.networking.scripted)
      macvlan
      dhcpSimple
      dhcpHostname
      dhcpOneIf
      ;
  };

  meta = with lib; {