increase writeLen for tests that want to trigger buffering
authorNathan Bronson <ngbronson@fb.com>
Wed, 7 Dec 2016 19:20:21 +0000 (11:20 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Wed, 7 Dec 2016 19:23:32 +0000 (11:23 -0800)
Summary:
Freshly opened TCP sockets can have a send buffer size bigger
than wmem_default, because connection parameters are cached in the
route cache.  Some of the async socket tests assumed that writing 8M of
data was enough to guarantee blocking behavior, but since wmem_max is
20M on our systems the resulting tests are flaky.

Reviewed By: marcinpe

Differential Revision: D4292201

fbshipit-source-id: ba5d606d080330e455eee2b17bcae6cf546bf981

folly/io/async/test/AsyncSocketTest2.cpp

index c42406a8a9e6d3a29dc7cdfb7ababf33ca4a089e..d4e07497716ebf617b602a84e714f91aa14a888b 100644 (file)
@@ -944,7 +944,7 @@ TEST(AsyncSocketTest, ConnectCallbackWrite) {
   testConnectOptWrite(100, 200);
 
   // Test using a large buffer in the connect callback, that should block
-  const size_t largeSize = 8*1024*1024;
+  const size_t largeSize = 32 * 1024 * 1024;
   testConnectOptWrite(100, largeSize);
 
   // Test using a large initial write
@@ -1013,8 +1013,12 @@ TEST(AsyncSocketTest, WriteTimeout) {
     AsyncSocket::newSocket(&evb, server.getAddress(), 30);
   evb.loop(); // loop until the socket is connected
 
-  // write() a large chunk of data, with no-one on the other end reading
-  size_t writeLength = 8*1024*1024;
+  // write() a large chunk of data, with no-one on the other end reading.
+  // Tricky: the kernel caches the connection metrics for recently-used
+  // routes (see tcp_no_metrics_save) so a freshly opened connection can
+  // have a send buffer size bigger than wmem_default.  This makes the test
+  // flaky on contbuild if writeLength is < wmem_max (20M on our systems).
+  size_t writeLength = 32 * 1024 * 1024;
   uint32_t timeout = 200;
   socket->setSendTimeout(timeout);
   scoped_array<char> buf(new char[writeLength]);
@@ -1071,7 +1075,7 @@ TEST(AsyncSocketTest, WritePipeError) {
   acceptedSocket->close();
 
   // write() a large chunk of data
-  size_t writeLength = 8*1024*1024;
+  size_t writeLength = 32 * 1024 * 1024;
   scoped_array<char> buf(new char[writeLength]);
   memset(buf.get(), 'a', writeLength);
   WriteCallback wcb;