From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Alexander Turenko Subject: [PATCH] test: fix hardcoded port in box/net.box.test.lua Date: Sun, 2 Dec 2018 19:38:02 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: Vladimir Davydov Cc: Alexander Turenko , tarantool-patches@freelists.org List-ID: It allows to run the test many times in parallel to investigate flaky test failures and decreases probability that the test fails, because this port was already used by, say, some other test. --- no issue https://github.com/tarantool/tarantool/tree/Totktonada/fix-hardcoded-port-in-net.box.test.lua The patch was created to reproduce the issue #3851. https://github.com/tarantool/tarantool/issues/3851 The branch is based on top of 2.1. I think it also good to cherry-pick test fixes to 1.10, but it is up to maintainers. test/box/net.box.result | 7 ++++--- test/box/net.box.test.lua | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/box/net.box.result b/test/box/net.box.result index 4f6979d5b..faae5e9a5 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -1880,7 +1880,7 @@ greeting = socket = require('socket'); --- ... -srv = socket.tcp_server('localhost', 3392, { +srv = socket.tcp_server('localhost', 0, { handler = function(fd) local fiber = require('fiber') fiber.sleep(0.1) @@ -1890,7 +1890,8 @@ srv = socket.tcp_server('localhost', 3392, { --- ... -- we must get timeout -nb = net.new('localhost:3392', { +port = srv:name().port +nb = net.new('localhost:' .. port, { wait_connected = true, console = true, connect_timeout = 0.01 }); @@ -1904,7 +1905,7 @@ nb:close(); --- ... -- we must get peer closed -nb = net.new('localhost:3392', { +nb = net.new('localhost:' .. port, { wait_connected = true, console = true, connect_timeout = 0.2 }); diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua index 5201e01a6..dd6c2fd94 100644 --- a/test/box/net.box.test.lua +++ b/test/box/net.box.test.lua @@ -754,22 +754,23 @@ greeting = "Tarantool 1.7.3 (Lua console)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" .. "type 'help' for interactive help~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; socket = require('socket'); -srv = socket.tcp_server('localhost', 3392, { +srv = socket.tcp_server('localhost', 0, { handler = function(fd) local fiber = require('fiber') fiber.sleep(0.1) fd:write(greeting) end }); +port = srv:name().port -- we must get timeout -nb = net.new('localhost:3392', { +nb = net.new('localhost:' .. port, { wait_connected = true, console = true, connect_timeout = 0.01 }); nb.error:find('timed out') ~= nil; nb:close(); -- we must get peer closed -nb = net.new('localhost:3392', { +nb = net.new('localhost:' .. port, { wait_connected = true, console = true, connect_timeout = 0.2 }); -- 2.19.2