mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-06 11:09:13 +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:
|
# Utility function:
|
||||||
# - invoke "servald start" command with given args and suitable environment
|
# - invoke "servald start" command with given args and suitable environment
|
||||||
servald_start() {
|
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 "$@"
|
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
|
# - does this by examining the server log files of the respective instances
|
||||||
# for tell-tale INFO messages
|
# for tell-tale INFO messages
|
||||||
bundle_received_by() {
|
bundle_received_by() {
|
||||||
local -a rexps
|
local -a rexps bundles
|
||||||
local restart=true
|
local restart=true
|
||||||
local arg bid version rexp
|
local arg bid version rexp bundle bundlefile i
|
||||||
|
local ret=0
|
||||||
for arg; do
|
for arg; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
+([0-9A-F])?(:+([0-9])))
|
+([0-9A-F])?(:+([0-9])))
|
||||||
$restart && rexps=()
|
$restart && rexps=() bundles=()
|
||||||
restart=false
|
restart=false
|
||||||
bid="${arg%%:*}"
|
bid="${arg%%:*}"
|
||||||
matches_rexp "$rexp_manifestid" "$bid" || error "invalid bundle ID: $bid"
|
matches_rexp "$rexp_manifestid" "$bid" || error "invalid bundle ID: $bid"
|
||||||
|
bundles+=("$arg")
|
||||||
if [ "$bid" = "$arg" ]; then
|
if [ "$bid" = "$arg" ]; then
|
||||||
rexps+=("RHIZOME ADD MANIFEST service=file bid=$bid")
|
rexps+=("RHIZOME ADD MANIFEST service=file bid=$bid")
|
||||||
else
|
else
|
||||||
@ -275,15 +277,34 @@ bundle_received_by() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
+[A-Z])
|
+[A-Z])
|
||||||
local logvar="LOG${arg#+}"
|
push_instance
|
||||||
for rexp in "${rexps[@]}"; do
|
tfw_nolog set_instance $arg || return $?
|
||||||
grep "$rexp" "${!logvar}" || return 1
|
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
|
done
|
||||||
restart=true
|
restart=true
|
||||||
|
pop_instance
|
||||||
;;
|
;;
|
||||||
--stderr)
|
--stderr)
|
||||||
for rexp in "${rexps[@]}"; do
|
for ((i = 0; i < ${#bundles[*]}; ++i)); do
|
||||||
replayStderr | grep "$rexp" || return 1
|
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
|
done
|
||||||
restart=true
|
restart=true
|
||||||
;;
|
;;
|
||||||
@ -293,7 +314,7 @@ bundle_received_by() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
return 0
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
extract_manifest_vars() {
|
extract_manifest_vars() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user