[WIP] Add knot tests

  • Open
  • quality assurance status badge
Details
5 participants
  • Julien Lepiller
  • Ludovic Courtès
  • Christopher Baines
  • Ricardo Wurmus
  • zimoun
Owner
unassigned
Submitted by
Julien Lepiller
Severity
normal
J
J
Julien Lepiller wrote on 11 Aug 2017 21:04
(address . guix-patches@gnu.org)
20170811210341.10ab9965@lepiller.eu
Hi,

This patch aims at adding a system test for knot. I've implemented the
DNS protocol to be able to communicate with the server and try some
queries. Unfortunately, although the server seems to be launched (the
first test passes), it then refuses to answer. Do you see anything
wrong, or anything I could do to understand why it doesn't pass?

Thanks :)
R
R
Ricardo Wurmus wrote on 16 Aug 2017 11:09
(name . Julien Lepiller)(address . julien@lepiller.eu)(address . 28055@debbugs.gnu.org)
87tw17khg0.fsf@elephly.net
Hi Julien,

Toggle quote (6 lines)
> This patch aims at adding a system test for knot. I've implemented the
> DNS protocol to be able to communicate with the server and try some
> queries. Unfortunately, although the server seems to be launched (the
> first test passes), it then refuses to answer. Do you see anything
> wrong, or anything I could do to understand why it doesn't pass?

It looks like overkill to implement DNS queries with bytevectors from
the ground up. Is there not an easier way to make a DNS test?

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
J
J
Julien Lepiller wrote on 16 Aug 2017 15:02
(address . 28055@debbugs.gnu.org)
FD67B377-F3AB-4467-8720-340CF97C7835@lepiller.eu
Hm... I followed the example of mail.scm and implemented the protocol. I also thought a pure scheme implementation would be prefered. I didn't really think of anything else.

I guess I could use the host utility to query the test server. Or if I can change the default dns server, I could use hostent:addr-list that I have just found in the manual. That would be better I think.

I'll try these methods.

Le 16 août 2017 11:09:03 GMT+02:00, Ricardo Wurmus <rekado@elephly.net> a écrit :
Toggle quote (19 lines)
>
>Hi Julien,
>
>> This patch aims at adding a system test for knot. I've implemented
>the
>> DNS protocol to be able to communicate with the server and try some
>> queries. Unfortunately, although the server seems to be launched (the
>> first test passes), it then refuses to answer. Do you see anything
>> wrong, or anything I could do to understand why it doesn't pass?
>
>It looks like overkill to implement DNS queries with bytevectors from
>the ground up. Is there not an easier way to make a DNS test?
>
>--
>Ricardo
>
>GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
>https://elephly.net

--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
Attachment: file
L
L
Ludovic Courtès wrote on 26 Sep 2017 10:27
(name . Ricardo Wurmus)(address . rekado@elephly.net)
87r2ut27cb.fsf@gnu.org
Howdy,

Ricardo Wurmus <rekado@elephly.net> skribis:

Toggle quote (9 lines)
>> This patch aims at adding a system test for knot. I've implemented the
>> DNS protocol to be able to communicate with the server and try some
>> queries. Unfortunately, although the server seems to be launched (the
>> first test passes), it then refuses to answer. Do you see anything
>> wrong, or anything I could do to understand why it doesn't pass?
>
> It looks like overkill to implement DNS queries with bytevectors from
> the ground up. Is there not an easier way to make a DNS test?

It’s a bit overkill indeed… but I like it. :-)

Julien: could you move the DNS code to a new module, say (guix dns), and
then add the Knot test?

(So first patch adds (guix dns), second patch adds the test.)

In passing, for (guix dns) it would be nice if you could add docstrings
as you see fit, and attempt to use full words in identifiers (“address”
rather than “addr”, “resolve” rather than “resolv”, etc.¹).

This looks really nice, thanks for working on it!

Ludo’.

L
L
Ludovic Courtès wrote on 1 Dec 2017 11:23
(name . Julien Lepiller)(address . julien@lepiller.eu)
878temiw5i.fsf@gnu.org
Julien,

Did you have a chance to look into that?

TIA,
Ludo’.

ludo@gnu.org (Ludovic Courtès) skribis:

