mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Improve Rhizome test defs: bundle_received_by()
Introduce per-instance server cache directory and use it to suppress duplicate log messages from bundle_received_by().
This commit is contained in:
parent
2b5b7fa896
commit
54d0e49a1d
@ -289,6 +289,8 @@ start_servald_server() {
|
||||
# Utility function:
|
||||
# - invoke "servald start" command with given args and suitable environment
|
||||
servald_start() {
|
||||
rm -r -f "$instance_dir/cache"
|
||||
mkdir "$instance_dir/cache" || error "mkdir failed"
|
||||
SERVALD_SERVER_CHDIR="$instance_dir" SERVALD_LOG_FILE="$instance_servald_log" $servald start "$@"
|
||||
}
|
||||
|
||||
|
@ -257,16 +257,18 @@ get_rhizome_server_port() {
|
||||
# - does this by examining the server log files of the respective instances
|
||||
# for tell-tale INFO messages
|
||||
bundle_received_by() {
|
||||
local -a rexps
|
||||
local -a rexps bundles
|
||||
local restart=true
|
||||
local arg bid version rexp
|
||||
local arg bid version rexp bundle bundlefile i
|
||||
local ret=0
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
+([0-9A-F])?(:+([0-9])))
|
||||
$restart && rexps=()
|
||||
$restart && rexps=() bundles=()
|
||||
restart=false
|
||||
bid="${arg%%:*}"
|
||||
matches_rexp "$rexp_manifestid" "$bid" || error "invalid bundle ID: $bid"
|
||||
bundles+=("$arg")
|
||||
if [ "$bid" = "$arg" ]; then
|
||||
rexps+=("RHIZOME ADD MANIFEST service=file bid=$bid")
|
||||
else
|
||||
@ -275,15 +277,34 @@ bundle_received_by() {
|
||||
fi
|
||||
;;
|
||||
+[A-Z])
|
||||
local logvar="LOG${arg#+}"
|
||||
for rexp in "${rexps[@]}"; do
|
||||
grep "$rexp" "${!logvar}" || return 1
|
||||
push_instance
|
||||
tfw_nolog set_instance $arg || return $?
|
||||
for ((i = 0; i < ${#bundles[*]}; ++i)); do
|
||||
bundle="${bundles[$i]}"
|
||||
rexp="${rexps[$i]}"
|
||||
bundledir="$instance_dir/cache/bundles_received"
|
||||
bundlefile="$bundledir/$bundle"
|
||||
if [ ! -s "$bundlefile" ]; then
|
||||
[ -d "$bundledir" ] || mkdir -p "$bundledir" || error "mkdir failed"
|
||||
if grep "$rexp" "$instance_servald_log" >"$bundlefile"; then
|
||||
tfw_log "bundle $bundle received by instance +$instance_name"
|
||||
else
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
restart=true
|
||||
pop_instance
|
||||
;;
|
||||
--stderr)
|
||||
for rexp in "${rexps[@]}"; do
|
||||
replayStderr | grep "$rexp" || return 1
|
||||
for ((i = 0; i < ${#bundles[*]}; ++i)); do
|
||||
bundle="${bundles[$i]}"
|
||||
rexp="${rexps[$i]}"
|
||||
if replayStderr | grep "$rexp" >/dev/null; then
|
||||
tfw_log "bundle $bundle received by ($executed)"
|
||||
else
|
||||
ret=1
|
||||
fi
|
||||
done
|
||||
restart=true
|
||||
;;
|
||||
@ -293,7 +314,7 @@ bundle_received_by() {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 0
|
||||
return $ret
|
||||
}
|
||||
|
||||
extract_manifest_vars() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user