-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
8 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |