new namestore CLI tests
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 30 Sep 2013 09:07:43 +0000 (09:07 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 30 Sep 2013 09:07:43 +0000 (09:07 +0000)
src/namestore/Makefile.am
src/namestore/test_namestore_lookup.sh [new file with mode: 0755]
src/namestore/test_namestore_put.sh [new file with mode: 0755]

index 0cb08fc77f329e0e42d98c3fdcb1a27b2a7f7390..13f025b75c68bf1f35fde80da7503af07ba60b75 100644 (file)
@@ -62,7 +62,9 @@ check_PROGRAMS = \
 endif
 
 if ENABLE_TEST_RUN
-TESTS = $(check_PROGRAMS)
+TESTS = \
+  $(check_PROGRAMS) \
+  $(check_SCRIPTS)  
 endif
 
 lib_LTLIBRARIES = \
@@ -266,18 +268,6 @@ test_namestore_record_serialization_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/namestore/libgnunetnamestore.la  
 
-EXTRA_DIST = \
-  test_namestore_api.conf \
-  test_plugin_namestore_sqlite.conf \
-  test_plugin_namestore_postgres.conf \
-  test_hostkey \
-  zonefiles/S5I9DSGQVAB5FVV16T3B3CC5H1B2JGL3Q412JBKURME8EKU0600G.zkey \
-  zonefiles/AQ835GVL939H4O8QJQ7GBLPTQC0QAAO91BN7QK01BA63MDSK6I4G.zkey \
-  zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey \
-  zonefiles/N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey
-
-
-
 test_plugin_namestore_sqlite_SOURCES = \
  test_plugin_namestore.c
 test_plugin_namestore_sqlite_LDADD = \
@@ -288,4 +278,21 @@ test_plugin_namestore_postgres_SOURCES = \
  test_plugin_namestore.c
 test_plugin_namestore_postgres_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la  
+ $(top_builddir)/src/util/libgnunetutil.la
+check_SCRIPTS = \
+       test_namestore_put.sh \
+       test_namestore_lookup.sh
+
+EXTRA_DIST = \
+  test_namestore_api.conf \
+  test_plugin_namestore_sqlite.conf \
+  test_plugin_namestore_postgres.conf \
+  test_namestore_defaults.conf \
+  test_hostkey \
+  zonefiles/S5I9DSGQVAB5FVV16T3B3CC5H1B2JGL3Q412JBKURME8EKU0600G.zkey \
+  zonefiles/AQ835GVL939H4O8QJQ7GBLPTQC0QAAO91BN7QK01BA63MDSK6I4G.zkey \
+  zonefiles/HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey \
+  zonefiles/N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey \
+  $(check_SCRIPTS)
+   
diff --git a/src/namestore/test_namestore_lookup.sh b/src/namestore/test_namestore_lookup.sh
new file mode 100755 (executable)
index 0000000..da4724e
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/bash
+CONFIGURATION="test_namestore_defaults.conf"
+trap "gnunet-arm -e -c $CONFIGURATION" SIGINT
+rm -rf `gnunet-config -c $CONFIGURATION -s PATHS -o SERVICEHOME`
+TEST_DOMAIN_PLUS="www.gnu"
+TEST_DOMAIN_DNS="www3.gnu"
+TEST_IP_PLUS="127.0.0.1"
+TEST_IP_DNS="131.159.74.67"
+TEST_RECORD_CNAME_SERVER="server"
+TEST_RECORD_CNAME_PLUS="server.+"
+TEST_RECORD_CNAME_DNS="gnunet.org"
+TEST_RECORD_NAME_SERVER="server"
+TEST_RECORD_NAME_PLUS="www"
+TEST_RECORD_NAME_DNS="www3"
+which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
+
+function start_peer
+{
+       gnunet-arm -s -c $CONFIGURATION
+       gnunet-identity -C testego -c $CONFIGURATION    
+}
+
+function stop_peer
+{
+       gnunet-identity -D testego -c $CONFIGURATION
+       gnunet-arm -e -c $CONFIGURATION
+}
+
+
+start_peer
+# Create a public record
+gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME_DNS -t A -V $TEST_IP_PLUS -e never -c $CONFIGURATION
+NAMESTORE_RES=$?
+# Lookup specific name
+OUTPUT=`gnunet-namestore -p -z testego -n $TEST_RECORD_NAME_DNS -D`
+
+
+FOUND_IP=false
+FOUND_NAME=false
+for LINE in $OUTPUT ;
+ do
+       if echo "$LINE" | grep -q "$TEST_RECORD_NAME_DNS"; then
+               FOUND_DNS=true;
+       fi
+       if echo "$LINE" | grep -q "$TEST_IP_PLUS"; then
+               FOUND_IP=true;
+       fi      
+ done
+stop_peer
+
+
+if [ $FOUND_DNS == true -a $FOUND_IP == true ]
+then
+  echo "PASS: Lookup name in namestore"
+  exit 0
+elif [ $FOUND_DNS == false ]
+then
+  echo "FAIL: Lookup name in namestore: name not returned"
+  exit 1
+elif [ $FOUND_IP == false ]
+then
+  echo "FAIL: Lookup name in namestore: IP not returned"
+  exit 1
+fi
diff --git a/src/namestore/test_namestore_put.sh b/src/namestore/test_namestore_put.sh
new file mode 100755 (executable)
index 0000000..1e8b0bd
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+CONFIGURATION="test_namestore_defaults.conf"
+trap "gnunet-arm -e -c $CONFIGURATION" SIGINT
+rm -rf `gnunet-config -c $CONFIGURATION -s PATHS -o SERVICEHOME`
+TEST_DOMAIN_PLUS="www.gnu"
+TEST_DOMAIN_DNS="www3.gnu"
+TEST_IP_PLUS="127.0.0.1"
+TEST_IP_DNS="131.159.74.67"
+TEST_RECORD_CNAME_SERVER="server"
+TEST_RECORD_CNAME_PLUS="server.+"
+TEST_RECORD_CNAME_DNS="gnunet.org"
+TEST_RECORD_NAME_SERVER="server"
+TEST_RECORD_NAME_PLUS="www"
+TEST_RECORD_NAME_DNS="www3"
+which timeout &> /dev/null && DO_TIMEOUT="timeout 5"
+
+function start_peer
+{
+       gnunet-arm -s -c $CONFIGURATION
+       gnunet-identity -C testego -c $CONFIGURATION    
+}
+
+function stop_peer
+{
+       gnunet-identity -D testego -c $CONFIGURATION
+       gnunet-arm -e -c $CONFIGURATION
+}
+
+
+start_peer
+# Create a public record
+gnunet-namestore -p -z testego -a -n $TEST_RECORD_NAME_DNS -t A -V $TEST_IP_PLUS -e never -c $CONFIGURATION
+NAMESTORE_RES=$?
+stop_peer
+
+if [ $NAMESTORE_RES == 0 ]
+then
+  echo "PASS: Creating name in namestore"
+else
+  echo "FAIL: Creating name in namestore failed with $NAMESTORE_RES."
+  exit 1
+fi