mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
89 lines
2.9 KiB
Plaintext
89 lines
2.9 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
# Tests for Serval DNA Route Java API
|
||
|
#
|
||
|
# Copyright 2018 Flinders Univerity
|
||
|
#
|
||
|
# 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"
|
||
|
source "${0%/*}/../testdefs_routing.sh"
|
||
|
source "${0%/*}/../testdefs_rest.sh"
|
||
|
source "${0%/*}/../testdefs_java.sh"
|
||
|
|
||
|
setup() {
|
||
|
setup_rest_utilities #XXX
|
||
|
setup_servald
|
||
|
setup_servald_so
|
||
|
assert_java_classes_exist
|
||
|
assert_no_servald_processes
|
||
|
}
|
||
|
|
||
|
teardown() {
|
||
|
stop_all_servald_servers
|
||
|
kill_all_servald_processes
|
||
|
assert_no_servald_processes
|
||
|
report_all_servald_servers
|
||
|
}
|
||
|
|
||
|
configure_servald_server() {
|
||
|
executeOk_servald config \
|
||
|
set debug.mdprequests yes \
|
||
|
set debug.linkstate yes \
|
||
|
set debug.subscriber yes \
|
||
|
set debug.verbose yes \
|
||
|
set debug.overlayrouting yes \
|
||
|
set debug.overlayinterfaces yes \
|
||
|
set log.console.level debug \
|
||
|
set log.console.show_pid on \
|
||
|
set log.console.show_time on \
|
||
|
set rhizome.enable no
|
||
|
}
|
||
|
|
||
|
doc_RouteListAll="Java API list entire routing table"
|
||
|
setup_RouteListAll() {
|
||
|
setup
|
||
|
setup_rest_config +A #XXX
|
||
|
DIDA1=565656
|
||
|
NAMEA1="Neddy Seagoon"
|
||
|
DIDA2=3020304
|
||
|
NAMEA2="Spike Milligan"
|
||
|
foreach_instance +A +B create_identities 2
|
||
|
foreach_instance +A +B add_servald_interface 1
|
||
|
foreach_instance +A +B start_servald_server
|
||
|
wait_until_rest_server_ready +A
|
||
|
get_servald_primary_sid +B PRIMARY_SIDB
|
||
|
wait_until --timeout=20 path_exists +A +B
|
||
|
wait_until --timeout=10 path_exists +B +A
|
||
|
set_instance +A
|
||
|
rest_request GET "/restful/route/all.json" #XXX
|
||
|
}
|
||
|
test_RouteListAll() {
|
||
|
executeJavaOk org.servalproject.test.Route list-all
|
||
|
tfw_cat --stdout --stderr
|
||
|
assertStdoutLineCount == 4
|
||
|
assertStdoutGrep --matches=1 "sid=$SIDA1, did=$DIDA1, name=$NAMEA1, isSelf=true, hopCount=0"
|
||
|
assertStdoutGrep --matches=1 "sid=$SIDA2, did=$DIDA2, name=$NAMEA2, isSelf=true, hopCount=0"
|
||
|
assertStdoutGrep --matches=1 "sid=$PRIMARY_SIDB,.*isSelf=false, hopCount=1,.*reachableUnicast=true,.*reachableIndirect=false"
|
||
|
for SID in "${SIDB[@]}"; do
|
||
|
if [ "$SID" != "$PRIMARY_SIDB" ]; then
|
||
|
assertStdoutGrep --matches=1 "sid=$SID,.*isSelf=false, hopCount=2,.*reachableUnicast=false,.*reachableIndirect=true"
|
||
|
fi
|
||
|
done
|
||
|
}
|
||
|
|
||
|
runTests "$@"
|