diff --git a/sync/plocker_test.go b/sync/plocker_test.go index 4c04adba..38ed6952 100644 --- a/sync/plocker_test.go +++ b/sync/plocker_test.go @@ -38,4 +38,24 @@ func TestPartitionLocker(t *testing.T) { wg.Wait() require.Equalf(t, goroutines, counter, "it should have incremented the counter %d times", goroutines) }) + + t.Run("Try to lock the same partition twice", func(t *testing.T) { + + type l struct { + locker sync.PartitionLocker + } + var s l + s.locker = *sync.NewPartitionLocker() + var locks int + const id = "id" + s.locker.Lock(id) + go func() { + s.locker.Lock(id) + locks = locks + 1 + s.locker.Unlock(id) + }() + require.Never(t, func() bool { return locks == 1 }, 100*time.Millisecond, 1*time.Millisecond) + s.locker.Unlock(id) + require.Eventually(t, func() bool { return locks == 1 }, 100*time.Millisecond, 1*time.Millisecond) + }) } diff --git a/testhelper/docker/resource/postgres.go b/testhelper/docker/resource/postgres.go index 972433c7..048c75b7 100644 --- a/testhelper/docker/resource/postgres.go +++ b/testhelper/docker/resource/postgres.go @@ -32,7 +32,7 @@ type PostgresResource struct { func SetupPostgres(pool *dockertest.Pool, d cleaner, opts ...func(*postgres.Config)) (*PostgresResource, error) { c := &postgres.Config{ Tag: "15-alpine", - ShmSize: 512 * bytesize.MB, + ShmSize: 128 * bytesize.MB, } for _, opt := range opts { opt(c)