Skip to content

Commit

Permalink
fix: Increase system's open files limit in integration tests (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
orpheuslummis authored Jul 13, 2022
1 parent eca5324 commit 4bafe70
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/integration/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"path"
"runtime"
"strings"
"syscall"
"testing"

badger "github.com/dgraph-io/badger/v3"
Expand All @@ -44,6 +45,19 @@ const (
documentationDirectoryName = "data_format_changes"
)

// The integration tests open many files. This increases the limits on the number of open files of
// the process to fix this issue. This is done by default in Go 1.19.
func init() {
var lim syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max {
lim.Cur = lim.Max
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)
if err != nil {
log.ErrorE(context.Background(), "error setting rlimit", err)
}
}
}

var (
log = logging.MustNewLogger("defra.tests.integration")
badgerInMemory bool
Expand Down

0 comments on commit 4bafe70

Please sign in to comment.