[PATCH] test: fix net.box occasional failure.

Serge Petrenko sergepetrenko at tarantool.org
Fri Jun 14 12:48:25 MSK 2019


The test used to fail occasionally with a following error:

```
[001] box/net.box.test.lua                                            [ fail ]
[001]
[001] Test failed! Result content mismatch:
[001] —- box/net.box.result  Thu Jun 13 06:16:34 2019
[001] +++ box/net.box.reject  Fri Jun 14 04:50:55 2019
[001] @@ -3774,23 +3774,23 @@
[001]  ...
[001]  test_run:grep_log('default', 'Got a corrupted row.*')
[001]  —-
[001] — 'Got a corrupted row:'
[001] +- null
[001]  ...
[001]  test_run:grep_log('default', '00000000:.*')
[001]  —-
[001] — '00000000: A3 02 D6 5A E4 D9 E7 68 A1 53 8D 53 60 5F 20 3F '
[001] +- null
[001]  ...
[001]  test_run:grep_log('default', '00000010:.*')
[001]  —-
[001] — '00000010: D8 E2 D6 E2 A3 02 D6 5A E4 D9 E7 68 A1 53 8D 53 '
[001] +- null
[001]  ...
[001]  test_run:grep_log('default', '00000020:.*')
[001]  —-
[001] — '00000020: 60 5F 20 3F D8 E2 D6 E2 A3 02 D6 5A E4 D9 E7 68 '
[001] +- null
[001]  ...
[001]  test_run:grep_log('default', '00000030:.*')
[001]  —-
[001] — '00000030: A1 53 8D 53 60 5F 20 3F D8 E2 D6 E2 '
[001] +- null
[001]  ...
[001]  test_run:grep_log('default', '00000040:.*')
[001]  —-
```

This happened because we used `grep_log` right after `socket:write`,
which should cause the expected log messages. Change to `wait_log`.

Follow-up #4273
---
https://github.com/tarantool/tarantool/issues/4273
https://github.com/tarantool/tarantool/tree/sp/netbox-test-fix

 test/box/net.box.result   | 11 ++++++-----
 test/box/net.box.test.lua | 11 ++++++-----
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/test/box/net.box.result b/test/box/net.box.result
index 474297af3..365276237 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -3772,26 +3772,27 @@ sock:close()
 ---
 - true
 ...
-test_run:grep_log('default', 'Got a corrupted row.*')
+test_run:wait_log('default', 'Got a corrupted row.*', nil, 10)
 ---
 - 'Got a corrupted row:'
 ...
-test_run:grep_log('default', '00000000:.*')
+test_run:wait_log('default', '00000000:.*', nil, 10)
 ---
 - '00000000: A3 02 D6 5A E4 D9 E7 68 A1 53 8D 53 60 5F 20 3F '
 ...
-test_run:grep_log('default', '00000010:.*')
+test_run:wait_log('default', '00000010:.*', nil, 10)
 ---
 - '00000010: D8 E2 D6 E2 A3 02 D6 5A E4 D9 E7 68 A1 53 8D 53 '
 ...
-test_run:grep_log('default', '00000020:.*')
+test_run:wait_log('default', '00000020:.*', nil, 10)
 ---
 - '00000020: 60 5F 20 3F D8 E2 D6 E2 A3 02 D6 5A E4 D9 E7 68 '
 ...
-test_run:grep_log('default', '00000030:.*')
+test_run:wait_log('default', '00000030:.*', nil, 10)
 ---
 - '00000030: A1 53 8D 53 60 5F 20 3F D8 E2 D6 E2 '
 ...
+-- we expect nothing below, so don't wait
 test_run:grep_log('default', '00000040:.*')
 ---
 - null
diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua
index bea43002d..96b15c778 100644
--- a/test/box/net.box.test.lua
+++ b/test/box/net.box.test.lua
@@ -1531,11 +1531,12 @@ data = string.fromhex('3C'..string.rep(require('digest').sha1_hex('bcde'), 3))
 sock:write(data)
 sock:close()
 
-test_run:grep_log('default', 'Got a corrupted row.*')
-test_run:grep_log('default', '00000000:.*')
-test_run:grep_log('default', '00000010:.*')
-test_run:grep_log('default', '00000020:.*')
-test_run:grep_log('default', '00000030:.*')
+test_run:wait_log('default', 'Got a corrupted row.*', nil, 10)
+test_run:wait_log('default', '00000000:.*', nil, 10)
+test_run:wait_log('default', '00000010:.*', nil, 10)
+test_run:wait_log('default', '00000020:.*', nil, 10)
+test_run:wait_log('default', '00000030:.*', nil, 10)
+-- we expect nothing below, so don't wait
 test_run:grep_log('default', '00000040:.*')
 
 box.cfg{log_level=log_level}
-- 
2.20.1 (Apple Git-117)




More information about the Tarantool-patches mailing list