Subject: Re: [bug#28055] [WIP] Add knot tests

From: [email-masked] (Ludovic Courtès)
Date: Fri, 15 Dec 2017 11:53:06 +0100

Hello,

Julien Lepiller <[email-masked]> skribis:

> Here is a new version. The tests still don't pass though. It can't send
> the request to the server.
>
> From ecc02fe8098d8763b95d2c71215a62e669f49568 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <[email-masked]>
> Date: Sat, 2 Dec 2017 10:51:18 +0100
> Subject: [PATCH 1/2] guix: Add DNS implementation.
>
> * guix/dns.scm: New file.
> * Makefile.am: Add it.

[...]

> +;;; Commentary:
> +;;;
> +;;; This module provides a DNS implementation. This modules helps construct
                                                  ^^^^^^^^^^^^
“It”.  :-)

Maybe add that it’s primarily for test purposes.

Very nice stuff!

> From 5146714c6615161fe3e496909f5a157c24d57ea0 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <[email-masked]>
> Date: Sat, 2 Dec 2017 12:15:28 +0100
> Subject: [PATCH 2/2] gnu: tests: Add knot test.
>
> * gnu/tests/dns.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.

[...]

> +(define (run-knot-test)
> +  "Return a test of an OS running Knot service."
> +  (define vm
> +    (virtual-machine
> +     (operating-system (marionette-operating-system
> +                        %knot-os
> +                        #:imported-modules '((gnu services herd))))
> +     (port-forwardings '((1053 . 53)))))

Note that this creates *TCP* port forwardings (see
‘port-forwardings->qemu-options’ in (gnu system vm)).

Perhaps you’ll want UDP forwarding?

> +          (test-eq "get the correct answer"
> +            #$%ip4-addr

Should be ‘test-equal’ since you’re comparing strings.

> +            (begin
> +              (format #t "test:\n")
> +              (let* ((query (simple-a-query "mail.guix-test.org"))
> +                     (dns (socket AF_INET SOCK_STREAM 0))
> +                     (addr (make-socket-address AF_INET INADDR_LOOPBACK 1053)))
> +                (connect dns addr)

I learned from
<https://serverfault.com/questions/181956/is-it-true-that-a-nameserver-have-to-answer-queries-over-tcp>
that DNS servers are now supposed to listen for TCP requests, but are we
sure this is the case here?

What error do you get?  Does the ‘connect’ call fail?  Does the message
go through?

Thanks!

Ludo’.