Merge pull request #453 from databasus/develop

FIX (agent): Make E2E test for locking check more stable
This commit is contained in:
Rostislav Dugin
2026-03-21 11:59:35 +03:00
committed by GitHub
4 changed files with 29 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ MODE="${1:-host}"
SCRIPT_DIR="$(dirname "$0")"
PASSED=0
FAILED=0
FAILED_NAMES=""
run_test() {
local name="$1"
@@ -21,6 +22,7 @@ run_test() {
else
echo " FAILED: $name"
FAILED=$((FAILED + 1))
FAILED_NAMES="${FAILED_NAMES}\n - ${name}"
fi
}
@@ -42,6 +44,11 @@ fi
echo ""
echo "========================================"
echo " Results: $PASSED passed, $FAILED failed"
if [ "$FAILED" -gt 0 ]; then
echo ""
echo " Failed:"
echo -e "$FAILED_NAMES"
fi
echo "========================================"
if [ "$FAILED" -gt 0 ]; then

View File

@@ -59,3 +59,6 @@ if [ "$VERSION" != "v1.0.0" ]; then
fi
echo "Upgrade correctly skipped, version still $VERSION"
# Cleanup daemon
"$AGENT" stop || true

View File

@@ -64,3 +64,6 @@ if [ "$VERSION" != "v2.0.0" ]; then
fi
echo "Binary upgraded successfully to $VERSION"
# Cleanup daemon
"$AGENT" stop || true

View File

@@ -50,8 +50,23 @@ func AcquireLock(log *slog.Logger) (*os.File, error) {
func ReleaseLock(f *os.File) {
_ = syscall.Flock(int(f.Fd()), syscall.LOCK_UN)
lockedStat, lockedErr := f.Stat()
_ = f.Close()
_ = os.Remove(lockFileName)
if lockedErr != nil {
_ = os.Remove(lockFileName)
return
}
diskStat, diskErr := os.Stat(lockFileName)
if diskErr != nil {
return
}
if os.SameFile(lockedStat, diskStat) {
_ = os.Remove(lockFileName)
}
}
func ReadLockFilePID() (int, error) {