gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [ascension] 32/45: testing and added logging of executed co


From: gnunet
Subject: [GNUnet-SVN] [ascension] 32/45: testing and added logging of executed commands to debug
Date: Fri, 25 Jan 2019 10:02:32 +0100

This is an automated email from the git hooks/post-receive script.

rexxnor pushed a commit to branch master
in repository ascension.

commit 046fbf4919c81ccc287a9c0cca1488826c68cc74
Author: rexxnor <address@hidden>
AuthorDate: Mon Nov 12 23:40:11 2018 +0100

    testing and added logging of executed commands to debug
---
 gnsmigrator/gnsmigrator.py                  | 19 +++++--
 gnsmigrator/test/test_gnsmigrator_simple.sh | 81 +++++++++++++++++++++++++++--
 2 files changed, 92 insertions(+), 8 deletions(-)

diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index 2cef855..853d97d 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -43,7 +43,7 @@ class GNSMigrator():
     @classmethod
     def __init__(cls, domain, transferns, port):
         cls.domain = domain
-        cls.port = port
+        cls.port = int(port)
         cls.soa = None
         cls.transferns = transferns
         cls.zone = None
@@ -89,10 +89,11 @@ class GNSMigrator():
             pkey_line.stdout.close()
             # Create identity in GNUnet
             try:
-                sp.run([GNUNET_ZONE_CREATION_COMMAND,
-                        '-C', domainpart],
-                       stdout=sp.DEVNULL,
-                       stderr=sp.DEVNULL)
+                ret = sp.run([GNUNET_ZONE_CREATION_COMMAND,
+                              '-C', domainpart],
+                             stdout=sp.DEVNULL,
+                             stderr=sp.DEVNULL)
+                logging.info("executed command: %s", " ".join(ret.args))
             except sp.CalledProcessError:
                 logging.info("Zone %s already exists!", domainpart)
             pkey_lookup = sp.Popen([GNUNET_ZONE_CREATION_COMMAND,
@@ -122,6 +123,7 @@ class GNSMigrator():
                                   '-t', 'PKEY',
                                   '-V', pkey_zone,
                                   '-e', 'never'])
+                    logging.info("executed command: %s", " ".join(ret.args))
                     if ret.returncode != 0:
                         logging.warning("failed to add record %s", domainpart)
                         logging.warning("failed to add %s record %s",
@@ -312,6 +314,7 @@ class GNSMigrator():
                           '-t', rtype_str,
                           '-V', str(rdata),
                           '-e', '%ds' % ttl])
+            logging.info("executed command: %s", " ".join(ret.args))
             if ret.returncode != 0:
                 logging.warning("failed to add %s record %s",
                                 rtype_str, str(dnsname))
@@ -339,6 +342,7 @@ class GNSMigrator():
                           '-t', rtype_str,
                           '-V', str(value),
                           '-e', '%ds' % ttl])
+            logging.info("executed command: %s", " ".join(ret.args))
             if ret.returncode != 0:
                 logging.warning("failed to add %s record %s",
                                 rtype_str, dnsname_str)
@@ -357,6 +361,7 @@ class GNSMigrator():
                           '-t', rtype_str,
                           '-V', str(rdata),
                           '-e', '%ds' % ttl])
+            logging.info("executed command: %s", " ".join(ret.args))
             if ret.returncode != 0:
                 logging.warning("failed to add %s record %s",
                                 rtype_str, str(dnsname))
@@ -366,6 +371,7 @@ class GNSMigrator():
                           '-t', 'LEHO',
                           '-V', '%s.%s' % (str(dnsname), domain),
                           '-e', '%ds' % ttl])
+            logging.info("executed command: %s", " ".join(ret.args))
             if ret.returncode != 0:
                 logging.warning("failed to add %s record %s",
                                 "LEHO", str(dnsname))
@@ -394,6 +400,7 @@ class GNSMigrator():
                          int(expiry), int(irefresh)
                         ),
                       '-e', '%ds' % ttl])
+        logging.info("executed command: %s", " ".join(ret.args))
         if ret.returncode != 0:
             logging.warning("failed to add %s record %s", "SOA", "@")
 
