fix: build plugins/common on windows
On windows, `LockDirectory` now takes a `LockFileEx` lock on a `.dokku.lock` file inside the directory, as `flock` is unavailable there.
This commit is contained in:
5 files changed
+91
-20
No files matched your search
@@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -269,6 +270,27 @@ func TestPropertyLockSerializesReadModifyWrite(t *testing.T) {
|
||||
Expect(PropertyGet(propertyTestPlugin, propertyTestApp, "counter")).To(Equal("50"))
|
||||
}
|
||||
|
||||
func TestLockDirectorySerializesConcurrentCallers(t *testing.T) {
|
||||
RegisterTestingT(t)
|
||||
t.Setenv(LockedDirectoriesEnvVar, "")
|
||||
|
||||
dir := t.TempDir()
|
||||
var active atomic.Int32
|
||||
var overlapped atomic.Bool
|
||||
Expect(runConcurrently(20, func(i int) error {
|
||||
return LockDirectory(dir, func() error {
|
||||
if active.Add(1) > 1 {
|
||||
overlapped.Store(true)
|
||||
}
|
||||
defer active.Add(-1)
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
return nil
|
||||
})
|
||||
})).To(Succeed())
|
||||
|
||||
Expect(overlapped.Load()).To(BeFalse())
|
||||
}
|
||||
|
||||
func TestLockDirectorySkipsDirectoriesHeldByParent(t *testing.T) {
|
||||
setupPropertyMapTest(t)
|
||||
|
||||
|
||||
Reference in new issue
Block a user