mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-13 22:03:09 +00:00
Add 'rhizomeprotocol' tests for push, pull, sync
See issue #9. These commands are not yet implemented, so of course the new tests fail.
This commit is contained in:
parent
00c9c540f5
commit
f93e32b4bc
29
testdefs.sh
29
testdefs.sh
@ -22,6 +22,7 @@ servald_source_root="${testdefs_sh%/*}"
|
||||
servald_build_root="$servald_source_root"
|
||||
servald_build_executable="$servald_build_root/servald"
|
||||
export TFW_LOGDIR="${TFW_LOGDIR:-$servald_build_root/testlog}"
|
||||
addr_localhost="127.0.0.1"
|
||||
|
||||
declare -a instance_stack=()
|
||||
|
||||
@ -445,7 +446,7 @@ configure_servald_server() {
|
||||
# Utility function:
|
||||
# - start a set of servald server processes running on a shared dummy interface
|
||||
# and with its own private monitor and MDP abstract socket names
|
||||
# - set variable DUMMYNET to the full path name of shared dummy interface
|
||||
# - set variables DUMMYx to the full path name of shared dummy interface
|
||||
# - set variables SIDx to the SID of instance x: SIDA, SIDB, etc.
|
||||
# - set variables DIDx to the DID of instance x: DIDA, DIDB, etc.
|
||||
# - set variables NAMEx to the names of instance x: NAMEA, NAMEB, etc.
|
||||
@ -454,9 +455,13 @@ configure_servald_server() {
|
||||
# - wait for all instances to detect each other
|
||||
# - assert that all instances are in each others' peer lists
|
||||
start_servald_instances() {
|
||||
local DUMMY=dummy
|
||||
case "$1" in
|
||||
dummy*) DUMMY="$1"; shift;;
|
||||
esac
|
||||
push_instance
|
||||
tfw_log "# start servald instances $*"
|
||||
DUMMYNET=$SERVALD_VAR/dummy
|
||||
tfw_log "# start servald instances DUMMY=$DUMMY $*"
|
||||
local DUMMYNET="$SERVALD_VAR/$DUMMY"
|
||||
>$DUMMYNET
|
||||
local I J
|
||||
for I; do
|
||||
@ -467,6 +472,7 @@ start_servald_instances() {
|
||||
executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name"
|
||||
configure_servald_server
|
||||
start_servald_server
|
||||
eval DUMMY$instance_name="$DUMMYNET"
|
||||
eval SID$instance_name="$SID"
|
||||
eval DID$instance_name="$(shellarg "$DID")"
|
||||
eval NAME$instance_name="$(shellarg "$NAME")"
|
||||
@ -503,3 +509,20 @@ instances_see_each_other() {
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
rhizome_http_server_started() {
|
||||
local logvar=LOG${1#+}
|
||||
grep 'RHIZOME HTTP SERVER,.*START.*port=[0-9]' "${!logvar}"
|
||||
}
|
||||
|
||||
get_rhizome_server_port() {
|
||||
local _var="$1"
|
||||
local _logvar=LOG${2#+}
|
||||
local _port=$(sed -n -e '/.*RHIZOME HTTP SERVER.*START/{s/.*port=\([0-9]\{1,\}\).*/\1/p;q}' "${!_logvar}")
|
||||
assert --message="instance $2 Rhizome HTTP server port number is known" [ -n "$_port" ]
|
||||
if [ -n "$_var" ]; then
|
||||
eval "$_var=\$_port"
|
||||
tfw_log "$_var=$_port"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
@ -51,15 +51,25 @@ configure_servald_server() {
|
||||
}
|
||||
|
||||
# Predicate function:
|
||||
# - return true if the file bundle identified by $BID and $VERSION has been
|
||||
# - return true if the file bundle identified by arg1=BID and arg2=VERSION has been
|
||||
# received by all the given instances
|
||||
# - does this by examining the server log files of the respective instances
|
||||
# for tell-tale INFO messages
|
||||
bundle_received_by() {
|
||||
local BID="$1"
|
||||
local VERSION="$2"
|
||||
shift 2
|
||||
local I
|
||||
for I; do
|
||||
logvar="LOG${I#+}"
|
||||
grep "RHIZOME ADD MANIFEST service=file bid=$BID version=$VERSION" "${!logvar}" || return 1
|
||||
case "$I" in
|
||||
+*)
|
||||
logvar="LOG${I#+}"
|
||||
grep "RHIZOME ADD MANIFEST service=file bid=$BID version=$VERSION" "${!logvar}" || return 1
|
||||
;;
|
||||
*)
|
||||
error "invalid instance argument: $I"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 0
|
||||
}
|
||||
@ -112,13 +122,13 @@ setup_FileTransfer() {
|
||||
start_servald_instances +A +B
|
||||
}
|
||||
test_FileTransfer() {
|
||||
wait_until bundle_received_by +B
|
||||
wait_until bundle_received_by $BID $VERSION +B
|
||||
set_instance +B
|
||||
assert_received file1
|
||||
set_instance +A
|
||||
update_file file1 file2
|
||||
set_instance +B
|
||||
wait_until bundle_received_by +B
|
||||
wait_until bundle_received_by $BID $VERSION +B
|
||||
assert_received file2
|
||||
}
|
||||
|
||||
@ -133,7 +143,7 @@ setup_FileTransferBig() {
|
||||
start_servald_instances +A +B
|
||||
}
|
||||
test_FileTransferBig() {
|
||||
wait_until bundle_received_by +B
|
||||
wait_until bundle_received_by $BID $VERSION +B
|
||||
set_instance +B
|
||||
assert_received file1
|
||||
}
|
||||
@ -158,7 +168,7 @@ setup_FileTransferMulti() {
|
||||
start_servald_instances +A +B +C +D +E
|
||||
}
|
||||
test_FileTransferMulti() {
|
||||
wait_until bundle_received_by +B +C +D +E
|
||||
wait_until bundle_received_by $BID $VERSION +B +C +D +E
|
||||
local I
|
||||
for I in +B +C +D +E; do
|
||||
set_instance $I
|
||||
@ -172,15 +182,73 @@ setup_FileTransferDelete() {
|
||||
set_instance +A
|
||||
add_file file1
|
||||
start_servald_instances +A +B
|
||||
wait_until bundle_received_by +B
|
||||
wait_until bundle_received_by $BID $VERSION +B
|
||||
set_instance +A
|
||||
>file1_2
|
||||
update_file file1 file1_2
|
||||
}
|
||||
test_FileTransferDelete() {
|
||||
wait_until bundle_received_by +B
|
||||
wait_until bundle_received_by $BID $VERSION +B
|
||||
set_instance +B
|
||||
assert_received file1_2
|
||||
}
|
||||
|
||||
setup_sync() {
|
||||
set_instance +A
|
||||
add_file file1
|
||||
BID1=$BID
|
||||
VERSION1=$VERSION
|
||||
start_servald_instances dummy1 +A
|
||||
wait_until rhizome_http_server_started +A
|
||||
get_rhizome_server_port PORTA +A
|
||||
set_instance +B
|
||||
add_file file2
|
||||
BID2=$BID
|
||||
VERSION2=$VERSION
|
||||
executeOk_servald config set rhizome.direct.address "$addr_localhost"
|
||||
executeOk_servald config set rhizome.direct.port "$PORTA"
|
||||
start_servald_instances dummy2 +B
|
||||
}
|
||||
|
||||
doc_Push="One way push bundle to unconnected node"
|
||||
setup_Push() {
|
||||
setup_common
|
||||
setup_sync
|
||||
}
|
||||
test_Push() {
|
||||
executeOk_servald rhizome push
|
||||
assert bundle_received_by $BID1 $VERSION1 +B
|
||||
assert ! bundle_received_by $BID2 $VERSION2 +A
|
||||
set_instance +B
|
||||
assert_received file1
|
||||
}
|
||||
|
||||
doc_Pull="One way pull bundle from unconnected node"
|
||||
setup_Pull() {
|
||||
setup_common
|
||||
setup_sync
|
||||
}
|
||||
test_Pull() {
|
||||
executeOk_servald rhizome pull
|
||||
assert bundle_received_by $BID2 $VERSION2 +A
|
||||
assert ! bundle_received_by $BID1 $VERSION1 +B
|
||||
set_instance +A
|
||||
assert_received file2
|
||||
}
|
||||
|
||||
doc_Sync="Two-way sync bundles between unconnected nodes"
|
||||
setup_Sync() {
|
||||
setup_common
|
||||
setup_sync
|
||||
}
|
||||
test_Sync() {
|
||||
executeOk_servald rhizome sync
|
||||
assert bundle_received_by $BID2 $VERSION2 +A
|
||||
assert bundle_received_by $BID1 $VERSION1 +B
|
||||
set_instance +A
|
||||
assert_received file2
|
||||
set_instance +B
|
||||
assert_received file1
|
||||
}
|
||||
|
||||
runTests "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user