2012-09-18 02:56:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Tests for Directory Services.
|
|
|
|
# Copyright 2012 Serval Project
|
|
|
|
#
|
|
|
|
# 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() {
|
|
|
|
executeOk_servald config set log.show_pid on
|
|
|
|
executeOk_servald config set log.show_time on
|
|
|
|
executeOk_servald config set debug.mdprequests Yes
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C create_single_identity
|
2012-09-20 06:51:18 +00:00
|
|
|
set_instance +D
|
|
|
|
DIDD1=$DIDC
|
|
|
|
NAMED1="Agent D Smith"
|
|
|
|
create_identities 1
|
|
|
|
SIDD=$SIDD1
|
|
|
|
DIDD=$DIDD1
|
|
|
|
NAMED=$NAMED1
|
2012-09-18 02:56:30 +00:00
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config set dna.helper.executable "$servald_build_root/directory_service"
|
|
|
|
executeOk_servald config set debug.dnahelper on
|
2012-09-20 06:51:18 +00:00
|
|
|
foreach_instance +B +C +D executeOk_servald config set directory.service $SIDA
|
|
|
|
start_servald_instances +A +B +C +D
|
2012-09-18 02:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
stop_all_servald_servers
|
|
|
|
kill_all_servald_processes
|
|
|
|
assert_no_servald_processes
|
|
|
|
}
|
|
|
|
|
|
|
|
is_published() {
|
|
|
|
grep "PUBLISHED" $LOGA || return 1
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
sent_directory_request() {
|
2012-09-20 06:51:18 +00:00
|
|
|
grep "Sending directory registration" $LOGD || return 1
|
2012-09-18 02:56:30 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_publish="Publish and retrieve a directory entry"
|
|
|
|
test_publish() {
|
|
|
|
wait_until sent_directory_request
|
|
|
|
wait_until is_published
|
|
|
|
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
|
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB\$"
|
|
|
|
executeOk_servald dna lookup "$DIDC"
|
2012-09-20 06:51:18 +00:00
|
|
|
assertStdoutLineCount '==' 2
|
2012-09-18 02:56:30 +00:00
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDC/$DIDC:$DIDC:$NAMEC\$"
|
2012-09-20 06:51:18 +00:00
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDD/$DIDD:$DIDD:$NAMED\$"
|
2012-09-18 02:56:30 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2012-09-19 00:24:41 +00:00
|
|
|
start_routing_instance() {
|
|
|
|
executeOk_servald config set interface.folder "$SERVALD_VAR"
|
|
|
|
executeOk_servald config set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name"
|
|
|
|
executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name"
|
|
|
|
executeOk_servald config set log.show_pid on
|
|
|
|
executeOk_servald config set log.show_time on
|
|
|
|
executeOk_servald config set debug.mdprequests Yes
|
|
|
|
start_servald_server
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_routing() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
# create three nodes, on two dummy interfaces, with no interface ticks or routing
|
|
|
|
foreach_instance +A +B +C create_single_identity
|
|
|
|
>$SERVALD_VAR/dummyB
|
|
|
|
>$SERVALD_VAR/dummyC
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config set interfaces "+>dummyB,+>dummyC"
|
|
|
|
executeOk_servald config set mdp.dummyB.tick_ms 0
|
|
|
|
executeOk_servald config set mdp.dummyC.tick_ms 0
|
|
|
|
executeOk_servald config set dna.helper.executable "$servald_build_root/directory_service"
|
|
|
|
executeOk_servald config set debug.dnahelper on
|
|
|
|
start_routing_instance
|
|
|
|
set_instance +B
|
|
|
|
executeOk_servald config set interfaces "+>dummyB"
|
|
|
|
executeOk_servald config set mdp.dummyB.tick_ms 0
|
|
|
|
executeOk_servald config set directory.service $SIDA
|
|
|
|
executeOk_servald config set $SIDA.interface "dummyB"
|
|
|
|
executeOk_servald config set $SIDA.address 127.0.0.1
|
|
|
|
start_routing_instance
|
|
|
|
set_instance +C
|
|
|
|
executeOk_servald config set interfaces "+>dummyC"
|
|
|
|
executeOk_servald config set mdp.dummyC.tick_ms 0
|
|
|
|
executeOk_servald config set directory.service $SIDA
|
|
|
|
executeOk_servald config set $SIDA.interface "dummyC"
|
|
|
|
executeOk_servald config set $SIDA.address 127.0.0.1
|
|
|
|
start_routing_instance
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_routing="Ping via relay node"
|
|
|
|
test_routing() {
|
|
|
|
set_instance +B
|
|
|
|
executeOk_servald dna lookup "$DIDC"
|
|
|
|
assertStdoutLineCount '==' 1
|
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDC/$DIDC:$DIDC:$NAMEC\$"
|
|
|
|
set_instance +C
|
|
|
|
executeOk_servald dna lookup "$DIDB"
|
|
|
|
assertStdoutLineCount '==' 1
|
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB\$"
|
|
|
|
executeOk_servald mdp ping $SIDB 3
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
}
|
2012-09-18 02:56:30 +00:00
|
|
|
runTests "$@"
|