Skip to content

Phase 12.L.E.2 — Linux state-dir env-var override (foundation for full E2E)

Placeholder ppxd requested to merge phase12.L.E.2-linux-state-dir-override into main

Summary

Enables the next phase of Linux E2E (12.L.E.3+ full lifecycle tests). Pre-this-PR upgrade-linux-tentacle.sh hardcoded STATUS_DIR="/var/lib/squid-tentacle" — no test isolation possible without running as root or in containers. Equivalent of pre-J.E.3 Windows lacking $env:ProgramData redirection.

This is the last production-side blocker before full Linux E2E coverage can land.

Operator value

Use case Override
FHS-strict deployments SQUID_TARGET_LINUX_TENTACLE_STATE_DIR=/srv/squid-tentacle
Container with mounted volume SQUID_TARGET_LINUX_TENTACLE_STATE_DIR=/data/squid-tentacle
E2E test isolation SQUID_TARGET_LINUX_TENTACLE_STATE_DIR=/tmp/test-{guid}/squid-tentacle
(default) /var/lib/squid-tentacle — pre-PR behaviour exactly

Production changes

LinuxTentacleUpgradeStrategy

  • public const StateDirEnvVar = "SQUID_TARGET_LINUX_TENTACLE_STATE_DIR"
  • internal const DefaultStateDir = "/var/lib/squid-tentacle"
  • ResolveStateDir() — trims trailing slashes + whitespace, falls back to default on empty (operator-friendly)
  • {{STATE_DIR}} placeholder wired into BuildScript

upgrade-linux-tentacle.sh

  • STATUS_DIR="{{STATE_DIR}}" replaces hardcoded "/var/lib/squid-tentacle"
  • All downstream paths (STATUS_FILE, LOCK_FILE, EVENTS_FILE) already derive from STATUS_DIR — auto-pick up override

Unit tests (6 new)

Test Pin
StateDirEnvVar_ConstantNamePinned Rule 8
ResolveStateDir_NoEnvVar_ReturnsDefaultVarLibPath Default /var/lib/squid-tentacle
ResolveStateDir_OperatorOverride_NormalisesAndReturns (Theory) 5 real operator scenarios
ResolveStateDir_EmptyOrWhitespace_FallsBackToDefault (Theory) Operator-friendly fallback
BuildScript_StateDirPlaceholder_SubstitutedFromEnv Positive + reverse-pin (no stale hardcoded path)
BuildScript_StateDir_DefaultsToVarLibInRender Default render unchanged

Drift detector updated

  • Squid.LinuxTentacleE2ETests.UpgradeLinuxScriptE2ETests.LinuxScript_PlaceholderSet_* now expects 9 placeholders (was 8 + STATE_DIR)

Local verification

  • 5068/5068 unit tests pass
  • 3/3 Linux E2E pass (incl. bash -n parse check on new STATE_DIR-substituted .sh)

Next phase (12.L.E.3)

With state-dir override in place, can build:

  • LinuxServiceFixture (systemd analog of WindowsServiceFixture)
  • First full lifecycle test (Linux E1.h analog)
  • Linux-side production hardening parity with Windows J.E.5/6/7/8

🤖 Generated with Claude Code

Merge request reports

Loading