-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add btests for fd limit-capping behavior at Zeek startup.
- Loading branch information
Showing
6 changed files
with
93 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
100 | ||
100 |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
warning in <...>/init-bare.zeek, line 1: reduced open file descriptor limits (soft/hard 1500000/2000000 -> 1048576/1048576) | ||
1048576 | ||
1048576 |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
1500000 | ||
2000000 |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
1500000 | ||
2000000 |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
100 | ||
150 |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Check the file descriptor limit behavior Zeek applies at startup. | ||
# Zeek's built-in default limit is 1024 * 1024 = 1048576 open fds. | ||
|
||
# @TEST-REQUIRES: ulimit -n -S >limit.soft | ||
# @TEST-REQUIRES: ulimit -n -H >limit.hard | ||
# @TEST-EXEC: unset ZEEK_NOFILE_MAX; LIM_SOFT=$(cat limit.soft) LIM_HARD=$(cat limit.hard) bash %INPUT | ||
# @TEST-EXEC: if [ ! -f skip ]; then TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output; fi | ||
|
||
# @TEST-START-FILE limits.zeek | ||
event zeek_init() | ||
{ | ||
# Report resulting limits to stderr: | ||
system("ulimit -n -S"); | ||
system("ulimit -n -H"); | ||
} | ||
# @TEST-END-FILE | ||
|
||
# @TEST-START-FILE limits.sh | ||
setcaps() { | ||
local soft=$1 | ||
local hard=$2 | ||
|
||
ulimit -S -n $soft || { | ||
echo "Skipping $TEST_NAME, could not set soft fd limit $soft." | ||
touch skip | ||
exit 0 | ||
} | ||
ulimit -H -n $hard || { | ||
echo "Skipping $TEST_NAME, could not set hard fd limit $hard." | ||
touch skip | ||
exit 0 | ||
} | ||
} | ||
# @TEST-END-FILE | ||
|
||
# Apply low limits and no ZEEK_NOFILE_MAX variable. | ||
# The limits should stay unchanged with no warning message. | ||
|
||
. ./limits.sh | ||
setcaps 100 150 | ||
zeek -b limits.zeek 2>output | ||
|
||
# @TEST-START-NEXT | ||
# Establish a low limit via ZEEK_NOFILE_MAX. | ||
# Zeek should apply these values, without a warning message. | ||
|
||
# Verify that one can actually set these values, then revert to defaults. | ||
setcaps 100 100 | ||
setcaps $LIM_SOFT $LIM_HARD | ||
|
||
export ZEEK_NOFILE_MAX=100 | ||
zeek -b limits.zeek 2>output | ||
|
||
# @TEST-START-NEXT | ||
# With high limits and no ZEEK_NOFILE_MAX Zeek should cap and produce a | ||
# warning message. | ||
|
||
. ./limits.sh | ||
setcaps 1500000 2000000 | ||
zeek -b limits.zeek 2>output | ||
|
||
# @TEST-START-NEXT | ||
# With high limits and the capping mechanism disabled, the values should remain intact. | ||
|
||
. ./limits.sh | ||
setcaps 1500000 2000000 | ||
export ZEEK_NOFILE_MAX= | ||
zeek -b limits.zeek 2>output | ||
|
||
# @TEST-START-NEXT | ||
# With high limits and the capping mechanism disabled, the values should remain intact. | ||
|
||
. ./limits.sh | ||
setcaps 1500000 2000000 | ||
export ZEEK_NOFILE_MAX=0 | ||
zeek -b limits.zeek 2>output | ||
|