diff --git a/src/box/sophia_index.cc b/src/box/sophia_index.cc index 9767e8a383c9ced3a4470751460ffed75e281982..c82c9a717f548747970285de45d4ec1a69ee36df 100644 --- a/src/box/sophia_index.cc +++ b/src/box/sophia_index.cc @@ -387,7 +387,8 @@ SophiaIndex::initIterator(struct iterator *ptr, enum iterator_type type, it->space = space_cache_find(key_def->space_id); const char *compare; switch (type) { - case ITER_EQ: it->base.next = sophia_iterator_eq; + case ITER_EQ: + it->base.next = sophia_iterator_eq; return; case ITER_ALL: case ITER_GE: compare = ">="; @@ -402,6 +403,7 @@ SophiaIndex::initIterator(struct iterator *ptr, enum iterator_type type, tnt_raise(ClientError, ER_UNSUPPORTED, "SophiaIndex", "requested iterator type"); } + it->base.next = sophia_iterator_next; void *o = NULL; if (key) { o = sp_object(db); diff --git a/test/sophia/box.lua b/test/sophia/box.lua new file mode 100644 index 0000000000000000000000000000000000000000..c9e32af1c76f0ff7bc75aa7409cf1f262d39e14a --- /dev/null +++ b/test/sophia/box.lua @@ -0,0 +1,23 @@ +#!/usr/bin/env tarantool +os = require('os') + +box.cfg{ + listen = os.getenv("LISTEN"), + slab_alloc_arena = 0.1, + pid_file = "tarantool.pid", + rows_per_wal = 50, + sophia_dir = "sophia_test" +} + +require('console').listen(os.getenv('ADMIN')) + +function sophia_printdir() + f = io.popen("ls -1 sophia_test") + ls = f:read("*all") + unused = f:close() + return ls +end + +function sophia_rmdir(dir) + os.execute("rm -rf sophia_test") +end diff --git a/test/sophia/crud.result b/test/sophia/crud.result new file mode 100644 index 0000000000000000000000000000000000000000..236262ca5bb91327cb6e2bb204c2fe03a5897cfc --- /dev/null +++ b/test/sophia/crud.result @@ -0,0 +1,1169 @@ +sophia_rmdir() +--- +... +-- insert +space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +--- +... +space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) +--- +... +for key = 1, 132 do space:insert({key}) end +--- +... +t = {} +--- +... +for key = 1, 132 do table.insert(t, space:get({key})) end +--- +... +t +--- +- - [1] + - [2] + - [3] + - [4] + - [5] + - [6] + - [7] + - [8] + - [9] + - [10] + - [11] + - [12] + - [13] + - [14] + - [15] + - [16] + - [17] + - [18] + - [19] + - [20] + - [21] + - [22] + - [23] + - [24] + - [25] + - [26] + - [27] + - [28] + - [29] + - [30] + - [31] + - [32] + - [33] + - [34] + - [35] + - [36] + - [37] + - [38] + - [39] + - [40] + - [41] + - [42] + - [43] + - [44] + - [45] + - [46] + - [47] + - [48] + - [49] + - [50] + - [51] + - [52] + - [53] + - [54] + - [55] + - [56] + - [57] + - [58] + - [59] + - [60] + - [61] + - [62] + - [63] + - [64] + - [65] + - [66] + - [67] + - [68] + - [69] + - [70] + - [71] + - [72] + - [73] + - [74] + - [75] + - [76] + - [77] + - [78] + - [79] + - [80] + - [81] + - [82] + - [83] + - [84] + - [85] + - [86] + - [87] + - [88] + - [89] + - [90] + - [91] + - [92] + - [93] + - [94] + - [95] + - [96] + - [97] + - [98] + - [99] + - [100] + - [101] + - [102] + - [103] + - [104] + - [105] + - [106] + - [107] + - [108] + - [109] + - [110] + - [111] + - [112] + - [113] + - [114] + - [115] + - [116] + - [117] + - [118] + - [119] + - [120] + - [121] + - [122] + - [123] + - [124] + - [125] + - [126] + - [127] + - [128] + - [129] + - [130] + - [131] + - [132] +... +-- replace/get +for key = 1, 132 do space:replace({key, key}) end +--- +... +t = {} +--- +... +for key = 1, 132 do table.insert(t, space:get({key})) end +--- +... +t +--- +- - [1, 1] + - [2, 2] + - [3, 3] + - [4, 4] + - [5, 5] + - [6, 6] + - [7, 7] + - [8, 8] + - [9, 9] + - [10, 10] + - [11, 11] + - [12, 12] + - [13, 13] + - [14, 14] + - [15, 15] + - [16, 16] + - [17, 17] + - [18, 18] + - [19, 19] + - [20, 20] + - [21, 21] + - [22, 22] + - [23, 23] + - [24, 24] + - [25, 25] + - [26, 26] + - [27, 27] + - [28, 28] + - [29, 29] + - [30, 30] + - [31, 31] + - [32, 32] + - [33, 33] + - [34, 34] + - [35, 35] + - [36, 36] + - [37, 37] + - [38, 38] + - [39, 39] + - [40, 40] + - [41, 41] + - [42, 42] + - [43, 43] + - [44, 44] + - [45, 45] + - [46, 46] + - [47, 47] + - [48, 48] + - [49, 49] + - [50, 50] + - [51, 51] + - [52, 52] + - [53, 53] + - [54, 54] + - [55, 55] + - [56, 56] + - [57, 57] + - [58, 58] + - [59, 59] + - [60, 60] + - [61, 61] + - [62, 62] + - [63, 63] + - [64, 64] + - [65, 65] + - [66, 66] + - [67, 67] + - [68, 68] + - [69, 69] + - [70, 70] + - [71, 71] + - [72, 72] + - [73, 73] + - [74, 74] + - [75, 75] + - [76, 76] + - [77, 77] + - [78, 78] + - [79, 79] + - [80, 80] + - [81, 81] + - [82, 82] + - [83, 83] + - [84, 84] + - [85, 85] + - [86, 86] + - [87, 87] + - [88, 88] + - [89, 89] + - [90, 90] + - [91, 91] + - [92, 92] + - [93, 93] + - [94, 94] + - [95, 95] + - [96, 96] + - [97, 97] + - [98, 98] + - [99, 99] + - [100, 100] + - [101, 101] + - [102, 102] + - [103, 103] + - [104, 104] + - [105, 105] + - [106, 106] + - [107, 107] + - [108, 108] + - [109, 109] + - [110, 110] + - [111, 111] + - [112, 112] + - [113, 113] + - [114, 114] + - [115, 115] + - [116, 116] + - [117, 117] + - [118, 118] + - [119, 119] + - [120, 120] + - [121, 121] + - [122, 122] + - [123, 123] + - [124, 124] + - [125, 125] + - [126, 126] + - [127, 127] + - [128, 128] + - [129, 129] + - [130, 130] + - [131, 131] + - [132, 132] +... +-- update/get +for key = 1, 132 do space:update({key}, {{'+', 2, key}}) end +--- +... +t = {} +--- +... +for key = 1, 132 do table.insert(t, space:get({key})) end +--- +... +t +--- +- - [1, 2] + - [2, 4] + - [3, 6] + - [4, 8] + - [5, 10] + - [6, 12] + - [7, 14] + - [8, 16] + - [9, 18] + - [10, 20] + - [11, 22] + - [12, 24] + - [13, 26] + - [14, 28] + - [15, 30] + - [16, 32] + - [17, 34] + - [18, 36] + - [19, 38] + - [20, 40] + - [21, 42] + - [22, 44] + - [23, 46] + - [24, 48] + - [25, 50] + - [26, 52] + - [27, 54] + - [28, 56] + - [29, 58] + - [30, 60] + - [31, 62] + - [32, 64] + - [33, 66] + - [34, 68] + - [35, 70] + - [36, 72] + - [37, 74] + - [38, 76] + - [39, 78] + - [40, 80] + - [41, 82] + - [42, 84] + - [43, 86] + - [44, 88] + - [45, 90] + - [46, 92] + - [47, 94] + - [48, 96] + - [49, 98] + - [50, 100] + - [51, 102] + - [52, 104] + - [53, 106] + - [54, 108] + - [55, 110] + - [56, 112] + - [57, 114] + - [58, 116] + - [59, 118] + - [60, 120] + - [61, 122] + - [62, 124] + - [63, 126] + - [64, 128] + - [65, 130] + - [66, 132] + - [67, 134] + - [68, 136] + - [69, 138] + - [70, 140] + - [71, 142] + - [72, 144] + - [73, 146] + - [74, 148] + - [75, 150] + - [76, 152] + - [77, 154] + - [78, 156] + - [79, 158] + - [80, 160] + - [81, 162] + - [82, 164] + - [83, 166] + - [84, 168] + - [85, 170] + - [86, 172] + - [87, 174] + - [88, 176] + - [89, 178] + - [90, 180] + - [91, 182] + - [92, 184] + - [93, 186] + - [94, 188] + - [95, 190] + - [96, 192] + - [97, 194] + - [98, 196] + - [99, 198] + - [100, 200] + - [101, 202] + - [102, 204] + - [103, 206] + - [104, 208] + - [105, 210] + - [106, 212] + - [107, 214] + - [108, 216] + - [109, 218] + - [110, 220] + - [111, 222] + - [112, 224] + - [113, 226] + - [114, 228] + - [115, 230] + - [116, 232] + - [117, 234] + - [118, 236] + - [119, 238] + - [120, 240] + - [121, 242] + - [122, 244] + - [123, 246] + - [124, 248] + - [125, 250] + - [126, 252] + - [127, 254] + - [128, 256] + - [129, 258] + - [130, 260] + - [131, 262] + - [132, 264] +... +-- delete/get +for key = 1, 132 do space:delete({key}) end +--- +... +for key = 1, 132 do assert(space:get({key}) == nil) end +--- +... +-- select +for key = 1, 96 do space:insert({key}) end +--- +... +index = space.index[0] +--- +... +index:select({}, {iterator = box.index.ALL}) +--- +- - [1] + - [2] + - [3] + - [4] + - [5] + - [6] + - [7] + - [8] + - [9] + - [10] + - [11] + - [12] + - [13] + - [14] + - [15] + - [16] + - [17] + - [18] + - [19] + - [20] + - [21] + - [22] + - [23] + - [24] + - [25] + - [26] + - [27] + - [28] + - [29] + - [30] + - [31] + - [32] + - [33] + - [34] + - [35] + - [36] + - [37] + - [38] + - [39] + - [40] + - [41] + - [42] + - [43] + - [44] + - [45] + - [46] + - [47] + - [48] + - [49] + - [50] + - [51] + - [52] + - [53] + - [54] + - [55] + - [56] + - [57] + - [58] + - [59] + - [60] + - [61] + - [62] + - [63] + - [64] + - [65] + - [66] + - [67] + - [68] + - [69] + - [70] + - [71] + - [72] + - [73] + - [74] + - [75] + - [76] + - [77] + - [78] + - [79] + - [80] + - [81] + - [82] + - [83] + - [84] + - [85] + - [86] + - [87] + - [88] + - [89] + - [90] + - [91] + - [92] + - [93] + - [94] + - [95] + - [96] +... +index:select({}, {iterator = box.index.GE}) +--- +- - [1] + - [2] + - [3] + - [4] + - [5] + - [6] + - [7] + - [8] + - [9] + - [10] + - [11] + - [12] + - [13] + - [14] + - [15] + - [16] + - [17] + - [18] + - [19] + - [20] + - [21] + - [22] + - [23] + - [24] + - [25] + - [26] + - [27] + - [28] + - [29] + - [30] + - [31] + - [32] + - [33] + - [34] + - [35] + - [36] + - [37] + - [38] + - [39] + - [40] + - [41] + - [42] + - [43] + - [44] + - [45] + - [46] + - [47] + - [48] + - [49] + - [50] + - [51] + - [52] + - [53] + - [54] + - [55] + - [56] + - [57] + - [58] + - [59] + - [60] + - [61] + - [62] + - [63] + - [64] + - [65] + - [66] + - [67] + - [68] + - [69] + - [70] + - [71] + - [72] + - [73] + - [74] + - [75] + - [76] + - [77] + - [78] + - [79] + - [80] + - [81] + - [82] + - [83] + - [84] + - [85] + - [86] + - [87] + - [88] + - [89] + - [90] + - [91] + - [92] + - [93] + - [94] + - [95] + - [96] +... +index:select(4, {iterator = box.index.GE}) +--- +- - [4] + - [5] + - [6] + - [7] + - [8] + - [9] + - [10] + - [11] + - [12] + - [13] + - [14] + - [15] + - [16] + - [17] + - [18] + - [19] + - [20] + - [21] + - [22] + - [23] + - [24] + - [25] + - [26] + - [27] + - [28] + - [29] + - [30] + - [31] + - [32] + - [33] + - [34] + - [35] + - [36] + - [37] + - [38] + - [39] + - [40] + - [41] + - [42] + - [43] + - [44] + - [45] + - [46] + - [47] + - [48] + - [49] + - [50] + - [51] + - [52] + - [53] + - [54] + - [55] + - [56] + - [57] + - [58] + - [59] + - [60] + - [61] + - [62] + - [63] + - [64] + - [65] + - [66] + - [67] + - [68] + - [69] + - [70] + - [71] + - [72] + - [73] + - [74] + - [75] + - [76] + - [77] + - [78] + - [79] + - [80] + - [81] + - [82] + - [83] + - [84] + - [85] + - [86] + - [87] + - [88] + - [89] + - [90] + - [91] + - [92] + - [93] + - [94] + - [95] + - [96] +... +index:select({}, {iterator = box.index.GT}) +--- +- - [1] + - [2] + - [3] + - [4] + - [5] + - [6] + - [7] + - [8] + - [9] + - [10] + - [11] + - [12] + - [13] + - [14] + - [15] + - [16] + - [17] + - [18] + - [19] + - [20] + - [21] + - [22] + - [23] + - [24] + - [25] + - [26] + - [27] + - [28] + - [29] + - [30] + - [31] + - [32] + - [33] + - [34] + - [35] + - [36] + - [37] + - [38] + - [39] + - [40] + - [41] + - [42] + - [43] + - [44] + - [45] + - [46] + - [47] + - [48] + - [49] + - [50] + - [51] + - [52] + - [53] + - [54] + - [55] + - [56] + - [57] + - [58] + - [59] + - [60] + - [61] + - [62] + - [63] + - [64] + - [65] + - [66] + - [67] + - [68] + - [69] + - [70] + - [71] + - [72] + - [73] + - [74] + - [75] + - [76] + - [77] + - [78] + - [79] + - [80] + - [81] + - [82] + - [83] + - [84] + - [85] + - [86] + - [87] + - [88] + - [89] + - [90] + - [91] + - [92] + - [93] + - [94] + - [95] + - [96] +... +index:select(4, {iterator = box.index.GT}) +--- +- - [5] + - [6] + - [7] + - [8] + - [9] + - [10] + - [11] + - [12] + - [13] + - [14] + - [15] + - [16] + - [17] + - [18] + - [19] + - [20] + - [21] + - [22] + - [23] + - [24] + - [25] + - [26] + - [27] + - [28] + - [29] + - [30] + - [31] + - [32] + - [33] + - [34] + - [35] + - [36] + - [37] + - [38] + - [39] + - [40] + - [41] + - [42] + - [43] + - [44] + - [45] + - [46] + - [47] + - [48] + - [49] + - [50] + - [51] + - [52] + - [53] + - [54] + - [55] + - [56] + - [57] + - [58] + - [59] + - [60] + - [61] + - [62] + - [63] + - [64] + - [65] + - [66] + - [67] + - [68] + - [69] + - [70] + - [71] + - [72] + - [73] + - [74] + - [75] + - [76] + - [77] + - [78] + - [79] + - [80] + - [81] + - [82] + - [83] + - [84] + - [85] + - [86] + - [87] + - [88] + - [89] + - [90] + - [91] + - [92] + - [93] + - [94] + - [95] + - [96] +... +index:select({}, {iterator = box.index.LE}) +--- +- - [96] + - [95] + - [94] + - [93] + - [92] + - [91] + - [90] + - [89] + - [88] + - [87] + - [86] + - [85] + - [84] + - [83] + - [82] + - [81] + - [80] + - [79] + - [78] + - [77] + - [76] + - [75] + - [74] + - [73] + - [72] + - [71] + - [70] + - [69] + - [68] + - [67] + - [66] + - [65] + - [64] + - [63] + - [62] + - [61] + - [60] + - [59] + - [58] + - [57] + - [56] + - [55] + - [54] + - [53] + - [52] + - [51] + - [50] + - [49] + - [48] + - [47] + - [46] + - [45] + - [44] + - [43] + - [42] + - [41] + - [40] + - [39] + - [38] + - [37] + - [36] + - [35] + - [34] + - [33] + - [32] + - [31] + - [30] + - [29] + - [28] + - [27] + - [26] + - [25] + - [24] + - [23] + - [22] + - [21] + - [20] + - [19] + - [18] + - [17] + - [16] + - [15] + - [14] + - [13] + - [12] + - [11] + - [10] + - [9] + - [8] + - [7] + - [6] + - [5] + - [4] + - [3] + - [2] + - [1] +... +index:select(7, {iterator = box.index.LE}) +--- +- - [7] + - [6] + - [5] + - [4] + - [3] + - [2] + - [1] +... +index:select({}, {iterator = box.index.LT}) +--- +- - [96] + - [95] + - [94] + - [93] + - [92] + - [91] + - [90] + - [89] + - [88] + - [87] + - [86] + - [85] + - [84] + - [83] + - [82] + - [81] + - [80] + - [79] + - [78] + - [77] + - [76] + - [75] + - [74] + - [73] + - [72] + - [71] + - [70] + - [69] + - [68] + - [67] + - [66] + - [65] + - [64] + - [63] + - [62] + - [61] + - [60] + - [59] + - [58] + - [57] + - [56] + - [55] + - [54] + - [53] + - [52] + - [51] + - [50] + - [49] + - [48] + - [47] + - [46] + - [45] + - [44] + - [43] + - [42] + - [41] + - [40] + - [39] + - [38] + - [37] + - [36] + - [35] + - [34] + - [33] + - [32] + - [31] + - [30] + - [29] + - [28] + - [27] + - [26] + - [25] + - [24] + - [23] + - [22] + - [21] + - [20] + - [19] + - [18] + - [17] + - [16] + - [15] + - [14] + - [13] + - [12] + - [11] + - [10] + - [9] + - [8] + - [7] + - [6] + - [5] + - [4] + - [3] + - [2] + - [1] +... +index:select(7, {iterator = box.index.LT}) +--- +- - [6] + - [5] + - [4] + - [3] + - [2] + - [1] +... +space:drop() +--- +... +sophia_rmdir() +--- +... diff --git a/test/sophia/crud.test.lua b/test/sophia/crud.test.lua new file mode 100644 index 0000000000000000000000000000000000000000..204853e301b6fdf7f5d15bc3bd69842c2a32745b --- /dev/null +++ b/test/sophia/crud.test.lua @@ -0,0 +1,48 @@ + +sophia_rmdir() + +-- insert + +space = box.schema.create_space('test', { engine = 'sophia', id = 100 }) +space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) +for key = 1, 132 do space:insert({key}) end +t = {} +for key = 1, 132 do table.insert(t, space:get({key})) end +t + +-- replace/get + +for key = 1, 132 do space:replace({key, key}) end +t = {} +for key = 1, 132 do table.insert(t, space:get({key})) end +t + +-- update/get + +for key = 1, 132 do space:update({key}, {{'+', 2, key}}) end +t = {} +for key = 1, 132 do table.insert(t, space:get({key})) end +t + +-- delete/get + +for key = 1, 132 do space:delete({key}) end +for key = 1, 132 do assert(space:get({key}) == nil) end + +-- select + +for key = 1, 96 do space:insert({key}) end +index = space.index[0] +index:select({}, {iterator = box.index.ALL}) +index:select({}, {iterator = box.index.GE}) +index:select(4, {iterator = box.index.GE}) +index:select({}, {iterator = box.index.GT}) +index:select(4, {iterator = box.index.GT}) +index:select({}, {iterator = box.index.LE}) +index:select(7, {iterator = box.index.LE}) +index:select({}, {iterator = box.index.LT}) +index:select(7, {iterator = box.index.LT}) + +space:drop() + +sophia_rmdir() diff --git a/test/sophia/dml.result b/test/sophia/dml.result new file mode 100644 index 0000000000000000000000000000000000000000..8276e134d01b32ee38e60b1cb41bbee6b9efe6b0 --- /dev/null +++ b/test/sophia/dml.result @@ -0,0 +1,138 @@ +sophia_rmdir() +--- +... +-- space create/drop +space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) +--- +... +sophia_printdir() +--- +- +... +space:drop() +--- +... +sophia_printdir() +--- +- +... +-- index create/drop +space = box.schema.create_space('test', { id = 101, engine = 'sophia' }) +--- +... +primary = space:create_index('primary') +--- +... +sophia_printdir() +--- +- '101 + +' +... +space:drop() +--- +... +sophia_printdir() +--- +- +... +-- index create/drop alter +space = box.schema.create_space('test', { id = 102, engine = 'sophia' }) +--- +... +primary = space:create_index('primary') +--- +... +sophia_printdir() +--- +- '102 + +' +... +_index = box.space[box.schema.INDEX_ID] +--- +... +_index:delete{102, 0} +--- +- [102, 0, 'primary', 'tree', 1, 1, 0, 'num'] +... +sophia_printdir() +--- +- +... +space:drop() +--- +... +-- index create/drop tree string +space = box.schema.create_space('test', { id = 103, engine = 'sophia' }) +--- +... +primary = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}}) +--- +... +space:insert({'test'}) +--- +- ['test'] +... +sophia_printdir() +--- +- '103 + +' +... +space:drop() +--- +... +-- index create/drop tree num +space = box.schema.create_space('test', { id = 104, engine = 'sophia' }) +--- +... +primary = space:create_index('primary', {type = 'tree', parts = {1, 'num'}}) +--- +... +space:insert({13}) +--- +- [13] +... +sophia_printdir() +--- +- '104 + +' +... +space:drop() +--- +... +-- index create hash +space = box.schema.create_space('test', { id = 105, engine = 'sophia' }) +--- +... +primary = space:create_index('primary', {type = 'hash'}) +--- +- error: Unsupported index type supplied for index 0 in space 105 +... +space:drop() +--- +... +-- secondary index create +space = box.schema.create_space('test', { id = 106, engine = 'sophia' }) +--- +... +space:create_index('primary') +--- +... +space:create_index('secondary') +--- +- error: 'Can''t create or modify index 1 in space 106: Sophia TREE secondary indexes + are not supported' +... +space:drop() +--- +... +sophia_printdir() +--- +- +... +sophia_rmdir() +--- +... diff --git a/test/sophia/dml.test.lua b/test/sophia/dml.test.lua new file mode 100644 index 0000000000000000000000000000000000000000..b26ba247b795eff9d047a9c4ca9bb9555603347f --- /dev/null +++ b/test/sophia/dml.test.lua @@ -0,0 +1,59 @@ + +sophia_rmdir() + +-- space create/drop + +space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) +sophia_printdir() +space:drop() +sophia_printdir() + +-- index create/drop + +space = box.schema.create_space('test', { id = 101, engine = 'sophia' }) +primary = space:create_index('primary') +sophia_printdir() +space:drop() +sophia_printdir() + +-- index create/drop alter + +space = box.schema.create_space('test', { id = 102, engine = 'sophia' }) +primary = space:create_index('primary') +sophia_printdir() +_index = box.space[box.schema.INDEX_ID] +_index:delete{102, 0} +sophia_printdir() +space:drop() + +-- index create/drop tree string + +space = box.schema.create_space('test', { id = 103, engine = 'sophia' }) +primary = space:create_index('primary', {type = 'tree', parts = {1, 'STR'}}) +space:insert({'test'}) +sophia_printdir() +space:drop() + +-- index create/drop tree num + +space = box.schema.create_space('test', { id = 104, engine = 'sophia' }) +primary = space:create_index('primary', {type = 'tree', parts = {1, 'num'}}) +space:insert({13}) +sophia_printdir() +space:drop() + +-- index create hash + +space = box.schema.create_space('test', { id = 105, engine = 'sophia' }) +primary = space:create_index('primary', {type = 'hash'}) +space:drop() + +-- secondary index create + +space = box.schema.create_space('test', { id = 106, engine = 'sophia' }) +space:create_index('primary') +space:create_index('secondary') +space:drop() +sophia_printdir() + +sophia_rmdir() diff --git a/test/sophia/gh.result b/test/sophia/gh.result new file mode 100644 index 0000000000000000000000000000000000000000..9b0340de6b4e16b98f109f45f9ff66abf9a2e336 --- /dev/null +++ b/test/sophia/gh.result @@ -0,0 +1,201 @@ +sophia_rmdir() +--- +... +-- gh-283: Sophia: hang after three creates and drops +s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +--- +... +i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) +--- +... +s:insert{'a', 'b', 'c'} +--- +- ['a', 'b', 'c'] +... +s:drop() +--- +... +s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +--- +... +i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) +--- +... +s:insert{'a', 'b', 'c'} +--- +- ['a', 'b', 'c'] +... +t = s.index[0]:select({}, {iterator = box.index.ALL}) +--- +... +t +--- +- - ['a', 'b', 'c'] +... +s:drop() +--- +... +s = box.schema.create_space('space0', {id = 33, engine='sophia'}) +--- +... +i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) +--- +... +s:insert{'a', 'b', 'c'} +--- +- ['a', 'b', 'c'] +... +t = s.index[0]:select({}, {iterator = box.index.ALL}) +--- +... +t +--- +- - ['a', 'b', 'c'] +... +s:drop() +--- +... +-- gh-280: Sophia: crash if insert without index +s = box.schema.create_space('test', {engine='sophia'}) +--- +... +s:insert{'a'} +--- +- error: 'No index #0 is defined in space ''test''' +... +s:drop() +--- +... +-- gh-431: Sophia: assertion if box.begin +s = box.schema.create_space('tester',{engine='sophia'}) +--- +... +s:create_index('sophia_index', {}) +--- +... +s:insert{10000, 'Hilton'} +--- +- [10000, 'Hilton'] +... +box.begin() +--- +... +s:delete{10000} -- exception +--- +- error: sophia does not support transactions +... +box.rollback() +--- +... +s:select{10000} +--- +- - [10000, 'Hilton'] +... +s:drop() +--- +... +-- gh-456: Sophia: index size() is unsupported +s = box.schema.create_space('tester',{engine='sophia'}) +--- +... +s:create_index('sophia_index', {}) +--- +... +s.index[0]:len() -- exception +--- +- error: SophiaIndex does not support size operation +... +box.error() +--- +- error: SophiaIndex does not support size operation +... +s:drop() +--- +... +-- gh-436: No error when creating temporary sophia space +s = box.schema.create_space('tester',{engine='sophia', temporary=true}) +--- +- error: 'Can''t modify space 512: space does not support temporary flag' +... +-- gh-432: Sophia: ignored limit +s = box.schema.create_space('tester',{id = 89, engine='sophia'}) +--- +... +s:create_index('sophia_index', {}) +--- +... +for v=1, 100 do s:insert({v}) end +--- +... +t = s:select({''},{iterator='GT', limit =1}) +--- +- error: 'Supplied key type of part 0 does not match index part type: expected NUM' +... +t +--- +- - ['a', 'b', 'c'] +... +t = s:select({},{iterator='GT', limit =1}) +--- +... +t +--- +- - [1] +... +s:drop() +--- +... +s = box.schema.create_space('tester', {id = 90, engine='sophia'}) +--- +... +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}) +--- +... +t +--- +- - ['1'] +... +t = s:select({},{iterator='GT', limit =1}) +--- +... +t +--- +- - ['1'] +... +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_rmdir() +--- +... diff --git a/test/box/sophia.test.lua b/test/sophia/gh.test.lua similarity index 68% rename from test/box/sophia.test.lua rename to test/sophia/gh.test.lua index d91a685e0711acee86fef224471b92fb8374a0c1..1cfc5e8101132fb959903d6e36eb896413532c08 100644 --- a/test/box/sophia.test.lua +++ b/test/sophia/gh.test.lua @@ -1,35 +1,7 @@ -os.execute("rm -rf sophia") -space = box.schema.create_space('tweedledum', { id = 123, engine = 'sophia' }) -space:create_index('primary', { type = 'tree', parts = {1, 'num'} }) +sophia_rmdir() -for v=1, 10 do space:insert({v}) end - -t = space.index[0]:select({}, {iterator = box.index.ALL}) -t - -t = space.index[0]:select({}, {iterator = box.index.GE}) -t - -t = space.index[0]:select(4, {iterator = box.index.GE}) -t - -t = space.index[0]:select({}, {iterator = box.index.LE}) -t - -t = space.index[0]:select(7, {iterator = box.index.LE}) -t - -t = {} -for v=1, 10 do table.insert(t, space:get({v})) end -t - -space:drop() -box.snapshot() - --- -- gh-283: Sophia: hang after three creates and drops --- s = box.schema.create_space('space0', {id = 33, engine='sophia'}) i = s:create_index('space0', {type = 'tree', parts = {1, 'STR'}}) @@ -50,19 +22,14 @@ t = s.index[0]:select({}, {iterator = box.index.ALL}) t s:drop() --- -- gh-280: Sophia: crash if insert without index --- s = box.schema.create_space('test', {engine='sophia'}) s:insert{'a'} s:drop() ---- ---- gh-431: Sophia: assertion if box.begin ---- +-- gh-431: Sophia: assertion if box.begin -box.cfg{} s = box.schema.create_space('tester',{engine='sophia'}) s:create_index('sophia_index', {}) s:insert{10000, 'Hilton'} @@ -72,27 +39,19 @@ box.rollback() s:select{10000} s:drop() ---- ---- gh-456: Sophia: index size() is unsupported ---- +-- gh-456: Sophia: index size() is unsupported -box.cfg{} s = box.schema.create_space('tester',{engine='sophia'}) s:create_index('sophia_index', {}) s.index[0]:len() -- exception box.error() s:drop() ---- ---- gh-436: No error when creating temporary sophia space ---- +-- gh-436: No error when creating temporary sophia space -box.cfg{} s = box.schema.create_space('tester',{engine='sophia', temporary=true}) ---- ---- gh-432: Sophia: ignored limit ---- +-- gh-432: Sophia: ignored limit s = box.schema.create_space('tester',{id = 89, engine='sophia'}) s:create_index('sophia_index', {}) @@ -112,9 +71,7 @@ t = s:select({},{iterator='GT', limit =1}) t s:drop() ---- ---- gh-282: Sophia: truncate() does nothing ---- +-- 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'}}) @@ -124,4 +81,4 @@ box.space['name_of_space']:truncate() box.space['name_of_space']:select{'a'} s:drop() -os.execute("rm -rf sophia") +sophia_rmdir() diff --git a/test/sophia/recover.result b/test/sophia/recover.result new file mode 100644 index 0000000000000000000000000000000000000000..4903baa4388743108b9dc90789309e54c050a27b --- /dev/null +++ b/test/sophia/recover.result @@ -0,0 +1,30 @@ +sophia_rmdir() +--- +... +-- snapshot +space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) +--- +... +space:create_index('primary') +--- +... +sophia_printdir() +--- +- '100 + +' +... +box.snapshot() +--- +- ok +... +space:drop() +--- +... +box.snapshot() +--- +- ok +... +sophia_rmdir() +--- +... diff --git a/test/sophia/recover.test.lua b/test/sophia/recover.test.lua new file mode 100644 index 0000000000000000000000000000000000000000..ffea2d43ca920888f7cbd065477306ab3d28ab6e --- /dev/null +++ b/test/sophia/recover.test.lua @@ -0,0 +1,13 @@ + +sophia_rmdir() + +-- snapshot + +space = box.schema.create_space('test', { id = 100, engine = 'sophia' }) +space:create_index('primary') +sophia_printdir() +box.snapshot() +space:drop() +box.snapshot() + +sophia_rmdir() diff --git a/test/box/sophia.result b/test/sophia/sophia.result similarity index 100% rename from test/box/sophia.result rename to test/sophia/sophia.result diff --git a/test/sophia/suite.ini b/test/sophia/suite.ini new file mode 100644 index 0000000000000000000000000000000000000000..5139d0b87a1637c650a005a530dc72e9ef6f6986 --- /dev/null +++ b/test/sophia/suite.ini @@ -0,0 +1,9 @@ +[default] +core = tarantool +description = sophia integration tests +script = box.lua +disabled = +valgrind_disabled = +release_disabled = +lua_libs = +use_unix_sockets = True