feat: add diagnostics and safe reset maintenance

This commit is contained in:
proxyctl coordinator
2026-07-17 03:28:29 +08:00
parent 3003450dce
commit d4c76e4b3c
13 changed files with 1041 additions and 23 deletions
+30
View File
@@ -0,0 +1,30 @@
package operationlock_test
import (
"context"
"testing"
"time"
"proxyctl/internal/operationlock"
)
func TestLockSerializesIndependentInstancesAndHonorsContext(t *testing.T) {
path := t.TempDir() + "/proxyctl.lock"
first := operationlock.New(path)
second := operationlock.New(path)
unlock, err := first.Lock(context.Background())
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Millisecond)
defer cancel()
if _, err := second.Lock(ctx); err == nil {
t.Fatal("second lock acquired while first held")
}
unlock()
unlockSecond, err := second.Lock(context.Background())
if err != nil {
t.Fatal(err)
}
unlockSecond()
}