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-03-26 07:54:37 +00:00
|
|
|
set log.stderr.show_pid on \
|
|
|
|
set log.stderr.show_time on \
|
2012-12-10 23:26:21 +00:00
|
|
|
set rhizome.enable No \
|
2012-12-06 02:01:19 +00:00
|
|
|
set debug.mdprequests 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() {
|
2012-12-04 04:17:57 +00:00
|
|
|
tfw_log "grep \"PUBLISHED.*$1\" $LOGA"
|
|
|
|
grep "PUBLISHED.*$1" $LOGA || return 1
|
2013-03-26 07:54:37 +00:00
|
|
|
return 0
|
2012-09-18 02:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sent_directory_request() {
|
2012-12-04 04:17:57 +00:00
|
|
|
grep "Sending directory registration" $1 || return 1
|
2012-09-18 02:56:30 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
start_servald_instances +A +B +C +D
|
2012-12-20 06:20:50 +00:00
|
|
|
wait_until grep "DNAHELPER got STARTED ACK" $LOGA
|
2012-12-08 04:39:41 +00:00
|
|
|
}
|
|
|
|
|
2012-09-18 02:56:30 +00:00
|
|
|
doc_publish="Publish and retrieve a directory entry"
|
|
|
|
test_publish() {
|
2012-12-04 04:17:57 +00:00
|
|
|
wait_until sent_directory_request $LOGB
|
|
|
|
wait_until sent_directory_request $LOGC
|
|
|
|
wait_until sent_directory_request $LOGD
|
|
|
|
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
|
|
|
set_instance +A
|
|
|
|
executeOk_servald dna lookup "$DIDB"
|
|
|
|
assertStdoutLineCount '==' 1
|
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"
|
2012-09-20 06:51:18 +00:00
|
|
|
assertStdoutLineCount '==' 2
|
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() {
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
2013-02-14 03:48:56 +00:00
|
|
|
set server.interface_path "$SERVALD_VAR" \
|
2012-12-06 02:01:19 +00:00
|
|
|
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
|
|
|
|
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
|
2012-12-10 23:26:21 +00:00
|
|
|
set rhizome.enable No \
|
2013-03-26 07:54:37 +00:00
|
|
|
set log.stderr.show_pid on \
|
|
|
|
set log.stderr.show_time on \
|
2012-12-06 02:01:19 +00:00
|
|
|
set debug.mdprequests Yes
|
2012-09-19 00:24:41 +00:00
|
|
|
start_servald_server
|
2012-12-10 03:54:52 +00:00
|
|
|
wait_until interface_up
|
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 \
|
|
|
|
executeOk_servald config \
|
2013-02-14 03:48:56 +00:00
|
|
|
set interfaces.0.file dummy1 \
|
2012-12-08 04:39:41 +00:00
|
|
|
set interfaces.0.mdp_tick_ms 0 \
|
|
|
|
set interfaces.0.default_route 1 \
|
|
|
|
set interfaces.0.dummy_netmask 255.255.255.0
|
2012-09-19 00:24:41 +00:00
|
|
|
set_instance +A
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
2012-12-08 04:39:41 +00:00
|
|
|
set interfaces.0.dummy_address 10.0.${instance_number}.1 \
|
2012-12-06 02:01:19 +00:00
|
|
|
set dna.helper.executable "$servald_build_root/directory_service" \
|
|
|
|
set debug.dnahelper on
|
2012-09-19 00:24:41 +00:00
|
|
|
set_instance +B
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
2012-12-08 04:39:41 +00:00
|
|
|
set interfaces.0.dummy_address 10.0.${instance_number}.1 \
|
2012-12-06 02:01:19 +00:00
|
|
|
set directory.service $SIDA \
|
2012-12-08 04:39:41 +00:00
|
|
|
set hosts.$SIDA.address 10.0.1.1
|
2012-09-19 00:24:41 +00:00
|
|
|
set_instance +C
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
2012-12-08 04:39:41 +00:00
|
|
|
set interfaces.0.dummy_address 10.0.${instance_number}.1 \
|
2012-12-06 02:01:19 +00:00
|
|
|
set directory.service $SIDA \
|
2012-12-08 04:39:41 +00:00
|
|
|
set hosts.$SIDA.address 10.0.1.1
|
2012-12-04 04:17:57 +00:00
|
|
|
foreach_instance +A +B +C start_routing_instance
|
2012-12-20 06:20:50 +00:00
|
|
|
wait_until grep "DNAHELPER got STARTED ACK" $LOGA
|
2012-09-19 00:24:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doc_routing="Ping via relay node"
|
|
|
|
test_routing() {
|
2012-12-08 04:39:41 +00:00
|
|
|
foreach_instance +B +C \
|
|
|
|
wait_until sent_directory_request $instance_servald_log
|
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
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDA:UNICAST :"
|
2012-09-19 00:24:41 +00:00
|
|
|
executeOk_servald dna lookup "$DIDC"
|
|
|
|
assertStdoutLineCount '==' 1
|
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
|
|
|
|
assertStdoutGrep --matches=1 "^$SIDA:UNICAST :"
|
2012-09-19 00:24:41 +00:00
|
|
|
executeOk_servald dna lookup "$DIDB"
|
|
|
|
assertStdoutLineCount '==' 1
|
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
|
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 "$@"
|