Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] test: fix app/socket sporadic failure
@ 2019-02-28 15:09 Vladimir Davydov
  2019-02-28 15:31 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Davydov @ 2019-02-28 15:09 UTC (permalink / raw)
  To: tarantool-patches

The patch fixes the following test failure:

 | --- app/socket.result	Mon Feb 25 17:32:49 2019
 | +++ app/socket.reject	Mon Feb 25 17:39:51 2019
 | @@ -2827,7 +2827,7 @@
 |  ...
 |  echo_fiber ~= nil
 |  ---
 | -- true
 | +- false
 |  ...
 |  client:write('hello')
 |  ---

This happens, because we don't wait for echo_fiber to start.
Use a channel to make sure it does. Also, increase read/write
timeouts from 0.1 up to 5 seconds - it won't increase the test
runtime, but it will make it more robust.

Closes #4022
---
https://github.com/tarantool/tarantool/issues/4022
https://github.com/tarantool/tarantool/commits/dv/test-fixes

 test/app/socket.result   | 12 +++++++++---
 test/app/socket.test.lua |  9 ++++++---
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/test/app/socket.result b/test/app/socket.result
index 4c92f157..0d029039 100644
--- a/test/app/socket.result
+++ b/test/app/socket.result
@@ -2804,8 +2804,10 @@ test_run:cmd("setopt delimiter ';'")
 - true
 ...
 echo_fiber = nil
+channel = fiber.channel()
 server = socket.tcp_server('localhost', 0, { handler = function(s)
     echo_fiber = fiber.self()
+    channel:put(true)
     while true do
         local b = s:read(1, 0.1)
         if b ~= nil then
@@ -2825,6 +2827,10 @@ addr = server:name()
 client = socket.tcp_connect(addr.host, addr.port)
 ---
 ...
+channel:get()
+---
+- true
+...
 echo_fiber ~= nil
 ---
 - true
@@ -2833,7 +2839,7 @@ client:write('hello')
 ---
 - 5
 ...
-client:read(5, 0.1) == 'hello'
+client:read(5, 5) == 'hello'
 ---
 - true
 ...
@@ -2848,7 +2854,7 @@ client:write('world')
 ---
 - 5
 ...
-client:read(5, 0.1) == 'world'
+client:read(5, 5) == 'world'
 ---
 - true
 ...
@@ -2856,7 +2862,7 @@ client:read(5, 0.1) == 'world'
 fiber.cancel(echo_fiber)
 ---
 ...
-client:read(1, 0.1) == ''
+client:read(1, 5) == ''
 ---
 - true
 ...
diff --git a/test/app/socket.test.lua b/test/app/socket.test.lua
index 462eacf4..dab168f9 100644
--- a/test/app/socket.test.lua
+++ b/test/app/socket.test.lua
@@ -954,8 +954,10 @@ listening_socket:close()
 --gh-3344 connection should not fail is there is a spurious wakeup for io fiber
 test_run:cmd("setopt delimiter ';'")
 echo_fiber = nil
+channel = fiber.channel()
 server = socket.tcp_server('localhost', 0, { handler = function(s)
     echo_fiber = fiber.self()
+    channel:put(true)
     while true do
         local b = s:read(1, 0.1)
         if b ~= nil then
@@ -966,17 +968,18 @@ end, name = 'echoserv'});
 test_run:cmd("setopt delimiter ''");
 addr = server:name()
 client = socket.tcp_connect(addr.host, addr.port)
+channel:get()
 echo_fiber ~= nil
 client:write('hello')
-client:read(5, 0.1) == 'hello'
+client:read(5, 5) == 'hello'
 -- send spurious wakeup
 fiber.wakeup(echo_fiber)
 fiber.sleep(0)
 client:write('world')
-client:read(5, 0.1) == 'world'
+client:read(5, 5) == 'world'
 -- cancel fiber
 fiber.cancel(echo_fiber)
-client:read(1, 0.1) == ''
+client:read(1, 5) == ''
 server:close()
 
 test_run:cmd("clear filter")
-- 
2.11.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-28 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-28 15:09 [PATCH] test: fix app/socket sporadic failure Vladimir Davydov
2019-02-28 15:31 ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox