2012-07-06 05:09:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Tests for Serval rhizome protocol.
|
|
|
|
#
|
|
|
|
# Copyright 2012 Paul Gardner-Stephen
|
|
|
|
#
|
|
|
|
# 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"
|
|
|
|
source "${0%/*}/../testdefs_rhizome.sh"
|
|
|
|
|
|
|
|
shopt -s extglob
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
stop_all_servald_servers
|
|
|
|
kill_all_servald_processes
|
|
|
|
assert_no_servald_processes
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_rhizome() {
|
|
|
|
set_instance +A
|
|
|
|
create_rhizome_identities 1
|
|
|
|
set_instance +B
|
|
|
|
create_rhizome_identities 1
|
|
|
|
}
|
|
|
|
|
2012-07-11 07:13:21 +00:00
|
|
|
# Called by start_servald_instances for each instance.
|
2012-07-06 05:09:25 +00:00
|
|
|
configure_servald_server() {
|
2012-07-11 07:39:50 +00:00
|
|
|
executeOk_servald config set log.show_pid on
|
|
|
|
executeOk_servald config set log.show_time on
|
2012-07-06 05:09:25 +00:00
|
|
|
executeOk_servald config set debug.rhizome on
|
2012-07-13 01:36:10 +00:00
|
|
|
executeOk_servald config set debug.rhizometx on
|
2012-07-12 07:09:01 +00:00
|
|
|
executeOk_servald config set debug.rhizomerx on
|
2012-07-10 10:30:20 +00:00
|
|
|
executeOk_servald config set mdp.wifi.tick_ms 100
|
|
|
|
executeOk_servald config set mdp.selfannounce.ticks_per_full_address 1
|
2012-07-11 07:20:50 +00:00
|
|
|
executeOk_servald config set rhizome.fetch_interval_ms 100
|
2012-07-06 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 08:12:30 +00:00
|
|
|
# Predicate function:
|
|
|
|
# - return true if the file bundle identified by $BID and $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 I
|
|
|
|
for I; do
|
|
|
|
logvar="LOG${I#+}"
|
|
|
|
grep "RHIZOME ADD MANIFEST service=file bid=$BID version=$VERSION" "${!logvar}" || return 1
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_FileTransferNew="One new bundle single transfer"
|
2012-07-06 05:09:25 +00:00
|
|
|
setup_FileTransferNew() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
assert_no_servald_processes
|
|
|
|
start_servald_instances +A +B
|
|
|
|
echo 'File one' >file1
|
2012-07-11 07:13:21 +00:00
|
|
|
set_instance +A
|
2012-07-06 05:09:25 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file1 file1.manifest
|
2012-07-11 05:21:25 +00:00
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
extract_manifest_version VERSION file1.manifest
|
2012-07-11 07:13:21 +00:00
|
|
|
set_instance +B
|
2012-07-06 05:09:25 +00:00
|
|
|
}
|
|
|
|
test_FileTransferNew() {
|
2012-07-11 08:12:30 +00:00
|
|
|
wait_until bundle_received_by +B
|
2012-07-06 05:09:25 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-07-11 04:52:55 +00:00
|
|
|
assert_rhizome_list file1!
|
2012-07-06 05:09:25 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 08:12:30 +00:00
|
|
|
doc_FileMultiTransferNew="One new bundle multi transfer"
|
|
|
|
setup_FileMultiTransferNew() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
assert_no_servald_processes
|
|
|
|
start_servald_instances +A +B +C +D +E
|
|
|
|
echo 'File one' >file1
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald rhizome add file '' '' file1 file1.manifest
|
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
extract_manifest_version VERSION file1.manifest
|
|
|
|
}
|
|
|
|
test_FileMultiTransferNew() {
|
|
|
|
wait_until bundle_received_by +B +C +D +E
|
|
|
|
local I
|
|
|
|
for I in +B +C +D +E; do
|
|
|
|
set_instance $I
|
|
|
|
executeOk_servald rhizome list ''
|
|
|
|
assert_rhizome_list file1!
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-07-06 05:09:25 +00:00
|
|
|
runTests "$@"
|