2012-10-18 07:16:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Stress tests for Serval rhizome protocol.
|
|
|
|
#
|
2013-02-06 08:25:31 +00:00
|
|
|
# Copyright 2012 Serval Project, Inc.
|
2012-10-18 07:16:17 +00:00
|
|
|
#
|
|
|
|
# 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 \
|
2013-06-18 02:43:14 +00:00
|
|
|
set log.file.show_pid on \
|
|
|
|
set log.file.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
|
|
|
}
|
|
|
|
|
2013-06-20 01:19:57 +00:00
|
|
|
doc_StressRhizomeTransfer="Five nodes each sharing 26 bundles from 0B to 620K"
|
2013-02-08 01:38:24 +00:00
|
|
|
setup_StressRhizomeTransfer() {
|
2012-10-18 07:16:17 +00:00
|
|
|
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
|
2013-06-20 01:19:57 +00:00
|
|
|
for n in 1 2 3 4 5 6 7 8 9 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
|
2012-10-18 07:16:17 +00:00
|
|
|
do
|
2013-02-08 08:13:37 +00:00
|
|
|
local sidvar="SID$instance_name"
|
2013-06-20 01:19:57 +00:00
|
|
|
local size=$((16 * (j ** 3)))
|
2013-06-18 02:43:14 +00:00
|
|
|
tfw_log "Adding file file-$i-$n, size $size"
|
|
|
|
create_file file-$i-$n $size
|
|
|
|
tfw_nolog executeOk_servald rhizome add file "${!sidvar}" file-$i-$n file-$i-$n.manifest
|
|
|
|
tfw_nolog extract_stdout_manifestid BID
|
|
|
|
tfw_nolog extract_stdout_version VERSION
|
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
|
|
|
|
}
|
2013-06-18 02:43:14 +00:00
|
|
|
|
|
|
|
start_instance() {
|
|
|
|
executeOk_servald config \
|
|
|
|
set server.interface_path "$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 interfaces.0.file dummy \
|
|
|
|
set interfaces.0.dummy_address 127.0.0.$instance_number \
|
|
|
|
set interfaces.0.dummy_netmask 255.255.255.224
|
|
|
|
start_servald_server
|
|
|
|
}
|
|
|
|
|
2013-02-08 01:38:24 +00:00
|
|
|
test_StressRhizomeTransfer() {
|
2013-06-18 02:43:14 +00:00
|
|
|
>$SERVALD_VAR/dummy
|
|
|
|
foreach_instance +A +B +C +D +E \
|
|
|
|
start_instance
|
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
|
|
|
|
}
|
|
|
|
|
2013-02-08 01:38:24 +00:00
|
|
|
amend_file() {
|
|
|
|
create_file --append file$instance_name 100
|
|
|
|
rm -f file$instance_name.manifest # ensure 'rhizome add file' generates a new Bundle ID
|
|
|
|
rhizome_add_file file$instance_name
|
2012-12-27 04:45:23 +00:00
|
|
|
}
|
|
|
|
|
2013-02-08 01:38:24 +00:00
|
|
|
rhizome_list_bundle_count() {
|
2012-12-27 04:45:23 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2013-02-08 01:38:24 +00:00
|
|
|
local lineCount=$(( $(replayStdout | wc -l) + 0 ))
|
|
|
|
tfw_log "lineCount=$lineCount"
|
|
|
|
echo $(($lineCount - 2))
|
2012-12-27 04:45:23 +00:00
|
|
|
}
|
|
|
|
|
2013-02-08 01:38:24 +00:00
|
|
|
rhizome_bundle_count_equals() {
|
|
|
|
[ $(rhizome_list_bundle_count) -eq $1 ]
|
|
|
|
}
|
|
|
|
|
2013-02-08 08:13:37 +00:00
|
|
|
doc_StressRhizomeAdd="Add new bundles while transferring"
|
|
|
|
setup_StressRhizomeAdd() {
|
|
|
|
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
|
|
|
|
}
|
2013-02-08 01:38:24 +00:00
|
|
|
test_StressRhizomeAdd() {
|
|
|
|
local total_files=0
|
2012-12-27 04:45:23 +00:00
|
|
|
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
|
2013-02-08 01:38:24 +00:00
|
|
|
foreach_instance +A +B +C +D +E +F +G +H amend_file
|
|
|
|
let total_files+=8
|
2012-12-27 04:45:23 +00:00
|
|
|
done
|
2013-02-08 01:38:24 +00:00
|
|
|
foreach_instance +A +B +C +D +E +F +G +H wait_until --timeout=120 rhizome_bundle_count_equals $total_files
|
2012-12-27 04:45:23 +00:00
|
|
|
}
|
|
|
|
|
2013-02-08 08:13:37 +00:00
|
|
|
doc_StressRhizomeDirect="Direct push/pull/sync 1500 bundles at once"
|
|
|
|
setup_StressRhizomeDirect() {
|
2013-02-11 08:09:46 +00:00
|
|
|
files_per_instance=300
|
2013-02-08 08:13:37 +00:00
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
foreach_instance +A +B +C +D +E create_single_identity
|
|
|
|
local i
|
|
|
|
for i in A B C D E
|
|
|
|
do
|
|
|
|
set_instance +$i
|
|
|
|
executeOk_servald config \
|
2013-06-18 02:43:14 +00:00
|
|
|
set log.file.show_time on \
|
2013-02-08 08:13:37 +00:00
|
|
|
set debug.rhizome off \
|
|
|
|
set debug.rhizome_tx off \
|
|
|
|
set debug.rhizome_rx off \
|
|
|
|
set server.respawn_on_crash off \
|
|
|
|
set mdp.iftype.wifi.tick_ms 500
|
|
|
|
local sidvar="SID$instance_name"
|
2013-02-11 08:09:46 +00:00
|
|
|
for ((n = 0; n < $files_per_instance; ++n)); do
|
2013-02-08 08:13:37 +00:00
|
|
|
create_file file-$i-$n 10000
|
2013-06-18 02:43:14 +00:00
|
|
|
tfw_quietly executeOk_servald rhizome add file "${!sidvar}" file-$i-$n file-$i-$n.manifest
|
2013-02-08 08:13:37 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
start_servald_instances dummy1 +A
|
|
|
|
wait_until rhizome_http_server_started +A
|
|
|
|
get_rhizome_server_port PORTA +A
|
|
|
|
for i in B C D E
|
|
|
|
do
|
|
|
|
set_instance +$i
|
|
|
|
executeOk_servald config \
|
2013-02-11 08:09:46 +00:00
|
|
|
set rhizome.direct.peer.0 "http://${addr_localhost}:${PORTA}" \
|
2013-06-18 02:43:14 +00:00
|
|
|
set log.file.path "$instance_servald_log"
|
2013-02-11 08:09:46 +00:00
|
|
|
|
2013-02-08 08:13:37 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
test_StressRhizomeDirect() {
|
|
|
|
set_instance +B
|
2013-02-11 08:09:46 +00:00
|
|
|
fork executeOk_servald rhizome direct sync
|
2013-02-08 08:13:37 +00:00
|
|
|
set_instance +C
|
|
|
|
fork executeOk_servald rhizome direct pull
|
|
|
|
set_instance +D
|
2013-02-11 08:09:46 +00:00
|
|
|
fork executeOk_servald rhizome direct push
|
2013-02-08 08:13:37 +00:00
|
|
|
set_instance +E
|
|
|
|
fork executeOk_servald rhizome direct sync
|
|
|
|
forkWaitAll
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald rhizome list ''
|
2013-02-11 08:09:46 +00:00
|
|
|
tfw_quietly assert_rhizome_list --fromhere=1 file-A-!(*.manifest) --fromhere=0 file-[BDE]-!(*.manifest)
|
2013-02-08 08:13:37 +00:00
|
|
|
set_instance +B
|
|
|
|
executeOk_servald rhizome list ''
|
2013-02-11 08:09:46 +00:00
|
|
|
tfw_quietly assert_rhizome_list --fromhere=1 file-B-!(*.manifest) --fromhere=0 file-A-!(*.manifest) --and-others
|
|
|
|
reportfiles CDE
|
2013-02-08 08:13:37 +00:00
|
|
|
set_instance +C
|
|
|
|
executeOk_servald rhizome list ''
|
2013-02-11 08:09:46 +00:00
|
|
|
tfw_quietly assert_rhizome_list --fromhere=1 file-C-!(*.manifest) --fromhere=0 file-A-!(*.manifest) --and-others
|
|
|
|
reportfiles BDE
|
2013-02-08 08:13:37 +00:00
|
|
|
set_instance +D
|
|
|
|
executeOk_servald rhizome list ''
|
2013-02-11 08:09:46 +00:00
|
|
|
tfw_quietly assert_rhizome_list --fromhere=1 file-D-!(*.manifest)
|
2013-02-08 08:13:37 +00:00
|
|
|
set_instance +E
|
|
|
|
executeOk_servald rhizome list ''
|
2013-02-11 08:09:46 +00:00
|
|
|
tfw_quietly assert_rhizome_list --fromhere=1 file-E-!(*.manifest) --fromhere=0 file-A-!(*.manifest) --and-others
|
|
|
|
reportfiles BCD
|
|
|
|
}
|
|
|
|
|
|
|
|
reportfiles() {
|
|
|
|
replayStdout | sed -n -e '1,2p' -e "/:file-[$1]-/p" | rhizome_list_dump name bundleid >extrafiles || exit $?
|
|
|
|
tfw_log "$(cat extrafiles | wc -l) file(s) received by instance +$instance_name"
|
|
|
|
sort -t- -k2,2 -k3,3n extrafiles
|
2013-02-08 08:13:37 +00:00
|
|
|
}
|
|
|
|
|
2012-10-18 07:16:17 +00:00
|
|
|
runTests "$@"
|