Commit a4e480b2 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

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
parent 9b816e89
...@@ -944,7 +944,7 @@ TEST(AsyncSocketTest, ConnectCallbackWrite) { ...@@ -944,7 +944,7 @@ TEST(AsyncSocketTest, ConnectCallbackWrite) {
testConnectOptWrite(100, 200); testConnectOptWrite(100, 200);
// Test using a large buffer in the connect callback, that should block // 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); testConnectOptWrite(100, largeSize);
// Test using a large initial write // Test using a large initial write
...@@ -1013,8 +1013,12 @@ TEST(AsyncSocketTest, WriteTimeout) { ...@@ -1013,8 +1013,12 @@ TEST(AsyncSocketTest, WriteTimeout) {
AsyncSocket::newSocket(&evb, server.getAddress(), 30); AsyncSocket::newSocket(&evb, server.getAddress(), 30);
evb.loop(); // loop until the socket is connected evb.loop(); // loop until the socket is connected
// write() a large chunk of data, with no-one on the other end reading // write() a large chunk of data, with no-one on the other end reading.
size_t writeLength = 8*1024*1024; // 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; uint32_t timeout = 200;
socket->setSendTimeout(timeout); socket->setSendTimeout(timeout);
scoped_array<char> buf(new char[writeLength]); scoped_array<char> buf(new char[writeLength]);
...@@ -1071,7 +1075,7 @@ TEST(AsyncSocketTest, WritePipeError) { ...@@ -1071,7 +1075,7 @@ TEST(AsyncSocketTest, WritePipeError) {
acceptedSocket->close(); acceptedSocket->close();
// write() a large chunk of data // 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]); scoped_array<char> buf(new char[writeLength]);
memset(buf.get(), 'a', writeLength); memset(buf.get(), 'a', writeLength);
WriteCallback wcb; WriteCallback wcb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment