From e8873abb7cd92b5b71785a0e5a24de68fae40b21 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 30 Sep 2013 09:07:43 +0000 Subject: [PATCH] new namestore CLI tests --- src/namestore/Makefile.am | 35 ++++++++------ src/namestore/test_namestore_lookup.sh | 64 ++++++++++++++++++++++++++ src/namestore/test_namestore_put.sh | 42 +++++++++++++++++ 3 files changed, 127 insertions(+), 14 deletions(-) create mode 100755 src/namestore/test_namestore_lookup.sh create mode 100755 src/namestore/test_namestore_put.sh diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 0cb08fc77..13f025b75 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am @@ -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 index 000000000..da4724ebf --- /dev/null +++ b/src/namestore/test_namestore_lookup.sh @@ -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 index 000000000..1e8b0bd46 --- /dev/null +++ b/src/namestore/test_namestore_put.sh @@ -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 -- 2.25.1