Toggle quote (29 lines)
> Howdy,
>
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>>> This patch aims at adding a system test for knot. I've implemented the
>>> DNS protocol to be able to communicate with the server and try some
>>> queries. Unfortunately, although the server seems to be launched (the
>>> first test passes), it then refuses to answer. Do you see anything
>>> wrong, or anything I could do to understand why it doesn't pass?
>>
>> It looks like overkill to implement DNS queries with bytevectors from
>> the ground up. Is there not an easier way to make a DNS test?
>
> It’s a bit overkill indeed… but I like it. :-)
>
> Julien: could you move the DNS code to a new module, say (guix dns), and
> then add the Knot test?
>
> (So first patch adds (guix dns), second patch adds the test.)
>
> In passing, for (guix dns) it would be nice if you could add docstrings
> as you see fit, and attempt to use full words in identifiers (“address”
> rather than “addr”, “resolve” rather than “resolv”, etc.¹).
>
> This looks really nice, thanks for working on it!
>
> Ludo’.
>
> ¹ https://www.gnu.org/software/guix/manual/html_node/Formatting-Code.html
J
J
Julien Lepiller wrote on 2 Dec 2017 12:18
(address . 28055@debbugs.gnu.org)
20171202121815.553c0b93@lepiller.eu
Le Fri, 01 Dec 2017 11:23:53 +0100,
ludo@gnu.org (Ludovic Courtès) a écrit :

Toggle quote (8 lines)
> Julien,
>
> Did you have a chance to look into that?
>
> TIA,
> Ludo’.
>

Here is a new version. The tests still don't pass though. It can't send
the request to the server.
From 5146714c6615161fe3e496909f5a157c24d57ea0 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
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.
---
gnu/local.mk | 1 +
gnu/tests/dns.scm | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+)
create mode 100644 gnu/tests/dns.scm

