Skip to content

Commit

Permalink
test: use socket connect in teardown
Browse files Browse the repository at this point in the history
Needed for #137

Reviewed-by: Alexander Turenko <alexander.turenko@tarantool.org>
  • Loading branch information
ligurio authored and Totktonada committed Jul 9, 2022
1 parent 2345949 commit ac9161e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/helpers.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local fio = require('fio')
local http_server = require('http.server')
local http_client = require('http.client')
local socket = require('socket')

local helpers = table.copy(require('luatest').helpers)

Expand Down Expand Up @@ -87,10 +87,17 @@ helpers.find_msg_in_log_queue = function(msg, strict)
end

helpers.teardown = function(httpd)
local host = httpd.host
local port = httpd.port
httpd:stop()
helpers.retrying({}, function()
local r = http_client.request('GET', helpers.base_uri)
return r == nil
helpers.retrying({
timeout = 1,
}, function()
local s, _ = socket.tcp_connect(host, port)
if s ~= nil then
s:close()
end
assert(s == nil, 'http server is stopped')
end)
end

Expand Down

0 comments on commit ac9161e

Please sign in to comment.