mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-21 22:17:53 +00:00
9d69a3c2bd
Replacing a bundle with an empty payload, "unsharing" in UI terms
126 lines
3.7 KiB
Bash
Executable File
126 lines
3.7 KiB
Bash
Executable File
#!/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
|
|
}
|
|
|
|
# Called by start_servald_instances for each instance.
|
|
configure_servald_server() {
|
|
executeOk_servald config set log.show_pid on
|
|
executeOk_servald config set log.show_time on
|
|
executeOk_servald config set debug.rhizome on
|
|
executeOk_servald config set debug.rhizometx on
|
|
executeOk_servald config set debug.rhizomerx on
|
|
executeOk_servald config set mdp.wifi.tick_ms 100
|
|
executeOk_servald config set mdp.selfannounce.ticks_per_full_address 1
|
|
executeOk_servald config set rhizome.fetch_interval_ms 100
|
|
}
|
|
|
|
# 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
|
|
}
|
|
|
|
setup_file_one() {
|
|
setup_servald
|
|
setup_rhizome
|
|
assert_no_servald_processes
|
|
echo 'File one' >file1
|
|
set_instance +A
|
|
executeOk_servald rhizome add file $SIDA '' file1 file1.manifest
|
|
extract_manifest_id BID file1.manifest
|
|
extract_manifest_version VERSION file1.manifest
|
|
}
|
|
|
|
doc_FileTransferNew="One new bundle transfers to one node"
|
|
setup_FileTransferNew() {
|
|
setup_file_one
|
|
start_servald_instances +A +B
|
|
set_instance +B
|
|
}
|
|
test_FileTransferNew() {
|
|
wait_until bundle_received_by +B
|
|
executeOk_servald rhizome list ''
|
|
assert_rhizome_list file1!
|
|
}
|
|
|
|
doc_FileMultiTransferNew="One new bundle transfers to four nodes"
|
|
setup_FileMultiTransferNew() {
|
|
setup_file_one
|
|
start_servald_instances +A +B +C +D +E
|
|
}
|
|
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
|
|
}
|
|
|
|
doc_FileTransferDelete="One bundle deletion transfers to one node"
|
|
setup_FileTransferDelete() {
|
|
setup_file_one
|
|
start_servald_instances +A +B
|
|
wait_until bundle_received_by +B
|
|
set_instance +A
|
|
>file1_2
|
|
sed -e '/^date=/d;/^filehash=/d;/^filesize=/d;/^version=/d' file1.manifest >file1_2.manifest
|
|
echo 'filesize=0' >>file1_2.manifest
|
|
executeOk_servald rhizome add file $SIDA '' '' file1_2.manifest
|
|
extract_manifest_version VERSION file1_2.manifest
|
|
executeOk_servald rhizome list ''
|
|
assert_rhizome_list file1_2
|
|
}
|
|
test_FileTransferDelete() {
|
|
wait_until bundle_received_by +B
|
|
set_instance +B
|
|
executeOk_servald rhizome list ''
|
|
assert_rhizome_list file1_2!
|
|
}
|
|
|
|
runTests "$@"
|