From eb0cc50ca2773559bb9d25147a786a6786658b78 Mon Sep 17 00:00:00 2001
From: Serge Petrenko <sergepetrenko@tarantool.org>
Date: Tue, 9 Jul 2019 12:16:33 +0300
Subject: [PATCH] test: fix net.box occasional failure. Again

The test regarding logging corrupted rows failed occasionally with
```
[016]  test_run:grep_log('default', 'Got a corrupted row.*')
[016]  ---
[016] -- 'Got a corrupted row:'
[016] +- null
[016]  ...
```
The logs then had
```
[010] 2019-07-06 19:36:16.857 [13046] iproto sio.c:261 !> SystemError writev(1),
called on fd 23, aka unix/:(socket), peer of unix/:(socket): Broken pipe
```
instead of the expected message.

This happened, because we closed a socket before tarantool could write a
greeting to the client, the connection was then closed, and execution
never got to processing the malformed request and thus printing the
desired message to the log.

To fix this, actually read the greeting prior to writing new data and
closing the socket.

Follow-up #4273
---
 test/box/net.box.result   | 4 ++++
 test/box/net.box.test.lua | 1 +
 2 files changed, 5 insertions(+)

diff --git a/test/box/net.box.result b/test/box/net.box.result
index ca976ab214..a18546d12c 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -3855,6 +3855,10 @@ box.cfg{log_level=6}
 sock = socket.tcp_connect(LISTEN.host, LISTEN.service)
 ---
 ...
+sock:read(9)
+---
+- Tarantool
+...
 -- we need to have a packet with correctly encoded length,
 -- so that it bypasses iproto length check, but cannot be
 -- decoded in xrow_header_decode
diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua
index fde4962831..07558a0dc4 100644
--- a/test/box/net.box.test.lua
+++ b/test/box/net.box.test.lua
@@ -1551,6 +1551,7 @@ box.cfg{readahead = readahead}
 log_level = box.cfg.log_level
 box.cfg{log_level=6}
 sock = socket.tcp_connect(LISTEN.host, LISTEN.service)
+sock:read(9)
 -- we need to have a packet with correctly encoded length,
 -- so that it bypasses iproto length check, but cannot be
 -- decoded in xrow_header_decode
-- 
GitLab