From 0aee0f94657b8b7d40511eda6b43f99be6019cdb Mon Sep 17 00:00:00 2001 From: Nico D'Cotta <45274424+cottand@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:38:32 +0000 Subject: [PATCH] test for locan DNS resolution in machine hosting leng (#78) This adds a failing test to keep track of progress to hopefully resolve_ https://github.com/cottand/leng/issues/75 --- flake.nix | 2 ++ nixos-tests/local-resolution.nix | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 nixos-tests/local-resolution.nix diff --git a/flake.nix b/flake.nix index f0e4c32..86329cc 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,8 @@ systemctl-start = pkgs.callPackage ./nixos-tests/systemctl-start.nix { inherit self; }; custom-dns = pkgs.callPackage ./nixos-tests/custom-dns.nix { inherit self; }; doh-upstream = pkgs.callPackage ./nixos-tests/doh-upstream.nix { inherit self; }; + # test fails, see https://github.com/cottand/leng/issues/75 + #local-resolution = pkgs.callPackage ./nixos-tests/local-resolution.nix { inherit self; }; }; })) diff --git a/nixos-tests/local-resolution.nix b/nixos-tests/local-resolution.nix new file mode 100644 index 0000000..bff7058 --- /dev/null +++ b/nixos-tests/local-resolution.nix @@ -0,0 +1,41 @@ +{ self, pkgs, home-manager, ... }: +let + nixpkgs = self.inputs.nixpkgs; +in +(nixpkgs.lib.nixos.runTest { + hostPkgs = pkgs; + defaults.documentation.enable = false; + node.specialArgs = { inherit self; }; + + name = "leng-local-resolution"; + + nodes = { + server = { config, pkgs, ... }: { + imports = [ self.nixosModules.default ]; + environment.systemPackages = [ pkgs.dig ]; + networking.firewall.allowedUDPPorts = [ 53 ]; + networking.nameservers = [ "127.0.0.1" ]; + + services.leng.enable = true; + services.leng.configuration = { + blocking.sourcesStore = "/tmp"; + customdnsrecords = [ + "example.com IN A 1.2.3.4" + ]; + }; + }; + }; + + testScript = + '' + start_all() + + server.wait_for_unit("leng", timeout=10) + server.wait_for_open_port(53) + + server.succeed( + "dig example.com" + ) + ''; + +}).config.result