fix(shared-ols): watcher executable bit, coalesce floor-window edits, harden test
CI run 6313 Shell-Checks failed "plain site docRoot .htaccess triggers (+0)": the watcher was tracked as mode 100644 (the image chmods it, a bare CI checkout does not), so `env ... ols-htaccess-watcher.sh` died with "Permission denied" and no case ever restarted. Not a watcher logic bug. - watcher: mode 100755 - watcher: an edit inside the FLOOR window is deferred to the end of the window (one coalesced restart, bounded by FLOOR) instead of dropped - test: assert executable bit, launch via bash, kill children before parent (leaked inotifywait/subshell from earlier sections), add floor/coalesce cases Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
1eca2566e8
commit
b395a198b1
2 files changed
+41
-5
No files matched your search
@@ -10,9 +10,17 @@ W="$HERE/ols-htaccess-watcher.sh"
|
||||
if ! command -v inotifywait >/dev/null 2>&1; then
|
||||
echo "SKIP - inotifywait (inotify-tools) not installed; watcher test not run"; exit 0
|
||||
fi
|
||||
## The watcher must be executable as checked out (CI run 6313 failed with
|
||||
## "Permission denied" because git tracked it 100644; the image chmods it, a bare
|
||||
## checkout does not). Assert it, and launch via bash so the test never depends on it.
|
||||
if [ ! -x "$W" ]; then echo "FAIL - $W is not executable (git mode must be 100755)"; exit 1; fi
|
||||
T=$(mktemp -d)
|
||||
WPID=""
|
||||
cleanup() { [ -n "$WPID" ] && kill "$WPID" 2>/dev/null || true; pkill -P "${WPID:-0}" 2>/dev/null || true; rm -rf "$T"; }
|
||||
## Stop children (inotifywait + the while-subshell) BEFORE the parent: once the
|
||||
## parent is dead they are reparented and `pkill -P` no longer finds them, and the
|
||||
## leaked watcher would keep restarting against later sections.
|
||||
stopw() { [ -n "$WPID" ] || return 0; pkill -P "$WPID" 2>/dev/null || true; kill "$WPID" 2>/dev/null || true; WPID=""; }
|
||||
cleanup() { stopw; rm -rf "$T"; }
|
||||
trap cleanup EXIT
|
||||
fail=0
|
||||
ok() { echo "ok - $1"; }
|
||||
@@ -36,7 +44,7 @@ chmod +x "$T/lswsctrl"
|
||||
|
||||
start() {
|
||||
env OLS_WATCH_ROOT="$U" OLS_LSWS_CONF="$CONF" OLS_SITES_ROOT="$SITES" LSWSCTRL="$T/lswsctrl" \
|
||||
OLS_HTACCESS_DEBOUNCE=1 OLS_HTACCESS_FLOOR=0 "$W" 2>"$T/log" &
|
||||
OLS_HTACCESS_DEBOUNCE=1 OLS_HTACCESS_FLOOR="${FLOOR_T:-0}" bash "$W" 2>"$T/log" &
|
||||
WPID=$!
|
||||
sleep 1.5
|
||||
}
|
||||
@@ -63,7 +71,7 @@ mkdir -p "$U/u4/d.example/public_html/pub"
|
||||
mkdir -p "$SITES/d"; printf 'docRoot %s\n' "$U/u4/d.example/public_html/pub" >"$SITES/d/vhconf.conf"
|
||||
echo '# cfg2' >"$CONF/.tmp" && mv "$CONF/.tmp" "$CONF/httpd_config.conf"
|
||||
check "site added after start (re-render) triggers" 1 "$U/u4/d.example/public_html/pub/.htaccess"
|
||||
kill "$WPID" 2>/dev/null || true; pkill -P "$WPID" 2>/dev/null || true; WPID=""
|
||||
stopw
|
||||
|
||||
## Fallback: no vhconf files -> legacy */public_html/.htaccess match
|
||||
rm -rf "$SITES"; mkdir -p "$SITES"
|
||||
@@ -71,4 +79,22 @@ start
|
||||
check "fallback (empty docRoot set): public_html/.htaccess triggers" 1 "$U/u3/c.example/public_html/.htaccess"
|
||||
check "fallback: deep plugin file still does NOT" 0 "$U/u1/a.example/public_html/wp-content/cache/x/.htaccess"
|
||||
|
||||
stopw
|
||||
|
||||
## Floor window: an edit inside it is DEFERRED to the window end (one restart),
|
||||
## not dropped; a burst of several edits inside it still costs a single restart.
|
||||
FLOOR_T=8
|
||||
start
|
||||
: >"$T/restarts"
|
||||
H="$U/u3/c.example/public_html/.htaccess"
|
||||
echo a >>"$H"; sleep 4
|
||||
r1=$(count)
|
||||
echo b >>"$H"; sleep 0.5; echo c >>"$H"; sleep 1
|
||||
r2=$(count)
|
||||
sleep 9
|
||||
r3=$(count)
|
||||
[ "$r1" -eq 1 ] && ok "floor: first edit restarts immediately" || bad "floor: first edit (restarts $r1, want 1)"
|
||||
[ "$r2" -eq 1 ] && ok "floor: edits inside window do not restart early" || bad "floor: early restart (restarts $r2, want 1)"
|
||||
[ "$r3" -eq 2 ] && ok "floor: edits inside window coalesce into ONE deferred restart" || bad "floor: deferred restart (restarts $r3, want 2)"
|
||||
|
||||
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo "FAILURES"; cat "$T/log"; exit 1; }
|
||||
Reference in new issue
Block a user