mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-04 14:25:08 +00:00
* chore: stop tests and rigs writing to shared paths Two shared-state problems, both of which show up as a permanently dirty checkout or an unreproducible test failure. test_display_dirty_tracking.py builds a real DisplayManager, whose _snapshot_path defaults to the fixed /tmp/led_matrix_preview.png that the web UI reads. Every pytest process on the machine shares that one file, so two concurrent runs -- CI shards, a second worktree, an agent running the suite alongside -- overwrite each other's snapshot and the mtime assertions stop meaning anything. The module fixture now points it at a session-unique temp path; the individual tests that care still override it further. To be clear about what this does and does not fix: this is a real shared-path hazard, but it is NOT the cause of the intermittent 15-test failure in that module. That turned out to be the emulator's fixed TCP port, fixed in the follow-up commit. This change stands on its own merits. web_interface/app.py writes data/plugin_operations.json, data/plugin_state.json and data/operation_history.json as the web interface runs, into a directory that ships tracked (data/.gitkeep) and was otherwise unignored. So every rig that ever opened the web UI -- and every test run that constructs the app -- left three untracked files behind and a permanently dirty `git status`. Only data/.gitkeep is tracked under data/, so the negation keeps it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test: stop the emulator binding a fixed port, so concurrent runs can't collide This is the cause of the intermittent full-suite failures we have been chasing: runs of identical code landing anywhere between 100 and 130 failures, while every implicated test passed in isolation. Six test modules set EMULATOR=true and build a real DisplayManager. The repo's emulator_config.json selects the "browser" adapter, which binds TCP port 8888 to serve the dev preview. That port is a machine-wide singleton, so a second pytest process -- a CI shard, another worktree, an agent running the suite alongside -- loses the bind. RGBMatrix construction then raises, DisplayManager catches it and falls back to `self.matrix = None`, and every test that subsequently touches the matrix dies with AttributeError: 'NoneType' object has no attribute 'SwapOnVSync' which names neither a port nor a socket, and points at the wrong file entirely. Because test_display_dirty_tracking's fixture is module-scoped, all 15 of its matrix-touching tests fail together or not at all -- the 15-test swing that made the totals look random. Demonstrated rather than assumed. Holding 0.0.0.0:8888 from a separate process and running test_display_dirty_tracking.py: without this change 15 failed, 6 passed with this change 21 passed The "raw" adapter renders in memory and binds nothing. Only display_adapter is overridden, in a throwaway config written per pytest process; the repo's emulator_config.json is untouched and `run.py -e` still opens the browser preview on 8888. Nothing in the suite referenced the adapter, and the tests wrap SwapOnVSync on the matrix object itself, so they are indifferent to what sits underneath. allow_adapter_fallback is forced off -- falling back would land us on the browser adapter and its fixed port, which is the whole problem. CONFIG_PATH is a bare relative filename resolved against the CWD, so it is set to an absolute path: the previous behaviour depended on where pytest was invoked from, and silently wrote a default config into whatever directory that was. Verified no regressions: full suite on this branch and with origin/main's versions of the touched files, same machine, back to back -- 115 failed / 4347 passed on both sides, zero failures unique to either. That 115 is the pre-existing Windows-environment baseline (POSIX file modes, fcntl, shell scripts, Linux-only binaries); CI on Linux remains authoritative. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: mark the shell entry points executable Eleven scripts shipped as 100644, so `./scripts/install/configure_web_sudo.sh` fails with "Permission denied" and only works if you know to prefix `bash`. That one matters most: the web UI's own error hint, added in #560, tells users to run exactly that path when a system action fails for want of passwordless sudo, and following that instruction verbatim did not work. All eleven carry a shebang and are invoked directly, never sourced. The two sourced libraries -- lib_lowmem.sh and lib_systemd_render.sh -- are deliberately left non-executable, which is what distinguishes a library from an entry point. Mode bits only, no content: 11 files changed, 0 insertions, 0 deletions. Applied with `git update-index --chmod=+x` because this checkout is on Windows, where core.fileMode is off and the working-tree bit is not tracked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
87 lines
3.2 KiB
Bash
Executable File
87 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# DNS single-request fix installation script.
|
|
#
|
|
# Optional. Install this only if plugins that call external APIs (Starlark
|
|
# apps, weather, sports, music) are timing out or feel slow to first paint
|
|
# while the network is otherwise fine. See the header of
|
|
# scripts/utils/apply_dns_single_request.sh for what it changes and why.
|
|
|
|
set -e
|
|
|
|
PROJECT_ROOT_DIR=$(cd "$(dirname "$0")/../.." && pwd)
|
|
SERVICE_NAME="ledmatrix-dns-fix"
|
|
UNIT_SRC="$PROJECT_ROOT_DIR/systemd/$SERVICE_NAME.service"
|
|
UNIT_DEST="/etc/systemd/system/$SERVICE_NAME.service"
|
|
DROPIN_DIR="/etc/systemd/system/ledmatrix.service.d"
|
|
|
|
if [ "$EUID" -eq 0 ]; then
|
|
SYSTEMCTL_CMD="systemctl"
|
|
SUDO=""
|
|
else
|
|
SYSTEMCTL_CMD="sudo systemctl"
|
|
SUDO="sudo"
|
|
fi
|
|
|
|
echo "Installing LED Matrix DNS fix service"
|
|
echo "Project root directory: $PROJECT_ROOT_DIR"
|
|
|
|
if [ ! -f "$UNIT_SRC" ]; then
|
|
echo "✗ Missing unit file: $UNIT_SRC"
|
|
exit 1
|
|
fi
|
|
|
|
chmod +x "$PROJECT_ROOT_DIR/scripts/utils/apply_dns_single_request.sh"
|
|
|
|
echo "Installing $UNIT_DEST..."
|
|
sed "s|__PROJECT_ROOT_DIR__|$PROJECT_ROOT_DIR|g" "$UNIT_SRC" \
|
|
| $SUDO tee "$UNIT_DEST" > /dev/null
|
|
|
|
# Order ledmatrix.service after the fix. `Before=` in the unit itself only
|
|
# orders units already in the same transaction, so a plain
|
|
# `systemctl restart ledmatrix` would not wait for it -- and since this fix is
|
|
# opt-in, ledmatrix.service cannot carry the dependency in the repo.
|
|
# Wants=, not Requires=: a DNS workaround failing should not stop the display.
|
|
echo "Installing the ledmatrix.service ordering drop-in..."
|
|
$SUDO mkdir -p "$DROPIN_DIR"
|
|
printf '[Unit]\nWants=%s.service\nAfter=%s.service\n' "$SERVICE_NAME" "$SERVICE_NAME" \
|
|
| $SUDO tee "$DROPIN_DIR/10-dns-fix.conf" > /dev/null
|
|
|
|
$SYSTEMCTL_CMD daemon-reload
|
|
$SYSTEMCTL_CMD enable "$SERVICE_NAME.service"
|
|
|
|
# Do not mask a failure here. The unit exits non-zero when it could not apply
|
|
# the option -- a systemd-resolved host, an unwritable resolv.conf, a failed
|
|
# `resolvconf -u` -- and reporting "installation complete" over that would
|
|
# leave the operator believing a workaround is active when it is not.
|
|
START_STATUS=0
|
|
$SYSTEMCTL_CMD start "$SERVICE_NAME.service" || START_STATUS=$?
|
|
|
|
echo ""
|
|
if grep -qs "^options single-request$" /etc/resolv.conf; then
|
|
echo "✓ 'options single-request' is active in /etc/resolv.conf"
|
|
elif [ "$START_STATUS" -ne 0 ]; then
|
|
echo "✗ The DNS fix could not be applied on this host."
|
|
echo " The service reported why:"
|
|
echo " journalctl -u $SERVICE_NAME -n 20"
|
|
echo ""
|
|
echo " The unit is installed and will try again on the next boot. Nothing"
|
|
echo " else about your install has changed."
|
|
exit "$START_STATUS"
|
|
else
|
|
echo "⚠ 'options single-request' is not in /etc/resolv.conf yet."
|
|
echo " Check what the service reported:"
|
|
echo " journalctl -u $SERVICE_NAME -n 20"
|
|
fi
|
|
|
|
echo ""
|
|
echo "DNS fix installation complete."
|
|
echo ""
|
|
echo "Useful commands:"
|
|
echo " sudo systemctl status $SERVICE_NAME # Check status"
|
|
echo " sudo journalctl -u $SERVICE_NAME -n 50 # View logs"
|
|
echo " sudo systemctl disable --now $SERVICE_NAME # Undo the service"
|
|
echo " sudo rm $DROPIN_DIR/10-dns-fix.conf # Undo the ordering drop-in"
|
|
echo " # then remove the 'options single-request' line from /etc/resolv.conf"
|
|
echo ""
|