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.
diff --git a/tests/unix/ConnectionFailTest.cc b/tests/unix/ConnectionFailTest.cc
index a05e6a3..11ac384 100644
--- a/tests/unix/ConnectionFailTest.cc
+++ b/tests/unix/ConnectionFailTest.cc
@@ -31,6 +31,10 @@
struct rlimit limit;
ASSERT_EQ(getrlimit(RLIMIT_NOFILE, &limit), 0);
maxFdCount_ = limit.rlim_max;
+ // The previous test leaves the soft fd limit lowered, which could make the HTTP request below fail
+ // to open a socket. Restore it before creating the topic.
+ limit.rlim_cur = limit.rlim_max;
+ ASSERT_EQ(setrlimit(RLIMIT_NOFILE, &limit), 0);
int numPartitions = GetParam();
topic_ = "test-connection-fail-" + std::to_string(numPartitions) + std::to_string(time(nullptr));
if (numPartitions > 0) {