diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 50c27ec6da79..2b538a450c2f 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -408,6 +408,7 @@ in containers-tmpfs = runTest ./containers-tmpfs.nix; containers-unified-hierarchy = runTest ./containers-unified-hierarchy.nix; convos = runTest ./convos.nix; + coredns = runTest ./coredns.nix; corerad = runTest ./corerad.nix; corteza = runTest ./corteza.nix; cosmic = runTest { diff --git a/nixos/tests/coredns.nix b/nixos/tests/coredns.nix new file mode 100644 index 000000000000..7f0c8dc8da3a --- /dev/null +++ b/nixos/tests/coredns.nix @@ -0,0 +1,42 @@ +{ pkgs, ... }: +{ + name = "coredns"; + meta = with pkgs.lib.maintainers; { + maintainers = [ johanot ]; + }; + + nodes.machine = + { pkgs, ... }: + { + environment.systemPackages = [ pkgs.dnsutils ]; + services.coredns = { + enable = true; + config = '' + .:10053 { + ipecho { + domain test.nixos.org + ttl 2629800 + } + } + ''; + package = pkgs.coredns.override { + externalPlugins = [ + { + name = "ipecho"; + repo = "github.com/Eun/coredns-ipecho"; + version = "224170ebca45cc59c6b071d280a18f42d1ff130c"; + position = "start-of-file"; + } + ]; + vendorHash = "sha256-dNxHpXkiqz7B/JhZdxfZluIHFVXILlSm3XtB+v/EoMY="; + }; + }; + }; + + testScript = '' + machine.start() + machine.wait_for_unit("coredns.service") + machine.wait_for_open_port(10053) + machine.succeed("dig @127.0.0.1 -p 10053 127.0.0.2.test.nixos.org A +short | grep 127.0.0.2") + ''; +} diff --git a/pkgs/by-name/co/coredns/package.nix b/pkgs/by-name/co/coredns/package.nix index dc4d4f26cefe..cd3626c21d2e 100644 --- a/pkgs/by-name/co/coredns/package.nix +++ b/pkgs/by-name/co/coredns/package.nix @@ -78,6 +78,7 @@ buildGoModule (finalAttrs: { for src in ${toString (attrsToSources externalPlugins)}; do go get $src; done go mod vendor CC= GOOS= GOARCH= go generate + go mod vendor go mod tidy ''; @@ -134,6 +135,7 @@ buildGoModule (finalAttrs: { ''; passthru.tests = { + coredns-external-plugins = nixosTests.coredns; kubernetes-single-node = nixosTests.kubernetes.dns-single-node; kubernetes-multi-node = nixosTests.kubernetes.dns-multi-node; };