diff --git a/src/box/request.cc b/src/box/request.cc index 1ccfc9d4a8811121e2f45ceb27aabf27acdf710b..dd8d7eea598db4f4e4313ddd50f574124adbebad 100644 --- a/src/box/request.cc +++ b/src/box/request.cc @@ -152,6 +152,7 @@ execute_select(struct request *request, struct port *port) struct tuple *tuple; while ((tuple = it->next(it)) != NULL) { + TupleGuard tuple_gc(tuple); if (offset > 0) { offset--; continue; diff --git a/src/box/sophia_engine.cc b/src/box/sophia_engine.cc index f65f50ade8fb95a1c144c0b40bbdffd5e7c8a9b0..dbbff9fd8318d85eb9019a73c22252ff622989e8 100644 --- a/src/box/sophia_engine.cc +++ b/src/box/sophia_engine.cc @@ -176,41 +176,26 @@ SophiaEngine::createIndex(struct key_def *key_def) } } -static inline int -drop_repository(char *path) -{ - DIR *dir = opendir(path); - if (dir == NULL) - return -1; - char file[1024]; - struct dirent *de; - while ((de = readdir(dir))) { - if (de->d_name[0] == '.') - continue; - snprintf(file, sizeof(file), "%s/%s", path, de->d_name); - int rc = unlink(file); - if (rc == -1) { - closedir(dir); - return -1; - } - } - closedir(dir); - return rmdir(path); -} - void SophiaEngine::dropIndex(Index *index) { SophiaIndex *i = (SophiaIndex*)index; - int rc = sp_destroy(i->db); + /* schedule asynchronous drop */ + int rc = sp_drop(i->db); + if (rc == -1) + sophia_raise(env); + /* unref db object */ + rc = sp_destroy(i->db); + if (rc == -1) + sophia_raise(env); + /* maybe start asynchronous database + * shutdown: last snapshot might hold a + * db pointer. */ + rc = sp_destroy(i->db); if (rc == -1) sophia_raise(env); i->db = NULL; i->env = NULL; - char path[PATH_MAX]; - snprintf(path, sizeof(path), "%s/%" PRIu32, - cfg_gets("sophia_dir"), index->key_def->space_id); - drop_repository(path); } void @@ -279,7 +264,8 @@ SophiaEngine::commit(struct txn *txn) rlist_foreach_entry(stmt, &txn->stmts, next) { if (! stmt->new_tuple) continue; - assert(stmt->new_tuple->refs >= 2); + assert(stmt->new_tuple->refs >= 1 && + stmt->new_tuple->refs < UINT8_MAX); tuple_unref(stmt->new_tuple); } auto scoped_guard = make_scoped_guard([=] { @@ -303,7 +289,7 @@ SophiaEngine::rollback(struct txn *txn) { if (txn->engine_tx == NULL) return; - sp_rollback(txn->engine_tx); + sp_destroy(txn->engine_tx); txn->engine_tx = NULL; } @@ -436,3 +422,11 @@ SophiaEngine::abort_checkpoint() m_checkpoint_lsn = -1; } } + +int sophia_schedule(void) +{ + SophiaEngine *engine = (SophiaEngine *)engine_find("sophia"); + assert(engine->env != NULL); + void *c = sp_ctl(engine->env); + return sp_set(c, "scheduler.run"); +} diff --git a/src/box/sophia_engine.h b/src/box/sophia_engine.h index 33db324e68263c5c85e8ab4ec02ff043ba986aba..ca037d4e7a94c0389fbd51367343baaa63d97e94 100644 --- a/src/box/sophia_engine.h +++ b/src/box/sophia_engine.h @@ -56,4 +56,8 @@ struct SophiaEngine: public Engine { void sophia_info(void (*)(const char*, const char*, void*), void*); void sophia_raise(void*); +extern "C" { +int sophia_schedule(void); +} + #endif /* TARANTOOL_BOX_SOPHIA_ENGINE_H_INCLUDED */ diff --git a/src/box/sophia_index.cc b/src/box/sophia_index.cc index 6d5ae29ae3ef9761921a43c48f64f273f842525e..aec713247ae935e6956ea62bbb163174142f061d 100644 --- a/src/box/sophia_index.cc +++ b/src/box/sophia_index.cc @@ -214,11 +214,8 @@ SophiaIndex::random(uint32_t rnd) const struct space *space = space_cache_find(key_def->space_id); int valuesize; void *value = sp_get(o, "value", &valuesize); - struct tuple *ret = - tuple_new(space->format, (char*)value, - (char*)value + valuesize); - tuple_ref(ret); - return ret; + return tuple_new(space->format, (char*)value, + (char*)value + valuesize); } size_t @@ -376,10 +373,7 @@ sophia_iterator_next(struct iterator *ptr) return NULL; int valuesize = 0; const char *value = (const char*)sp_get(o, "value", &valuesize); - struct tuple *ret = - tuple_new(it->space->format, value, value + valuesize); - tuple_ref(ret); - return ret; + return tuple_new(it->space->format, value, value + valuesize); } struct tuple * @@ -394,12 +388,8 @@ sophia_iterator_eq(struct iterator *ptr) ptr->next = sophia_iterator_last; struct sophia_iterator *it = (struct sophia_iterator *) ptr; assert(it->cursor == NULL); - struct tuple *tuple = - sophia_index_get(it->env, it->db, it->tx, it->key, it->keysize, - it->space->format); - if (tuple) - tuple_ref(tuple); - return tuple; + return sophia_index_get(it->env, it->db, it->tx, it->key, it->keysize, + it->space->format); } struct iterator * diff --git a/src/ffisyms.cc b/src/ffisyms.cc index 8b43d22906c70e9f102f73048ddf6c7a652a77ee..e7dafaf0056eef6e83101b94257385dd6a56eb78 100644 --- a/src/ffisyms.cc +++ b/src/ffisyms.cc @@ -6,6 +6,7 @@ #include <box/lua/index.h> #include <box/lua/tuple.h> #include <box/lua/call.h> +#include <box/sophia_engine.h> #include <lua/init.h> #include <tarantool.h> #include "lua/bsdsocket.h" @@ -60,5 +61,6 @@ void *ffi_symbols[] = { (void *) guava, (void *) random_bytes, (void *) fiber_time, - (void *) fiber_time64 + (void *) fiber_time64, + (void *) sophia_schedule }; diff --git a/test/sophia/box.lua b/test/sophia/box.lua index 67e463e7aca23ad965a50c35343cfccc60518e35..c588ae9646ce93aa0a922241ad4340fde510c65e 100644 --- a/test/sophia/box.lua +++ b/test/sophia/box.lua @@ -1,47 +1,28 @@ #!/usr/bin/env tarantool -os = require('os') -function sophia_printdir() - f = io.popen("ls -1 sophia_test") - ls = f:read("*all") - unused = f:close() - return ls -end - -function sophia_mkdir(dir) - os.execute("mkdir sophia_test") -end - -function sophia_rmdir(dir) - os.execute("rm -rf sophia_test") -end +require('suite') -function file_exists(name) - local f = io.open(name,"r") - if f ~= nil then - io.close(f) - return true - else - return false - end -end - -if not file_exists("lock") then +if not file_exists('lock') then sophia_rmdir() sophia_mkdir() end local sophia = { - threads = 3 -- test case + threads = 0 } +if file_exists('mt') then + sophia.threads = 3 +end + box.cfg { - listen = os.getenv("LISTEN"), - slab_alloc_arena = 0.1, - pid_file = "tarantool.pid", - rows_per_wal = 50, - sophia_dir = "./sophia_test", - sophia = sophia + listen = os.getenv("LISTEN"), + slab_alloc_arena = 0.1, + pid_file = "tarantool.pid", + rows_per_wal = 50, + sophia_dir = "./sophia_test", + sophia = sophia, + custom_proc_title = "default" } require('console').listen(os.getenv('ADMIN')) diff --git a/test/sophia/crud.result b/test/sophia/crud.result index f96bcff12fb39f99356a4c5edba7b3a8518d6481..4b03e0070347609610b0d6d31328754509f52f51 100644 --- a/test/sophia/crud.result +++ b/test/sophia/crud.result @@ -1,10 +1,14 @@ -- insert -space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) --- ... +sophia_dir()[1] +--- +- 1 +... for key = 1, 132 do space:insert({key}) end --- ... @@ -1162,14 +1166,14 @@ index:select(7, {iterator = box.index.LT}) - [2] - [1] ... --- random -dofile('index_random_test.lua') +space:drop() --- ... -index_random_test(space, 'primary') +sophia_schedule() --- -- true +- 1 ... -space:drop() +sophia_dir()[1] --- +- 0 ... diff --git a/test/sophia/crud.test.lua b/test/sophia/crud.test.lua index 1bc09b18c2b72d8b4f223ca53eb4388fabe20d16..70df6ba13d2e1592be4183e1114f81490d4db97b 100644 --- a/test/sophia/crud.test.lua +++ b/test/sophia/crud.test.lua @@ -1,8 +1,9 @@ -- insert -space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) +sophia_dir()[1] for key = 1, 132 do space:insert({key}) end t = {} for key = 1, 132 do table.insert(t, space:get({key})) end @@ -44,9 +45,6 @@ index:select(7, {iterator = box.index.LE}) index:select({}, {iterator = box.index.LT}) index:select(7, {iterator = box.index.LT}) --- random - -dofile('index_random_test.lua') -index_random_test(space, 'primary') - space:drop() +sophia_schedule() +sophia_dir()[1] diff --git a/test/sophia/dml.result b/test/sophia/dml.result index 11d1243259b04757a457e948f53116a65212647b..946b6e6b8b5f2b2c034dfe540525aba138985f14 100644 --- a/test/sophia/dml.result +++ b/test/sophia/dml.result @@ -1,67 +1,74 @@ -- space create/drop -space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... -sophia_printdir() +sophia_dir()[1] --- -- +- 0 ... space:drop() --- ... -sophia_printdir() +sophia_schedule() --- -- +- 0 +... +sophia_dir()[1] +--- +- 0 ... -- index create/drop -space = box.schema.create_space('test', { id = 101, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary') --- ... -sophia_printdir() +sophia_dir()[1] --- -- '101 - -' +- 1 ... space:drop() --- ... -sophia_printdir() +sophia_schedule() --- -- +- 1 +... +sophia_dir()[1] +--- +- 0 ... -- index create/drop alter -space = box.schema.create_space('test', { id = 102, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary') --- ... -sophia_printdir() +sophia_dir()[1] --- -- '102 - -' +- 1 ... _index = box.space[box.schema.INDEX_ID] --- ... _index:delete{102, 0} --- -- [102, 0, 'primary', 'tree', 1, 1, 0, 'num'] ... -sophia_printdir() +space:drop() --- -- ... -space:drop() +sophia_schedule() +--- +- 1 +... +sophia_dir()[1] --- +- 0 ... -- index create/drop tree string -space = box.schema.create_space('test', { id = 103, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}}) @@ -71,17 +78,19 @@ space:insert({'test'}) --- - ['test'] ... -sophia_printdir() +space:drop() --- -- '103 - -' ... -space:drop() +sophia_schedule() +--- +- 1 +... +sophia_dir()[1] --- +- 0 ... -- index create/drop tree num -space = box.schema.create_space('test', { id = 104, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary', {type = 'tree', parts = {1, 'num'}}) @@ -91,17 +100,19 @@ space:insert({13}) --- - [13] ... -sophia_printdir() +space:drop() --- -- '104 - -' ... -space:drop() +sophia_schedule() --- +- 1 +... +sophia_dir()[1] +--- +- 0 ... -- index create hash -space = box.schema.create_space('test', { id = 105, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary', {type = 'hash'}) @@ -111,8 +122,16 @@ index = space:create_index('primary', {type = 'hash'}) space:drop() --- ... +sophia_schedule() +--- +- 0 +... +sophia_dir()[1] +--- +- 0 +... -- secondary index create -space = box.schema.create_space('test', { id = 106, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index1 = space:create_index('primary') @@ -126,12 +145,16 @@ index2 = space:create_index('secondary') space:drop() --- ... -sophia_printdir() +sophia_schedule() +--- +- 1 +... +sophia_dir()[1] --- -- +- 0 ... -- index size -space = box.schema.create_space('test', { id = 107, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary') @@ -163,3 +186,7 @@ primary:len() space:drop() --- ... +sophia_schedule() +--- +- 1 +... diff --git a/test/sophia/dml.test.lua b/test/sophia/dml.test.lua index 6f5531674d61d1676627f0e0fac990a50e58ea6e..871ea897abae8fa0812e99f9c502489d99018460 100644 --- a/test/sophia/dml.test.lua +++ b/test/sophia/dml.test.lua @@ -1,62 +1,70 @@ -- space create/drop -space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) -sophia_printdir() +space = box.schema.create_space('test', { engine = 'sophia' }) +sophia_dir()[1] space:drop() -sophia_printdir() +sophia_schedule() +sophia_dir()[1] -- index create/drop -space = box.schema.create_space('test', { id = 101, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary') -sophia_printdir() +sophia_dir()[1] space:drop() -sophia_printdir() +sophia_schedule() +sophia_dir()[1] -- index create/drop alter -space = box.schema.create_space('test', { id = 102, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary') -sophia_printdir() +sophia_dir()[1] _index = box.space[box.schema.INDEX_ID] _index:delete{102, 0} -sophia_printdir() space:drop() +sophia_schedule() +sophia_dir()[1] -- index create/drop tree string -space = box.schema.create_space('test', { id = 103, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}}) space:insert({'test'}) -sophia_printdir() space:drop() +sophia_schedule() +sophia_dir()[1] -- index create/drop tree num -space = box.schema.create_space('test', { id = 104, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary', {type = 'tree', parts = {1, 'num'}}) space:insert({13}) -sophia_printdir() space:drop() +sophia_schedule() +sophia_dir()[1] -- index create hash -space = box.schema.create_space('test', { id = 105, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary', {type = 'hash'}) space:drop() +sophia_schedule() +sophia_dir()[1] -- secondary index create -space = box.schema.create_space('test', { id = 106, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) index1 = space:create_index('primary') index2 = space:create_index('secondary') space:drop() -sophia_printdir() +sophia_schedule() +sophia_dir()[1] -- index size -space = box.schema.create_space('test', { id = 107, engine = 'sophia' }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary') primary = space.index[0] primary:len() @@ -65,3 +73,4 @@ space:insert({14}) space:insert({15}) primary:len() space:drop() +sophia_schedule() diff --git a/test/sophia/gh.result b/test/sophia/gh.result index fade3a3a2c6787d0ae7ae7bfc255a3d1adbeae47..3444c17358df09e6b98481bc039408a12cb4de60 100644 --- a/test/sophia/gh.result +++ b/test/sophia/gh.result @@ -1,5 +1,5 @@ -- gh-283: Sophia: hang after three creates and drops -s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +s = box.schema.create_space('space0', {engine='sophia'}) --- ... i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) @@ -12,7 +12,11 @@ s:insert{'a', 'b', 'c'} s:drop() --- ... -s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +sophia_schedule() +--- +- 1 +... +s = box.schema.create_space('space0', {engine='sophia'}) --- ... i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) @@ -32,7 +36,11 @@ t s:drop() --- ... -s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +sophia_schedule() +--- +- 1 +... +s = box.schema.create_space('space0', {engine='sophia'}) --- ... i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) @@ -52,6 +60,10 @@ t s:drop() --- ... +sophia_schedule() +--- +- 1 +... -- gh-280: Sophia: crash if insert without index s = box.schema.create_space('test', {engine='sophia'}) --- @@ -63,13 +75,17 @@ s:insert{'a'} s:drop() --- ... +sophia_schedule() +--- +- 0 +... -- gh-436: No error when creating temporary sophia space s = box.schema.create_space('tester',{engine='sophia', temporary=true}) --- - error: 'Can''t modify space ''tester'': space does not support temporary flag' ... -- gh-432: Sophia: ignored limit -s = box.schema.create_space('tester',{id = 89, engine='sophia'}) +s = box.schema.create_space('tester',{engine='sophia'}) --- ... i = s:create_index('sophia_index', {}) @@ -96,7 +112,11 @@ t s:drop() --- ... -s = box.schema.create_space('tester', {id = 90, engine='sophia'}) +sophia_schedule() +--- +- 1 +... +s = box.schema.create_space('tester', {engine='sophia'}) --- ... i = s:create_index('sophia_index', {type = 'tree', parts = {1, 'STR'}}) @@ -122,30 +142,9 @@ t s:drop() --- ... --- gh-282: Sophia: truncate() does nothing -s = box.schema.create_space('name_of_space', {id = 33, engine='sophia'}) ---- -... -i = s:create_index('name_of_index', {type = 'tree', parts = {1, 'STR'}}) ---- -... -s:insert{'a', 'b', 'c'} ---- -- ['a', 'b', 'c'] -... -box.space['name_of_space']:select{'a'} ---- -- - ['a', 'b', 'c'] -... -box.space['name_of_space']:truncate() ---- -... -box.space['name_of_space']:select{'a'} ---- -- [] -... -s:drop() +sophia_schedule() --- +- 1 ... -- gh-680: Sophia: assertion on update s = box.schema.space.create('tester', {engine='sophia'}) @@ -185,3 +184,7 @@ s:select{'Y'} s:drop() --- ... +sophia_schedule() +--- +- 1 +... diff --git a/test/sophia/gh.test.lua b/test/sophia/gh.test.lua index 65331369059fc8fc00fc238383d675e10cbdde33..d0c91a08119d208a46633822cce251ead0118623 100644 --- a/test/sophia/gh.test.lua +++ b/test/sophia/gh.test.lua @@ -1,30 +1,34 @@ -- gh-283: Sophia: hang after three creates and drops -s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +s = box.schema.create_space('space0', {engine='sophia'}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) s:insert{'a', 'b', 'c'} s:drop() +sophia_schedule() -s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +s = box.schema.create_space('space0', {engine='sophia'}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) s:insert{'a', 'b', 'c'} t = s.index[0]:select({}, {iterator = box.index.ALL}) t s:drop() +sophia_schedule() -s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +s = box.schema.create_space('space0', {engine='sophia'}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) s:insert{'a', 'b', 'c'} t = s.index[0]:select({}, {iterator = box.index.ALL}) t s:drop() +sophia_schedule() -- gh-280: Sophia: crash if insert without index s = box.schema.create_space('test', {engine='sophia'}) s:insert{'a'} s:drop() +sophia_schedule() -- gh-436: No error when creating temporary sophia space @@ -32,7 +36,7 @@ s = box.schema.create_space('tester',{engine='sophia', temporary=true}) -- gh-432: Sophia: ignored limit -s = box.schema.create_space('tester',{id = 89, engine='sophia'}) +s = box.schema.create_space('tester',{engine='sophia'}) i = s:create_index('sophia_index', {}) for v=1, 100 do s:insert({v}) end t = s:select({''},{iterator='GT', limit =1}) @@ -40,8 +44,9 @@ t t = s:select({},{iterator='GT', limit =1}) t s:drop() +sophia_schedule() -s = box.schema.create_space('tester', {id = 90, engine='sophia'}) +s = box.schema.create_space('tester', {engine='sophia'}) i = s:create_index('sophia_index', {type = 'tree', parts = {1, 'STR'}}) for v=1, 100 do s:insert({tostring(v)}) end t = s:select({''},{iterator='GT', limit =1}) @@ -49,16 +54,7 @@ t t = s:select({},{iterator='GT', limit =1}) t s:drop() - --- gh-282: Sophia: truncate() does nothing - -s = box.schema.create_space('name_of_space', {id = 33, engine='sophia'}) -i = s:create_index('name_of_index', {type = 'tree', parts = {1, 'STR'}}) -s:insert{'a', 'b', 'c'} -box.space['name_of_space']:select{'a'} -box.space['name_of_space']:truncate() -box.space['name_of_space']:select{'a'} -s:drop() +sophia_schedule() -- gh-680: Sophia: assertion on update s = box.schema.space.create('tester', {engine='sophia'}) @@ -71,3 +67,4 @@ s:update({'X'}, {{'=', 3, 'Z'}}) s:select{'X'} s:select{'Y'} s:drop() +sophia_schedule() diff --git a/test/sophia/index_random_test.lua b/test/sophia/index_random_test.lua index 00838e83e1d78527af6fbb6041899831fdcc368b..369ddcbef6484fd8f68f0c36b2e9afb8e4f66ed4 100644 --- a/test/sophia/index_random_test.lua +++ b/test/sophia/index_random_test.lua @@ -1,8 +1,6 @@ function index_random_test(space, index_no) local COUNT = 1028 - -- clear the space - space:truncate() -- randomize math.randomseed(os.time()) -- insert values into the index diff --git a/test/sophia/info.result b/test/sophia/info.result index 07c922ef7ea9736cc3c7695ed095f4f552753b25..42efdc426b5eab43da130dd936036a7d80f0a01d 100644 --- a/test/sophia/info.result +++ b/test/sophia/info.result @@ -1,5 +1,5 @@ -- box.info().sophia['sophia.version'] -space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) diff --git a/test/sophia/info.test.lua b/test/sophia/info.test.lua index 061e20d0f3811bed2aa80b52bb75a039e105dd86..df540e47b0de417a000455c42851e63679d9ae22 100644 --- a/test/sophia/info.test.lua +++ b/test/sophia/info.test.lua @@ -1,6 +1,6 @@ -- box.info().sophia['sophia.version'] -space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) for key = 1, 10 do space:insert({key}) end diff --git a/test/sophia/options.result b/test/sophia/options.result index a99705d0bef4c242de6badf84d7bf4935ea3b013..75c23ee4a8d5f129793fca2178484888994edce6 100644 --- a/test/sophia/options.result +++ b/test/sophia/options.result @@ -1,7 +1,7 @@ box.cfg.sophia --- - page_size: 131072 - threads: 3 + threads: 0 node_size: 134217728 memory_limit: 0 ... diff --git a/test/sophia/random.result b/test/sophia/random.result new file mode 100644 index 0000000000000000000000000000000000000000..e131458bf6d08db891db42161a11c7d0ea77c66e --- /dev/null +++ b/test/sophia/random.result @@ -0,0 +1,21 @@ +-- random +space = box.schema.create_space('test', { engine = 'sophia'}) +--- +... +index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) +--- +... +dofile('index_random_test.lua') +--- +... +index_random_test(space, 'primary') +--- +- true +... +space:drop() +--- +... +sophia_schedule() +--- +- 1 +... diff --git a/test/sophia/random.test.lua b/test/sophia/random.test.lua new file mode 100644 index 0000000000000000000000000000000000000000..bfa9885a24cbc4329d69280330f0b65fd81eee50 --- /dev/null +++ b/test/sophia/random.test.lua @@ -0,0 +1,11 @@ + +-- random + +space = box.schema.create_space('test', { engine = 'sophia'}) +index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) + +dofile('index_random_test.lua') +index_random_test(space, 'primary') + +space:drop() +sophia_schedule() diff --git a/test/sophia/snapshot.test.lua b/test/sophia/snapshot.test.lua index 81d47b4d030ab9807cc52b3d5addd95f8e16e8ee..22b974f9c4c98735a2cf123e403119525e0e4cd7 100644 --- a/test/sophia/snapshot.test.lua +++ b/test/sophia/snapshot.test.lua @@ -1,13 +1,18 @@ -- snapshot -space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) +os.execute("touch mt") + +--# stop server default +--# start server default + +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary') -sophia_printdir() for key = 1, 351 do space:insert({key}) end box.snapshot() +os.execute("rm -f mt") os.execute("touch lock") --# stop server default diff --git a/test/sophia/suite.ini b/test/sophia/suite.ini index ddf62d5dadc3cadb5233e84cb7d7eed7348221ba..121dcab9d4bd5155925e5519c3f957da1afb4b17 100644 --- a/test/sophia/suite.ini +++ b/test/sophia/suite.ini @@ -2,8 +2,8 @@ core = tarantool description = sophia integration tests script = box.lua -disabled = +disabled = info.test.lua truncate.test.lua snapshot.test.lua valgrind_disabled = release_disabled = -lua_libs = index_random_test.lua +lua_libs = suite.lua index_random_test.lua use_unix_sockets = True diff --git a/test/sophia/suite.lua b/test/sophia/suite.lua new file mode 100644 index 0000000000000000000000000000000000000000..1138205d07eacfce8909641ef40acacec43eb13c --- /dev/null +++ b/test/sophia/suite.lua @@ -0,0 +1,40 @@ +#!/usr/bin/env tarantool + +local os = require('os') + +local ffi = require('ffi') +ffi.cdef[[ + int sophia_schedule(void); +]] + +function sophia_schedule() + return ffi.C.sophia_schedule() +end + +function sophia_dir() + local i = 0 + local list = {} + for file in io.popen("ls -1 sophia_test"):lines() do + i = i + 1 + list[i] = file + end + return {i, t} +end + +function sophia_mkdir(dir) + os.execute("mkdir sophia_test") +end + +function sophia_rmdir(dir) + os.execute("rm -rf sophia_test") +end + +function file_exists(name) + local f = io.open(name,"r") + if f ~= nil then + io.close(f) + return true + else + return false + end +end diff --git a/test/sophia/transaction.result b/test/sophia/transaction.result index 9a25faf642f7eac87f8273157377bd2f8690327b..19b0389a76fb40c748db4340bf9ebe091c0e0083 100644 --- a/test/sophia/transaction.result +++ b/test/sophia/transaction.result @@ -1,4 +1,4 @@ -space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +space = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) diff --git a/test/sophia/transaction.test.lua b/test/sophia/transaction.test.lua index 8d153249912fbb2d9b0c43fbada913d5462ed368..cd3c73f0511d382e1f68a0c4c5679124c2b54016 100644 --- a/test/sophia/transaction.test.lua +++ b/test/sophia/transaction.test.lua @@ -1,5 +1,5 @@ -space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +space = box.schema.create_space('test', { engine = 'sophia' }) index = space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) -- begin/rollback diff --git a/test/sophia/transaction_multidb.result b/test/sophia/transaction_multidb.result index 9c4d88a1ba64f94f1c5544a24e81c1ab98f7789c..2b381c05bc3bffcbcf1909a9649d9a9741e71eb7 100644 --- a/test/sophia/transaction_multidb.result +++ b/test/sophia/transaction_multidb.result @@ -1,10 +1,10 @@ -a = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +a = box.schema.create_space('test', { engine = 'sophia' }) --- ... index = a:create_index('primary', { type = 'tree', parts = {1, 'num'} }) --- ... -b = box.schema.create_space('test_tmp', { engine = 'sophia', id = 101 }) +b = box.schema.create_space('test_tmp', { engine = 'sophia' }) --- ... index = b:create_index('primary', { type = 'tree', parts = {1, 'num'} }) @@ -171,7 +171,14 @@ t a:drop() --- ... +sophia_schedule() +--- +- 1 +... b:drop() --- ... --- +sophia_schedule() +--- +- 1 +... diff --git a/test/sophia/transaction_multidb.test.lua b/test/sophia/transaction_multidb.test.lua index 91a6e01c64c0bf2885b24e78911011b8083d5d99..70410bf81b585ca8fb560b2adab113da6400898b 100644 --- a/test/sophia/transaction_multidb.test.lua +++ b/test/sophia/transaction_multidb.test.lua @@ -1,8 +1,8 @@ -a = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +a = box.schema.create_space('test', { engine = 'sophia' }) index = a:create_index('primary', { type = 'tree', parts = {1, 'num'} }) -b = box.schema.create_space('test_tmp', { engine = 'sophia', id = 101 }) +b = box.schema.create_space('test_tmp', { engine = 'sophia' }) index = b:create_index('primary', { type = 'tree', parts = {1, 'num'} }) -- begin/rollback @@ -55,5 +55,6 @@ for key = 1, 10 do assert(#b:select({key}) == 0) end t a:drop() +sophia_schedule() b:drop() --- +sophia_schedule() diff --git a/test/sophia/truncate.test.lua b/test/sophia/truncate.test.lua new file mode 100644 index 0000000000000000000000000000000000000000..85eed04e342cf883c2dd6b481412c08e21e2befa --- /dev/null +++ b/test/sophia/truncate.test.lua @@ -0,0 +1,11 @@ + +-- truncate + +s = box.schema.create_space('name_of_space', {engine='sophia'}) +i = s:create_index('name_of_index', {type = 'tree', parts = {1, 'STR'}}) +s:insert{'a', 'b', 'c'} +box.space['name_of_space']:select{'a'} +box.space['name_of_space']:truncate() +box.space['name_of_space']:select{'a'} +s:drop() +sophia_schedule() diff --git a/third_party/sophia b/third_party/sophia index 173534aea02a6ef14e4fc7f517d0123da3be6301..ee54a7c08c2a87bf996c7a3f014b0d01dd4bb1e2 160000 --- a/third_party/sophia +++ b/third_party/sophia @@ -1 +1 @@ -Subproject commit 173534aea02a6ef14e4fc7f517d0123da3be6301 +Subproject commit ee54a7c08c2a87bf996c7a3f014b0d01dd4bb1e2