Skip to content

Commit

Permalink
kasey's review
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas committed May 7, 2022
1 parent a1e592f commit 60c4b1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
1 change: 1 addition & 0 deletions runtime/fdlimits/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ go_test(
deps = [
":go_default_library",
"//testing/assert:go_default_library",
"@com_github_ethereum_go_ethereum//common/fdlimit:go_default_library",
],
)
23 changes: 7 additions & 16 deletions runtime/fdlimits/fdlimits_test.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
package fdlimits_test

import (
"syscall"
"testing"

gethLimit "github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/prysmaticlabs/prysm/runtime/fdlimits"
"github.com/prysmaticlabs/prysm/testing/assert"
)

func TestSetMaxFdLimits(t *testing.T) {
var limit syscall.Rlimit
assert.NoError(t, syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit))
wantedMax := limit.Max
assert.NoError(t, fdlimits.SetMaxFdLimits())

// Set it to a low value.
limit.Cur = 2000
assert.NoError(t, syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit))
limit = syscall.Rlimit{}
curr, err := gethLimit.Current()
assert.NoError(t, err)

// Double check it works
assert.NoError(t, syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit))
assert.Equal(t, uint64(2000), limit.Cur)
max, err := gethLimit.Maximum()
assert.NoError(t, err)

assert.NoError(t, fdlimits.SetMaxFdLimits())
// Retrieve fd limit again.
assert.NoError(t, syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit))
assert.Equal(t, max, curr, "current and maximum file descriptor limits do not match up.")

assert.Equal(t, wantedMax, limit.Cur)
assert.NotEqual(t, 2000, limit.Cur)
}

0 comments on commit 60c4b1c

Please sign in to comment.