Skip to content
Snippets Groups Projects
Commit 31906195 authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

gh-1094: extract a test case from box/snapshot_daemon.test.lua

parent 10d9df5d
No related branches found
No related tags found
No related merge requests found
env = require('test_run')
---
...
test_run = env.new()
---
...
-- gh-1094: box.snapshot() aborts if the server is out of file descriptors
ffi=require('ffi')
---
...
test_run:cmd("setopt delimiter ';;;'")
---
- true
...
ffi.cdef[[
struct rlimit {unsigned long cur; unsigned long max;};
int getrlimit(int resource, struct rlimit *rlim);
int setrlimit(int resource, const struct rlimit *rlim);
]];;;
---
...
test_run:cmd("setopt delimiter ''");;;
---
- true
...
_ = box.space._schema:insert({'gh1094'})
---
...
r = ffi.new('struct rlimit')
---
...
ffi.C.getrlimit(7, r)
---
- 0
...
orig_limit = r.cur;
---
...
r.cur = 1
---
...
ffi.C.setrlimit(7, r)
---
- 0
...
box.snapshot()
---
- error: can't save snapshot, errno 24 (Too many open files)
...
r.cur = orig_limit
---
...
ffi.C.setrlimit(7, r)
---
- 0
...
box.snapshot()
---
- ok
...
_ = box.space._schema:delete({'gh1094'})
---
...
env = require('test_run')
test_run = env.new()
-- gh-1094: box.snapshot() aborts if the server is out of file descriptors
ffi=require('ffi')
test_run:cmd("setopt delimiter ';;;'")
ffi.cdef[[
struct rlimit {unsigned long cur; unsigned long max;};
int getrlimit(int resource, struct rlimit *rlim);
int setrlimit(int resource, const struct rlimit *rlim);
]];;;
test_run:cmd("setopt delimiter ''");;;
_ = box.space._schema:insert({'gh1094'})
r = ffi.new('struct rlimit')
ffi.C.getrlimit(7, r)
orig_limit = r.cur;
r.cur = 1
ffi.C.setrlimit(7, r)
box.snapshot()
r.cur = orig_limit
ffi.C.setrlimit(7, r)
box.snapshot()
_ = box.space._schema:delete({'gh1094'})
......@@ -132,55 +132,3 @@ daemon.snapshot_count = 20
box.cfg{ snapshot_count = 0 }
---
...
--test for failed snapshot in case of insufficient descriptors
f=require('ffi')
---
...
test_run:cmd("setopt delimiter ';;;'")
---
- true
...
f.cdef[[
struct rlimit {unsigned long cur; unsigned long max;};
int getrlimit(int resource, struct rlimit *rlim);
int setrlimit(int resource, const struct rlimit *rlim);
]];;;
---
...
test_run:cmd("setopt delimiter ''");;;
---
- true
...
r = f.new('struct rlimit')
---
...
f.C.getrlimit(7, r)
---
- 0
...
orig_limit = r.cur;
---
...
r.cur = 1
---
...
f.C.setrlimit(7, r)
---
- 0
...
box.snapshot()
---
- error: can't save snapshot, errno 24 (Too many open files)
...
r.cur = orig_limit
---
...
f.C.setrlimit(7, r)
---
- 0
...
box.snapshot()
---
- ok
...
......@@ -72,32 +72,3 @@ daemon.snapshot_count = 20
-- stop daemon
box.cfg{ snapshot_count = 0 }
--test for failed snapshot in case of insufficient descriptors
f=require('ffi')
test_run:cmd("setopt delimiter ';;;'")
f.cdef[[
struct rlimit {unsigned long cur; unsigned long max;};
int getrlimit(int resource, struct rlimit *rlim);
int setrlimit(int resource, const struct rlimit *rlim);
]];;;
test_run:cmd("setopt delimiter ''");;;
r = f.new('struct rlimit')
f.C.getrlimit(7, r)
orig_limit = r.cur;
r.cur = 1
f.C.setrlimit(7, r)
box.snapshot()
r.cur = orig_limit
f.C.setrlimit(7, r)
box.snapshot()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment