Skip to content

Commit

Permalink
Add explicit route tests and improve test speed
Browse files Browse the repository at this point in the history
  • Loading branch information
lakeman committed Dec 11, 2012
1 parent bc91b05 commit dc6d0da
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
6 changes: 4 additions & 2 deletions testdefs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ start_servald_instances() {
eval DUMMY$instance_name="\$DUMMYNET"
done
# Now wait until they see each other.
wait_until --sleep=0.25 instances_see_each_other "$@"
foreach "$@" \
wait_until --sleep=0.25 has_seen_instances "$@"
tfw_log "# dummynet file:" $(ls -l $DUMMYNET)
pop_instance
}
Expand All @@ -675,12 +676,13 @@ assert_peers_are_instances() {
# selfannounce mechanism
has_seen_instances() {
local I N
executeOk_servald route print
for I; do
[ $I = $instance_arg ] && continue
for ((N=1; 1; ++N)); do
local sidvar=SID${I#+}$N
[ -n "${!sidvar}" ] || break
if ! grep "ADD OVERLAY NODE sid=${!sidvar}" $instance_servald_log; then
if ! grep "^${!sidvar}" $_tfw_tmp/stdout; then
return 1
fi
done
Expand Down
6 changes: 6 additions & 0 deletions tests/directory_service
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ configure_servald_server() {
executeOk_servald config \
set log.show_pid on \
set log.show_time on \
set rhizome.enable No \
set debug.mdprequests Yes
}

Expand Down Expand Up @@ -95,6 +96,7 @@ start_routing_instance() {
set server.dummy_interface_dir "$SERVALD_VAR" \
set monitor.socket "org.servalproject.servald.monitor.socket.$TFWUNIQUE.$instance_name" \
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
set rhizome.enable No \
set log.show_pid on \
set log.show_time on \
set debug.mdprequests Yes
Expand Down Expand Up @@ -138,10 +140,14 @@ test_routing() {
wait_until is_published $SIDB
wait_until is_published $SIDC
set_instance +B
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDA:UNICAST :"
executeOk_servald dna lookup "$DIDC"
assertStdoutLineCount '==' 1
assertStdoutGrep --matches=1 "^sid://$SIDC/local/$DIDC:$DIDC:$NAMEC\$"
set_instance +C
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDA:UNICAST :"
executeOk_servald dna lookup "$DIDB"
assertStdoutLineCount '==' 1
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
Expand Down
1 change: 1 addition & 0 deletions tests/dnaprotocol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ set_server_vars() {
set log.show_pid on \
set log.show_time on \
set mdp.iftype.wifi.tick_ms 100 \
set rhizome.enable No \
set debug.interfaces Yes \
set debug.packetformats No \
set debug.routing No \
Expand Down
53 changes: 35 additions & 18 deletions tests/routing
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
source "${0%/*}/../testframework.sh"
source "${0%/*}/../testdefs.sh"

configure_servald_server() {
executeOk_servald config \
set log.show_pid on \
set log.show_time on \
set debug.mdprequests Yes
}

add_interface() {
>$SERVALD_VAR/dummy$1
executeOk_servald config \
Expand All @@ -47,7 +40,8 @@ start_routing_instance() {
set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name" \
set log.show_pid on \
set log.show_time on \
set debug.mdprequests Yes
set debug.mdprequests Yes \
set rhizome.enable no
start_servald_server
wait_until interface_up
}
Expand Down Expand Up @@ -75,9 +69,13 @@ setup_single_link() {

doc_single_link="Start 2 instances on one link"
test_single_link() {
foreach_instance +A +B \
wait_until has_seen_instances +A +B
set_instance +A
executeOk_servald mdp ping $SIDB 10
executeOk_servald mdp ping $SIDB 1
tfw_cat --stdout --stderr
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST :"
}

setup_multiple_nodes() {
Expand All @@ -90,13 +88,19 @@ setup_multiple_nodes() {

doc_multiple_nodes="Multiple nodes on one link"
test_multiple_nodes() {
foreach +A +B +C +D \
wait_until has_seen_instances +A +B +C +D
set_instance +A
executeOk_servald mdp ping $SIDB 10
executeOk_servald mdp ping $SIDB 1
tfw_cat --stdout --stderr
executeOk_servald mdp ping $SIDC 3
executeOk_servald mdp ping $SIDC 1
tfw_cat --stdout --stderr
executeOk_servald mdp ping $SIDD 3
executeOk_servald mdp ping $SIDD 1
tfw_cat --stdout --stderr
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST :"
assertStdoutGrep --matches=1 "^$SIDC:BROADCAST :"
assertStdoutGrep --matches=1 "^$SIDD:BROADCAST :"
}

setup_scan() {
Expand All @@ -117,10 +121,13 @@ scan_completed() {

doc_scan="Simulate isolated clients"
test_scan() {
set_instance +A
executeOk_servald scan
wait_until scan_completed
executeOk_servald mdp ping $SIDB 3
set_instance +A
executeOk_servald scan
wait_until scan_completed
wait_until has_seen_instances +B
executeOk_servald mdp ping $SIDB 1
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDB:UNICAST :"
}

setup_multihop_linear() {
Expand All @@ -135,9 +142,15 @@ setup_multihop_linear() {

doc_multihop_linear="Start 4 instances in a linear arrangement"
test_multihop_linear() {
foreach_instance +A +B +C +D \
wait_until has_seen_instances +A +B +C +D
set_instance +A
executeOk_servald mdp ping $SIDD 10
executeOk_servald mdp ping $SIDD 1
tfw_cat --stdout --stderr
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDB:BROADCAST :"
assertStdoutGrep --matches=1 "^$SIDC:INDIRECT :"
assertStdoutGrep --matches=1 "^$SIDD:INDIRECT :"
}

setup_crowded_mess() {
Expand All @@ -157,9 +170,13 @@ setup_crowded_mess() {

doc_crowded_mess="Multiple possible paths"
test_crowded_mess() {
foreach_instance +A +H \
wait_until has_seen_instances +A +H
set_instance +A
executeOk_servald mdp ping $SIDH 10
executeOk_servald mdp ping $SIDH 1
tfw_cat --stdout --stderr
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDH:INDIRECT :"
}

runTests "$@"

0 comments on commit dc6d0da

Please sign in to comment.