Skip to content

Commit

Permalink
chore: configurable shared memory size for postgres container (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum authored Sep 11, 2023
1 parent 1f9dde1 commit ff2dc63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion testhelper/docker/resource/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (

_ "github.com/lib/pq"
"github.com/ory/dockertest/v3"
dc "github.com/ory/dockertest/v3/docker"

"github.com/rudderlabs/rudder-go-kit/bytesize"
"github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/postgres"
)

Expand All @@ -29,7 +31,8 @@ type PostgresResource struct {

func SetupPostgres(pool *dockertest.Pool, d cleaner, opts ...func(*postgres.Config)) (*PostgresResource, error) {
c := &postgres.Config{
Tag: "15-alpine",
Tag: "15-alpine",
ShmSize: 512 * bytesize.MB,
}
for _, opt := range opts {
opt(c)
Expand All @@ -49,6 +52,8 @@ func SetupPostgres(pool *dockertest.Pool, d cleaner, opts ...func(*postgres.Conf
"POSTGRES_USER=" + postgresDefaultUser,
},
Cmd: cmd,
}, func(hc *dc.HostConfig) {
hc.ShmSize = c.ShmSize
})
if err != nil {
return nil, err
Expand Down
7 changes: 7 additions & 0 deletions testhelper/docker/resource/postgres/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ func WithOptions(options ...string) Opt {
}
}

func WithShmSize(shmSize int64) Opt {
return func(c *Config) {
c.ShmSize = shmSize
}
}

type Config struct {
Tag string
Options []string
ShmSize int64
}

0 comments on commit ff2dc63

Please sign in to comment.