From 6ba6edb8712eb656431d4f628ec7663877e164c3 Mon Sep 17 00:00:00 2001 From: Aris Tzoumas Date: Wed, 18 Oct 2023 17:23:05 +0300 Subject: [PATCH] chore: change default postgres container shm size to 128MB --- sync/plocker_test.go | 20 ++++++++++++++++++++ testhelper/docker/resource/postgres.go | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) 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)