Toggle diff (138 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 2e74c4d81..2fa736523 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -507,6 +507,7 @@ GNU_SYSTEM_MODULES = \
%D%/tests/databases.scm \
%D%/tests/desktop.scm \
%D%/tests/dict.scm \
+ %D%/tests/dns.scm \
%D%/tests/nfs.scm \
%D%/tests/install.scm \
%D%/tests/mail.scm \
diff --git a/gnu/tests/dns.scm b/gnu/tests/dns.scm
new file mode 100644
index 000000000..228204e31
--- /dev/null
+++ b/gnu/tests/dns.scm
@@ -0,0 +1,118 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu tests dns)
+ #:use-module (gnu tests)
+ #:use-module (gnu system)
+ #:use-module (gnu system vm)
+ #:use-module (gnu services)
+ #:use-module (gnu services dns)
+ #:use-module (gnu services networking)
+ #:use-module (guix dns)
+ #:use-module (guix gexp)
+ #:use-module (guix store)
+ #:use-module (ice-9 ftw)
+ #:export (%test-knot))
+
+(define %ip4-addr
+;; a random IPv4 address
+ "136.12.251.84")
+
+(define-zone-entries %test-entries
+;; Test entries, with no real data
+;; Name TTL Class Type Data
+ ("@" "" "IN" "A" "1.2.3.4")
+ ("@" "" "IN" "MX" "10 mail")
+ ("mail" "" "IN" "A" %ip4-addr))
+
+(define %test-zone
+;; A test zone that uses the fake data
+ (knot-zone-configuration
+ (domain "guix-test.org")
+ (zone (zone-file
+ (origin "guix-test.org")
+ (entries %test-entries)))))
+
+(define %knot-zones
+ (list %test-zone))
+
+(define %knot-os
+ (simple-operating-system
+ (dhcp-client-service)
+ (service knot-service-type
+ (knot-configuration
+ (zones %knot-zones)))))
+
+(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)))))
+
+ (define test
+ (with-imported-modules '((gnu build marionette)
+ (guix dns))
+ #~(begin
+ (use-modules (guix dns)
+ (gnu build marionette)
+ (srfi srfi-64))
+
+ (define marionette
+ (make-marionette '(#$vm)))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin "knot")
+
+ (test-assert "service is running"
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (start-service 'knot)
+ #t)
+ marionette))
+
+ (test-eq "get the correct answer"
+ #$%ip4-addr
+ (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)
+ (put-bytevector dns (dns-query->bytevector query #t))
+ (bytevector->ipv4
+ (dns-record-rdata
+ (car (dns-query-answers
+ (bytevector->dns-query
+ (get-bytevector-n dns 500)))))))))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation "knot-test" test))
+
+(define %test-knot
+ (system-test
+ (name "knot")
+ (description "Send a DNS request to a running Knot server.")
+ (value (run-knot-test))))
--
2.15.0
L
L
Ludovic Courtès wrote on 15 Dec 2017 11:53
(name . Julien Lepiller)(address . julien@lepiller.eu)(address . 28055@debbugs.gnu.org)
87fu8cjm99.fsf@gnu.org
Hello,

Julien Lepiller <julien@lepiller.eu> skribis:

Toggle quote (11 lines)
> 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 <julien@lepiller.eu>
> 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.

[...]

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

Maybe add that it’s primarily for test purposes.

Very nice stuff!

Toggle quote (8 lines)
> From 5146714c6615161fe3e496909f5a157c24d57ea0 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> 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.

[...]

Toggle quote (9 lines)
> +(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?

Toggle quote (3 lines)
> + (test-eq "get the correct answer"
> + #$%ip4-addr

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

Toggle quote (7 lines)
> + (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
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’.
C
C
Christopher Baines wrote on 19 Mar 2018 09:20
control message for bug #28055
(address . control@debbugs.gnu.org)
87k1u85ve2.fsf@cbaines.net
tags 28055 patch
Z
Z
zimoun wrote on 13 Jan 2022 16:12
Re: bug#28055: [WIP] Add knot tests
(name . Julien Lepiller)(address . julien@lepiller.eu)(address . 28055@debbugs.gnu.org)
861r1bk6up.fsf_-_@gmail.com
Hi Julien,

On Sat, 02 Dec 2017 at 12:18, Julien Lepiller <julien@lepiller.eu> wrote:

Toggle quote (3 lines)
> Here is a new version. The tests still don't pass though. It can't send
> the request to the server.

What is the status of this patch [1] adding DNS system tests for knot?

It seems almost ready, no?



Cheers,
simon
Z
Z
zimoun wrote on 23 Mar 2022 11:48
(name . Julien Lepiller)(address . julien@lepiller.eu)(address . 28055@debbugs.gnu.org)
86ils50wsq.fsf_-_@gmail.com
Hi,

On Thu, 13 Jan 2022 at 16:12, zimoun <zimon.toutoune@gmail.com> wrote:
Toggle quote (11 lines)
> On Sat, 02 Dec 2017 at 12:18, Julien Lepiller <julien@lepiller.eu> wrote:
>
>> Here is a new version. The tests still don't pass though. It can't send
>> the request to the server.
>
> What is the status of this patch [1] adding DNS system tests for knot?
>
> It seems almost ready, no?
>
> 1: <http://issues.guix.gnu.org/issue/28055>

What is the status of this old patch [1]? It is there since a long time
and not a comment since the past 9 weeks. Therefore, I am going to
close it in the coming weeks.




Cheers,
simon
Z
Z
zimoun wrote on 23 Jun 2022 11:55
(name . Julien Lepiller)(address . julien@lepiller.eu)(address . 28055@debbugs.gnu.org)
86tu8b7lgy.fsf_-_@gmail.com
Hi,

On Wed, 23 Mar 2022 at 11:48, zimoun <zimon.toutoune@gmail.com> wrote:
Toggle quote (16 lines)
> On Thu, 13 Jan 2022 at 16:12, zimoun <zimon.toutoune@gmail.com> wrote:
>> On Sat, 02 Dec 2017 at 12:18, Julien Lepiller <julien@lepiller.eu> wrote:
>>
>>> Here is a new version. The tests still don't pass though. It can't send
>>> the request to the server.
>>
>> What is the status of this patch [1] adding DNS system tests for knot?
>>
>> It seems almost ready, no?
>>
>> 1: <http://issues.guix.gnu.org/issue/28055>
>
> What is the status of this old patch [1]? It is there since a long time
> and not a comment since the past 9 weeks. Therefore, I am going to
> close it in the coming weeks.

Any objection for closing?


Cheers,
simon
J
J
Julien Lepiller wrote on 18 Sep 2022 20:28
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 28055@debbugs.gnu.org)
D7C930B6-D963-4BC3-9BB6-9200D6C24186@lepiller.eu
Hi Simon,

I think I have an idea for this patch, please keep it open :)

Le 23 juin 2022 11:55:25 GMT+02:00, zimoun <zimon.toutoune@gmail.com> a écrit :
Toggle quote (24 lines)
>Hi,
>
>On Wed, 23 Mar 2022 at 11:48, zimoun <zimon.toutoune@gmail.com> wrote:
>> On Thu, 13 Jan 2022 at 16:12, zimoun <zimon.toutoune@gmail.com> wrote:
>>> On Sat, 02 Dec 2017 at 12:18, Julien Lepiller <julien@lepiller.eu> wrote:
>>>
>>>> Here is a new version. The tests still don't pass though. It can't send
>>>> the request to the server.
>>>
>>> What is the status of this patch [1] adding DNS system tests for knot?
>>>
>>> It seems almost ready, no?
>>>
>>> 1: <http://issues.guix.gnu.org/issue/28055>
>>
>> What is the status of this old patch [1]? It is there since a long time
>> and not a comment since the past 9 weeks. Therefore, I am going to
>> close it in the coming weeks.
>
>Any objection for closing?
>
>
>Cheers,
>simon
Attachment: file
S
S
Simon Tournier wrote on 23 Oct 2023 23:00
(name . Julien Lepiller)(address . julien@lepiller.eu)(address . 28055@debbugs.gnu.org)
86ttqhuka3.fsf_-_@gmail.com
Hi Julien,

On Sun, 18 Sep 2022 at 20:28, Julien Lepiller <julien@lepiller.eu> wrote:

Toggle quote (2 lines)
> I think I have an idea for this patch, please keep it open :)

We are now more than one year later, about #28055 [1]. Did you have a
chance to look into this?

Cheers,
simon


?