From d6d3c1f413904926b8de4a30570e3f28b71a64a8 Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 28 May 2013 15:48:04 +0930 Subject: [PATCH] Add ping backward compatibility test --- testdefs.sh | 22 ++++++++--- tests/compatibility | 89 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 6 deletions(-) create mode 100755 tests/compatibility diff --git a/testdefs.sh b/testdefs.sh index 19091fd3..5c67d0a0 100644 --- a/testdefs.sh +++ b/testdefs.sh @@ -20,7 +20,8 @@ shopt -s extglob testdefs_sh=$(abspath "${BASH_SOURCE[0]}") servald_source_root="${testdefs_sh%/*}" servald_build_root="$servald_source_root" -servald_build_executable="$servald_build_root/servald" +servald_basename="servald" +servald_build_executable="$servald_build_root/$servald_basename" export TFW_LOGDIR="${TFW_LOGDIR:-$servald_build_root/testlog}" addr_localhost="127.0.0.1" @@ -76,15 +77,14 @@ extract_stdout_keyvalue() { # - set $servald variable (executable under test) # - set the current instance to be "Z" setup_servald() { - export SERVALD_VAR=$TFWVAR/servald - mkdir $SERVALD_VAR - servald_basename=servald - servald=$SERVALD_VAR/$servald_basename # The servald executable under test if ! [ -x "$servald_build_executable" ]; then error "servald executable not present: $servald" return 1 fi - cp -f "$servald_build_executable" $servald + export SERVALD_VAR="$TFWVAR/servald" + mkdir "$SERVALD_VAR" + servald="$SERVALD_VAR/$servald_basename" # The servald executable under test + cp -f "$servald_build_executable" "$servald" unset SERVALD_OUTPUT_DELIMITER unset SERVALD_SERVER_START_DELAY unset SERVALD_SERVER_CHDIR @@ -154,6 +154,16 @@ set_instance() { instance_arg="${1}" instance_name="${instance_arg#+}" instance_number=$((36#$instance_name - 9)) + local servald_binary_var=servald${instance_name} + if [ -z "${!servald_binary_var}" ]; then + servald="$SERVALD_VAR/$servald_basename" + else + servald="$SERVALD_VAR/${!servald_binary_var}" + fi + if ! [ -x "$servald" ]; then + error "servald executable not present: $servald" + return 1 + fi tfw_log "# set instance = $instance_name, number = $instance_number" export instance_dir="${servald_instances_dir?:}/$instance_name" mkdir -p "$instance_dir" diff --git a/tests/compatibility b/tests/compatibility new file mode 100755 index 00000000..b5da0e91 --- /dev/null +++ b/tests/compatibility @@ -0,0 +1,89 @@ +#!/bin/bash + +# Tests for network backwards compatibility +# +# Copyright 2012 Serval Project, Inc. +# +# This program 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 2 +# of the License, or (at your option) any later version. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +source "${0%/*}/../testframework.sh" +source "${0%/*}/../testdefs.sh" + +teardown() { + stop_all_servald_servers + kill_all_servald_processes + assert_no_servald_processes + report_all_servald_servers +} + +doc_ping_090_version="Ping version of servald in Serval Mesh 0.90" +setup_ping_090_version() { + setup_servald + if ! [ -x "$SERVALD_090" ]; then + error "SERVALD_090 must point to a build being tested for compatibility" + return 1 + fi + servald_binary=servald_090 + cp "$SERVALD_090" "$SERVALD_VAR/$servald_binary" + export servaldA=$servald_binary +} + +start_servald_090() { +# servald configuration and log output has changed, and will continue to change in future +# therefore the operations to start a version 0.90 servald instance are preserved here for future reference + executeOk_servald keyring add + assert [ -e "$SERVALINSTANCE_PATH/serval.keyring" ] + extract_stdout_keyvalue SIDA sid "$rexp_sid" + SERVALD_SERVER_CHDIR="$instance_dir" SERVALD_LOG_FILE="$instance_servald_log" executeOk_servald start + wait_until grep "[Ii]nterface .* is up" "$instance_servald_log" +} + +test_ping_090_version() { + local DUMMYNET="$SERVALD_VAR/dummy" + >$DUMMYNET + set_instance +A + executeOk_servald config \ + set interfaces.0.dummy "$DUMMYNET" \ + set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \ + set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" + start_servald_090 + set_instance +B + executeOk_servald config \ + set interfaces.1.file "$DUMMYNET" \ + set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \ + set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \ + set debug.linkstate on \ + set debug.overlayrouting on + create_single_identity + start_servald_server + wait_until grep "LINK STATE; new legacy neighbour $SIDA" "$instance_servald_log" + wait_until grep "REACHABLE VIA BROADCAST sid=$SIDA" "$instance_servald_log" + executeOk_servald route print + tfw_cat --stdout --stderr + assertStdoutGrep --stdout --matches=1 "^${SIDA}:BROADCAST :$DUMMYNET:0*\$" + set_instance +A + wait_until grep "PEER REACHABLE, sid=$SIDB" "$instance_servald_log" + executeOk_servald route print + tfw_cat --stdout --stderr + assertStdoutGrep --stdout --matches=1 "^${SIDB}:BROADCAST :0*\$" + executeOk_servald mdp ping $SIDB 1 + tfw_cat --stdout --stderr + set_instance +B + executeOk_servald mdp ping $SIDA 1 + tfw_cat --stdout --stderr +} + +runTests "$@" +