Skip to content

Commit f71d7e9

Browse files
authored
Fix flaky ConnectionFailTest: restore fd limit in SetUp (#612)
ConnectionFailTest lowers the process soft fd limit (RLIMIT_NOFILE) in a loop and never restores it, so a test leaves the limit as low as ~8 for the next one. The next test's SetUp() then makes an HTTP request to create the partitioned topic, and curl can intermittently fail to open a socket (res: -1) when the previous client's async connection teardown still holds file descriptors. Restore the soft limit to the hard limit in SetUp() before making the HTTP request.
1 parent 0f13c1b commit f71d7e9

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎tests/unix/ConnectionFailTest.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class ConnectionFailTest : public ::testing::TestWithParam<int> {
3131
struct rlimit limit;
3232
ASSERT_EQ(getrlimit(RLIMIT_NOFILE, &limit), 0);
3333
maxFdCount_ = limit.rlim_max;
34+
// The previous test leaves the soft fd limit lowered, which could make the HTTP request below fail
35+
// to open a socket. Restore it before creating the topic.
36+
limit.rlim_cur = limit.rlim_max;
37+
ASSERT_EQ(setrlimit(RLIMIT_NOFILE, &limit), 0);
3438
int numPartitions = GetParam();
3539
topic_ = "test-connection-fail-" + std::to_string(numPartitions) + std::to_string(time(nullptr));
3640
if (numPartitions > 0) {

0 commit comments

Comments
 (0)