2012-10-18 07:16:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Stress tests for Serval rhizome protocol.
|
|
|
|
#
|
|
|
|
# Copyright 2012 Serval Project Inc.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
|
finally() {
|
|
|
|
stop_all_servald_servers
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
kill_all_servald_processes
|
|
|
|
assert_no_servald_processes
|
|
|
|
report_all_servald_servers
|
|
|
|
}
|
|
|
|
|
|
|
|
# Called by start_servald_instances for each instance.
|
|
|
|
configure_servald_server() {
|
2012-12-06 02:01:19 +00:00
|
|
|
executeOk_servald config \
|
|
|
|
set log.show_pid on \
|
|
|
|
set log.show_time on \
|
2012-12-11 05:29:46 +00:00
|
|
|
set debug.rhizome off \
|
|
|
|
set debug.rhizome_tx off \
|
|
|
|
set debug.rhizome_rx off \
|
2012-12-06 02:01:19 +00:00
|
|
|
set server.respawn_on_crash off \
|
2012-12-07 03:39:55 +00:00
|
|
|
set mdp.iftype.wifi.tick_ms 500
|
2012-10-18 07:16:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doc_FileTransferStress="Stress - five nodes each sharing 16 bundles"
|
|
|
|
setup_FileTransferStress() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C +D +E create_single_identity
|
|
|
|
for i in A B C D E
|
|
|
|
do
|
|
|
|
eval "bundles$i=()"
|
|
|
|
set_instance +$i
|
2012-10-31 07:47:06 +00:00
|
|
|
let j=0
|
2012-10-18 07:16:17 +00:00
|
|
|
for n in 1 2 3 4 5 6 7 8 9 a b c d e f g
|
|
|
|
do
|
2012-10-31 07:47:06 +00:00
|
|
|
rhizome_add_file file-$i-$n $((2 ** (j + 10)))
|
2012-10-18 07:16:17 +00:00
|
|
|
eval "bundles$i+=(\$BID:\$VERSION)"
|
2012-10-31 07:47:06 +00:00
|
|
|
let j=j+1
|
2012-10-18 07:16:17 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
test_FileTransferStress() {
|
|
|
|
start_servald_instances +A +B +C +D +E
|
2012-11-05 04:15:23 +00:00
|
|
|
wait_until --timeout=600 bundle_received_by \
|
2012-10-18 07:16:17 +00:00
|
|
|
${bundlesA[*]} +B +C +D +E \
|
|
|
|
${bundlesB[*]} +A +C +D +E \
|
|
|
|
${bundlesC[*]} +A +B +D +E \
|
|
|
|
${bundlesD[*]} +A +B +C +E \
|
|
|
|
${bundlesE[*]} +A +B +C +D
|
|
|
|
stop_all_servald_servers
|
|
|
|
local i
|
|
|
|
for i in A B C D E; do
|
|
|
|
set_instance +$i
|
|
|
|
executeOk_servald rhizome list ''
|
|
|
|
assert_rhizome_list --fromhere=1 file-$i-? --fromhere=0 file-!($i)-?
|
|
|
|
assert_rhizome_received file-!($i)-?
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-12-27 04:45:23 +00:00
|
|
|
setup_AddStressTest() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C +D +E +F +G +H create_single_identity
|
|
|
|
start_servald_instances +A +B +C +D +E +F +G +H
|
|
|
|
}
|
|
|
|
|
|
|
|
ammendfile() {
|
|
|
|
echo "XXX ${instance_name} XXX" >> $instance_dir/file
|
2012-12-28 01:30:43 +00:00
|
|
|
executeOk_servald rhizome add file "" "" "$instance_dir/file" "$instance_dir/file.manifest"
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
extract_manifest_filehash filehash "$instance_dir/file.manifest"
|
|
|
|
executeOk_servald rhizome extract file $filehash
|
|
|
|
rm "$instance_dir/file.manifest"
|
2012-12-27 04:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
alldone() {
|
|
|
|
executeOk_servald rhizome list ''
|
|
|
|
local lineCount=$(( $(cat $_tfw_tmp/stdout | wc -l) + 0 ))
|
|
|
|
tfw_log "lines $lineCount"
|
|
|
|
# total files = 26 * 8 + 2
|
|
|
|
if [ "$lineCount" -eq "210" ]; then return 0; fi
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddStressTest="Add files while transferring"
|
|
|
|
test_AddStressTest() {
|
|
|
|
for i in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
|
|
|
|
do
|
|
|
|
foreach_instance +A +B +C +D +E +F +G +H ammendfile
|
|
|
|
done
|
|
|
|
foreach_instance +A +B +C +D +E +F +G +H wait_until --timeout=120 alldone
|
|
|
|
sleep 10
|
|
|
|
}
|
|
|
|
|
2012-10-18 07:16:17 +00:00
|
|
|
runTests "$@"
|