From: Nathan Bronson Date: Wed, 7 Dec 2016 19:20:21 +0000 (-0800) Subject: increase writeLen for tests that want to trigger buffering X-Git-Tag: v2016.12.12.00~15 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a4e480b2397b3c62d036ad75e5fe42a8343ddaed;p=folly.git increase writeLen for tests that want to trigger buffering 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 --- diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index c42406a8..d4e07497 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -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 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 buf(new char[writeLength]); memset(buf.get(), 'a', writeLength); WriteCallback wcb;