@@ -431,6 +438,7 @@ class GNSMigrator():
                               '-t', 'GNS2DNS',
                               '-u', '%s.%s' % (str(dnsname), zonename)],
                              stdout=sp.PIPE)
+                logging.info("executed command: %s", " ".join(ret.args))
                 if 'Got'.encode() not in ret.stdout:
                     ret = sp.run([GNUNET_NAMESTORE_COMMAND,
                                   '-z', zonename,
@@ -458,6 +466,7 @@ class GNSMigrator():
                           '-t', dns.rdatatype.to_text(rdata.rdtype),
                           '-V', value,
                           '-e', '%ds' % int(ttl)])
+            logging.info("executed command: %s", " ".join(ret.args))
             if ret.returncode != 0:
                 logging.warning("failed to add %s record %s",
                                 "GNS2DNS", str(dnsname))
diff --git a/gnsmigrator/test/test_gnsmigrator_simple.sh 
b/gnsmigrator/test/test_gnsmigrator_simple.sh
index 2cb6045..f0e6eb2 100644
--- a/gnsmigrator/test/test_gnsmigrator_simple.sh
+++ b/gnsmigrator/test/test_gnsmigrator_simple.sh
@@ -1,24 +1,99 @@
 #!/bin/bash
+# Author: rexxnor
+# Returns 1 on basic error
+# Returns 2 on explicit test case errors
+# Returns 3 on implicit test case errors
+
+# Shutdown named
+function cleanup {
+    pkill named
+    gnunet-identity -D gnunet
+    gnunet-identity -D org
+}
 
 # Check for required packages
+
 if ! [ -x "$(command -v named)" ]; then
     echo 'bind/named is not installed' >&2
     exit 1
 fi
 
+if ! [ -x "$(command -v gnsmigrator)" ]; then
+    echo 'gnsmigrator is not installed' >&2
+    exit 1
+fi
+
 # Start named with a simple zone
 named -c basic_named.conf -p 5000
 
 # Check if domain resolves
 nslookup gnunet.org 127.0.0.1 -port=5000
-if $?; then
+if [ "$?" -ne 0 ]; then
     echo "Something went wrong with named"
+    cleanup
     exit 1
 fi
 
 # Let gnsmigrator run on gnunet.org test domain
+gnsmigrator gnunet.org -ns 127.0.0.1 -p 5000
+if [ "$?" -ne 0 ]; then
+    echo "gnsmigrator failed adding the records!"
+    cleanup
+    exit 1
+fi
 
+function checkfailexp  {
+    if [ "$?" -ne 0 ]; then
+        echo "required record not present"
+        cleanup
+        exit 2
+    fi
+}
 
+function checkfailimp  {
+    if [ "$?" -ne 0 ]; then
+        echo "implied record not present"
+        cleanup
+        exit 3
+    fi
+}
 
-# Shutdown named
-pkill named
+# TESTING explicit records
+gnunet-gns -t CNAME -u asdf.gnunet
+checkfailexp
+gnunet-gns -t AAAA -u foo.gnunet
+checkfailexp
+gnunet-gns -t A -u mail.gnunet
+checkfailexp
+gnunet-gns -t A -u ns1.gnunet
+checkfailexp
+gnunet-gns -t A -u ns2.gnunet
+checkfailexp
+gnunet-gns -t A -u ns2.gnunet.org
+checkfailexp
+gnunet-gns -t MX -u mail.gnunet
+checkfailexp
+gnunet-gns -t A -u nextcloud.gnunet
+checkfailexp
+gnunet-gns -t SOA -u @.gnunet
+checkfailexp
+
+# TESTING implicit records
+gnunet-gns -t LEHO -u foo.gnunet
+checkfailimp
+gnunet-gns -t LEHO -u mail.gnunet
+checkfailimp
+gnunet-gns -t LEHO -u nextcloud.gnunet
+checkfailimp
+gnunet-gns -t LEHO -u owncloud.gnunet
+checkfailimp
+gnunet-gns -t LEHO -u ns1.gnunet
+checkfailimp
+gnunet-gns -t LEHO -u ns2.gnunet
+checkfailimp
+
+# cleanup if we get this far
+cleanup
+
+# finish
+echo "All records added successfully!!"

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]