Skip to content

Commit 1293463

Browse files
committed
Sandbox unit.cfg_errors test
Recently we've encountered a weird test behavior: a test (`unit.upload` from #1266) succeded when run alone, but failed in conjunction with `unit.cfg_errors` test. The reason is in monkeypatching and reloading of lua modules used there. With this patch, all test functions are moved to a simple empty server and run over netbox (remote-control).
1 parent 6a5cebf commit 1293463

File tree

2 files changed

+330
-292
lines changed

2 files changed

+330
-292
lines changed

test/helper.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
require('strict').on()
22

33
local fio = require('fio')
4+
local checks = require('checks')
45
local digest = require('digest')
56
local helpers = table.copy(require('cartridge.test-helpers'))
7+
local utils = require('cartridge.utils')
68

79
local errno = require('errno')
810
local errno_list = getmetatable(errno).__index
@@ -154,4 +156,20 @@ function helpers.random_cookie()
154156
return digest.urandom(6):hex()
155157
end
156158

159+
function helpers.run_remotely(srv, fn)
160+
checks('table', 'function')
161+
utils.assert_upvalues(fn, {})
162+
163+
local ok, ret = srv.net_box:eval([[
164+
local fn = loadstring(...)
165+
return pcall(fn)
166+
]], {string.dump(fn)})
167+
168+
if not ok then
169+
error(ret, 0)
170+
end
171+
172+
return ret
173+
end
174+
157175
return helpers

0 commit comments

Comments
 (0)