2012-09-18 02:56:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Tests for Directory Services.
|
2013-02-06 08:25:31 +00:00
|
|
|
#
|
|
|
|
# Copyright 2012 Serval Project, Inc.
|
2012-09-18 02:56:30 +00:00
|
|
|
#
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
configure_servald_server() {
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
2013-04-05 06:25:14 +00:00
|
|
|
set log.console.show_pid on \
|
|
|
|
set log.console.show_time on \
|
2012-12-10 23:26:21 +00:00
|
|
|
set rhizome.enable No \
|
2013-04-26 07:23:04 +00:00
|
|
|
set debug.mdprequests Yes \
|
|
|
|
set debug.overlayframes Yes
|
2012-09-18 02:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
kill_all_servald_processes
|
|
|
|
assert_no_servald_processes
|
2012-10-17 07:40:39 +00:00
|
|
|
report_all_servald_servers
|
2012-09-18 02:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
is_published() {
|
2013-08-12 04:51:31 +00:00
|
|
|
tfw_log "grep \"PUBLISHED.*$1\" $instance_servald_log"
|
2014-03-03 04:40:59 +00:00
|
|
|
grep "PUBLISHED.*$1" $instance_servald_log
|
2012-09-18 02:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sent_directory_request() {
|
2014-03-03 04:40:59 +00:00
|
|
|
grep "Sending directory registration" $instance_servald_log
|
2012-09-18 02:56:30 +00:00
|
|
|
}
|
|
|
|
|
2012-12-08 04:39:41 +00:00
|
|
|
setup_publish() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C +D create_single_identity
|
|
|
|
set_instance +D
|
2013-02-14 05:36:01 +00:00
|
|
|
executeOk_servald keyring set did $SIDD $DIDC "Agent D Smith"
|
2012-12-08 04:39:41 +00:00
|
|
|
DIDD1=$DIDC
|
|
|
|
NAMED1="Agent D Smith"
|
|
|
|
DIDD=$DIDC1
|
|
|
|
NAMED=$NAMED1
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config \
|
|
|
|
set dna.helper.executable "$servald_build_root/directory_service" \
|
|
|
|
set debug.dnahelper on
|
|
|
|
foreach_instance +B +C +D executeOk_servald config set directory.service $SIDA
|
2014-01-23 06:01:56 +00:00
|
|
|
foreach_instance +A +B +C +D add_servald_interface
|
2012-12-08 04:39:41 +00:00
|
|
|
start_servald_instances +A +B +C +D
|
|
|
|
}
|
|
|
|
|
2012-09-18 02:56:30 +00:00
|
|
|
doc_publish="Publish and retrieve a directory entry"
|
|
|
|
test_publish() {
|
2014-01-23 06:01:56 +00:00
|
|
|
wait_until grep "DNAHELPER got STARTED ACK" $LOGA
|
2014-03-03 04:37:58 +00:00
|
|
|
foreach_instance +B +C +D wait_until sent_directory_request
|
2012-12-04 04:17:57 +00:00
|
|
|
wait_until is_published $SIDB
|
|
|
|
wait_until is_published $SIDC
|
|
|
|
wait_until is_published $SIDD
|
2012-09-18 02:56:30 +00:00
|
|
|
stop_servald_server +B
|
|
|
|
stop_servald_server +C
|
2012-09-20 06:51:18 +00:00
|
|
|
stop_servald_server +D
|
2012-09-18 02:56:30 +00:00
|
|
|
executeOk_servald dna lookup "$DIDB"
|
2014-02-19 05:05:08 +00:00
|
|
|
assertStdoutLineCount '==' 3
|
2012-09-21 05:47:56 +00:00
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
2012-09-18 02:56:30 +00:00
|
|
|
executeOk_servald dna lookup "$DIDC"
|
2014-02-19 05:05:08 +00:00
|
|
|
assertStdoutLineCount '==' 4
|
2012-09-21 05:47:56 +00:00
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDC/local/$DIDC:$DIDC:$NAMEC\$"
|
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDD/local/$DIDD:$DIDD:$NAMED\$"
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_status_all_servald_servers running
|
2012-09-18 02:56:30 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 03:54:52 +00:00
|
|
|
interface_up() {
|
2013-02-14 03:48:56 +00:00
|
|
|
grep "Interface .* is up" $instance_servald_log || return 1
|
2012-12-10 03:54:52 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-09-19 00:24:41 +00:00
|
|
|
start_routing_instance() {
|
|
|
|
start_servald_server
|
2012-12-10 03:54:52 +00:00
|
|
|
wait_until interface_up
|
2012-09-19 00:24:41 +00:00
|
|
|
}
|
|
|
|
|
2013-08-13 01:25:48 +00:00
|
|
|
configure_node() {
|
|
|
|
executeOk_servald config \
|
2014-01-23 06:01:56 +00:00
|
|
|
set server.interface_path "$SERVALD_VAR" \
|
|
|
|
set rhizome.enable No \
|
|
|
|
set log.console.show_pid on \
|
|
|
|
set log.console.show_time on \
|
|
|
|
set debug.mdprequests Yes \
|
|
|
|
set debug.overlayframes Yes \
|
2013-08-13 01:25:48 +00:00
|
|
|
set interfaces.0.file dummy1 \
|
2014-01-23 06:01:56 +00:00
|
|
|
set interfaces.0.socket_type file \
|
2013-08-13 01:25:48 +00:00
|
|
|
set interfaces.0.send_broadcasts 0 \
|
2014-06-16 07:52:46 +00:00
|
|
|
set interfaces.0.dont_route 1 \
|
2013-08-13 01:25:48 +00:00
|
|
|
set interfaces.0.drop_broadcasts on \
|
|
|
|
set interfaces.0.default_route 1 \
|
|
|
|
set interfaces.0.dummy_address 10.0.${instance_number}.1 \
|
|
|
|
set interfaces.0.dummy_netmask 255.255.255.0
|
|
|
|
}
|
|
|
|
|
2012-09-19 00:24:41 +00:00
|
|
|
setup_routing() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C create_single_identity
|
2012-12-08 04:39:41 +00:00
|
|
|
>$SERVALD_VAR/dummy1
|
|
|
|
foreach_instance +A +B +C \
|
2013-08-13 01:25:48 +00:00
|
|
|
configure_node
|
2012-09-19 00:24:41 +00:00
|
|
|
set_instance +A
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
|
|
|
set dna.helper.executable "$servald_build_root/directory_service" \
|
|
|
|
set debug.dnahelper on
|
2013-08-12 04:51:31 +00:00
|
|
|
foreach_instance +B +C \
|
|
|
|
executeOk_servald config \
|
|
|
|
set directory.service $SIDA \
|
|
|
|
set hosts.$SIDA.address 10.0.1.1
|
2012-12-04 04:17:57 +00:00
|
|
|
foreach_instance +A +B +C start_routing_instance
|
2013-08-12 04:51:31 +00:00
|
|
|
set_instance +A
|
|
|
|
wait_until grep "DNAHELPER got STARTED ACK" $instance_servald_log
|
2012-09-19 00:24:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doc_routing="Ping via relay node"
|
|
|
|
test_routing() {
|
2013-08-12 04:51:31 +00:00
|
|
|
foreach_instance +B +C \
|
|
|
|
wait_until sent_directory_request
|
|
|
|
set_instance +A
|
2012-12-04 04:17:57 +00:00
|
|
|
wait_until is_published $SIDB
|
|
|
|
wait_until is_published $SIDC
|
2012-09-19 00:24:41 +00:00
|
|
|
set_instance +B
|
2012-12-10 23:26:21 +00:00
|
|
|
executeOk_servald route print
|
2013-08-09 06:49:45 +00:00
|
|
|
assertStdoutGrep --matches=1 "^$SIDA:UNICAST:"
|
2014-06-16 07:52:46 +00:00
|
|
|
assertStdoutGrep --matches=0 "^$SIDC:"
|
2012-09-19 00:24:41 +00:00
|
|
|
executeOk_servald dna lookup "$DIDC"
|
2014-02-19 05:05:08 +00:00
|
|
|
assertStdoutLineCount '==' 3
|
2012-09-21 05:47:56 +00:00
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDC/local/$DIDC:$DIDC:$NAMEC\$"
|
2012-09-19 00:24:41 +00:00
|
|
|
set_instance +C
|
2012-12-10 23:26:21 +00:00
|
|
|
executeOk_servald route print
|
2013-08-09 06:49:45 +00:00
|
|
|
assertStdoutGrep --matches=1 "^$SIDA:UNICAST:"
|
2014-06-16 07:52:46 +00:00
|
|
|
assertStdoutGrep --matches=0 "^$SIDB:"
|
2012-09-19 00:24:41 +00:00
|
|
|
executeOk_servald dna lookup "$DIDB"
|
2014-02-19 05:05:08 +00:00
|
|
|
assertStdoutLineCount '==' 3
|
2012-09-21 05:47:56 +00:00
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
2012-09-19 00:24:41 +00:00
|
|
|
executeOk_servald mdp ping $SIDB 3
|
|
|
|
tfw_cat --stdout --stderr
|
2014-06-16 07:52:46 +00:00
|
|
|
executeOk_servald route print
|
|
|
|
tfw_cat --stdout
|
|
|
|
set_instance +B
|
|
|
|
executeOk_servald route print
|
|
|
|
tfw_cat --stdout
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_status_all_servald_servers running
|
2012-09-19 00:24:41 +00:00
|
|
|
}
|
2012-10-17 07:40:39 +00:00
|
|
|
|
2012-09-18 02:56:30 +00:00
|
|
|
runTests "$@"
|