diff --git a/test/big/bitset.result b/test/big/bitset.result index 0ee6d3b8f78be6c6666798997a2e222491b1ec85..999adfbf34e4a708d59e316b81cb5340baa39ce0 100644 --- a/test/big/bitset.result +++ b/test/big/bitset.result @@ -1,7 +1,7 @@ -lua dofile('utils.lua') +dofile('utils.lua') --- ... -lua dofile('bitset.lua') +dofile('bitset.lua') --- ... @@ -9,7 +9,7 @@ lua dofile('bitset.lua') # BitsetIndex: insert/delete #-----------------------------------------------------------------------------# -lua test_insert_delete(128) +test_insert_delete(128) --- sorted output $ 1$ @@ -19,13 +19,13 @@ $ 1$ # BitsetIndex: ALL #-----------------------------------------------------------------------------# -lua clear() +clear() --- ... -lua fill(1, 128) +fill(1, 128) --- ... -lua dump(box.index.BITS_ALL) +dump(box.index.BITS_ALL) --- sorted output $ 1$ @@ -162,11 +162,11 @@ $ 128$ # BitsetIndex: BITS_ALL_SET (single bit) #-----------------------------------------------------------------------------# -lua dump(box.index.BITS_ALL_SET, 0) +dump(box.index.BITS_ALL_SET, 0) --- sorted output ... -lua dump(box.index.BITS_ALL_SET, 1) +dump(box.index.BITS_ALL_SET, 1) --- sorted output $ 1$ @@ -234,7 +234,7 @@ $ 123$ $ 125$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 2) +dump(box.index.BITS_ALL_SET, 2) --- sorted output $ 2$ @@ -302,7 +302,7 @@ $ 123$ $ 126$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 8) +dump(box.index.BITS_ALL_SET, 8) --- sorted output $ 8$ @@ -370,15 +370,15 @@ $ 125$ $ 126$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 1073741824) +dump(box.index.BITS_ALL_SET, 1073741824) --- sorted output ... -lua dump(box.index.BITS_ALL_SET, 2147483648) +dump(box.index.BITS_ALL_SET, 2147483648) --- sorted output ... -lua dump(box.index.BITS_ALL_SET, 4294967296) +dump(box.index.BITS_ALL_SET, 4294967296) --- error: 'Supplied key field type does not match index type: expected u32' ... @@ -387,7 +387,7 @@ error: 'Supplied key field type does not match index type: expected u32' # BitsetIndex: BITS_ALL_SET (multiple bit) #-----------------------------------------------------------------------------# -lua dump(box.index.BITS_ALL_SET, 3) +dump(box.index.BITS_ALL_SET, 3) --- sorted output $ 3$ @@ -423,7 +423,7 @@ $ 119$ $ 123$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 7) +dump(box.index.BITS_ALL_SET, 7) --- sorted output $ 7$ @@ -443,7 +443,7 @@ $ 111$ $ 119$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 31) +dump(box.index.BITS_ALL_SET, 31) --- sorted output $ 31$ @@ -451,7 +451,7 @@ $ 63$ $ 95$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 5) +dump(box.index.BITS_ALL_SET, 5) --- sorted output $ 5$ @@ -487,7 +487,7 @@ $ 119$ $ 125$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 10) +dump(box.index.BITS_ALL_SET, 10) --- sorted output $ 10$ @@ -523,7 +523,7 @@ $ 123$ $ 126$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 27) +dump(box.index.BITS_ALL_SET, 27) --- sorted output $ 27$ @@ -535,15 +535,15 @@ $ 95$ $ 123$ $ 127$ ... -lua dump(box.index.BITS_ALL_SET, 341) +dump(box.index.BITS_ALL_SET, 341) --- sorted output ... -lua dump(box.index.BITS_ALL_SET, 2147483649) +dump(box.index.BITS_ALL_SET, 2147483649) --- sorted output ... -lua dump(box.index.BITS_ALL_SET, 4294967295) +dump(box.index.BITS_ALL_SET, 4294967295) --- sorted output ... @@ -552,7 +552,7 @@ sorted output # BitsetIndex: BITS_ALL_NOT_SET (single bit) #-----------------------------------------------------------------------------# -lua dump(box.index.BITS_ALL_NOT_SET, 0) +dump(box.index.BITS_ALL_NOT_SET, 0) --- sorted output $ 1$ @@ -684,7 +684,7 @@ $ 126$ $ 127$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 2) +dump(box.index.BITS_ALL_NOT_SET, 2) --- sorted output $ 1$ @@ -752,7 +752,7 @@ $ 124$ $ 125$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 8) +dump(box.index.BITS_ALL_NOT_SET, 8) --- sorted output $ 1$ @@ -820,7 +820,7 @@ $ 118$ $ 119$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 4294967296) +dump(box.index.BITS_ALL_NOT_SET, 4294967296) --- error: 'Supplied key field type does not match index type: expected u32' ... @@ -829,7 +829,7 @@ error: 'Supplied key field type does not match index type: expected u32' # BitsetIndex: BITS_ALL_NOT_SET (multiple bit) #-----------------------------------------------------------------------------# -lua dump(box.index.BITS_ALL_NOT_SET, 3) +dump(box.index.BITS_ALL_NOT_SET, 3) --- sorted output $ 4$ @@ -865,7 +865,7 @@ $ 120$ $ 124$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 7) +dump(box.index.BITS_ALL_NOT_SET, 7) --- sorted output $ 8$ @@ -885,7 +885,7 @@ $ 112$ $ 120$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 10) +dump(box.index.BITS_ALL_NOT_SET, 10) --- sorted output $ 1$ @@ -921,7 +921,7 @@ $ 116$ $ 117$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 27) +dump(box.index.BITS_ALL_NOT_SET, 27) --- sorted output $ 4$ @@ -933,7 +933,7 @@ $ 96$ $ 100$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 85) +dump(box.index.BITS_ALL_NOT_SET, 85) --- sorted output $ 2$ @@ -945,7 +945,7 @@ $ 40$ $ 42$ $ 128$ ... -lua dump(box.index.BITS_ALL_NOT_SET, 4294967295) +dump(box.index.BITS_ALL_NOT_SET, 4294967295) --- sorted output ... @@ -954,11 +954,11 @@ sorted output # BitsetIndex: BITS_ANY_SET (single bit) #-----------------------------------------------------------------------------# -lua dump(box.index.BITS_ANY_SET, 0) +dump(box.index.BITS_ANY_SET, 0) --- sorted output ... -lua dump(box.index.BITS_ANY_SET, 16) +dump(box.index.BITS_ANY_SET, 16) --- sorted output $ 16$ @@ -1026,12 +1026,12 @@ $ 125$ $ 126$ $ 127$ ... -lua dump(box.index.BITS_ANY_SET, 128) +dump(box.index.BITS_ANY_SET, 128) --- sorted output $ 128$ ... -lua dump(box.index.BITS_ANY_SET, 4294967296) +dump(box.index.BITS_ANY_SET, 4294967296) --- error: 'Supplied key field type does not match index type: expected u32' ... @@ -1040,7 +1040,7 @@ error: 'Supplied key field type does not match index type: expected u32' # BitsetIndex: BITS_ANY_SET (multiple bit) #-----------------------------------------------------------------------------# -lua dump(box.index.BITS_ANY_SET, 7) +dump(box.index.BITS_ANY_SET, 7) --- sorted output $ 1$ @@ -1156,7 +1156,7 @@ $ 125$ $ 126$ $ 127$ ... -lua dump(box.index.BITS_ANY_SET, 84) +dump(box.index.BITS_ANY_SET, 84) --- sorted output $ 4$ @@ -1272,7 +1272,7 @@ $ 125$ $ 126$ $ 127$ ... -lua dump(box.index.BITS_ANY_SET, 113) +dump(box.index.BITS_ANY_SET, 113) --- sorted output $ 1$ diff --git a/test/big/bitset.test b/test/big/bitset.test index fe89b7fc0f96e317bdd8b2aafc987ca2dd1edf01..985301f0562649745cdbe634c24bbf3908897a45 100644 --- a/test/big/bitset.test +++ b/test/big/bitset.test @@ -8,7 +8,7 @@ for file in ("utils.lua", "bitset.lua"): src_path = os.path.join("big/", file) dst_path = os.path.join(vardir, file) shutil.copy(src_path, dst_path) - admin("lua dofile('%s')" % (file)) + admin("dofile('%s')" % (file)) os.unlink(dst_path); print """ @@ -17,7 +17,7 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua test_insert_delete(128)") +admin("test_insert_delete(128)") print """ #-----------------------------------------------------------------------------# @@ -25,9 +25,9 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua clear()") -admin("lua fill(1, 128)") -admin("lua dump(box.index.BITS_ALL)") +admin("clear()") +admin("fill(1, 128)") +admin("dump(box.index.BITS_ALL)") print """ #-----------------------------------------------------------------------------# @@ -35,14 +35,14 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua dump(box.index.BITS_ALL_SET, 0)") +admin("dump(box.index.BITS_ALL_SET, 0)") -admin("lua dump(box.index.BITS_ALL_SET, 1)") -admin("lua dump(box.index.BITS_ALL_SET, 2)") -admin("lua dump(box.index.BITS_ALL_SET, 8)") -admin("lua dump(box.index.BITS_ALL_SET, 1073741824)") -admin("lua dump(box.index.BITS_ALL_SET, 2147483648)") -admin("lua dump(box.index.BITS_ALL_SET, 4294967296)") +admin("dump(box.index.BITS_ALL_SET, 1)") +admin("dump(box.index.BITS_ALL_SET, 2)") +admin("dump(box.index.BITS_ALL_SET, 8)") +admin("dump(box.index.BITS_ALL_SET, 1073741824)") +admin("dump(box.index.BITS_ALL_SET, 2147483648)") +admin("dump(box.index.BITS_ALL_SET, 4294967296)") print """ #-----------------------------------------------------------------------------# @@ -50,15 +50,15 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua dump(box.index.BITS_ALL_SET, 3)") -admin("lua dump(box.index.BITS_ALL_SET, 7)") -admin("lua dump(box.index.BITS_ALL_SET, 31)") -admin("lua dump(box.index.BITS_ALL_SET, 5)") -admin("lua dump(box.index.BITS_ALL_SET, 10)") -admin("lua dump(box.index.BITS_ALL_SET, 27)") -admin("lua dump(box.index.BITS_ALL_SET, 341)") -admin("lua dump(box.index.BITS_ALL_SET, 2147483649)") -admin("lua dump(box.index.BITS_ALL_SET, 4294967295)") +admin("dump(box.index.BITS_ALL_SET, 3)") +admin("dump(box.index.BITS_ALL_SET, 7)") +admin("dump(box.index.BITS_ALL_SET, 31)") +admin("dump(box.index.BITS_ALL_SET, 5)") +admin("dump(box.index.BITS_ALL_SET, 10)") +admin("dump(box.index.BITS_ALL_SET, 27)") +admin("dump(box.index.BITS_ALL_SET, 341)") +admin("dump(box.index.BITS_ALL_SET, 2147483649)") +admin("dump(box.index.BITS_ALL_SET, 4294967295)") print """ #-----------------------------------------------------------------------------# @@ -66,11 +66,11 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua dump(box.index.BITS_ALL_NOT_SET, 0)") +admin("dump(box.index.BITS_ALL_NOT_SET, 0)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 2)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 8)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 4294967296)") +admin("dump(box.index.BITS_ALL_NOT_SET, 2)") +admin("dump(box.index.BITS_ALL_NOT_SET, 8)") +admin("dump(box.index.BITS_ALL_NOT_SET, 4294967296)") print """ #-----------------------------------------------------------------------------# @@ -78,12 +78,12 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua dump(box.index.BITS_ALL_NOT_SET, 3)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 7)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 10)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 27)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 85)") -admin("lua dump(box.index.BITS_ALL_NOT_SET, 4294967295)") +admin("dump(box.index.BITS_ALL_NOT_SET, 3)") +admin("dump(box.index.BITS_ALL_NOT_SET, 7)") +admin("dump(box.index.BITS_ALL_NOT_SET, 10)") +admin("dump(box.index.BITS_ALL_NOT_SET, 27)") +admin("dump(box.index.BITS_ALL_NOT_SET, 85)") +admin("dump(box.index.BITS_ALL_NOT_SET, 4294967295)") print """ #-----------------------------------------------------------------------------# @@ -91,11 +91,11 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua dump(box.index.BITS_ANY_SET, 0)") +admin("dump(box.index.BITS_ANY_SET, 0)") -admin("lua dump(box.index.BITS_ANY_SET, 16)") -admin("lua dump(box.index.BITS_ANY_SET, 128)") -admin("lua dump(box.index.BITS_ANY_SET, 4294967296)") +admin("dump(box.index.BITS_ANY_SET, 16)") +admin("dump(box.index.BITS_ANY_SET, 128)") +admin("dump(box.index.BITS_ANY_SET, 4294967296)") print """ #-----------------------------------------------------------------------------# @@ -103,6 +103,6 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua dump(box.index.BITS_ANY_SET, 7)") -admin("lua dump(box.index.BITS_ANY_SET, 84)") -admin("lua dump(box.index.BITS_ANY_SET, 113)") +admin("dump(box.index.BITS_ANY_SET, 7)") +admin("dump(box.index.BITS_ANY_SET, 84)") +admin("dump(box.index.BITS_ANY_SET, 113)") diff --git a/test/big/hash.result b/test/big/hash.result index 6ed4f4de56e5b290a058e9a90c02ef66e1793578..758b09e6e9d52bd9896c8d545780cecf50487060 100644 --- a/test/big/hash.result +++ b/test/big/hash.result @@ -11,26 +11,26 @@ # Insert valid fieds -lua box.space[10]:insert(0, 'value1 v1.0', 'value2 v1.0') +box.space[10]:insert(0, 'value1 v1.0', 'value2 v1.0') --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[10]:insert(1, 'value1 v1.0', 'value2 v1.0') +box.space[10]:insert(1, 'value1 v1.0', 'value2 v1.0') --- - 1: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[10]:insert(2, 'value1 v1.0', 'value2 v1.0') +box.space[10]:insert(2, 'value1 v1.0', 'value2 v1.0') --- - 2: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[10]:insert(3, 'value1 v1.0', 'value2 v1.0') +box.space[10]:insert(3, 'value1 v1.0', 'value2 v1.0') --- - 3: {'value1 v1.0', 'value2 v1.0'} ... # Insert invalid fields -lua box.space[10]:insert('invalid key', 'value1 v1.0', 'value2 v1.0') +box.space[10]:insert('invalid key', 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM' ... @@ -42,22 +42,22 @@ error: 'Supplied key field type does not match index type: expected NUM' # Replace valid fieds -lua box.space[10]:replace(3, 'value1 v1.31', 'value2 1.12') +box.space[10]:replace(3, 'value1 v1.31', 'value2 1.12') --- - 3: {'value1 v1.31', 'value2 1.12'} ... -lua box.space[10]:replace(1, 'value1 v1.32', 'value2 1.72') +box.space[10]:replace(1, 'value1 v1.32', 'value2 1.72') --- - 1: {'value1 v1.32', 'value2 1.72'} ... -lua box.space[10]:replace(2, 'value1 v1.43', 'value2 1.92') +box.space[10]:replace(2, 'value1 v1.43', 'value2 1.92') --- - 2: {'value1 v1.43', 'value2 1.92'} ... # Replace invalid fields -lua box.space[10]:replace('invalid key', 'value1 v1.0', 'value2 v1.0') +box.space[10]:replace('invalid key', 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM' ... @@ -69,36 +69,36 @@ error: 'Supplied key field type does not match index type: expected NUM' # select by valid keys -lua box.space[10]:select(0, 0) +box.space[10]:select(0, 0) --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[10]:select(0, 1) +box.space[10]:select(0, 1) --- - 1: {'value1 v1.32', 'value2 1.72'} ... -lua box.space[10]:select(0, 2) +box.space[10]:select(0, 2) --- - 2: {'value1 v1.43', 'value2 1.92'} ... -lua box.space[10]:select(0, 3) +box.space[10]:select(0, 3) --- - 3: {'value1 v1.31', 'value2 1.12'} ... -lua box.space[10]:select(0, 4) +box.space[10]:select(0, 4) --- ... -lua box.space[10]:select(0, 5) +box.space[10]:select(0, 5) --- ... # select by invalid keys -lua box.space[10]:select(0, 'invalid key') +box.space[10]:select(0, 'invalid key') --- error: 'Supplied key field type does not match index type: expected u32' ... -lua box.space[10]:select(0, 1, 2) +box.space[10]:select(0, 1, 2) --- error: 'Invalid key part count (expected [0..1], got 2)' ... @@ -110,36 +110,36 @@ error: 'Invalid key part count (expected [0..1], got 2)' # delete by valid keys -lua box.space[10]:delete(0) +box.space[10]:delete(0) --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[10]:delete(1) +box.space[10]:delete(1) --- - 1: {'value1 v1.32', 'value2 1.72'} ... -lua box.space[10]:delete(2) +box.space[10]:delete(2) --- - 2: {'value1 v1.43', 'value2 1.92'} ... -lua box.space[10]:delete(3) +box.space[10]:delete(3) --- - 3: {'value1 v1.31', 'value2 1.12'} ... -lua box.space[10]:delete(4) +box.space[10]:delete(4) --- ... -lua box.space[10]:delete(5) +box.space[10]:delete(5) --- ... # delete by invalid keys -lua box.space[10]:delete('invalid key') +box.space[10]:delete('invalid key') --- error: 'Supplied key field type does not match index type: expected u32' ... -lua box.space[10]:delete(1, 2) +box.space[10]:delete(1, 2) --- error: 'Invalid key part count in an exact match (expected 1, got 2)' ... @@ -156,42 +156,42 @@ error: 'Invalid key part count in an exact match (expected 1, got 2)' # Insert valid fieds -lua box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0') --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0') --- - 1: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0') --- - 2: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0') --- - 3: {'value1 v1.0', 'value2 v1.0'} ... # Insert invalid fields -lua box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM64' ... -lua box.space[11]:insert(101, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(101, 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM64' ... -lua box.space[11]:insert(102, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(102, 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM64' ... -lua box.space[11]:insert(103, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(103, 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM64' ... -lua box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM64' ... @@ -203,34 +203,34 @@ error: 'Supplied key field type does not match index type: expected NUM64' # Replace valid fieds -lua box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12') +box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12') --- - 3: {'value1 v1.31', 'value2 1.12'} ... -lua box.space[11]:replace(1ULL, 'value1 v1.32', 'value2 1.72') +box.space[11]:replace(1ULL, 'value1 v1.32', 'value2 1.72') --- - 1: {'value1 v1.32', 'value2 1.72'} ... -lua box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92') +box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92') --- - 2: {'value1 v1.43', 'value2 1.92'} ... # Replace invalid fields -lua box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12') +box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12') --- error: 'Supplied key field type does not match index type: expected NUM64' ... -lua box.space[11]:replace(1, 'value1 v1.32', 'value2 1.72') +box.space[11]:replace(1, 'value1 v1.32', 'value2 1.72') --- error: 'Supplied key field type does not match index type: expected NUM64' ... -lua box.space[11]:replace(2, 'value1 v1.43', 'value2 1.92') +box.space[11]:replace(2, 'value1 v1.43', 'value2 1.92') --- error: 'Supplied key field type does not match index type: expected NUM64' ... -lua box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0') +box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0') --- error: 'Supplied key field type does not match index type: expected NUM64' ... @@ -242,61 +242,61 @@ error: 'Supplied key field type does not match index type: expected NUM64' # select by valid keys -lua box.space[11]:select(0, 0ULL) +box.space[11]:select(0, 0ULL) --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:select(0, 1ULL) +box.space[11]:select(0, 1ULL) --- - 1: {'value1 v1.32', 'value2 1.72'} ... -lua box.space[11]:select(0, 2ULL) +box.space[11]:select(0, 2ULL) --- - 2: {'value1 v1.43', 'value2 1.92'} ... -lua box.space[11]:select(0, 3ULL) +box.space[11]:select(0, 3ULL) --- - 3: {'value1 v1.31', 'value2 1.12'} ... -lua box.space[11]:select(0, 4ULL) +box.space[11]:select(0, 4ULL) --- ... -lua box.space[11]:select(0, 5ULL) +box.space[11]:select(0, 5ULL) --- ... # select by valid NUM keys -lua box.space[11]:select(0, 0) +box.space[11]:select(0, 0) --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:select(0, 1) +box.space[11]:select(0, 1) --- - 1: {'value1 v1.32', 'value2 1.72'} ... -lua box.space[11]:select(0, 2) +box.space[11]:select(0, 2) --- - 2: {'value1 v1.43', 'value2 1.92'} ... -lua box.space[11]:select(0, 3) +box.space[11]:select(0, 3) --- - 3: {'value1 v1.31', 'value2 1.12'} ... -lua box.space[11]:select(0, 4) +box.space[11]:select(0, 4) --- ... -lua box.space[11]:select(0, 5) +box.space[11]:select(0, 5) --- ... # select by invalid keys -lua box.space[11]:select(0, 'invalid key') +box.space[11]:select(0, 'invalid key') --- error: 'Supplied key field type does not match index type: expected u64' ... -lua box.space[11]:select(0, '00000001', '00000002') +box.space[11]:select(0, '00000001', '00000002') --- error: 'Invalid key part count (expected [0..1], got 2)' ... @@ -308,77 +308,77 @@ error: 'Invalid key part count (expected [0..1], got 2)' # delete by valid keys -lua box.space[11]:delete(0ULL) +box.space[11]:delete(0ULL) --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:delete(1ULL) +box.space[11]:delete(1ULL) --- - 1: {'value1 v1.32', 'value2 1.72'} ... -lua box.space[11]:delete(2ULL) +box.space[11]:delete(2ULL) --- - 2: {'value1 v1.43', 'value2 1.92'} ... -lua box.space[11]:delete(3ULL) +box.space[11]:delete(3ULL) --- - 3: {'value1 v1.31', 'value2 1.12'} ... -lua box.space[11]:delete(4ULL) +box.space[11]:delete(4ULL) --- ... -lua box.space[11]:delete(5ULL) +box.space[11]:delete(5ULL) --- ... -lua box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0') --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0') --- - 1: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0') --- - 2: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0') +box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0') --- - 3: {'value1 v1.0', 'value2 v1.0'} ... # delete by valid NUM keys -lua box.space[11]:delete(0) +box.space[11]:delete(0) --- - 0: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:delete(1) +box.space[11]:delete(1) --- - 1: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:delete(2) +box.space[11]:delete(2) --- - 2: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:delete(3) +box.space[11]:delete(3) --- - 3: {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[11]:delete(4) +box.space[11]:delete(4) --- ... -lua box.space[11]:delete(5) +box.space[11]:delete(5) --- ... # delete by invalid keys -lua box.space[11]:delete('invalid key') +box.space[11]:delete('invalid key') --- error: 'Supplied key field type does not match index type: expected u64' ... -lua box.space[11]:delete('00000001', '00000002') +box.space[11]:delete('00000001', '00000002') --- error: 'Invalid key part count in an exact match (expected 1, got 2)' ... @@ -395,19 +395,19 @@ error: 'Invalid key part count in an exact match (expected 1, got 2)' # Insert valid fieds -lua box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0') +box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0') --- - 'key 0': {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[12]:insert('key 1', 'value1 v1.0', 'value2 v1.0') +box.space[12]:insert('key 1', 'value1 v1.0', 'value2 v1.0') --- - 'key 1': {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[12]:insert('key 2', 'value1 v1.0', 'value2 v1.0') +box.space[12]:insert('key 2', 'value1 v1.0', 'value2 v1.0') --- - 'key 2': {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0') +box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0') --- - 'key 3': {'value1 v1.0', 'value2 v1.0'} ... @@ -419,15 +419,15 @@ lua box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0') # Replace valid fieds -lua box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12') +box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12') --- - 'key 3': {'value1 v1.31', 'value2 1.12'} ... -lua box.space[12]:replace('key 1', 'value1 v1.32', 'value2 1.72') +box.space[12]:replace('key 1', 'value1 v1.32', 'value2 1.72') --- - 'key 1': {'value1 v1.32', 'value2 1.72'} ... -lua box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92') +box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92') --- - 'key 2': {'value1 v1.43', 'value2 1.92'} ... @@ -439,32 +439,32 @@ lua box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92') # select by valid keys -lua box.space[12]:select(0, 'key 0') +box.space[12]:select(0, 'key 0') --- - 'key 0': {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[12]:select(0, 'key 1') +box.space[12]:select(0, 'key 1') --- - 'key 1': {'value1 v1.32', 'value2 1.72'} ... -lua box.space[12]:select(0, 'key 2') +box.space[12]:select(0, 'key 2') --- - 'key 2': {'value1 v1.43', 'value2 1.92'} ... -lua box.space[12]:select(0, 'key 3') +box.space[12]:select(0, 'key 3') --- - 'key 3': {'value1 v1.31', 'value2 1.12'} ... -lua box.space[12]:select(0, 'key 4') +box.space[12]:select(0, 'key 4') --- ... -lua box.space[12]:select(0, 'key 5') +box.space[12]:select(0, 'key 5') --- ... # select by invalid keys -lua box.space[12]:select(0, 'key 1', 'key 2') +box.space[12]:select(0, 'key 1', 'key 2') --- error: 'Invalid key part count (expected [0..1], got 2)' ... @@ -476,45 +476,45 @@ error: 'Invalid key part count (expected [0..1], got 2)' # delete by valid keys -lua box.space[12]:delete('key 0') +box.space[12]:delete('key 0') --- - 'key 0': {'value1 v1.0', 'value2 v1.0'} ... -lua box.space[12]:delete('key 1') +box.space[12]:delete('key 1') --- - 'key 1': {'value1 v1.32', 'value2 1.72'} ... -lua box.space[12]:delete('key 2') +box.space[12]:delete('key 2') --- - 'key 2': {'value1 v1.43', 'value2 1.92'} ... -lua box.space[12]:delete('key 3') +box.space[12]:delete('key 3') --- - 'key 3': {'value1 v1.31', 'value2 1.12'} ... -lua box.space[12]:delete('key 4') +box.space[12]:delete('key 4') --- ... -lua box.space[12]:delete('key 5') +box.space[12]:delete('key 5') --- ... # delete by invalid keys -lua box.space[12]:delete('key 1', 'key 2') +box.space[12]:delete('key 1', 'key 2') --- error: 'Invalid key part count in an exact match (expected 1, got 2)' ... -lua box.space[10]:truncate() +box.space[10]:truncate() --- ... -lua box.space[11]:truncate() +box.space[11]:truncate() --- ... -lua box.space[12]:truncate() +box.space[12]:truncate() --- ... -lua box.space[21]:truncate() +box.space[21]:truncate() --- ... insert into t21 values (0, 0, 0, 0) @@ -636,6 +636,6 @@ No match select * from t21 WHERE k3 = 0 Found 1 tuple: [0, 0, 0, 0] -lua box.space[21]:truncate() +box.space[21]:truncate() --- ... diff --git a/test/big/hash.test b/test/big/hash.test index 6625705d8b2d0dc8336e1e3ec7e56dec8f3e0095..76b5b153e6cf7cbfafd73cbef73c82a974f96c41 100644 --- a/test/big/hash.test +++ b/test/big/hash.test @@ -16,15 +16,15 @@ print """ print """ # Insert valid fieds """ -admin("lua box.space[10]:insert(0, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[10]:insert(1, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[10]:insert(2, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[10]:insert(3, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[10]:insert(0, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[10]:insert(1, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[10]:insert(2, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[10]:insert(3, 'value1 v1.0', 'value2 v1.0')") print """ # Insert invalid fields """ -admin("lua box.space[10]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[10]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')") print """ @@ -36,14 +36,14 @@ print """ print """ # Replace valid fieds """ -admin("lua box.space[10]:replace(3, 'value1 v1.31', 'value2 1.12')") -admin("lua box.space[10]:replace(1, 'value1 v1.32', 'value2 1.72')") -admin("lua box.space[10]:replace(2, 'value1 v1.43', 'value2 1.92')") +admin("box.space[10]:replace(3, 'value1 v1.31', 'value2 1.12')") +admin("box.space[10]:replace(1, 'value1 v1.32', 'value2 1.72')") +admin("box.space[10]:replace(2, 'value1 v1.43', 'value2 1.92')") print """ # Replace invalid fields """ -admin("lua box.space[10]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[10]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')") print """ @@ -55,18 +55,18 @@ print """ print """ # select by valid keys """ -admin("lua box.space[10]:select(0, 0)") -admin("lua box.space[10]:select(0, 1)") -admin("lua box.space[10]:select(0, 2)") -admin("lua box.space[10]:select(0, 3)") -admin("lua box.space[10]:select(0, 4)") -admin("lua box.space[10]:select(0, 5)") +admin("box.space[10]:select(0, 0)") +admin("box.space[10]:select(0, 1)") +admin("box.space[10]:select(0, 2)") +admin("box.space[10]:select(0, 3)") +admin("box.space[10]:select(0, 4)") +admin("box.space[10]:select(0, 5)") print """ # select by invalid keys """ -admin("lua box.space[10]:select(0, 'invalid key')") -admin("lua box.space[10]:select(0, 1, 2)") +admin("box.space[10]:select(0, 'invalid key')") +admin("box.space[10]:select(0, 1, 2)") print """ @@ -78,18 +78,18 @@ print """ print """ # delete by valid keys """ -admin("lua box.space[10]:delete(0)") -admin("lua box.space[10]:delete(1)") -admin("lua box.space[10]:delete(2)") -admin("lua box.space[10]:delete(3)") -admin("lua box.space[10]:delete(4)") -admin("lua box.space[10]:delete(5)") +admin("box.space[10]:delete(0)") +admin("box.space[10]:delete(1)") +admin("box.space[10]:delete(2)") +admin("box.space[10]:delete(3)") +admin("box.space[10]:delete(4)") +admin("box.space[10]:delete(5)") print """ # delete by invalid keys """ -admin("lua box.space[10]:delete('invalid key')") -admin("lua box.space[10]:delete(1, 2)") +admin("box.space[10]:delete('invalid key')") +admin("box.space[10]:delete(1, 2)") print """ @@ -107,19 +107,19 @@ print """ print """ # Insert valid fieds """ -admin("lua box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')") print """ # Insert invalid fields """ -admin("lua box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(101, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(102, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(103, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(100, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(101, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(102, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(103, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert('invalid key', 'value1 v1.0', 'value2 v1.0')") print """ #-----------------------------------------------------------------------------# @@ -130,17 +130,17 @@ print """ print """ # Replace valid fieds """ -admin("lua box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12')") -admin("lua box.space[11]:replace(1ULL, 'value1 v1.32', 'value2 1.72')") -admin("lua box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92')") +admin("box.space[11]:replace(3ULL, 'value1 v1.31', 'value2 1.12')") +admin("box.space[11]:replace(1ULL, 'value1 v1.32', 'value2 1.72')") +admin("box.space[11]:replace(2ULL, 'value1 v1.43', 'value2 1.92')") print """ # Replace invalid fields """ -admin("lua box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12')") -admin("lua box.space[11]:replace(1, 'value1 v1.32', 'value2 1.72')") -admin("lua box.space[11]:replace(2, 'value1 v1.43', 'value2 1.92')") -admin("lua box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:replace(3, 'value1 v1.31', 'value2 1.12')") +admin("box.space[11]:replace(1, 'value1 v1.32', 'value2 1.72')") +admin("box.space[11]:replace(2, 'value1 v1.43', 'value2 1.92')") +admin("box.space[11]:replace('invalid key', 'value1 v1.0', 'value2 v1.0')") print """ #-----------------------------------------------------------------------------# @@ -151,28 +151,28 @@ print """ print """ # select by valid keys """ -admin("lua box.space[11]:select(0, 0ULL)") -admin("lua box.space[11]:select(0, 1ULL)") -admin("lua box.space[11]:select(0, 2ULL)") -admin("lua box.space[11]:select(0, 3ULL)") -admin("lua box.space[11]:select(0, 4ULL)") -admin("lua box.space[11]:select(0, 5ULL)") +admin("box.space[11]:select(0, 0ULL)") +admin("box.space[11]:select(0, 1ULL)") +admin("box.space[11]:select(0, 2ULL)") +admin("box.space[11]:select(0, 3ULL)") +admin("box.space[11]:select(0, 4ULL)") +admin("box.space[11]:select(0, 5ULL)") print """ # select by valid NUM keys """ -admin("lua box.space[11]:select(0, 0)") -admin("lua box.space[11]:select(0, 1)") -admin("lua box.space[11]:select(0, 2)") -admin("lua box.space[11]:select(0, 3)") -admin("lua box.space[11]:select(0, 4)") -admin("lua box.space[11]:select(0, 5)") +admin("box.space[11]:select(0, 0)") +admin("box.space[11]:select(0, 1)") +admin("box.space[11]:select(0, 2)") +admin("box.space[11]:select(0, 3)") +admin("box.space[11]:select(0, 4)") +admin("box.space[11]:select(0, 5)") print """ # select by invalid keys """ -admin("lua box.space[11]:select(0, 'invalid key')") -admin("lua box.space[11]:select(0, '00000001', '00000002')") +admin("box.space[11]:select(0, 'invalid key')") +admin("box.space[11]:select(0, '00000001', '00000002')") print """ #-----------------------------------------------------------------------------# @@ -183,33 +183,33 @@ print """ print """ # delete by valid keys """ -admin("lua box.space[11]:delete(0ULL)") -admin("lua box.space[11]:delete(1ULL)") -admin("lua box.space[11]:delete(2ULL)") -admin("lua box.space[11]:delete(3ULL)") -admin("lua box.space[11]:delete(4ULL)") -admin("lua box.space[11]:delete(5ULL)") +admin("box.space[11]:delete(0ULL)") +admin("box.space[11]:delete(1ULL)") +admin("box.space[11]:delete(2ULL)") +admin("box.space[11]:delete(3ULL)") +admin("box.space[11]:delete(4ULL)") +admin("box.space[11]:delete(5ULL)") -admin("lua box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(0ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(1ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(2ULL, 'value1 v1.0', 'value2 v1.0')") +admin("box.space[11]:insert(3ULL, 'value1 v1.0', 'value2 v1.0')") print """ # delete by valid NUM keys """ -admin("lua box.space[11]:delete(0)") -admin("lua box.space[11]:delete(1)") -admin("lua box.space[11]:delete(2)") -admin("lua box.space[11]:delete(3)") -admin("lua box.space[11]:delete(4)") -admin("lua box.space[11]:delete(5)") +admin("box.space[11]:delete(0)") +admin("box.space[11]:delete(1)") +admin("box.space[11]:delete(2)") +admin("box.space[11]:delete(3)") +admin("box.space[11]:delete(4)") +admin("box.space[11]:delete(5)") print """ # delete by invalid keys """ -admin("lua box.space[11]:delete('invalid key')") -admin("lua box.space[11]:delete('00000001', '00000002')") +admin("box.space[11]:delete('invalid key')") +admin("box.space[11]:delete('00000001', '00000002')") print """ @@ -227,10 +227,10 @@ print """ print """ # Insert valid fieds """ -admin("lua box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[12]:insert('key 1', 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[12]:insert('key 2', 'value1 v1.0', 'value2 v1.0')") -admin("lua box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[12]:insert('key 0', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[12]:insert('key 1', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[12]:insert('key 2', 'value1 v1.0', 'value2 v1.0')") +admin("box.space[12]:insert('key 3', 'value1 v1.0', 'value2 v1.0')") print """ @@ -242,9 +242,9 @@ print """ print """ # Replace valid fieds """ -admin("lua box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12')") -admin("lua box.space[12]:replace('key 1', 'value1 v1.32', 'value2 1.72')") -admin("lua box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92')") +admin("box.space[12]:replace('key 3', 'value1 v1.31', 'value2 1.12')") +admin("box.space[12]:replace('key 1', 'value1 v1.32', 'value2 1.72')") +admin("box.space[12]:replace('key 2', 'value1 v1.43', 'value2 1.92')") print """ @@ -256,17 +256,17 @@ print """ print """ # select by valid keys """ -admin("lua box.space[12]:select(0, 'key 0')") -admin("lua box.space[12]:select(0, 'key 1')") -admin("lua box.space[12]:select(0, 'key 2')") -admin("lua box.space[12]:select(0, 'key 3')") -admin("lua box.space[12]:select(0, 'key 4')") -admin("lua box.space[12]:select(0, 'key 5')") +admin("box.space[12]:select(0, 'key 0')") +admin("box.space[12]:select(0, 'key 1')") +admin("box.space[12]:select(0, 'key 2')") +admin("box.space[12]:select(0, 'key 3')") +admin("box.space[12]:select(0, 'key 4')") +admin("box.space[12]:select(0, 'key 5')") print """ # select by invalid keys """ -admin("lua box.space[12]:select(0, 'key 1', 'key 2')") +admin("box.space[12]:select(0, 'key 1', 'key 2')") print """ @@ -278,28 +278,28 @@ print """ print """ # delete by valid keys """ -admin("lua box.space[12]:delete('key 0')") -admin("lua box.space[12]:delete('key 1')") -admin("lua box.space[12]:delete('key 2')") -admin("lua box.space[12]:delete('key 3')") -admin("lua box.space[12]:delete('key 4')") -admin("lua box.space[12]:delete('key 5')") +admin("box.space[12]:delete('key 0')") +admin("box.space[12]:delete('key 1')") +admin("box.space[12]:delete('key 2')") +admin("box.space[12]:delete('key 3')") +admin("box.space[12]:delete('key 4')") +admin("box.space[12]:delete('key 5')") print """ # delete by invalid keys """ -admin("lua box.space[12]:delete('key 1', 'key 2')") +admin("box.space[12]:delete('key 1', 'key 2')") # clean-up -admin("lua box.space[10]:truncate()") -admin("lua box.space[11]:truncate()") -admin("lua box.space[12]:truncate()") +admin("box.space[10]:truncate()") +admin("box.space[11]:truncate()") +admin("box.space[12]:truncate()") # # hash::replace tests # -admin("lua box.space[21]:truncate()") +admin("box.space[21]:truncate()") sql("insert into t21 values (0, 0, 0, 0)") sql("insert into t21 values (1, 1, 1, 1)") @@ -374,4 +374,4 @@ sql("select * from t21 WHERE k2 = 10") sql("select * from t21 WHERE k3 = 10") sql("select * from t21 WHERE k3 = 0") -admin("lua box.space[21]:truncate()") +admin("box.space[21]:truncate()") diff --git a/test/big/hash_multipart.result b/test/big/hash_multipart.result index 9c2a07d05c84664fa7db991ebaa02cf16bbca93a..f0b858fc8dcf9431a3ceedde0d026bc3c1326092 100644 --- a/test/big/hash_multipart.result +++ b/test/big/hash_multipart.result @@ -16,7 +16,7 @@ insert into t27 values (1, 'bar', 1, '', 4) Insert OK, 1 row affected insert into t27 values (1, 'bar', 1, '', 5) An error occurred: ER_TUPLE_FOUND, 'Duplicate key exists in unique index 0' -lua function box.select_all(space) space = tonumber(space) local result = {} for k, v in box.space[space]:pairs() do table.insert(result, v) end return unpack(result) end + function box.select_all(space) space = tonumber(space) local result = {} for k, v in box.space[space]:pairs() do table.insert(result, v) end return unpack(result) end --- ... call box.select_all('27') @@ -29,45 +29,45 @@ Found 8 tuples: [1, 'bar', 1, '', 4] [1, 'foo', 0, '', 2] [1, 'foo', 1, '', 2] -lua box.select(27, 0, 1, 'foo', 0) +box.select(27, 0, 1, 'foo', 0) --- - 1: {'foo', 0, '', 2} ... -lua box.select(27, 0, 1, 'bar', 0) +box.select(27, 0, 1, 'bar', 0) --- - 1: {'bar', 0, '', 4} ... -lua box.select(27, 0, 1, 'foo') +box.select(27, 0, 1, 'foo') --- error: 'Invalid key part count in an exact match (expected 3, got 2)' ... -lua box.select(27, 0, 1, 'foo', 0, 0) +box.select(27, 0, 1, 'foo', 0, 0) --- error: 'Invalid key part count (expected [0..3], got 4)' ... -lua box.select(27, 0, 1, 'foo', 'baz') +box.select(27, 0, 1, 'foo', 'baz') --- error: 'Supplied key field type does not match index type: expected u32' ... -lua box.select(27, 1, 1, 4) +box.select(27, 1, 1, 4) --- - 1: {'bar', 1, '', 4} ... -lua box.select(27, 1, 1, 5) +box.select(27, 1, 1, 5) --- ... -lua box.select(27, 1, 1) +box.select(27, 1, 1) --- error: 'Invalid key part count in an exact match (expected 2, got 1)' ... -lua box.select(27, 1, 1, 'baz') +box.select(27, 1, 1, 'baz') --- error: 'Supplied key field type does not match index type: expected u32' ... -lua box.space[27]:truncate() +box.space[27]:truncate() --- ... -lua box.space[27]:len() +box.space[27]:len() --- - 0 ... diff --git a/test/big/hash_multipart.test b/test/big/hash_multipart.test index 63451042aa79ddaf5fcafee07db89c87c34d4e31..178dd696d0e44a126c77c5dc539436de2beba567 100644 --- a/test/big/hash_multipart.test +++ b/test/big/hash_multipart.test @@ -24,30 +24,30 @@ function box.select_all(space) return unpack(result) end """ -admin("lua " + lua_code.replace('\n', ' ')) +admin(lua_code.replace('\n', ' ')) sql.sort = True sql("call box.select_all('27')") sql.sort = False # primary index select -admin("lua box.select(27, 0, 1, 'foo', 0)") -admin("lua box.select(27, 0, 1, 'bar', 0)") +admin("box.select(27, 0, 1, 'foo', 0)") +admin("box.select(27, 0, 1, 'bar', 0)") # primary index slect with missing part -admin("lua box.select(27, 0, 1, 'foo')") +admin("box.select(27, 0, 1, 'foo')") # primary index slect with extra part -admin("lua box.select(27, 0, 1, 'foo', 0, 0)") +admin("box.select(27, 0, 1, 'foo', 0, 0)") # primary index select with wrong type -admin("lua box.select(27, 0, 1, 'foo', 'baz')") +admin("box.select(27, 0, 1, 'foo', 'baz')") # secondary index select -admin("lua box.select(27, 1, 1, 4)") +admin("box.select(27, 1, 1, 4)") # secondary index select with no such key -admin("lua box.select(27, 1, 1, 5)") +admin("box.select(27, 1, 1, 5)") # secondary index select with missing part -admin("lua box.select(27, 1, 1)") +admin("box.select(27, 1, 1)") # secondary index select with wrong type -admin("lua box.select(27, 1, 1, 'baz')") +admin("box.select(27, 1, 1, 'baz')") # cleanup -admin("lua box.space[27]:truncate()") -admin("lua box.space[27]:len()") +admin("box.space[27]:truncate()") +admin("box.space[27]:len()") diff --git a/test/big/iterator.result b/test/big/iterator.result index 1c832db3fdf2f25c8526613911879a6a91c76c10..65baf70a82e75336aa8dac0cddb9fcfeacf1d36a 100644 --- a/test/big/iterator.result +++ b/test/big/iterator.result @@ -1,43 +1,43 @@ -lua dofile('utils.lua') +dofile('utils.lua') --- ... -lua box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a') +box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a') --- - 'pid_001': {'sid_001', 'tid_998', 'a'} ... -lua box.insert(20, 'pid_002', 'sid_001', 'tid_997', 'a') +box.insert(20, 'pid_002', 'sid_001', 'tid_997', 'a') --- - 'pid_002': {'sid_001', 'tid_997', 'a'} ... -lua box.insert(20, 'pid_003', 'sid_002', 'tid_997', 'b') +box.insert(20, 'pid_003', 'sid_002', 'tid_997', 'b') --- - 'pid_003': {'sid_002', 'tid_997', 'b'} ... -lua box.insert(20, 'pid_005', 'sid_002', 'tid_996', 'b') +box.insert(20, 'pid_005', 'sid_002', 'tid_996', 'b') --- - 'pid_005': {'sid_002', 'tid_996', 'b'} ... -lua box.insert(20, 'pid_007', 'sid_003', 'tid_996', 'a') +box.insert(20, 'pid_007', 'sid_003', 'tid_996', 'a') --- - 'pid_007': {'sid_003', 'tid_996', 'a'} ... -lua box.insert(20, 'pid_011', 'sid_004', 'tid_996', 'c') +box.insert(20, 'pid_011', 'sid_004', 'tid_996', 'c') --- - 'pid_011': {'sid_004', 'tid_996', 'c'} ... -lua box.insert(20, 'pid_013', 'sid_005', 'tid_996', 'b') +box.insert(20, 'pid_013', 'sid_005', 'tid_996', 'b') --- - 'pid_013': {'sid_005', 'tid_996', 'b'} ... -lua box.insert(20, 'pid_017', 'sid_006', 'tid_996', 'a') +box.insert(20, 'pid_017', 'sid_006', 'tid_996', 'a') --- - 'pid_017': {'sid_006', 'tid_996', 'a'} ... -lua box.insert(20, 'pid_019', 'sid_005', 'tid_995', 'a') +box.insert(20, 'pid_019', 'sid_005', 'tid_995', 'a') --- - 'pid_019': {'sid_005', 'tid_995', 'a'} ... -lua box.insert(20, 'pid_023', 'sid_005', 'tid_994', 'a') +box.insert(20, 'pid_023', 'sid_005', 'tid_994', 'a') --- - 'pid_023': {'sid_005', 'tid_994', 'a'} ... @@ -46,7 +46,7 @@ lua box.insert(20, 'pid_023', 'sid_005', 'tid_994', 'a') # Iterator: tree single-part unique #-----------------------------------------------------------------------------# -lua iterate(20, 0, 0, 1) +iterate(20, 0, 0, 1) --- $pid_001$ $pid_002$ @@ -59,7 +59,7 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 0, 0, 1, box.index.ALL) +iterate(20, 0, 0, 1, box.index.ALL) --- $pid_001$ $pid_002$ @@ -72,7 +72,7 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 0, 0, 1, box.index.EQ) +iterate(20, 0, 0, 1, box.index.EQ) --- $pid_001$ $pid_002$ @@ -85,7 +85,7 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 0, 0, 1, box.index.REQ) +iterate(20, 0, 0, 1, box.index.REQ) --- $pid_023$ $pid_019$ @@ -98,7 +98,7 @@ $pid_003$ $pid_002$ $pid_001$ ... -lua iterate(20, 0, 0, 1, box.index.GE) +iterate(20, 0, 0, 1, box.index.GE) --- $pid_001$ $pid_002$ @@ -111,7 +111,7 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 0, 0, 1, box.index.GT) +iterate(20, 0, 0, 1, box.index.GT) --- $pid_001$ $pid_002$ @@ -124,7 +124,7 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 0, 0, 1, box.index.LE) +iterate(20, 0, 0, 1, box.index.LE) --- $pid_023$ $pid_019$ @@ -137,7 +137,7 @@ $pid_003$ $pid_002$ $pid_001$ ... -lua iterate(20, 0, 0, 1, box.index.LT) +iterate(20, 0, 0, 1, box.index.LT) --- $pid_023$ $pid_019$ @@ -150,21 +150,21 @@ $pid_003$ $pid_002$ $pid_001$ ... -lua iterate(20, 0, 0, 1, box.index.EQ, 'pid_003') +iterate(20, 0, 0, 1, box.index.EQ, 'pid_003') --- $pid_003$ ... -lua iterate(20, 0, 0, 1, box.index.REQ, 'pid_003') +iterate(20, 0, 0, 1, box.index.REQ, 'pid_003') --- $pid_003$ ... -lua iterate(20, 0, 0, 1, box.index.EQ, 'pid_666') +iterate(20, 0, 0, 1, box.index.EQ, 'pid_666') --- ... -lua iterate(20, 0, 0, 1, box.index.REQ, 'pid_666') +iterate(20, 0, 0, 1, box.index.REQ, 'pid_666') --- ... -lua iterate(20, 0, 0, 1, box.index.GE, 'pid_001') +iterate(20, 0, 0, 1, box.index.GE, 'pid_001') --- $pid_001$ $pid_002$ @@ -177,7 +177,7 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 0, 0, 1, box.index.GT, 'pid_001') +iterate(20, 0, 0, 1, box.index.GT, 'pid_001') --- $pid_002$ $pid_003$ @@ -189,25 +189,25 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 0, 0, 1, box.index.GE, 'pid_999') +iterate(20, 0, 0, 1, box.index.GE, 'pid_999') --- ... -lua iterate(20, 0, 0, 1, box.index.GT, 'pid_999') +iterate(20, 0, 0, 1, box.index.GT, 'pid_999') --- ... -lua iterate(20, 0, 0, 1, box.index.LE, 'pid_002') +iterate(20, 0, 0, 1, box.index.LE, 'pid_002') --- $pid_002$ $pid_001$ ... -lua iterate(20, 0, 0, 1, box.index.LT, 'pid_002') +iterate(20, 0, 0, 1, box.index.LT, 'pid_002') --- $pid_001$ ... -lua iterate(20, 0, 0, 1, box.index.LE, 'pid_000') +iterate(20, 0, 0, 1, box.index.LE, 'pid_000') --- ... -lua iterate(20, 0, 0, 1, box.index.LT, 'pid_000') +iterate(20, 0, 0, 1, box.index.LT, 'pid_000') --- ... @@ -215,7 +215,7 @@ lua iterate(20, 0, 0, 1, box.index.LT, 'pid_000') # Iterator: tree single-part non-unique #-----------------------------------------------------------------------------# -lua iterate(20, 1, 1, 2, box.index.ALL) +iterate(20, 1, 1, 2, box.index.ALL) --- $sid_001$ $sid_001$ @@ -228,7 +228,7 @@ $sid_005$ $sid_005$ $sid_006$ ... -lua iterate(20, 1, 1, 2, box.index.EQ) +iterate(20, 1, 1, 2, box.index.EQ) --- $sid_001$ $sid_001$ @@ -241,7 +241,7 @@ $sid_005$ $sid_005$ $sid_006$ ... -lua iterate(20, 1, 1, 2, box.index.REQ) +iterate(20, 1, 1, 2, box.index.REQ) --- $sid_006$ $sid_005$ @@ -254,7 +254,7 @@ $sid_002$ $sid_001$ $sid_001$ ... -lua iterate(20, 1, 1, 2, box.index.GE) +iterate(20, 1, 1, 2, box.index.GE) --- $sid_001$ $sid_001$ @@ -267,7 +267,7 @@ $sid_005$ $sid_005$ $sid_006$ ... -lua iterate(20, 1, 1, 2, box.index.GT) +iterate(20, 1, 1, 2, box.index.GT) --- $sid_001$ $sid_001$ @@ -280,7 +280,7 @@ $sid_005$ $sid_005$ $sid_006$ ... -lua iterate(20, 1, 1, 2, box.index.LE) +iterate(20, 1, 1, 2, box.index.LE) --- $sid_006$ $sid_005$ @@ -293,7 +293,7 @@ $sid_002$ $sid_001$ $sid_001$ ... -lua iterate(20, 1, 1, 2, box.index.LT) +iterate(20, 1, 1, 2, box.index.LT) --- $sid_006$ $sid_005$ @@ -306,36 +306,36 @@ $sid_002$ $sid_001$ $sid_001$ ... -lua iterate(20, 1, 1, 2, box.index.EQ, 'sid_005') +iterate(20, 1, 1, 2, box.index.EQ, 'sid_005') --- $sid_005$ $sid_005$ $sid_005$ ... -lua iterate(20, 1, 1, 2, box.index.REQ, 'sid_005') +iterate(20, 1, 1, 2, box.index.REQ, 'sid_005') --- $sid_005$ $sid_005$ $sid_005$ ... -lua iterate(20, 1, 1, 2, box.index.GE, 'sid_005') +iterate(20, 1, 1, 2, box.index.GE, 'sid_005') --- $sid_005$ $sid_005$ $sid_005$ $sid_006$ ... -lua iterate(20, 1, 1, 2, box.index.GT, 'sid_005') +iterate(20, 1, 1, 2, box.index.GT, 'sid_005') --- $sid_006$ ... -lua iterate(20, 1, 1, 2, box.index.GE, 'sid_999') +iterate(20, 1, 1, 2, box.index.GE, 'sid_999') --- ... -lua iterate(20, 1, 1, 2, box.index.GT, 'sid_999') +iterate(20, 1, 1, 2, box.index.GT, 'sid_999') --- ... -lua iterate(20, 1, 1, 2, box.index.LE, 'sid_005') +iterate(20, 1, 1, 2, box.index.LE, 'sid_005') --- $sid_005$ $sid_005$ @@ -347,7 +347,7 @@ $sid_002$ $sid_001$ $sid_001$ ... -lua iterate(20, 1, 1, 2, box.index.LT, 'sid_005') +iterate(20, 1, 1, 2, box.index.LT, 'sid_005') --- $sid_004$ $sid_003$ @@ -356,10 +356,10 @@ $sid_002$ $sid_001$ $sid_001$ ... -lua iterate(20, 1, 1, 2, box.index.LE, 'sid_000') +iterate(20, 1, 1, 2, box.index.LE, 'sid_000') --- ... -lua iterate(20, 1, 1, 2, box.index.LT, 'sid_000') +iterate(20, 1, 1, 2, box.index.LT, 'sid_000') --- ... @@ -367,7 +367,7 @@ lua iterate(20, 1, 1, 2, box.index.LT, 'sid_000') # Iterator: tree multi-part unique #-----------------------------------------------------------------------------# -lua iterate(20, 2, 1, 3, box.index.ALL) +iterate(20, 2, 1, 3, box.index.ALL) --- $sid_001$tid_997$ $sid_001$tid_998$ @@ -380,7 +380,7 @@ $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.EQ) +iterate(20, 2, 1, 3, box.index.EQ) --- $sid_001$tid_997$ $sid_001$tid_998$ @@ -393,7 +393,7 @@ $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.REQ) +iterate(20, 2, 1, 3, box.index.REQ) --- $sid_006$tid_996$ $sid_005$tid_996$ @@ -406,7 +406,7 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.GE) +iterate(20, 2, 1, 3, box.index.GE) --- $sid_001$tid_997$ $sid_001$tid_998$ @@ -419,7 +419,7 @@ $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GT) +iterate(20, 2, 1, 3, box.index.GT) --- $sid_001$tid_997$ $sid_001$tid_998$ @@ -432,7 +432,7 @@ $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.LE) +iterate(20, 2, 1, 3, box.index.LE) --- $sid_006$tid_996$ $sid_005$tid_996$ @@ -445,7 +445,7 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.LT) +iterate(20, 2, 1, 3, box.index.LT) --- $sid_006$tid_996$ $sid_005$tid_996$ @@ -458,69 +458,69 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005') +iterate(20, 2, 1, 3, box.index.EQ, 'sid_005') --- $sid_005$tid_994$ $sid_005$tid_995$ $sid_005$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') +iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') --- $sid_005$tid_995$ ... -lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') +iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') --- ... -lua iterate(20, 2, 1, 3, box.index.REQ, 'sid_005') +iterate(20, 2, 1, 3, box.index.REQ, 'sid_005') --- $sid_005$tid_996$ $sid_005$tid_995$ $sid_005$tid_994$ ... -lua iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995') +iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995') --- $sid_005$tid_995$ ... -lua iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999') +iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999') --- ... -lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005') +iterate(20, 2, 1, 3, box.index.GE, 'sid_005') --- $sid_005$tid_994$ $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GT, 'sid_005') +iterate(20, 2, 1, 3, box.index.GT, 'sid_005') --- $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') +iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') --- $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995') +iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995') --- $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') +iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') --- $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999') +iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999') --- $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GE, 'sid_999') +iterate(20, 2, 1, 3, box.index.GE, 'sid_999') --- ... -lua iterate(20, 2, 1, 3, box.index.GT, 'sid_999') +iterate(20, 2, 1, 3, box.index.GT, 'sid_999') --- ... -lua iterate(20, 2, 1, 3, box.index.LE, 'sid_005') +iterate(20, 2, 1, 3, box.index.LE, 'sid_005') --- $sid_005$tid_996$ $sid_005$tid_995$ @@ -532,7 +532,7 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.LT, 'sid_005') +iterate(20, 2, 1, 3, box.index.LT, 'sid_005') --- $sid_004$tid_996$ $sid_003$tid_996$ @@ -541,7 +541,7 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997') +iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997') --- $sid_005$tid_996$ $sid_005$tid_995$ @@ -553,7 +553,7 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997') +iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997') --- $sid_005$tid_996$ $sid_005$tid_995$ @@ -565,7 +565,7 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000') +iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000') --- $sid_004$tid_996$ $sid_003$tid_996$ @@ -574,7 +574,7 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000') +iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000') --- $sid_004$tid_996$ $sid_003$tid_996$ @@ -583,10 +583,10 @@ $sid_002$tid_996$ $sid_001$tid_998$ $sid_001$tid_997$ ... -lua iterate(20, 2, 1, 3, box.index.LE, 'sid_000') +iterate(20, 2, 1, 3, box.index.LE, 'sid_000') --- ... -lua iterate(20, 2, 1, 3, box.index.LT, 'sid_000') +iterate(20, 2, 1, 3, box.index.LT, 'sid_000') --- ... @@ -594,7 +594,7 @@ lua iterate(20, 2, 1, 3, box.index.LT, 'sid_000') # Iterator: tree multi-part non-unique #-----------------------------------------------------------------------------# -lua iterate(20, 3, 2, 4, box.index.ALL) +iterate(20, 3, 2, 4, box.index.ALL) --- $tid_994$a$ $tid_995$a$ @@ -607,7 +607,7 @@ $tid_997$a$ $tid_997$b$ $tid_998$a$ ... -lua iterate(20, 3, 2, 4, box.index.EQ) +iterate(20, 3, 2, 4, box.index.EQ) --- $tid_994$a$ $tid_995$a$ @@ -620,7 +620,7 @@ $tid_997$a$ $tid_997$b$ $tid_998$a$ ... -lua iterate(20, 3, 2, 4, box.index.REQ) +iterate(20, 3, 2, 4, box.index.REQ) --- $tid_998$a$ $tid_997$b$ @@ -633,7 +633,7 @@ $tid_996$a$ $tid_995$a$ $tid_994$a$ ... -lua iterate(20, 3, 2, 4, box.index.GE) +iterate(20, 3, 2, 4, box.index.GE) --- $tid_994$a$ $tid_995$a$ @@ -646,7 +646,7 @@ $tid_997$a$ $tid_997$b$ $tid_998$a$ ... -lua iterate(20, 3, 2, 4, box.index.GT) +iterate(20, 3, 2, 4, box.index.GT) --- $tid_994$a$ $tid_995$a$ @@ -659,7 +659,7 @@ $tid_997$a$ $tid_997$b$ $tid_998$a$ ... -lua iterate(20, 3, 2, 4, box.index.LE) +iterate(20, 3, 2, 4, box.index.LE) --- $tid_998$a$ $tid_997$b$ @@ -672,7 +672,7 @@ $tid_996$a$ $tid_995$a$ $tid_994$a$ ... -lua iterate(20, 3, 2, 4, box.index.LT) +iterate(20, 3, 2, 4, box.index.LT) --- $tid_998$a$ $tid_997$b$ @@ -685,7 +685,7 @@ $tid_996$a$ $tid_995$a$ $tid_994$a$ ... -lua iterate(20, 3, 2, 4, box.index.EQ, 'tid_996') +iterate(20, 3, 2, 4, box.index.EQ, 'tid_996') --- $tid_996$a$ $tid_996$a$ @@ -693,15 +693,15 @@ $tid_996$b$ $tid_996$b$ $tid_996$c$ ... -lua iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'a') +iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'a') --- $tid_996$a$ $tid_996$a$ ... -lua iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'z') +iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'z') --- ... -lua iterate(20, 3, 2, 4, box.index.REQ, 'tid_996') +iterate(20, 3, 2, 4, box.index.REQ, 'tid_996') --- $tid_996$c$ $tid_996$b$ @@ -709,32 +709,32 @@ $tid_996$b$ $tid_996$a$ $tid_996$a$ ... -lua iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', 'a') +iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', 'a') --- $tid_996$a$ $tid_996$a$ ... -lua iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', '0') +iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', '0') --- ... -lua iterate(20, 3, 2, 4, box.index.GE, 'tid_997') +iterate(20, 3, 2, 4, box.index.GE, 'tid_997') --- $tid_997$a$ $tid_997$b$ $tid_998$a$ ... -lua iterate(20, 3, 2, 4, box.index.GT, 'tid_997') +iterate(20, 3, 2, 4, box.index.GT, 'tid_997') --- $tid_998$a$ ... -lua iterate(20, 3, 2, 4, box.index.GE, 'tid_998') +iterate(20, 3, 2, 4, box.index.GE, 'tid_998') --- $tid_998$a$ ... -lua iterate(20, 3, 2, 4, box.index.GT, 'tid_998') +iterate(20, 3, 2, 4, box.index.GT, 'tid_998') --- ... -lua iterate(20, 3, 2, 4, box.index.LE, 'tid_997') +iterate(20, 3, 2, 4, box.index.LE, 'tid_997') --- $tid_997$b$ $tid_997$a$ @@ -746,7 +746,7 @@ $tid_996$a$ $tid_995$a$ $tid_994$a$ ... -lua iterate(20, 3, 2, 4, box.index.LT, 'tid_997') +iterate(20, 3, 2, 4, box.index.LT, 'tid_997') --- $tid_996$c$ $tid_996$b$ @@ -756,13 +756,13 @@ $tid_996$a$ $tid_995$a$ $tid_994$a$ ... -lua iterate(20, 3, 2, 4, box.index.LE, 'tid_000') +iterate(20, 3, 2, 4, box.index.LE, 'tid_000') --- ... -lua iterate(20, 3, 2, 4, box.index.LT, 'tid_000') +iterate(20, 3, 2, 4, box.index.LT, 'tid_000') --- ... -lua iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys') +iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys') --- error: 'utils.lua:27: Key part count 4 is greater than index part count 2' ... @@ -771,7 +771,7 @@ error: 'utils.lua:27: Key part count 4 is greater than index part count 2' # Iterator: hash single-part unique #-----------------------------------------------------------------------------# -lua iterate(20, 4, 0, 1) +iterate(20, 4, 0, 1) --- sorted output $pid_001$ @@ -785,7 +785,7 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 4, 0, 1, box.index.ALL) +iterate(20, 4, 0, 1, box.index.ALL) --- sorted output $pid_001$ @@ -799,11 +799,11 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 4, 0, 1, box.index.EQ) +iterate(20, 4, 0, 1, box.index.EQ) --- error: 'Invalid key part count in an exact match (expected 1, got 0)' ... -lua iterate(20, 4, 0, 1, box.index.GE) +iterate(20, 4, 0, 1, box.index.GE) --- sorted output $pid_001$ @@ -817,16 +817,16 @@ $pid_017$ $pid_019$ $pid_023$ ... -lua iterate(20, 4, 0, 1, box.index.EQ, 'pid_003') +iterate(20, 4, 0, 1, box.index.EQ, 'pid_003') --- sorted output $pid_003$ ... -lua iterate(20, 4, 0, 1, box.index.EQ, 'pid_666') +iterate(20, 4, 0, 1, box.index.EQ, 'pid_666') --- sorted output ... -lua iterate(20, 4, 0, 1, box.index.GE, 'pid_001') +iterate(20, 4, 0, 1, box.index.GE, 'pid_001') --- sorted output $pid_001$ @@ -835,7 +835,7 @@ $pid_011$ $pid_019$ $pid_023$ ... -lua iterate(20, 4, 0, 1, box.index.GE, 'pid_999') +iterate(20, 4, 0, 1, box.index.GE, 'pid_999') --- sorted output ... @@ -844,7 +844,7 @@ sorted output # Iterator: hash multi-part unique #-----------------------------------------------------------------------------# -lua iterate(20, 5, 1, 3, box.index.ALL) +iterate(20, 5, 1, 3, box.index.ALL) --- sorted output $sid_001$tid_997$ @@ -858,15 +858,15 @@ $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 5, 1, 3, box.index.EQ) +iterate(20, 5, 1, 3, box.index.EQ) --- error: 'Invalid key part count in an exact match (expected 2, got 0)' ... -lua iterate(20, 5, 1, 3, box.index.EQ, 'sid_005') +iterate(20, 5, 1, 3, box.index.EQ, 'sid_005') --- error: 'Invalid key part count in an exact match (expected 2, got 1)' ... -lua iterate(20, 5, 1, 3, box.index.GE) +iterate(20, 5, 1, 3, box.index.GE) --- sorted output $sid_001$tid_997$ @@ -880,24 +880,24 @@ $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') +iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995') --- $sid_005$tid_995$ ... -lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') +iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999') --- ... -lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a') +iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a') --- error: 'utils.lua:27: Key part count 3 is greater than index part count 2' ... -lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') +iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995') --- $sid_005$tid_995$ $sid_005$tid_996$ $sid_006$tid_996$ ... -lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') +iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999') --- $sid_006$tid_996$ ... @@ -906,10 +906,10 @@ $sid_006$tid_996$ # Iterator: various #-----------------------------------------------------------------------------# -lua box.space[20].index[0]:iterator(-666) +box.space[20].index[0]:iterator(-666) --- error: 'unknown iterator type: -666' ... -lua box.space[20]:truncate() +box.space[20]:truncate() --- ... diff --git a/test/big/iterator.test b/test/big/iterator.test index 2eda566b2ed55d2a3dc254a3d826c02af05e4bfa..2fab2f5e7de15a1c065ebe1b5cd2e7dfb9d5c601 100644 --- a/test/big/iterator.test +++ b/test/big/iterator.test @@ -6,103 +6,103 @@ import shutil iterator_lua_path = os.path.join(vardir, "utils.lua") shutil.copy("big/utils.lua", iterator_lua_path) -admin("lua dofile('utils.lua')") +admin("dofile('utils.lua')") shutil.rmtree(iterator_lua_path, True) -admin("lua box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a')") -admin("lua box.insert(20, 'pid_002', 'sid_001', 'tid_997', 'a')") -admin("lua box.insert(20, 'pid_003', 'sid_002', 'tid_997', 'b')") -admin("lua box.insert(20, 'pid_005', 'sid_002', 'tid_996', 'b')") -admin("lua box.insert(20, 'pid_007', 'sid_003', 'tid_996', 'a')") -admin("lua box.insert(20, 'pid_011', 'sid_004', 'tid_996', 'c')") -admin("lua box.insert(20, 'pid_013', 'sid_005', 'tid_996', 'b')") -admin("lua box.insert(20, 'pid_017', 'sid_006', 'tid_996', 'a')") -admin("lua box.insert(20, 'pid_019', 'sid_005', 'tid_995', 'a')") -admin("lua box.insert(20, 'pid_023', 'sid_005', 'tid_994', 'a')") +admin("box.insert(20, 'pid_001', 'sid_001', 'tid_998', 'a')") +admin("box.insert(20, 'pid_002', 'sid_001', 'tid_997', 'a')") +admin("box.insert(20, 'pid_003', 'sid_002', 'tid_997', 'b')") +admin("box.insert(20, 'pid_005', 'sid_002', 'tid_996', 'b')") +admin("box.insert(20, 'pid_007', 'sid_003', 'tid_996', 'a')") +admin("box.insert(20, 'pid_011', 'sid_004', 'tid_996', 'c')") +admin("box.insert(20, 'pid_013', 'sid_005', 'tid_996', 'b')") +admin("box.insert(20, 'pid_017', 'sid_006', 'tid_996', 'a')") +admin("box.insert(20, 'pid_019', 'sid_005', 'tid_995', 'a')") +admin("box.insert(20, 'pid_023', 'sid_005', 'tid_994', 'a')") print """ #-----------------------------------------------------------------------------# # Iterator: tree single-part unique #-----------------------------------------------------------------------------# """ -admin("lua iterate(20, 0, 0, 1)") -admin("lua iterate(20, 0, 0, 1, box.index.ALL)") -admin("lua iterate(20, 0, 0, 1, box.index.EQ)") -admin("lua iterate(20, 0, 0, 1, box.index.REQ)") -admin("lua iterate(20, 0, 0, 1, box.index.GE)") -admin("lua iterate(20, 0, 0, 1, box.index.GT)") -admin("lua iterate(20, 0, 0, 1, box.index.LE)") -admin("lua iterate(20, 0, 0, 1, box.index.LT)") -admin("lua iterate(20, 0, 0, 1, box.index.EQ, 'pid_003')") -admin("lua iterate(20, 0, 0, 1, box.index.REQ, 'pid_003')") -admin("lua iterate(20, 0, 0, 1, box.index.EQ, 'pid_666')") -admin("lua iterate(20, 0, 0, 1, box.index.REQ, 'pid_666')") -admin("lua iterate(20, 0, 0, 1, box.index.GE, 'pid_001')") -admin("lua iterate(20, 0, 0, 1, box.index.GT, 'pid_001')") -admin("lua iterate(20, 0, 0, 1, box.index.GE, 'pid_999')") -admin("lua iterate(20, 0, 0, 1, box.index.GT, 'pid_999')") -admin("lua iterate(20, 0, 0, 1, box.index.LE, 'pid_002')") -admin("lua iterate(20, 0, 0, 1, box.index.LT, 'pid_002')") -admin("lua iterate(20, 0, 0, 1, box.index.LE, 'pid_000')") -admin("lua iterate(20, 0, 0, 1, box.index.LT, 'pid_000')") +admin("iterate(20, 0, 0, 1)") +admin("iterate(20, 0, 0, 1, box.index.ALL)") +admin("iterate(20, 0, 0, 1, box.index.EQ)") +admin("iterate(20, 0, 0, 1, box.index.REQ)") +admin("iterate(20, 0, 0, 1, box.index.GE)") +admin("iterate(20, 0, 0, 1, box.index.GT)") +admin("iterate(20, 0, 0, 1, box.index.LE)") +admin("iterate(20, 0, 0, 1, box.index.LT)") +admin("iterate(20, 0, 0, 1, box.index.EQ, 'pid_003')") +admin("iterate(20, 0, 0, 1, box.index.REQ, 'pid_003')") +admin("iterate(20, 0, 0, 1, box.index.EQ, 'pid_666')") +admin("iterate(20, 0, 0, 1, box.index.REQ, 'pid_666')") +admin("iterate(20, 0, 0, 1, box.index.GE, 'pid_001')") +admin("iterate(20, 0, 0, 1, box.index.GT, 'pid_001')") +admin("iterate(20, 0, 0, 1, box.index.GE, 'pid_999')") +admin("iterate(20, 0, 0, 1, box.index.GT, 'pid_999')") +admin("iterate(20, 0, 0, 1, box.index.LE, 'pid_002')") +admin("iterate(20, 0, 0, 1, box.index.LT, 'pid_002')") +admin("iterate(20, 0, 0, 1, box.index.LE, 'pid_000')") +admin("iterate(20, 0, 0, 1, box.index.LT, 'pid_000')") print """ #-----------------------------------------------------------------------------# # Iterator: tree single-part non-unique #-----------------------------------------------------------------------------# """ -admin("lua iterate(20, 1, 1, 2, box.index.ALL)") -admin("lua iterate(20, 1, 1, 2, box.index.EQ)") -admin("lua iterate(20, 1, 1, 2, box.index.REQ)") -admin("lua iterate(20, 1, 1, 2, box.index.GE)") -admin("lua iterate(20, 1, 1, 2, box.index.GT)") -admin("lua iterate(20, 1, 1, 2, box.index.LE)") -admin("lua iterate(20, 1, 1, 2, box.index.LT)") -admin("lua iterate(20, 1, 1, 2, box.index.EQ, 'sid_005')") -admin("lua iterate(20, 1, 1, 2, box.index.REQ, 'sid_005')") -admin("lua iterate(20, 1, 1, 2, box.index.GE, 'sid_005')") -admin("lua iterate(20, 1, 1, 2, box.index.GT, 'sid_005')") -admin("lua iterate(20, 1, 1, 2, box.index.GE, 'sid_999')") -admin("lua iterate(20, 1, 1, 2, box.index.GT, 'sid_999')") -admin("lua iterate(20, 1, 1, 2, box.index.LE, 'sid_005')") -admin("lua iterate(20, 1, 1, 2, box.index.LT, 'sid_005')") -admin("lua iterate(20, 1, 1, 2, box.index.LE, 'sid_000')") -admin("lua iterate(20, 1, 1, 2, box.index.LT, 'sid_000')") +admin("iterate(20, 1, 1, 2, box.index.ALL)") +admin("iterate(20, 1, 1, 2, box.index.EQ)") +admin("iterate(20, 1, 1, 2, box.index.REQ)") +admin("iterate(20, 1, 1, 2, box.index.GE)") +admin("iterate(20, 1, 1, 2, box.index.GT)") +admin("iterate(20, 1, 1, 2, box.index.LE)") +admin("iterate(20, 1, 1, 2, box.index.LT)") +admin("iterate(20, 1, 1, 2, box.index.EQ, 'sid_005')") +admin("iterate(20, 1, 1, 2, box.index.REQ, 'sid_005')") +admin("iterate(20, 1, 1, 2, box.index.GE, 'sid_005')") +admin("iterate(20, 1, 1, 2, box.index.GT, 'sid_005')") +admin("iterate(20, 1, 1, 2, box.index.GE, 'sid_999')") +admin("iterate(20, 1, 1, 2, box.index.GT, 'sid_999')") +admin("iterate(20, 1, 1, 2, box.index.LE, 'sid_005')") +admin("iterate(20, 1, 1, 2, box.index.LT, 'sid_005')") +admin("iterate(20, 1, 1, 2, box.index.LE, 'sid_000')") +admin("iterate(20, 1, 1, 2, box.index.LT, 'sid_000')") print """ #-----------------------------------------------------------------------------# # Iterator: tree multi-part unique #-----------------------------------------------------------------------------# """ -admin("lua iterate(20, 2, 1, 3, box.index.ALL)") -admin("lua iterate(20, 2, 1, 3, box.index.EQ)") -admin("lua iterate(20, 2, 1, 3, box.index.REQ)") -admin("lua iterate(20, 2, 1, 3, box.index.GE)") -admin("lua iterate(20, 2, 1, 3, box.index.GT)") -admin("lua iterate(20, 2, 1, 3, box.index.LE)") -admin("lua iterate(20, 2, 1, 3, box.index.LT)") -admin("lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005')") -admin("lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995')") -admin("lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999')") -admin("lua iterate(20, 2, 1, 3, box.index.REQ, 'sid_005')") -admin("lua iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995')") -admin("lua iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999')") -admin("lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005')") -admin("lua iterate(20, 2, 1, 3, box.index.GT, 'sid_005')") -admin("lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995')") -admin("lua iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995')") -admin("lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999')") -admin("lua iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999')") -admin("lua iterate(20, 2, 1, 3, box.index.GE, 'sid_999')") -admin("lua iterate(20, 2, 1, 3, box.index.GT, 'sid_999')") -admin("lua iterate(20, 2, 1, 3, box.index.LE, 'sid_005')") -admin("lua iterate(20, 2, 1, 3, box.index.LT, 'sid_005')") -admin("lua iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997')") -admin("lua iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997')") -admin("lua iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000')") -admin("lua iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000')") -admin("lua iterate(20, 2, 1, 3, box.index.LE, 'sid_000')") -admin("lua iterate(20, 2, 1, 3, box.index.LT, 'sid_000')") +admin("iterate(20, 2, 1, 3, box.index.ALL)") +admin("iterate(20, 2, 1, 3, box.index.EQ)") +admin("iterate(20, 2, 1, 3, box.index.REQ)") +admin("iterate(20, 2, 1, 3, box.index.GE)") +admin("iterate(20, 2, 1, 3, box.index.GT)") +admin("iterate(20, 2, 1, 3, box.index.LE)") +admin("iterate(20, 2, 1, 3, box.index.LT)") +admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005')") +admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995')") +admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999')") +admin("iterate(20, 2, 1, 3, box.index.REQ, 'sid_005')") +admin("iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_995')") +admin("iterate(20, 2, 1, 3, box.index.REQ, 'sid_005', 'tid_999')") +admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005')") +admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_005')") +admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995')") +admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_995')") +admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999')") +admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_005', 'tid_999')") +admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_999')") +admin("iterate(20, 2, 1, 3, box.index.GT, 'sid_999')") +admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_005')") +admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_005')") +admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_997')") +admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_997')") +admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_005', 'tid_000')") +admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_005', 'tid_000')") +admin("iterate(20, 2, 1, 3, box.index.LE, 'sid_000')") +admin("iterate(20, 2, 1, 3, box.index.LT, 'sid_000')") print """ #-----------------------------------------------------------------------------# @@ -110,28 +110,28 @@ print """ #-----------------------------------------------------------------------------# """ -admin("lua iterate(20, 3, 2, 4, box.index.ALL)") -admin("lua iterate(20, 3, 2, 4, box.index.EQ)") -admin("lua iterate(20, 3, 2, 4, box.index.REQ)") -admin("lua iterate(20, 3, 2, 4, box.index.GE)") -admin("lua iterate(20, 3, 2, 4, box.index.GT)") -admin("lua iterate(20, 3, 2, 4, box.index.LE)") -admin("lua iterate(20, 3, 2, 4, box.index.LT)") -admin("lua iterate(20, 3, 2, 4, box.index.EQ, 'tid_996')") -admin("lua iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'a')") -admin("lua iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'z')") -admin("lua iterate(20, 3, 2, 4, box.index.REQ, 'tid_996')") -admin("lua iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', 'a')") -admin("lua iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', '0')") -admin("lua iterate(20, 3, 2, 4, box.index.GE, 'tid_997')") -admin("lua iterate(20, 3, 2, 4, box.index.GT, 'tid_997')") -admin("lua iterate(20, 3, 2, 4, box.index.GE, 'tid_998')") -admin("lua iterate(20, 3, 2, 4, box.index.GT, 'tid_998')") -admin("lua iterate(20, 3, 2, 4, box.index.LE, 'tid_997')") -admin("lua iterate(20, 3, 2, 4, box.index.LT, 'tid_997')") -admin("lua iterate(20, 3, 2, 4, box.index.LE, 'tid_000')") -admin("lua iterate(20, 3, 2, 4, box.index.LT, 'tid_000')") -admin("lua iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys')") +admin("iterate(20, 3, 2, 4, box.index.ALL)") +admin("iterate(20, 3, 2, 4, box.index.EQ)") +admin("iterate(20, 3, 2, 4, box.index.REQ)") +admin("iterate(20, 3, 2, 4, box.index.GE)") +admin("iterate(20, 3, 2, 4, box.index.GT)") +admin("iterate(20, 3, 2, 4, box.index.LE)") +admin("iterate(20, 3, 2, 4, box.index.LT)") +admin("iterate(20, 3, 2, 4, box.index.EQ, 'tid_996')") +admin("iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'a')") +admin("iterate(20, 3, 2, 4, box.index.EQ, 'tid_996', 'z')") +admin("iterate(20, 3, 2, 4, box.index.REQ, 'tid_996')") +admin("iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', 'a')") +admin("iterate(20, 3, 2, 4, box.index.REQ, 'tid_996', '0')") +admin("iterate(20, 3, 2, 4, box.index.GE, 'tid_997')") +admin("iterate(20, 3, 2, 4, box.index.GT, 'tid_997')") +admin("iterate(20, 3, 2, 4, box.index.GE, 'tid_998')") +admin("iterate(20, 3, 2, 4, box.index.GT, 'tid_998')") +admin("iterate(20, 3, 2, 4, box.index.LE, 'tid_997')") +admin("iterate(20, 3, 2, 4, box.index.LT, 'tid_997')") +admin("iterate(20, 3, 2, 4, box.index.LE, 'tid_000')") +admin("iterate(20, 3, 2, 4, box.index.LT, 'tid_000')") +admin("iterate(20, 3, 2, 4, box.index.LT, 'tid_996', 'to', 'many', 'keys')") print """ #-----------------------------------------------------------------------------# @@ -139,29 +139,29 @@ print """ #-----------------------------------------------------------------------------# """ -admin("lua iterate(20, 4, 0, 1)") -admin("lua iterate(20, 4, 0, 1, box.index.ALL)") -admin("lua iterate(20, 4, 0, 1, box.index.EQ)") -admin("lua iterate(20, 4, 0, 1, box.index.GE)") -admin("lua iterate(20, 4, 0, 1, box.index.EQ, 'pid_003')") -admin("lua iterate(20, 4, 0, 1, box.index.EQ, 'pid_666')") -admin("lua iterate(20, 4, 0, 1, box.index.GE, 'pid_001')") -admin("lua iterate(20, 4, 0, 1, box.index.GE, 'pid_999')") +admin("iterate(20, 4, 0, 1)") +admin("iterate(20, 4, 0, 1, box.index.ALL)") +admin("iterate(20, 4, 0, 1, box.index.EQ)") +admin("iterate(20, 4, 0, 1, box.index.GE)") +admin("iterate(20, 4, 0, 1, box.index.EQ, 'pid_003')") +admin("iterate(20, 4, 0, 1, box.index.EQ, 'pid_666')") +admin("iterate(20, 4, 0, 1, box.index.GE, 'pid_001')") +admin("iterate(20, 4, 0, 1, box.index.GE, 'pid_999')") print """ #-----------------------------------------------------------------------------# # Iterator: hash multi-part unique #-----------------------------------------------------------------------------# """ -admin("lua iterate(20, 5, 1, 3, box.index.ALL)") -admin("lua iterate(20, 5, 1, 3, box.index.EQ)") -admin("lua iterate(20, 5, 1, 3, box.index.EQ, 'sid_005')") -admin("lua iterate(20, 5, 1, 3, box.index.GE)") -admin("lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995')") -admin("lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999')") -admin("lua iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a')") -admin("lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995')") -admin("lua iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999')") +admin("iterate(20, 5, 1, 3, box.index.ALL)") +admin("iterate(20, 5, 1, 3, box.index.EQ)") +admin("iterate(20, 5, 1, 3, box.index.EQ, 'sid_005')") +admin("iterate(20, 5, 1, 3, box.index.GE)") +admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995')") +admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_999')") +admin("iterate(20, 2, 1, 3, box.index.EQ, 'sid_005', 'tid_995', 'a')") +admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_995')") +admin("iterate(20, 2, 1, 3, box.index.GE, 'sid_005', 'tid_999')") print """ #-----------------------------------------------------------------------------# @@ -169,6 +169,6 @@ print """ #-----------------------------------------------------------------------------# """ -admin("lua box.space[20].index[0]:iterator(-666)") +admin("box.space[20].index[0]:iterator(-666)") -admin("lua box.space[20]:truncate()") +admin("box.space[20]:truncate()") diff --git a/test/big/lua.result b/test/big/lua.result index e10bb33fa784b591572a8ff333051615d6561a44..0c8cebeb9bc762f4f0f8e5b3e4b86380a76c2046 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -1,13 +1,13 @@ -lua dofile('index_random_test.lua') +dofile('index_random_test.lua') --- ... insert into t1 values ('brave', 'new', 'world') Insert OK, 1 row affected -lua box.space[1].index[1]:min() +box.space[1].index[1]:min() --- - 'brave': {'new', 'world'} ... -lua box.space[1].index[1]:max() +box.space[1].index[1]:max() --- - 'brave': {'new', 'world'} ... @@ -31,7 +31,7 @@ Found 1 tuple: # insert into t1 values ('item 1', 'alabama', 'song') Insert OK, 1 row affected -lua box.select(1, 1, 'alabama') +box.select(1, 1, 'alabama') --- - 'item 1': {'alabama', 1735290739} ... @@ -41,17 +41,17 @@ insert into t1 values ('item 3', 'california', 'uber alles') Insert OK, 1 row affected insert into t1 values ('item 4', 'georgia', 'on my mind') Insert OK, 1 row affected -lua iter, tuple = box.space[1].index[1]:next('california') +iter, tuple = box.space[1].index[1]:next('california') --- ... -lua tuple +tuple --- - 'item 2': {'california', 'dreaming '} ... -lua iter, tuple = box.space[1].index[1]:next(iter) +iter, tuple = box.space[1].index[1]:next(iter) --- ... -lua tuple +tuple --- - 'item 3': {'california', 'uber alles'} ... @@ -81,126 +81,126 @@ call box.select_reverse_range(5, 1, 2, 'of') Found 2 tuples: ['00000000', 'of', 'puppets'] ['00000001', 'of', 'might', 'and', 'magic'] -lua box.space[5]:truncate() +box.space[5]:truncate() --- ... -lua box.insert('8', tonumber64('18446744073709551615'), 'magic') +box.insert('8', tonumber64('18446744073709551615'), 'magic') --- - 18446744073709551615: {'magic'} ... -lua tu = box.select('8', '0', tonumber64('18446744073709551615')) +tu = box.select('8', '0', tonumber64('18446744073709551615')) --- ... -lua num = box.unpack('l', tu[0]) +num = box.unpack('l', tu[0]) --- ... -lua print(num) +print(num) --- 18446744073709551615 ... -lua type(num) == 'cdata' +type(num) == 'cdata' --- - true ... -lua num == tonumber64('18446744073709551615') +num == tonumber64('18446744073709551615') --- - true ... -lua num = box.unpack('l', tu[0]) +num = box.unpack('l', tu[0]) --- ... -lua num == tonumber64('18446744073709551615') +num == tonumber64('18446744073709551615') --- - true ... -lua box.delete(8, 18446744073709551615ULL) +box.delete(8, 18446744073709551615ULL) --- - 18446744073709551615: {'magic'} ... -lua box.insert('8', 125ULL, 'magic') +box.insert('8', 125ULL, 'magic') --- - 125: {'magic'} ... -lua tu = box.select('8', '0', 125) +tu = box.select('8', '0', 125) --- ... -lua tu2 = box.select('8', '0', 125LL) +tu2 = box.select('8', '0', 125LL) --- ... -lua num = box.unpack('l', tu[0]) +num = box.unpack('l', tu[0]) --- ... -lua num2 = box.unpack('l', tu2[0]) +num2 = box.unpack('l', tu2[0]) --- ... -lua print(num) +print(num) --- 125 ... -lua print(num2) +print(num2) --- 125 ... -lua type(num) == 'cdata' +type(num) == 'cdata' --- - true ... -lua type(num2) == 'cdata' +type(num2) == 'cdata' --- - true ... -lua num == tonumber64('125') +num == tonumber64('125') --- - true ... -lua num2 == tonumber64('125') +num2 == tonumber64('125') --- - true ... -lua box.space[8]:truncate() +box.space[8]:truncate() --- ... -lua box.insert(14, 0, 0) +box.insert(14, 0, 0) --- - 0: {0} ... -lua box.insert(14, 1, 0) +box.insert(14, 1, 0) --- - 1: {0} ... -lua box.insert(14, 2, 0) +box.insert(14, 2, 0) --- - 2: {0} ... -lua box.insert(14, 3, 0) +box.insert(14, 3, 0) --- - 3: {0} ... -lua box.insert(14, 4, 0) +box.insert(14, 4, 0) --- - 4: {0} ... -lua box.insert(14, 5, 0) +box.insert(14, 5, 0) --- - 5: {0} ... -lua box.insert(14, 6, 0) +box.insert(14, 6, 0) --- - 6: {0} ... -lua box.insert(14, 7, 0) +box.insert(14, 7, 0) --- - 7: {0} ... -lua box.insert(14, 8, 0) +box.insert(14, 8, 0) --- - 8: {0} ... -lua box.insert(14, 9, 0) +box.insert(14, 9, 0) --- - 9: {0} ... -lua box.select_range(14, 1, 10) +box.select_range(14, 1, 10) --- - 0: {0} - 1: {0} @@ -213,7 +213,7 @@ lua box.select_range(14, 1, 10) - 8: {0} - 9: {0} ... -lua box.select_reverse_range(14, 1, 10) +box.select_reverse_range(14, 1, 10) --- - 9: {0} - 8: {0} @@ -226,14 +226,14 @@ lua box.select_reverse_range(14, 1, 10) - 1: {0} - 0: {0} ... -lua box.select_reverse_range(14, 1, 4) +box.select_reverse_range(14, 1, 4) --- - 9: {0} - 8: {0} - 7: {0} - 6: {0} ... -lua box.space[14]:truncate() +box.space[14]:truncate() --- ... @@ -241,31 +241,31 @@ lua box.space[14]:truncate() # Tests for box.index iterators # -lua box.insert(16, 'pid_1', 'sid_1', 'tid_999') +box.insert(16, 'pid_1', 'sid_1', 'tid_999') --- - 'pid_1': {'sid_1', 'tid_999'} ... -lua box.insert(16, 'pid_2', 'sid_1', 'tid_998') +box.insert(16, 'pid_2', 'sid_1', 'tid_998') --- - 'pid_2': {'sid_1', 'tid_998'} ... -lua box.insert(16, 'pid_3', 'sid_1', 'tid_997') +box.insert(16, 'pid_3', 'sid_1', 'tid_997') --- - 'pid_3': {'sid_1', 'tid_997'} ... -lua box.insert(16, 'pid_4', 'sid_2', 'tid_996') +box.insert(16, 'pid_4', 'sid_2', 'tid_996') --- - 'pid_4': {'sid_2', 'tid_996'} ... -lua box.insert(16, 'pid_5', 'sid_2', 'tid_995') +box.insert(16, 'pid_5', 'sid_2', 'tid_995') --- - 'pid_5': {'sid_2', 'tid_995'} ... -lua box.insert(16, 'pid_6', 'sid_2', 'tid_994') +box.insert(16, 'pid_6', 'sid_2', 'tid_994') --- - 'pid_6': {'sid_2', 'tid_994'} ... -lua for k, v in box.space[16].index[1].next, box.space[16].index[1], 'sid_1' do print(v) end +for k, v in box.space[16].index[1].next, box.space[16].index[1], 'sid_1' do print(v) end --- 'pid_3': {'sid_1', 'tid_997'} 'pid_2': {'sid_1', 'tid_998'} @@ -274,7 +274,7 @@ lua for k, v in box.space[16].index[1].next, box.space[16].index[1], 'sid_1' do 'pid_5': {'sid_2', 'tid_995'} 'pid_4': {'sid_2', 'tid_996'} ... -lua for k, v in box.space[16].index[1].prev, box.space[16].index[1], 'sid_2' do print(v) end +for k, v in box.space[16].index[1].prev, box.space[16].index[1], 'sid_2' do print(v) end --- 'pid_4': {'sid_2', 'tid_996'} 'pid_5': {'sid_2', 'tid_995'} @@ -283,271 +283,271 @@ lua for k, v in box.space[16].index[1].prev, box.space[16].index[1], 'sid_2' do 'pid_2': {'sid_1', 'tid_998'} 'pid_3': {'sid_1', 'tid_997'} ... -lua for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(v) end +for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(v) end --- 'pid_3': {'sid_1', 'tid_997'} 'pid_2': {'sid_1', 'tid_998'} 'pid_1': {'sid_1', 'tid_999'} ... -lua for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(v) end +for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(v) end --- 'pid_1': {'sid_1', 'tid_999'} 'pid_2': {'sid_1', 'tid_998'} 'pid_3': {'sid_1', 'tid_997'} ... -lua for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(v) end +for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(v) end --- 'pid_6': {'sid_2', 'tid_994'} 'pid_5': {'sid_2', 'tid_995'} 'pid_4': {'sid_2', 'tid_996'} ... -lua for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(v) end +for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(v) end --- 'pid_4': {'sid_2', 'tid_996'} 'pid_5': {'sid_2', 'tid_995'} 'pid_6': {'sid_2', 'tid_994'} ... -lua box.space[16]:truncate() +box.space[16]:truncate() --- ... -lua box.insert(17, 1, 1, 1) +box.insert(17, 1, 1, 1) --- - 1: {1, 1} ... -lua box.insert(17, 2, 2, 0) +box.insert(17, 2, 2, 0) --- - 2: {2, 0} ... -lua box.insert(17, 3, 2, 1) +box.insert(17, 3, 2, 1) --- - 3: {2, 1} ... -lua box.insert(17, 4, 3, 0) +box.insert(17, 4, 3, 0) --- - 4: {3, 0} ... -lua box.insert(17, 5, 3, 1) +box.insert(17, 5, 3, 1) --- - 5: {3, 1} ... -lua box.insert(17, 6, 3, 2) +box.insert(17, 6, 3, 2) --- - 6: {3, 2} ... -lua box.space[17].index[1]:count(1) +box.space[17].index[1]:count(1) --- - 1 ... -lua box.space[17].index[1]:count(2) +box.space[17].index[1]:count(2) --- - 2 ... -lua box.space[17].index[1]:count(2, 1) +box.space[17].index[1]:count(2, 1) --- - 1 ... -lua box.space[17].index[1]:count(2, 2) +box.space[17].index[1]:count(2, 2) --- - 0 ... -lua box.space[17].index[1]:count(3) +box.space[17].index[1]:count(3) --- - 3 ... -lua box.space[17].index[1]:count(3, 3) +box.space[17].index[1]:count(3, 3) --- - 0 ... -lua box.space[17].index[1]:count() +box.space[17].index[1]:count() --- error: 'index.count(): one or more arguments expected' ... -lua box.space[17]:truncate() +box.space[17]:truncate() --- ... -lua box.space[18]:truncate() +box.space[18]:truncate() --- ... -lua box.auto_increment(18, 'a') +box.auto_increment(18, 'a') --- - 1: {'a'} ... -lua box.insert(18, 5) +box.insert(18, 5) --- - 5: {} ... -lua box.auto_increment(18, 'b') +box.auto_increment(18, 'b') --- - 6: {'b'} ... -lua box.auto_increment(18, 'c') +box.auto_increment(18, 'c') --- - 7: {'c'} ... -lua box.space[18]:truncate() +box.space[18]:truncate() --- ... -lua box.space[25]:truncate() +box.space[25]:truncate() --- ... -lua box.auto_increment(25, 'a') +box.auto_increment(25, 'a') --- - 1: {'a'} ... -lua box.insert(25, tonumber64(5)) +box.insert(25, tonumber64(5)) --- - 5: {} ... -lua box.auto_increment(25, 'b') +box.auto_increment(25, 'b') --- - 6: {'b'} ... -lua box.auto_increment(25, 'c') +box.auto_increment(25, 'c') --- - 7: {'c'} ... -lua box.space[25]:truncate() +box.space[25]:truncate() --- ... -lua t=box.insert(12, '1', '2', '3', '4', '5', '6', '7') +t=box.insert(12, '1', '2', '3', '4', '5', '6', '7') --- ... -lua t:transform(7, 0, '8', '9', '100') +t:transform(7, 0, '8', '9', '100') --- - '1': {'2', '3', '4', '5', '6', '7', '8', '9', '100'} ... -lua t:transform(0, 1) +t:transform(0, 1) --- - '2': {'3', '4', '5', '6', '7'} ... -lua t:transform(1, 4) +t:transform(1, 4) --- - '1': {'6', '7'} ... -lua t:transform(-1, 1) +t:transform(-1, 1) --- - '1': {'2', '3', '4', '5', '6'} ... -lua t:transform(-3, 2) +t:transform(-3, 2) --- - '1': {'2', '3', '4', '7'} ... -lua t:transform(0, 0, 'A') +t:transform(0, 0, 'A') --- - 'A': {'1', '2', '3', '4', '5', '6', '7'} ... -lua t:transform(-1, 0, 'A') +t:transform(-1, 0, 'A') --- - '1': {'2', '3', '4', '5', '6', 'A', '7'} ... -lua t:transform(0, 1, 'A') +t:transform(0, 1, 'A') --- - 'A': {'2', '3', '4', '5', '6', '7'} ... -lua t:transform(-1, 1, 'B') +t:transform(-1, 1, 'B') --- - '1': {'2', '3', '4', '5', '6', 'B'} ... -lua t:transform(0, 2, 'C') +t:transform(0, 2, 'C') --- - 'C': {'3', '4', '5', '6', '7'} ... -lua t:transform(2, 0, 'hello') +t:transform(2, 0, 'hello') --- - '1': {'2', 'hello', '3', '4', '5', '6', '7'} ... -lua t:transform(0, -1, 'C') +t:transform(0, -1, 'C') --- error: 'tuple.transform(): len is negative' ... -lua t:transform(0, 100) +t:transform(0, 100) --- - '': {} ... -lua t:transform(-100, 1) +t:transform(-100, 1) --- error: 'tuple.transform(): offset is out of bound' ... -lua t:transform(0, 3, 1, 2, 3) +t:transform(0, 3, 1, 2, 3) --- - 1: {2, 3, '4', '5', '6', '7'} ... -lua t:transform(3, 1, tonumber64(4)) +t:transform(3, 1, tonumber64(4)) --- - '1': {'2', '3', 4, '5', '6', '7'} ... -lua t:transform(0, 1, {}) +t:transform(0, 1, {}) --- error: 'tuple.transform(): unsupported field type ''table''' ... -lua t=box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7') +t=box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7') --- ... -lua t:find('2') +t:find('2') --- - 1 ... -lua t:find('4') +t:find('4') --- - 3 ... -lua t:find('5') +t:find('5') --- - 6 ... -lua t:find('A') +t:find('A') --- - 0 ... -lua t:find('0') +t:find('0') --- ... -lua t:findall('A') +t:findall('A') --- - 0 ... -lua t:findall('2') +t:findall('2') --- - 1 - 5 ... -lua t:findall('3') +t:findall('3') --- - 2 - 4 - 8 ... -lua t:findall('0') +t:findall('0') --- ... -lua t:find(2, '2') +t:find(2, '2') --- - 5 ... -lua t:find(89, '2') +t:find(89, '2') --- ... -lua t:findall(4, '3') +t:findall(4, '3') --- - 4 - 8 ... -lua t=box.insert(12, 'Z', '2', 2, 3, tonumber64(2)) +t=box.insert(12, 'Z', '2', 2, 3, tonumber64(2)) --- ... -lua t:find(2) +t:find(2) --- - 2 ... -lua t:find(tonumber64(2)) +t:find(tonumber64(2)) --- - 4 ... -lua t:find('2') +t:find('2') --- - 1 ... -lua box.space[12]:truncate() +box.space[12]:truncate() --- ... # @@ -555,71 +555,71 @@ lua box.space[12]:truncate() # transform returns wrong tuple and put broken reply into socket # https://bugs.launchpad.net/tarantool/+bug/1038784 # -lua dofile('push.lua') +dofile('push.lua') --- ... -lua push_collection(0, 1038784, 'hello') +push_collection(0, 1038784, 'hello') --- - 1038784: {'hello'} ... -lua push_collection(0, 1038784, 'hello') +push_collection(0, 1038784, 'hello') --- - 1038784: {} ... -lua push_collection(0, 1038784, 'hello') +push_collection(0, 1038784, 'hello') --- - 1038784: {} ... -lua push_collection(1, 1038784, 'hi') +push_collection(1, 1038784, 'hi') --- - 1038784: {26984} ... -lua push_collection(2, 1038784, 'hi') +push_collection(2, 1038784, 'hi') --- - 1038784: {26984, 26984} ... -lua push_collection(2, 1038784, 'hi') +push_collection(2, 1038784, 'hi') --- - 1038784: {26984, 26984} ... -lua push_collection(5, 1038784, 'hey') +push_collection(5, 1038784, 'hey') --- - 1038784: {26984, 26984, 'hey'} ... -lua push_collection(5, 1038784, 'hey') +push_collection(5, 1038784, 'hey') --- - 1038784: {26984, 26984, 'hey', 'hey'} ... -lua push_collection(5, 1038784, 'hey') +push_collection(5, 1038784, 'hey') --- - 1038784: {26984, 26984, 'hey', 'hey', 'hey'} ... -lua push_collection(5, 1038784, 'hey') +push_collection(5, 1038784, 'hey') --- - 1038784: {26984, 'hey', 'hey', 'hey', 'hey'} ... # A test case for Bug#1060967: truncation of 64-bit numbers -lua box.space[5]:insert(2^51, 'hello', 'world') +box.space[5]:insert(2^51, 'hello', 'world') --- - 2251799813685248: {'hello', 'world'} ... -lua box.space[5]:select(0, 2^51) +box.space[5]:select(0, 2^51) --- - 2251799813685248: {'hello', 'world'} ... -lua box.space[5]:truncate() +box.space[5]:truncate() --- ... # Test that we print index number in error ER_INDEX_VIOLATION -lua box.space[1]:insert(1, 'hello', 'world') +box.space[1]:insert(1, 'hello', 'world') --- - 1: {'hello', 'world'} ... -lua box.space[1]:insert(2, 'hello', 'world') +box.space[1]:insert(2, 'hello', 'world') --- error: 'Duplicate key exists in unique index 1' ... -lua box.space[1]:truncate() +box.space[1]:truncate() --- ... # @@ -627,33 +627,33 @@ lua box.space[1]:truncate() # Truncate hangs when primary key is not in linear or starts at the first field # https://bugs.launchpad.net/tarantool/+bug/1042798 # -lua for k, f in pairs(box.space[23].index[0].key_field) do print(k, ' => ', f.fieldno) end +for k, f in pairs(box.space[23].index[0].key_field) do print(k, ' => ', f.fieldno) end --- 0 => 2 1 => 1 ... -lua box.insert(23, 1, 2, 3, 4) +box.insert(23, 1, 2, 3, 4) --- - 1: {2, 3, 4} ... -lua box.insert(23, 10, 20, 30, 40) +box.insert(23, 10, 20, 30, 40) --- - 10: {20, 30, 40} ... -lua box.insert(23, 20, 30, 40, 50) +box.insert(23, 20, 30, 40, 50) --- - 20: {30, 40, 50} ... -lua for _k, v in box.space[23]:pairs() do print(v) end +for _k, v in box.space[23]:pairs() do print(v) end --- 1: {2, 3, 4} 10: {20, 30, 40} 20: {30, 40, 50} ... -lua box.space[23]:truncate() +box.space[23]:truncate() --- ... -lua for _k, v in box.space[23]:pairs() do print(v) end +for _k, v in box.space[23]:pairs() do print(v) end --- ... @@ -661,7 +661,7 @@ lua for _k, v in box.space[23]:pairs() do print(v) end # TreeIndex::random() #-----------------------------------------------------------------------------# -lua index_random_test(26, 0) +index_random_test(26, 0) --- all values have been found - true @@ -671,7 +671,7 @@ all values have been found # HashIndex::random() #-----------------------------------------------------------------------------# -lua index_random_test(26, 1) +index_random_test(26, 1) --- all values have been found - true @@ -684,7 +684,7 @@ all values have been found # Test for correct little-endian comparison of integer fields. # (unsigned) # -lua for i = 1, 300 do box.insert(2, i, i) print(box.space[2].index[0]:max()) end +for i = 1, 300 do box.insert(2, i, i) print(box.space[2].index[0]:max()) end --- 1: {1} 2: {2} @@ -987,7 +987,7 @@ lua for i = 1, 300 do box.insert(2, i, i) print(box.space[2].index[0]:max()) end 299: {299} 300: {300} ... -lua box.space[2]:select_range(0, 300) +box.space[2]:select_range(0, 300) --- - 1: {1} - 2: {2} @@ -1290,6 +1290,6 @@ lua box.space[2]:select_range(0, 300) - 299: {299} - 300: {300} ... -lua box.space[2]:truncate() +box.space[2]:truncate() --- ... diff --git a/test/big/lua.test b/test/big/lua.test index 2d2930537b761ddc3f157e97397d103083b16fbf..a73a740307b9a87204dda48345f7207a066b6d38 100644 --- a/test/big/lua.test +++ b/test/big/lua.test @@ -7,12 +7,12 @@ for file in ("index_random_test.lua",): src_path = os.path.join("big/", file) dst_path = os.path.join(vardir, file) shutil.copy(src_path, dst_path) - admin("lua dofile('%s')" % (file)) + admin("dofile('%s')" % (file)) os.unlink(dst_path); sql("insert into t1 values ('brave', 'new', 'world')") -admin("lua box.space[1].index[1]:min()") -admin("lua box.space[1].index[1]:max()") +admin("box.space[1].index[1]:min()") +admin("box.space[1].index[1]:max()") sql("call box.select('1', '1', 'new', 'world')") print """# # A test case for Bug #904208 @@ -28,14 +28,14 @@ print """# # https://bugs.launchpad.net/tarantool/+bug/902091 #""" sql("insert into t1 values ('item 1', 'alabama', 'song')") -admin("lua box.select(1, 1, 'alabama')") +admin("box.select(1, 1, 'alabama')") sql("insert into t1 values ('item 2', 'california', 'dreaming ')") sql("insert into t1 values ('item 3', 'california', 'uber alles')") sql("insert into t1 values ('item 4', 'georgia', 'on my mind')") -admin("lua iter, tuple = box.space[1].index[1]:next('california')") -admin("lua tuple") -admin("lua iter, tuple = box.space[1].index[1]:next(iter)") -admin("lua tuple") +admin("iter, tuple = box.space[1].index[1]:next('california')") +admin("tuple") +admin("iter, tuple = box.space[1].index[1]:next(iter)") +admin("tuple") sql("call box.delete('1', 'item 1')") sql("call box.delete('1', 'item 2')") sql("call box.delete('1', 'item 3')") @@ -49,50 +49,50 @@ sql("insert into t5 values ('00000000', 'of', 'puppets')") sql("insert into t5 values ('00000001', 'of', 'might', 'and', 'magic')") sql("call box.select_range(5, 1, 2, 'of')") sql("call box.select_reverse_range(5, 1, 2, 'of')") -admin("lua box.space[5]:truncate()") +admin("box.space[5]:truncate()") # # Lua 64bit numbers support # -admin("lua box.insert('8', tonumber64('18446744073709551615'), 'magic')") -admin("lua tu = box.select('8', '0', tonumber64('18446744073709551615'))") -admin("lua num = box.unpack('l', tu[0])") -admin("lua print(num)") -admin("lua type(num) == 'cdata'") -admin("lua num == tonumber64('18446744073709551615')") -admin("lua num = box.unpack('l', tu[0])") -admin("lua num == tonumber64('18446744073709551615')") -admin("lua box.delete(8, 18446744073709551615ULL)") -admin("lua box.insert('8', 125ULL, 'magic')") -admin("lua tu = box.select('8', '0', 125)") -admin("lua tu2 = box.select('8', '0', 125LL)") -admin("lua num = box.unpack('l', tu[0])") -admin("lua num2 = box.unpack('l', tu2[0])") -admin("lua print(num)") -admin("lua print(num2)") -admin("lua type(num) == 'cdata'") -admin("lua type(num2) == 'cdata'") -admin("lua num == tonumber64('125')") -admin("lua num2 == tonumber64('125')") -admin("lua box.space[8]:truncate()") +admin("box.insert('8', tonumber64('18446744073709551615'), 'magic')") +admin("tu = box.select('8', '0', tonumber64('18446744073709551615'))") +admin("num = box.unpack('l', tu[0])") +admin("print(num)") +admin("type(num) == 'cdata'") +admin("num == tonumber64('18446744073709551615')") +admin("num = box.unpack('l', tu[0])") +admin("num == tonumber64('18446744073709551615')") +admin("box.delete(8, 18446744073709551615ULL)") +admin("box.insert('8', 125ULL, 'magic')") +admin("tu = box.select('8', '0', 125)") +admin("tu2 = box.select('8', '0', 125LL)") +admin("num = box.unpack('l', tu[0])") +admin("num2 = box.unpack('l', tu2[0])") +admin("print(num)") +admin("print(num2)") +admin("type(num) == 'cdata'") +admin("type(num2) == 'cdata'") +admin("num == tonumber64('125')") +admin("num2 == tonumber64('125')") +admin("box.space[8]:truncate()") # # Lua select_reverse_range # -admin("lua box.insert(14, 0, 0)") -admin("lua box.insert(14, 1, 0)") -admin("lua box.insert(14, 2, 0)") -admin("lua box.insert(14, 3, 0)") -admin("lua box.insert(14, 4, 0)") -admin("lua box.insert(14, 5, 0)") -admin("lua box.insert(14, 6, 0)") -admin("lua box.insert(14, 7, 0)") -admin("lua box.insert(14, 8, 0)") -admin("lua box.insert(14, 9, 0)") -admin("lua box.select_range(14, 1, 10)") -admin("lua box.select_reverse_range(14, 1, 10)") -admin("lua box.select_reverse_range(14, 1, 4)") -admin("lua box.space[14]:truncate()") +admin("box.insert(14, 0, 0)") +admin("box.insert(14, 1, 0)") +admin("box.insert(14, 2, 0)") +admin("box.insert(14, 3, 0)") +admin("box.insert(14, 4, 0)") +admin("box.insert(14, 5, 0)") +admin("box.insert(14, 6, 0)") +admin("box.insert(14, 7, 0)") +admin("box.insert(14, 8, 0)") +admin("box.insert(14, 9, 0)") +admin("box.select_range(14, 1, 10)") +admin("box.select_reverse_range(14, 1, 10)") +admin("box.select_reverse_range(14, 1, 4)") +admin("box.space[14]:truncate()") print """ # @@ -103,102 +103,102 @@ pid = 1 tid = 999 for sid in [1, 2]: for i in range(1, 4): - admin("lua box.insert(16, 'pid_%d', 'sid_%d', 'tid_%d')" % (pid, sid, tid)) + admin("box.insert(16, 'pid_%d', 'sid_%d', 'tid_%d')" % (pid, sid, tid)) pid += 1 tid -= 1 -admin("lua for k, v in box.space[16].index[1].next, box.space[16].index[1], 'sid_1' do print(v) end") -admin("lua for k, v in box.space[16].index[1].prev, box.space[16].index[1], 'sid_2' do print(v) end") -admin("lua for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(v) end") -admin("lua for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(v) end") -admin("lua for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(v) end") -admin("lua for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(v) end") -admin("lua box.space[16]:truncate()") +admin("for k, v in box.space[16].index[1].next, box.space[16].index[1], 'sid_1' do print(v) end") +admin("for k, v in box.space[16].index[1].prev, box.space[16].index[1], 'sid_2' do print(v) end") +admin("for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_1' do print(v) end") +admin("for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_1' do print(v) end") +admin("for k, v in box.space[16].index[1].next_equal, box.space[16].index[1], 'sid_2' do print(v) end") +admin("for k, v in box.space[16].index[1].prev_equal, box.space[16].index[1], 'sid_2' do print(v) end") +admin("box.space[16]:truncate()") # # Tests for lua idx:count() # -admin("lua box.insert(17, 1, 1, 1)") -admin("lua box.insert(17, 2, 2, 0)") -admin("lua box.insert(17, 3, 2, 1)") -admin("lua box.insert(17, 4, 3, 0)") -admin("lua box.insert(17, 5, 3, 1)") -admin("lua box.insert(17, 6, 3, 2)") -admin("lua box.space[17].index[1]:count(1)") -admin("lua box.space[17].index[1]:count(2)") -admin("lua box.space[17].index[1]:count(2, 1)") -admin("lua box.space[17].index[1]:count(2, 2)") -admin("lua box.space[17].index[1]:count(3)") -admin("lua box.space[17].index[1]:count(3, 3)") -admin("lua box.space[17].index[1]:count()") -admin("lua box.space[17]:truncate()") +admin("box.insert(17, 1, 1, 1)") +admin("box.insert(17, 2, 2, 0)") +admin("box.insert(17, 3, 2, 1)") +admin("box.insert(17, 4, 3, 0)") +admin("box.insert(17, 5, 3, 1)") +admin("box.insert(17, 6, 3, 2)") +admin("box.space[17].index[1]:count(1)") +admin("box.space[17].index[1]:count(2)") +admin("box.space[17].index[1]:count(2, 1)") +admin("box.space[17].index[1]:count(2, 2)") +admin("box.space[17].index[1]:count(3)") +admin("box.space[17].index[1]:count(3, 3)") +admin("box.space[17].index[1]:count()") +admin("box.space[17]:truncate()") # # Tests for lua box.auto_increment # -admin("lua box.space[18]:truncate()") -admin("lua box.auto_increment(18, 'a')") -admin("lua box.insert(18, 5)") -admin("lua box.auto_increment(18, 'b')") -admin("lua box.auto_increment(18, 'c')") -admin("lua box.space[18]:truncate()") +admin("box.space[18]:truncate()") +admin("box.auto_increment(18, 'a')") +admin("box.insert(18, 5)") +admin("box.auto_increment(18, 'b')") +admin("box.auto_increment(18, 'c')") +admin("box.space[18]:truncate()") # # Tests for lua box.auto_increment with NUM64 keys # -admin("lua box.space[25]:truncate()") -admin("lua box.auto_increment(25, 'a')") -admin("lua box.insert(25, tonumber64(5))") -admin("lua box.auto_increment(25, 'b')") -admin("lua box.auto_increment(25, 'c')") -admin("lua box.space[25]:truncate()") +admin("box.space[25]:truncate()") +admin("box.auto_increment(25, 'a')") +admin("box.insert(25, tonumber64(5))") +admin("box.auto_increment(25, 'b')") +admin("box.auto_increment(25, 'c')") +admin("box.space[25]:truncate()") # # Tests for lua tuple:transform() # -admin("lua t=box.insert(12, '1', '2', '3', '4', '5', '6', '7')") -admin("lua t:transform(7, 0, '8', '9', '100')") -admin("lua t:transform(0, 1)") -admin("lua t:transform(1, 4)") -admin("lua t:transform(-1, 1)") -admin("lua t:transform(-3, 2)") -admin("lua t:transform(0, 0, 'A')") -admin("lua t:transform(-1, 0, 'A')") -admin("lua t:transform(0, 1, 'A')") -admin("lua t:transform(-1, 1, 'B')") -admin("lua t:transform(0, 2, 'C')") -admin("lua t:transform(2, 0, 'hello')") -admin("lua t:transform(0, -1, 'C')") -admin("lua t:transform(0, 100)") -admin("lua t:transform(-100, 1)") -admin("lua t:transform(0, 3, 1, 2, 3)") -admin("lua t:transform(3, 1, tonumber64(4))") -admin("lua t:transform(0, 1, {})") +admin("t=box.insert(12, '1', '2', '3', '4', '5', '6', '7')") +admin("t:transform(7, 0, '8', '9', '100')") +admin("t:transform(0, 1)") +admin("t:transform(1, 4)") +admin("t:transform(-1, 1)") +admin("t:transform(-3, 2)") +admin("t:transform(0, 0, 'A')") +admin("t:transform(-1, 0, 'A')") +admin("t:transform(0, 1, 'A')") +admin("t:transform(-1, 1, 'B')") +admin("t:transform(0, 2, 'C')") +admin("t:transform(2, 0, 'hello')") +admin("t:transform(0, -1, 'C')") +admin("t:transform(0, 100)") +admin("t:transform(-100, 1)") +admin("t:transform(0, 3, 1, 2, 3)") +admin("t:transform(3, 1, tonumber64(4))") +admin("t:transform(0, 1, {})") # # Tests for lua tuple:find() and tuple:findall() # -admin("lua t=box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7')") -admin("lua t:find('2')") -admin("lua t:find('4')") -admin("lua t:find('5')") -admin("lua t:find('A')") -admin("lua t:find('0')") +admin("t=box.insert(12, 'A', '2', '3', '4', '3', '2', '5', '6', '3', '7')") +admin("t:find('2')") +admin("t:find('4')") +admin("t:find('5')") +admin("t:find('A')") +admin("t:find('0')") -admin("lua t:findall('A')") -admin("lua t:findall('2')") -admin("lua t:findall('3')") -admin("lua t:findall('0')") +admin("t:findall('A')") +admin("t:findall('2')") +admin("t:findall('3')") +admin("t:findall('0')") -admin("lua t:find(2, '2')") -admin("lua t:find(89, '2')") -admin("lua t:findall(4, '3')") +admin("t:find(2, '2')") +admin("t:find(89, '2')") +admin("t:findall(4, '3')") -admin("lua t=box.insert(12, 'Z', '2', 2, 3, tonumber64(2))") -admin("lua t:find(2)") -admin("lua t:find(tonumber64(2))") -admin("lua t:find('2')") -admin("lua box.space[12]:truncate()") +admin("t=box.insert(12, 'Z', '2', 2, 3, tonumber64(2))") +admin("t:find(2)") +admin("t:find(tonumber64(2))") +admin("t:find('2')") +admin("box.space[12]:truncate()") print """# # A test case for Bug #1038784 @@ -209,30 +209,30 @@ print """# push_lua_path = os.path.join(vardir, "push.lua") shutil.copy("big/push.lua", push_lua_path) -admin("lua dofile('push.lua')") +admin("dofile('push.lua')") shutil.rmtree(push_lua_path, True) -admin("lua push_collection(0, 1038784, 'hello')") -admin("lua push_collection(0, 1038784, 'hello')") -admin("lua push_collection(0, 1038784, 'hello')") +admin("push_collection(0, 1038784, 'hello')") +admin("push_collection(0, 1038784, 'hello')") +admin("push_collection(0, 1038784, 'hello')") -admin("lua push_collection(1, 1038784, 'hi')") -admin("lua push_collection(2, 1038784, 'hi')") -admin("lua push_collection(2, 1038784, 'hi')") +admin("push_collection(1, 1038784, 'hi')") +admin("push_collection(2, 1038784, 'hi')") +admin("push_collection(2, 1038784, 'hi')") -admin("lua push_collection(5, 1038784, 'hey')") -admin("lua push_collection(5, 1038784, 'hey')") -admin("lua push_collection(5, 1038784, 'hey')") -admin("lua push_collection(5, 1038784, 'hey')") +admin("push_collection(5, 1038784, 'hey')") +admin("push_collection(5, 1038784, 'hey')") +admin("push_collection(5, 1038784, 'hey')") +admin("push_collection(5, 1038784, 'hey')") print """# A test case for Bug#1060967: truncation of 64-bit numbers""" -admin("lua box.space[5]:insert(2^51, 'hello', 'world')") -admin("lua box.space[5]:select(0, 2^51)") -admin("lua box.space[5]:truncate()") +admin("box.space[5]:insert(2^51, 'hello', 'world')") +admin("box.space[5]:select(0, 2^51)") +admin("box.space[5]:truncate()") print """# Test that we print index number in error ER_INDEX_VIOLATION""" -admin("lua box.space[1]:insert(1, 'hello', 'world')") -admin("lua box.space[1]:insert(2, 'hello', 'world')") -admin("lua box.space[1]:truncate()") +admin("box.space[1]:insert(1, 'hello', 'world')") +admin("box.space[1]:insert(2, 'hello', 'world')") +admin("box.space[1]:truncate()") print """# # A test case for Bug #1042798 @@ -241,15 +241,15 @@ print """# #""" # Print key fields in pk -admin("lua for k, f in pairs(box.space[23].index[0].key_field) do print(k, ' => ', f.fieldno) end") -admin("lua box.insert(23, 1, 2, 3, 4)") -admin("lua box.insert(23, 10, 20, 30, 40)") -admin("lua box.insert(23, 20, 30, 40, 50)") -admin("lua for _k, v in box.space[23]:pairs() do print(v) end") +admin("for k, f in pairs(box.space[23].index[0].key_field) do print(k, ' => ', f.fieldno) end") +admin("box.insert(23, 1, 2, 3, 4)") +admin("box.insert(23, 10, 20, 30, 40)") +admin("box.insert(23, 20, 30, 40, 50)") +admin("for _k, v in box.space[23]:pairs() do print(v) end") # Truncate must not hang -admin("lua box.space[23]:truncate()") +admin("box.space[23]:truncate()") # Empty result -admin("lua for _k, v in box.space[23]:pairs() do print(v) end") +admin("for _k, v in box.space[23]:pairs() do print(v) end") print """ #-----------------------------------------------------------------------------# @@ -257,7 +257,7 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua index_random_test(26, 0)") +admin("index_random_test(26, 0)") print """ #-----------------------------------------------------------------------------# @@ -265,7 +265,7 @@ print """ #-----------------------------------------------------------------------------# """; -admin("lua index_random_test(26, 1)") +admin("index_random_test(26, 1)") print """ # @@ -275,6 +275,6 @@ print """ # Test for correct little-endian comparison of integer fields. # (unsigned) #""" -admin("lua for i = 1, 300 do box.insert(2, i, i) print(box.space[2].index[0]:max()) end") -admin("lua box.space[2]:select_range(0, 300)") -admin("lua box.space[2]:truncate()") +admin("for i = 1, 300 do box.insert(2, i, i) print(box.space[2].index[0]:max()) end") +admin("box.space[2]:select_range(0, 300)") +admin("box.space[2]:truncate()") diff --git a/test/big/sql.result b/test/big/sql.result index 8cfaf98431963b4ae406e032984dd7de6e55bcb3..3e8ecdedac061135a44b08ca6539aa6740b6a336 100644 --- a/test/big/sql.result +++ b/test/big/sql.result @@ -82,7 +82,7 @@ insert into t1 values ('key2', 'part1', 'part2_a') Insert OK, 1 row affected insert into t1 values ('key3', 'part1', 'part2_b') Insert OK, 1 row affected -lua for k, v in box.space[1]:pairs() do print(v) end +for k, v in box.space[1]:pairs() do print(v) end --- 846816619: {'part1', 'part2_a'} 863593835: {'part1', 'part2_b'} @@ -126,7 +126,7 @@ insert into t5 values ('31234567', 'part1_a', 'part2') Insert OK, 1 row affected insert into t5 values ('41234567', 'part1_a', 'part2_a') Insert OK, 1 row affected -lua for k, v in box.space[5]:pairs() do print(v) end +for k, v in box.space[5]:pairs() do print(v) end --- 3978425819141910832: {'part1', 'part2'} 3978425819141910833: {'part1', 'part2'} @@ -181,7 +181,7 @@ Found 1 tuple: select * from t7 where k1='world' Found 1 tuple: [4, 'world'] -lua box.space[7]:truncate() +box.space[7]:truncate() --- ... select * from t1 where k0='key1' @@ -221,7 +221,7 @@ delete from t5 where k0='31234567' Delete OK, 1 row affected delete from t5 where k0='41234567' Delete OK, 1 row affected -lua for k, v in box.space[5]:pairs() do print(v) end +for k, v in box.space[5]:pairs() do print(v) end --- ... @@ -332,25 +332,25 @@ insert into t4 values(2, 'Bilimbi') Insert OK, 1 row affected insert into t4 values(3, 'Creature ') Insert OK, 1 row affected -lua for k, v in box.space[4]:pairs() do print(v) end +for k, v in box.space[4]:pairs() do print(v) end --- 2: {'Bilimbi'} 3: {'Creature '} 1: {'Aardvark '} ... -lua box.space[4].index[0].idx:min() +box.space[4].index[0].idx:min() --- error: 'Hash index does not support min()' ... -lua box.space[4].index[0].idx:max() +box.space[4].index[0].idx:max() --- error: 'Hash index does not support max()' ... -lua box.space[4].index[1].idx:min() +box.space[4].index[1].idx:min() --- - 1: {'Aardvark '} ... -lua box.space[4].index[1].idx:max() +box.space[4].index[1].idx:max() --- - 3: {'Creature '} ... diff --git a/test/big/sql.test b/test/big/sql.test index 99f9242927be5b55d503a7e4902bae96ff73f1fc..07c52e97e32d6916fda3c45881b0832a90043d1d 100644 --- a/test/big/sql.test +++ b/test/big/sql.test @@ -56,7 +56,7 @@ sql("insert into t1 values ('key1', 'part1', 'part2')") sql("replace into t1 values ('key1', 'part1', 'part2')") sql("insert into t1 values ('key2', 'part1', 'part2_a')") sql("insert into t1 values ('key3', 'part1', 'part2_b')") -admin("lua for k, v in box.space[1]:pairs() do print(v) end") +admin("for k, v in box.space[1]:pairs() do print(v) end") sql("select * from t1 where k0='key1'") sql("select * from t1 where k0='key2'") sql("select * from t1 where k0='key3'") @@ -70,7 +70,7 @@ sql("insert into t5 values ('11234567', 'part1', 'part2')") sql("insert into t5 values ('21234567', 'part1', 'part2_a')") sql("insert into t5 values ('31234567', 'part1_a', 'part2')") sql("insert into t5 values ('41234567', 'part1_a', 'part2_a')") -admin("lua for k, v in box.space[5]:pairs() do print(v) end") +admin("for k, v in box.space[5]:pairs() do print(v) end") sql("select * from t5 where k0='01234567'") sql("select * from t5 where k0='11234567'") sql("select * from t5 where k0='21234567'") @@ -92,7 +92,7 @@ sql("select * from t7 where k1='hello'") sql("select * from t7 where k1='brave'") sql("select * from t7 where k1='new'") sql("select * from t7 where k1='world'") -admin("lua box.space[7]:truncate()") +admin("box.space[7]:truncate()") sql("select * from t1 where k0='key1'") sql("select * from t1 where k0='key2'") sql("select * from t1 where k0='key3'") @@ -108,7 +108,7 @@ sql("delete from t5 where k0='11234567'") sql("delete from t5 where k0='21234567'") sql("delete from t5 where k0='31234567'") sql("delete from t5 where k0='41234567'") -admin("lua for k, v in box.space[5]:pairs() do print(v) end") +admin("for k, v in box.space[5]:pairs() do print(v) end") print """ # @@ -170,11 +170,11 @@ sql("delete from t4 where k0=15") sql("insert into t4 values(1, 'Aardvark ')") sql("insert into t4 values(2, 'Bilimbi')") sql("insert into t4 values(3, 'Creature ')") -admin("lua for k, v in box.space[4]:pairs() do print(v) end") -admin("lua box.space[4].index[0].idx:min()") -admin("lua box.space[4].index[0].idx:max()") -admin("lua box.space[4].index[1].idx:min()") -admin("lua box.space[4].index[1].idx:max()") +admin("for k, v in box.space[4]:pairs() do print(v) end") +admin("box.space[4].index[0].idx:min()") +admin("box.space[4].index[0].idx:max()") +admin("box.space[4].index[1].idx:min()") +admin("box.space[4].index[1].idx:max()") sql("delete from t4 where k0=1") sql("delete from t4 where k0=2") sql("delete from t4 where k0=3") diff --git a/test/big/suite.ini b/test/big/suite.ini index 4c9d65bcc5f5f528c7e51e57a5d3bdf7de8fc46b..84f40d225a1988aba3e60b450918429f4290f4db 100644 --- a/test/big/suite.ini +++ b/test/big/suite.ini @@ -1,4 +1,5 @@ [default] +core = python tarantool description = tarantool/box, various namespace configurations and properties config = tarantool.cfg # put disabled tests here diff --git a/test/big/tree_pk.result b/test/big/tree_pk.result index d00a981e789f5771562da92dd1962e1ebd02a622..5c1b32e9118fc16d5fc36dcd400f4489c7382e30 100644 --- a/test/big/tree_pk.result +++ b/test/big/tree_pk.result @@ -75,7 +75,7 @@ insert into t3 values (1, 'tuple') Insert OK, 1 row affected insert into t3 values (2, 'tuple') Insert OK, 1 row affected -lua function box.crossjoin(space0, space1, limit) space0 = tonumber(space0) space1 = tonumber(space1) limit = tonumber(limit) local result = {} for k0, v0 in box.space[space0]:pairs() do for k1, v1 in box.space[space1]:pairs() do if limit <= 0 then return unpack(result) end newtuple = {v0:unpack()} for _, v in v1:pairs() do table.insert(newtuple, v) end table.insert(result, newtuple) limit = limit - 1 end end return unpack(result) end + function box.crossjoin(space0, space1, limit) space0 = tonumber(space0) space1 = tonumber(space1) limit = tonumber(limit) local result = {} for k0, v0 in box.space[space0]:pairs() do for k1, v1 in box.space[space1]:pairs() do if limit <= 0 then return unpack(result) end newtuple = {v0:unpack()} for _, v in v1:pairs() do table.insert(newtuple, v) end table.insert(result, newtuple) limit = limit - 1 end end return unpack(result) end --- ... call box.crossjoin('3', '3', '0') @@ -96,7 +96,7 @@ call box.crossjoin('3', '2', '10000') Found 2 tuples: [1, 'tuple', 1, 'tuple'] [2, 'tuple', 1, 'tuple'] -lua box.space[3]:truncate() +box.space[3]:truncate() --- ... insert into t2 values (200, 'select me!') @@ -126,16 +126,16 @@ insert into t15 values ('abcdc') Insert OK, 1 row affected insert into t15 values ('abcdc_') Insert OK, 1 row affected -lua box.space[15].index[0]:select_range(3, 'abcdb') +box.space[15].index[0]:select_range(3, 'abcdb') --- - 'abcdb': {} - 'abcdb_': {} - 'abcdb__': {} ... -lua box.space[15]:truncate() +box.space[15]:truncate() --- ... -lua box.space[22]:truncate() +box.space[22]:truncate() --- ... insert into t22 values (0, 0, 0, 0) @@ -278,6 +278,6 @@ Found 3 tuples: [0, 0, 0, 0] [4, 4, 0, 4] [6, 6, 0, 6] -lua box.space[22]:truncate() +box.space[22]:truncate() --- ... diff --git a/test/big/tree_pk.test b/test/big/tree_pk.test index 6a44723812ff95e1f232af507284ce37d1d96e82..8484a4064a530ffef2cd811244b87716fbeefa96 100644 --- a/test/big/tree_pk.test +++ b/test/big/tree_pk.test @@ -61,12 +61,12 @@ end""" sql("insert into t2 values (1, 'tuple')") sql("insert into t3 values (1, 'tuple')") sql("insert into t3 values (2, 'tuple')") -admin("lua "+ lua.replace('\n', ' ')) +admin(lua.replace('\n', ' ')) sql("call box.crossjoin('3', '3', '0')") sql("call box.crossjoin('3', '3', '5')") sql("call box.crossjoin('3', '3', '10000')") sql("call box.crossjoin('3', '2', '10000')") -admin("lua box.space[3]:truncate()") +admin("box.space[3]:truncate()") # Bug #922520 - select missing keys sql("insert into t2 values (200, 'select me!')") @@ -84,14 +84,14 @@ sql("insert into t15 values ('abcdb__')") sql("insert into t15 values ('abcdb___')") sql("insert into t15 values ('abcdc')") sql("insert into t15 values ('abcdc_')") -admin("lua box.space[15].index[0]:select_range(3, 'abcdb')") -admin("lua box.space[15]:truncate()") +admin("box.space[15].index[0]:select_range(3, 'abcdb')") +admin("box.space[15]:truncate()") # # tree::replace tests # -admin("lua box.space[22]:truncate()") +admin("box.space[22]:truncate()") sql("insert into t22 values (0, 0, 0, 0)") sql("insert into t22 values (1, 1, 1, 1)") @@ -177,5 +177,5 @@ sql("delete from t22 WHERE k0 = 5") sql("select * from t22 WHERE k2 = 0") sql.sort = False -admin("lua box.space[22]:truncate()") +admin("box.space[22]:truncate()") diff --git a/test/big/tree_pk_multipart.result b/test/big/tree_pk_multipart.result index c63f11b590b12178c1df7256680f883c4aee5d9e..2f3294de9578bfe2b924ed149c8244526f4478e8 100644 --- a/test/big/tree_pk_multipart.result +++ b/test/big/tree_pk_multipart.result @@ -38,87 +38,87 @@ insert into t9 values ('The Wolf!', 'Vincent', 3, 'I don`t mean any disrespect, Insert OK, 1 row affected insert into t9 values ('Vincent', 'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.') Insert OK, 1 row affected -lua box.select(9, 0, 'Vincent', 'Jules', 0) +box.select(9, 0, 'Vincent', 'Jules', 0) --- - 'Vincent': {'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'} ... -lua box.select(9, 0, 'Jules', 'Vincent', 0) +box.select(9, 0, 'Jules', 'Vincent', 0) --- - 'Jules': {'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?'} ... -lua box.select(9, 0, 'Vincent', 'Jules', 1) +box.select(9, 0, 'Vincent', 'Jules', 1) --- - 'Vincent': {'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.'} ... -lua box.select(9, 0, 'Jules', 'Vincent', 1) +box.select(9, 0, 'Jules', 'Vincent', 1) --- - 'Jules': {'Vincent', 1, 'Then what do they call it?'} ... -lua box.select(9, 0, 'Vincent', 'Jules', 2) +box.select(9, 0, 'Vincent', 'Jules', 2) --- - 'Vincent': {'Jules', 2, 'They call it a `Royale` with cheese.'} ... -lua box.select(9, 0, 'Jules', 'Vincent', 2) +box.select(9, 0, 'Jules', 'Vincent', 2) --- - 'Jules': {'Vincent', 2, 'A `Royale` with cheese!'} ... -lua box.select(9, 0, 'Vincent', 'Jules', 3) +box.select(9, 0, 'Vincent', 'Jules', 3) --- - 'Vincent': {'Jules', 3, 'That`s right.'} ... -lua box.select(9, 0, 'Jules', 'Vincent', 3) +box.select(9, 0, 'Jules', 'Vincent', 3) --- - 'Jules': {'Vincent', 3, 'What do they call a Big Mac?'} ... -lua box.select(9, 0, 'Vincent', 'Jules', 4) +box.select(9, 0, 'Vincent', 'Jules', 4) --- - 'Vincent': {'Jules', 4, 'A Big Mac`s a Big Mac, but they call it `Le Big Mac.`'} ... -lua box.select(9, 0, 'Jules', 'Vincent', 4) +box.select(9, 0, 'Jules', 'Vincent', 4) --- - 'Jules': {'Vincent', 4, '`Le Big Mac!`'} ... -lua box.select(9, 0, 'Vincent', 'Jules', 5) +box.select(9, 0, 'Vincent', 'Jules', 5) --- - 'Vincent': {'Jules', 5, 'Ha, ha, ha.'} ... -lua box.select(9, 0, 'Jules', 'Vincent', 5) +box.select(9, 0, 'Jules', 'Vincent', 5) --- - 'Jules': {'Vincent', 5, 'What do they call a `Whopper`?'} ... -lua box.select(9, 0, 'Vincent', 'Jules', 6) +box.select(9, 0, 'Vincent', 'Jules', 6) --- - 'Vincent': {'Jules', 6, 'I dunno, I didn`t go into Burger King.'} ... -lua box.select(9, 0, 'The Wolf!', 'Vincent', 0) +box.select(9, 0, 'The Wolf!', 'Vincent', 0) --- - 'The Wolf!': {'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'} ... -lua box.select(9, 0, 'Vincent', 'The Wolf!', 0) +box.select(9, 0, 'Vincent', 'The Wolf!', 0) --- - 'Vincent': {'The Wolf!', 0, 'A please would be nice.'} ... -lua box.select(9, 0, 'The Wolf!', 'Vincent', 1) +box.select(9, 0, 'The Wolf!', 'Vincent', 1) --- - 'The Wolf!': {'Vincent', 1, 'Come again?'} ... -lua box.select(9, 0, 'Vincent', 'The Wolf!', 1) +box.select(9, 0, 'Vincent', 'The Wolf!', 1) --- - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'} ... -lua box.select(9, 0, 'The Wolf!', 'Vincent', 2) +box.select(9, 0, 'The Wolf!', 'Vincent', 2) --- - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'} ... -lua box.select(9, 0, 'The Wolf!', 'Vincent', 3) +box.select(9, 0, 'The Wolf!', 'Vincent', 3) --- - 'The Wolf!': {'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.'} ... -lua box.select(9, 0, 'Vincent', 'The Wolf!', 2) +box.select(9, 0, 'Vincent', 'The Wolf!', 2) --- - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'} ... -lua box.select(9, 0, 'Vincent', 'Jules') +box.select(9, 0, 'Vincent', 'Jules') --- - 'Vincent': {'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'} - 'Vincent': {'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.'} @@ -128,7 +128,7 @@ lua box.select(9, 0, 'Vincent', 'Jules') - 'Vincent': {'Jules', 5, 'Ha, ha, ha.'} - 'Vincent': {'Jules', 6, 'I dunno, I didn`t go into Burger King.'} ... -lua box.select(9, 0, 'Jules', 'Vincent') +box.select(9, 0, 'Jules', 'Vincent') --- - 'Jules': {'Vincent', 0, 'They don`t call it a Quarter Pounder with cheese?'} - 'Jules': {'Vincent', 1, 'Then what do they call it?'} @@ -137,20 +137,20 @@ lua box.select(9, 0, 'Jules', 'Vincent') - 'Jules': {'Vincent', 4, '`Le Big Mac!`'} - 'Jules': {'Vincent', 5, 'What do they call a `Whopper`?'} ... -lua box.select(9, 0, 'Vincent', 'The Wolf!') +box.select(9, 0, 'Vincent', 'The Wolf!') --- - 'Vincent': {'The Wolf!', 0, 'A please would be nice.'} - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'} - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'} ... -lua box.select(9, 0, 'The Wolf!', 'Vincent') +box.select(9, 0, 'The Wolf!', 'Vincent') --- - 'The Wolf!': {'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'} - 'The Wolf!': {'Vincent', 1, 'Come again?'} - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'} - 'The Wolf!': {'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.'} ... -lua box.select(9, 0, 'Vincent') +box.select(9, 0, 'Vincent') --- - 'Vincent': {'Jules', 0, 'Do you know what they call a - a - a Quarter Pounder with cheese in Paris?'} - 'Vincent': {'Jules', 1, 'No man, they got the metric system. They wouldn`t know what the f--k a Quarter Pounder is.'} @@ -163,171 +163,171 @@ lua box.select(9, 0, 'Vincent') - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'} - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'} ... -lua box.delete(9, 'The Wolf!', 'Vincent', 0) +box.delete(9, 'The Wolf!', 'Vincent', 0) --- - 'The Wolf!': {'Vincent', 0, 'Jimmie, lead the way. Boys, get to work.'} ... -lua box.delete(9, 'The Wolf!', 'Vincent', 3) +box.delete(9, 'The Wolf!', 'Vincent', 3) --- - 'The Wolf!': {'Vincent', 3, 'I don`t mean any disrespect, I just don`t like people barking orders at me.'} ... -lua box.delete(9, 'Vincent', 'The Wolf!', 0) +box.delete(9, 'Vincent', 'The Wolf!', 0) --- - 'Vincent': {'The Wolf!', 0, 'A please would be nice.'} ... -lua box.update(9, {'Vincent', 'The Wolf!', 1}, '=p=p', 0, 'Updated', 4, 'New') +box.update(9, {'Vincent', 'The Wolf!', 1}, '=p=p', 0, 'Updated', 4, 'New') --- - 'Updated': {'The Wolf!', 1, 'I said a please would be nice.', 'New'} ... -lua box.update(9, {'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, '') +box.update(9, {'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, '') --- - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'} ... -lua box.select(9, 0, 'Vincent', 'The Wolf!') +box.select(9, 0, 'Vincent', 'The Wolf!') --- - 'Vincent': {'The Wolf!', 1, 'I said a please would be nice.'} - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'} ... -lua box.select(9, 0, 'The Wolf!', 'Vincent') +box.select(9, 0, 'The Wolf!', 'Vincent') --- - 'The Wolf!': {'Vincent', 1, 'Come again?'} - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'} ... -lua box.delete(9, 'Vincent', 'The Wolf!', 3) +box.delete(9, 'Vincent', 'The Wolf!', 3) --- ... -lua box.delete(9, 'Vincent', 'The Wolf!') +box.delete(9, 'Vincent', 'The Wolf!') --- error: 'Invalid key part count in an exact match (expected 3, got 2)' ... -lua box.delete(9, 'The Wolf!', 'Vincent', 1, 'Come again?') +box.delete(9, 'The Wolf!', 'Vincent', 1, 'Come again?') --- error: 'Invalid key part count in an exact match (expected 3, got 4)' ... -lua box.update(9, {'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>') +box.update(9, {'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>') --- - 'The Wolf!': {'Vincent', 1, '<ooops>'} ... -lua box.update(9, {'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>') +box.update(9, {'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>') --- - 'Vincent': {'The Wolf!', 1, '<ooops>'} ... -lua box.select(9, 0, 'Vincent', 'The Wolf!') +box.select(9, 0, 'Vincent', 'The Wolf!') --- - 'Vincent': {'The Wolf!', 1, '<ooops>'} - 'Vincent': {'The Wolf!', 2, 'If I`m curt with you it`s because time is a factor. I think fast, I talk fast and I need you guys to act fast if you wanna get out of this. So, pretty please... with sugar on top. Clean the fucking car.'} ... -lua box.select(9, 0, 'The Wolf!', 'Vincent') +box.select(9, 0, 'The Wolf!', 'Vincent') --- - 'The Wolf!': {'Vincent', 1, '<ooops>'} - 'The Wolf!': {'Vincent', 2, 'Get it straight buster - I`m not here to say please, I`m here to tell you what to do and if self-preservation is an instinct you possess you`d better fucking do it and do it quick. I`m here to help - if my help`s not appreciated then lotsa luck, gentlemen.'} ... -lua box.update(9, {'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>') +box.update(9, {'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>') --- ... -lua box.update(9, {'Vincent', 'The Wolf!'}, '=p', 3, '<ooops>') +box.update(9, {'Vincent', 'The Wolf!'}, '=p', 3, '<ooops>') --- error: 'Invalid key part count in an exact match (expected 3, got 2)' ... -lua box.update(9, {'The Wolf!', 'Vincent', 1, 'Come again?'}, '=p', 3, '<ooops>') +box.update(9, {'The Wolf!', 'Vincent', 1, 'Come again?'}, '=p', 3, '<ooops>') --- error: 'Invalid key part count in an exact match (expected 3, got 4)' ... -lua box.space[9]:len() +box.space[9]:len() --- - 17 ... -lua box.space[9]:truncate() +box.space[9]:truncate() --- ... -lua box.space[9]:len() +box.space[9]:len() --- - 0 ... A test case for Bug#1051006 Tree iterators return garbage if an index is modified between calls -lua box.space[16]:insert('a', 'a', 'a') +box.space[16]:insert('a', 'a', 'a') --- - 'a': {'a', 'a'} ... -lua box.space[16]:insert('d', 'd', 'd') +box.space[16]:insert('d', 'd', 'd') --- - 'd': {'d', 'd'} ... -lua box.space[16]:insert('e', 'e', 'e') +box.space[16]:insert('e', 'e', 'e') --- - 'e': {'e', 'e'} ... -lua box.space[16]:insert('b', 'b', 'b') +box.space[16]:insert('b', 'b', 'b') --- - 'b': {'b', 'b'} ... -lua box.space[16]:insert('c', 'c', 'c') +box.space[16]:insert('c', 'c', 'c') --- - 'c': {'c', 'c'} ... -lua k,v = box.space[16].index[1]:next(k) +k,v = box.space[16].index[1]:next(k) --- ... -lua print(v) +print(v) --- 'a': {'a', 'a'} ... -lua k,v = box.space[16].index[1]:next(k) +k,v = box.space[16].index[1]:next(k) --- ... -lua print(v) +print(v) --- 'b': {'b', 'b'} ... -lua box.space[16]:truncate() +box.space[16]:truncate() --- ... -lua print(v) +print(v) --- 'b': {'b', 'b'} ... -lua collectgarbage('collect') +collectgarbage('collect') --- - 0 ... -lua print(v) +print(v) --- 'b': {'b', 'b'} ... -lua k,v = box.space[16].index[1]:next(k) +k,v = box.space[16].index[1]:next(k) --- ... -lua print(v) +print(v) --- nil ... -lua collectgarbage('collect') +collectgarbage('collect') --- - 0 ... -lua print(v) +print(v) --- nil ... -lua k,v = box.space[16].index[1]:next(k) +k,v = box.space[16].index[1]:next(k) --- ... -lua print(v) +print(v) --- nil ... -lua k,v = box.space[16].index[1]:next(k) +k,v = box.space[16].index[1]:next(k) --- ... -lua print(v) +print(v) --- nil ... -lua k,v = box.space[16].index[1]:next(k) +k,v = box.space[16].index[1]:next(k) --- ... -lua print(v) +print(v) --- nil ... diff --git a/test/big/tree_pk_multipart.test b/test/big/tree_pk_multipart.test index 4ae161d1aab68cece42dd3fd109c26fec11e7f57..8df02f155a8004a0eb414c9425db97edb26cdaed 100644 --- a/test/big/tree_pk_multipart.test +++ b/test/big/tree_pk_multipart.test @@ -32,113 +32,113 @@ sql("insert into t9 values ('Vincent', 'The Wolf!', 2, 'If I`m curt with you it` # # Select by one entry -admin("lua box.select(9, 0, 'Vincent', 'Jules', 0)") -admin("lua box.select(9, 0, 'Jules', 'Vincent', 0)") -admin("lua box.select(9, 0, 'Vincent', 'Jules', 1)") -admin("lua box.select(9, 0, 'Jules', 'Vincent', 1)") -admin("lua box.select(9, 0, 'Vincent', 'Jules', 2)") -admin("lua box.select(9, 0, 'Jules', 'Vincent', 2)") -admin("lua box.select(9, 0, 'Vincent', 'Jules', 3)") -admin("lua box.select(9, 0, 'Jules', 'Vincent', 3)") -admin("lua box.select(9, 0, 'Vincent', 'Jules', 4)") -admin("lua box.select(9, 0, 'Jules', 'Vincent', 4)") -admin("lua box.select(9, 0, 'Vincent', 'Jules', 5)") -admin("lua box.select(9, 0, 'Jules', 'Vincent', 5)") -admin("lua box.select(9, 0, 'Vincent', 'Jules', 6)") - -admin("lua box.select(9, 0, 'The Wolf!', 'Vincent', 0)") -admin("lua box.select(9, 0, 'Vincent', 'The Wolf!', 0)") -admin("lua box.select(9, 0, 'The Wolf!', 'Vincent', 1)") -admin("lua box.select(9, 0, 'Vincent', 'The Wolf!', 1)") -admin("lua box.select(9, 0, 'The Wolf!', 'Vincent', 2)") -admin("lua box.select(9, 0, 'The Wolf!', 'Vincent', 3)") -admin("lua box.select(9, 0, 'Vincent', 'The Wolf!', 2)") +admin("box.select(9, 0, 'Vincent', 'Jules', 0)") +admin("box.select(9, 0, 'Jules', 'Vincent', 0)") +admin("box.select(9, 0, 'Vincent', 'Jules', 1)") +admin("box.select(9, 0, 'Jules', 'Vincent', 1)") +admin("box.select(9, 0, 'Vincent', 'Jules', 2)") +admin("box.select(9, 0, 'Jules', 'Vincent', 2)") +admin("box.select(9, 0, 'Vincent', 'Jules', 3)") +admin("box.select(9, 0, 'Jules', 'Vincent', 3)") +admin("box.select(9, 0, 'Vincent', 'Jules', 4)") +admin("box.select(9, 0, 'Jules', 'Vincent', 4)") +admin("box.select(9, 0, 'Vincent', 'Jules', 5)") +admin("box.select(9, 0, 'Jules', 'Vincent', 5)") +admin("box.select(9, 0, 'Vincent', 'Jules', 6)") + +admin("box.select(9, 0, 'The Wolf!', 'Vincent', 0)") +admin("box.select(9, 0, 'Vincent', 'The Wolf!', 0)") +admin("box.select(9, 0, 'The Wolf!', 'Vincent', 1)") +admin("box.select(9, 0, 'Vincent', 'The Wolf!', 1)") +admin("box.select(9, 0, 'The Wolf!', 'Vincent', 2)") +admin("box.select(9, 0, 'The Wolf!', 'Vincent', 3)") +admin("box.select(9, 0, 'Vincent', 'The Wolf!', 2)") # Select all messages from Vincent to Jules -admin("lua box.select(9, 0, 'Vincent', 'Jules')") +admin("box.select(9, 0, 'Vincent', 'Jules')") # Select all messages from Jules to Vincent -admin("lua box.select(9, 0, 'Jules', 'Vincent')") +admin("box.select(9, 0, 'Jules', 'Vincent')") # Select all messages from Vincent to The Wolf -admin("lua box.select(9, 0, 'Vincent', 'The Wolf!')") +admin("box.select(9, 0, 'Vincent', 'The Wolf!')") # Select all messages from The Wolf to Vincent -admin("lua box.select(9, 0, 'The Wolf!', 'Vincent')") +admin("box.select(9, 0, 'The Wolf!', 'Vincent')") # Select all Vincent messages -admin("lua box.select(9, 0, 'Vincent')") +admin("box.select(9, 0, 'Vincent')") # # Delete test # # Delete some messages from the The Wolf and Vincent dialog -admin("lua box.delete(9, 'The Wolf!', 'Vincent', 0)") -admin("lua box.delete(9, 'The Wolf!', 'Vincent', 3)") -admin("lua box.delete(9, 'Vincent', 'The Wolf!', 0)") +admin("box.delete(9, 'The Wolf!', 'Vincent', 0)") +admin("box.delete(9, 'The Wolf!', 'Vincent', 3)") +admin("box.delete(9, 'Vincent', 'The Wolf!', 0)") -admin("lua box.update(9, {'Vincent', 'The Wolf!', 1}, '=p=p', 0, 'Updated', 4, 'New')") -admin("lua box.update(9, {'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, '')") +admin("box.update(9, {'Vincent', 'The Wolf!', 1}, '=p=p', 0, 'Updated', 4, 'New')") +admin("box.update(9, {'Updated', 'The Wolf!', 1}, '=p#p', 0, 'Vincent', 4, '')") # Checking Vincent's last messages -admin("lua box.select(9, 0, 'Vincent', 'The Wolf!')") +admin("box.select(9, 0, 'Vincent', 'The Wolf!')") # Checking The Wolf's last messages -admin("lua box.select(9, 0, 'The Wolf!', 'Vincent')") +admin("box.select(9, 0, 'The Wolf!', 'Vincent')") # try to delete nonexistent message -admin("lua box.delete(9, 'Vincent', 'The Wolf!', 3)") +admin("box.delete(9, 'Vincent', 'The Wolf!', 3)") # try to delete patrial defined key -admin("lua box.delete(9, 'Vincent', 'The Wolf!')") +admin("box.delete(9, 'Vincent', 'The Wolf!')") # try to delete by invalid key -admin("lua box.delete(9, 'The Wolf!', 'Vincent', 1, 'Come again?')") +admin("box.delete(9, 'The Wolf!', 'Vincent', 1, 'Come again?')") # # Update test # -admin("lua box.update(9, {'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>')") -admin("lua box.update(9, {'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>')") +admin("box.update(9, {'The Wolf!', 'Vincent', 1}, '=p', 3, '<ooops>')") +admin("box.update(9, {'Vincent', 'The Wolf!', 1}, '=p', 3, '<ooops>')") # Checking Vincent's last messages -admin("lua box.select(9, 0, 'Vincent', 'The Wolf!')") +admin("box.select(9, 0, 'Vincent', 'The Wolf!')") # Checking The Wolf's last messages -admin("lua box.select(9, 0, 'The Wolf!', 'Vincent')") +admin("box.select(9, 0, 'The Wolf!', 'Vincent')") # try to update a nonexistent message -admin("lua box.update(9, {'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>')") +admin("box.update(9, {'Vincent', 'The Wolf!', 3}, '=p', 3, '<ooops>')") # try to update patrial defined key -admin("lua box.update(9, {'Vincent', 'The Wolf!'}, '=p', 3, '<ooops>')") +admin("box.update(9, {'Vincent', 'The Wolf!'}, '=p', 3, '<ooops>')") # try to update by invalid key -admin("lua box.update(9, {'The Wolf!', 'Vincent', 1, 'Come again?'}, '=p', 3, '<ooops>')") -admin("lua box.space[9]:len()") -admin("lua box.space[9]:truncate()") -admin("lua box.space[9]:len()") +admin("box.update(9, {'The Wolf!', 'Vincent', 1, 'Come again?'}, '=p', 3, '<ooops>')") +admin("box.space[9]:len()") +admin("box.space[9]:truncate()") +admin("box.space[9]:len()") print """ A test case for Bug#1051006 Tree iterators return garbage if an index is modified between calls""" -admin("lua box.space[16]:insert('a', 'a', 'a')") -admin("lua box.space[16]:insert('d', 'd', 'd')") -admin("lua box.space[16]:insert('e', 'e', 'e')") -admin("lua box.space[16]:insert('b', 'b', 'b')") -admin("lua box.space[16]:insert('c', 'c', 'c')") -admin("lua k,v = box.space[16].index[1]:next(k)") -admin("lua print(v)") -admin("lua k,v = box.space[16].index[1]:next(k)") -admin("lua print(v)") -admin("lua box.space[16]:truncate()") -admin("lua print(v)") -admin("lua collectgarbage('collect')") -admin("lua print(v)") -admin("lua k,v = box.space[16].index[1]:next(k)") -admin("lua print(v)") -admin("lua collectgarbage('collect')") -admin("lua print(v)") -admin("lua k,v = box.space[16].index[1]:next(k)") -admin("lua print(v)") -admin("lua k,v = box.space[16].index[1]:next(k)") -admin("lua print(v)") -admin("lua k,v = box.space[16].index[1]:next(k)") -admin("lua print(v)") +admin("box.space[16]:insert('a', 'a', 'a')") +admin("box.space[16]:insert('d', 'd', 'd')") +admin("box.space[16]:insert('e', 'e', 'e')") +admin("box.space[16]:insert('b', 'b', 'b')") +admin("box.space[16]:insert('c', 'c', 'c')") +admin("k,v = box.space[16].index[1]:next(k)") +admin("print(v)") +admin("k,v = box.space[16].index[1]:next(k)") +admin("print(v)") +admin("box.space[16]:truncate()") +admin("print(v)") +admin("collectgarbage('collect')") +admin("print(v)") +admin("k,v = box.space[16].index[1]:next(k)") +admin("print(v)") +admin("collectgarbage('collect')") +admin("print(v)") +admin("k,v = box.space[16].index[1]:next(k)") +admin("print(v)") +admin("k,v = box.space[16].index[1]:next(k)") +admin("print(v)") +admin("k,v = box.space[16].index[1]:next(k)") +admin("print(v)") # Bug #1082356 sql("insert into t19 values(1, 1)") diff --git a/test/big/tree_variants.result b/test/big/tree_variants.result index 1f7b485689b88c1b3fb2d9783f52c2ce381446ea..d29b54249b8f090fed853976c3968848684cc7c8 100644 --- a/test/big/tree_variants.result +++ b/test/big/tree_variants.result @@ -29,7 +29,7 @@ Found 3 tuples: [3, '00000003', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Corona Extra', 'bar', 2003] [4, '00000004', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004] [5, '00000005', '00000300', 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005] -lua box.space[6]:select(3, 'Joe', 'Sixpack') +box.space[6]:select(3, 'Joe', 'Sixpack') --- - 0: {3472328296227680304, 3472329395739308080, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000} - 1: {3544385890265608240, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 7954882400208119112, 'bar', 2001} @@ -38,25 +38,25 @@ lua box.space[6]:select(3, 'Joe', 'Sixpack') - 4: {3760558672379392048, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Stella Artois', 'bar', 2004} - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005} ... -lua box.space[6]:select(3, 'John') +box.space[6]:select(3, 'John') --- - 6: {3904673860455247920, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006} - 7: {3976731454493175856, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007} - 8: {4048789048531103792, 3472332694274191408, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008} - 9: {4120846642569031728, 3472332694274191408, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} ... -lua box.space[6]:select(4, 'A Pipe') +box.space[6]:select(4, 'A Pipe') --- - 6: {3904673860455247920, 3472332694274191408, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006} ... -lua box.space[6]:select(4, 'Miller Genuine Draft', 'Drinks') +box.space[6]:select(4, 'Miller Genuine Draft', 'Drinks') --- - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005} ... select * from t6 where k5 = 2007 Found 1 tuple: [7, '00000007', '00000400', 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007] -lua box.space[6]:select(6, 'Miller Genuine Draft', 'Drinks') +box.space[6]:select(6, 'Miller Genuine Draft', 'Drinks') --- - 5: {3832616266417319984, 3472331594762563632, 'Joe', 'Sixpack', 'Drinks', 'Miller Genuine Draft', 'bar', 2005} ... @@ -68,45 +68,45 @@ delete from t6 where k0 = 8 Delete OK, 1 row affected delete from t6 where k0 = 9 Delete OK, 1 row affected -lua box.insert(6, 6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 ) +box.insert(6, 6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 ) --- - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006} ... -lua box.insert(6, 7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 ) +box.insert(6, 7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 ) --- - 7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007} ... -lua box.insert(6, 8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 ) +box.insert(6, 8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 ) --- - 8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008} ... -lua box.insert(6, 9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 ) +box.insert(6, 9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 ) --- - 9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} ... -lua box.select(6, 1, 6ULL) +box.select(6, 1, 6ULL) --- - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006} ... -lua box.select(6, 1, 6) +box.select(6, 1, 6) --- - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006} ... -lua box.select(6, 2, 400ULL) +box.select(6, 2, 400ULL) --- - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006} - 7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007} - 8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008} - 9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} ... -lua box.select(6, 2, 400) +box.select(6, 2, 400) --- - 6: {6, 400, 1852337994, 'Smoker', 1937008968, 'A Pipe', 'foo', 2006} - 7: {7, 400, 1852337994, 'Smoker', 1937008968, 'A Bong', 'foo', 2007} - 8: {8, 400, 1852337994, 'Smoker', 'Rolls', 'A Joint', 'foo', 2008} - 9: {9, 400, 1852337994, 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009} ... -lua for k,v in box.space[6]:pairs() do print(v) end +for k,v in box.space[6]:pairs() do print(v) end --- 0: {3472328296227680304, 3472329395739308080, 'Joe', 'Sixpack', 'Drinks', 'Amstel', 'bar', 2000} 1: {3544385890265608240, 3472330495250935856, 'Joe', 'Sixpack', 'Drinks', 7954882400208119112, 'bar', 2001} diff --git a/test/big/tree_variants.test b/test/big/tree_variants.test index f5e52802ab1483ebc1b84da02a5a9a2e817300e7..21133d6052091bc5eb4674314897634ccb67ab5c 100644 --- a/test/big/tree_variants.test +++ b/test/big/tree_variants.test @@ -15,29 +15,29 @@ sql("insert into t6 values (9, '00000009', '00000400', 'John', 'Smoker', 'Rolls' sql("select * from t6 where k0 = 1") sql("select * from t6 where k1 = '00000002'") sql("select * from t6 where k2 = '00000300'") -admin("lua box.space[6]:select(3, 'Joe', 'Sixpack')") -admin("lua box.space[6]:select(3, 'John')") -admin("lua box.space[6]:select(4, 'A Pipe')") -admin("lua box.space[6]:select(4, 'Miller Genuine Draft', 'Drinks')") +admin("box.space[6]:select(3, 'Joe', 'Sixpack')") +admin("box.space[6]:select(3, 'John')") +admin("box.space[6]:select(4, 'A Pipe')") +admin("box.space[6]:select(4, 'Miller Genuine Draft', 'Drinks')") sql("select * from t6 where k5 = 2007") -admin("lua box.space[6]:select(6, 'Miller Genuine Draft', 'Drinks')") +admin("box.space[6]:select(6, 'Miller Genuine Draft', 'Drinks')") sql("delete from t6 where k0 = 6") sql("delete from t6 where k0 = 7") sql("delete from t6 where k0 = 8") sql("delete from t6 where k0 = 9") -admin("lua box.insert(6, 6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 )") -admin("lua box.insert(6, 7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 )") -admin("lua box.insert(6, 8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 )") -admin("lua box.insert(6, 9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 )") +admin("box.insert(6, 6, 6ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Pipe', 'foo', 2006 )") +admin("box.insert(6, 7, 7ULL, 400ULL, 'John', 'Smoker', 'Hits', 'A Bong', 'foo', 2007 )") +admin("box.insert(6, 8, 8ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Joint', 'foo', 2008 )") +admin("box.insert(6, 9, 9ULL, 400ULL, 'John', 'Smoker', 'Rolls', 'A Blunt', 'foo', 2009 )") -admin("lua box.select(6, 1, 6ULL)") -admin("lua box.select(6, 1, 6)") -admin("lua box.select(6, 2, 400ULL)") -admin("lua box.select(6, 2, 400)") +admin("box.select(6, 1, 6ULL)") +admin("box.select(6, 1, 6)") +admin("box.select(6, 2, 400ULL)") +admin("box.select(6, 2, 400)") -admin("lua for k,v in box.space[6]:pairs() do print(v) end") +admin("for k,v in box.space[6]:pairs() do print(v) end") # Test incorrect keys - supplied key field type does not match index type # https://bugs.launchpad.net/tarantool/+bug/1072624 diff --git a/test/box/cjson.result b/test/box/cjson.result index 7cd8fdeaf3764600a49088386b901ee77f54731e..7289f2a76d97b00e41f83dccf7b39c74eb7cc298 100644 --- a/test/box/cjson.result +++ b/test/box/cjson.result @@ -1,37 +1,37 @@ cjson tests -lua type(box.cjson) +type(box.cjson) --- - table ... -lua box.cjson.encode(123) +box.cjson.encode(123) --- - 123 ... -lua box.cjson.encode({123}) +box.cjson.encode({123}) --- - [123] ... -lua box.cjson.encode({123, 234, 345}) +box.cjson.encode({123, 234, 345}) --- - [123,234,345] ... -lua box.cjson.encode({abc = 234, cde = 345}) +box.cjson.encode({abc = 234, cde = 345}) --- - {"cde":345,"abc":234} ... -lua box.cjson.encode({ÐœÐµÑ‚Ð°Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ = { 'Метазначение' } }) +box.cjson.encode({ÐœÐµÑ‚Ð°Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ = { 'Метазначение' } }) --- - {"МетапеременнаÑ":["Метазначение"]} ... -lua box.cjson.decode('123') +box.cjson.decode('123') --- - 123 ... -lua box.cjson.decode('[123, "Кудыкины горы"]')[2] +box.cjson.decode('[123, "Кудыкины горы"]')[2] --- - Кудыкины горы ... -lua box.cjson.decode('{"test": "Результат"}').test +box.cjson.decode('{"test": "Результат"}').test --- - Результат ... diff --git a/test/box/cjson.test b/test/box/cjson.test index 5900409d72df44d7bf2c0f8e295a1859818f80bc..bbe343282581fe532d65a96bec6fbb98ffe8267a 100644 --- a/test/box/cjson.test +++ b/test/box/cjson.test @@ -1,13 +1,13 @@ # encoding: utf-8 # print("cjson tests") -admin("lua type(box.cjson)") -admin("lua box.cjson.encode(123)") -admin("lua box.cjson.encode({123})") -admin("lua box.cjson.encode({123, 234, 345})") -admin("lua box.cjson.encode({abc = 234, cde = 345})") -admin("lua box.cjson.encode({ÐœÐµÑ‚Ð°Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ = { 'Метазначение' } })") +admin("type(box.cjson)") +admin("box.cjson.encode(123)") +admin("box.cjson.encode({123})") +admin("box.cjson.encode({123, 234, 345})") +admin("box.cjson.encode({abc = 234, cde = 345})") +admin("box.cjson.encode({ÐœÐµÑ‚Ð°Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ = { 'Метазначение' } })") -admin("lua box.cjson.decode('123')") -admin("lua box.cjson.decode('[123, \"Кудыкины горы\"]')[2]") -admin("lua box.cjson.decode('{\"test\": \"Результат\"}').test") +admin("box.cjson.decode('123')") +admin("box.cjson.decode('[123, \"Кудыкины горы\"]')[2]") +admin("box.cjson.decode('{\"test\": \"Результат\"}').test") diff --git a/test/box/configuration.result b/test/box/configuration.result index 18faf41fc841cc7951c9d431d434f7ade9d3729c..c98aa49e3a9bc9be6a76aab24e70a7bbbcc9d733 100644 --- a/test/box/configuration.result +++ b/test/box/configuration.result @@ -185,7 +185,7 @@ configuration: # Test floating point values (wal_fsync_delay) with fractional part # (https://bugs.launchpad.net/bugs/876541) -lua box.cfg.wal_fsync_delay +box.cfg.wal_fsync_delay --- - 0.01 ... @@ -193,11 +193,11 @@ lua box.cfg.wal_fsync_delay # Bug#928413 Lua malfunction on certain configuration # (https://bugs.launchpad.net/bugs/928413) -lua box.cfg.wal_fsync_delay +box.cfg.wal_fsync_delay --- - 0.1 ... -lua box.space[0].enabled +box.space[0].enabled --- - true ... @@ -212,7 +212,7 @@ tarantool_box -c tarantool_bad_type.cfg tarantool_box: can't load config: - (space = 0 fieldno = 0) index field type mismatch -lua print_config() +print_config() --- io_collect_interval = 0 pid_file = box.pid diff --git a/test/box/configuration.test b/test/box/configuration.test index 0dbd67936f3510dfcf22f8b713067650a84bf80e..4db50b00692ce5ebb6e0f77a8d1846b844a7125d 100644 --- a/test/box/configuration.test +++ b/test/box/configuration.test @@ -42,7 +42,7 @@ print """ server.stop() server.deploy("box/tarantool_bug876541.cfg") # check values -admin("lua box.cfg.wal_fsync_delay") +admin("box.cfg.wal_fsync_delay") print """ # Bug#928413 Lua malfunction on certain configuration @@ -52,8 +52,8 @@ print """ server.stop() server.deploy("box/tarantool_bug928413.cfg") # check values -admin("lua box.cfg.wal_fsync_delay") -admin("lua box.space[0].enabled") +admin("box.cfg.wal_fsync_delay") +admin("box.space[0].enabled") admin("reload configuration") print """ @@ -73,7 +73,7 @@ shutil.copy("box/test_init.lua", os.path.join(script_dir_path, "init.lua")) server.stop() server.deploy("box/tarantool_scriptdir.cfg") -admin("lua print_config()") +admin("print_config()") # restore default server diff --git a/test/box/errinj.result b/test/box/errinj.result index 8156e496766c40c24f700da34457e0fe9c4dd27c..973b593aeddb2f7b65eeb0cd61bb18c4739ee3f4 100644 --- a/test/box/errinj.result +++ b/test/box/errinj.result @@ -55,7 +55,7 @@ set injection ERRINJ_WAL_IO off --- ok ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... set injection ERRINJ_WAL_ROTATE on @@ -98,7 +98,7 @@ set injection ERRINJ_WAL_ROTATE on --- ok ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- error: 'Failed to write to disk' ... @@ -106,6 +106,6 @@ set injection ERRINJ_WAL_ROTATE off --- ok ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... diff --git a/test/box/errinj.test b/test/box/errinj.test index 68696811d39ce977675577fa3d8d249621990818..0bb9ce2976b6f5b575b0fd25017da4b6717d4f99 100644 --- a/test/box/errinj.test +++ b/test/box/errinj.test @@ -23,7 +23,7 @@ sql("update t0 set k0=2 where k0=1") sql("select * from t0 where k0=1") sql("select * from t0 where k0=2") admin("set injection ERRINJ_WAL_IO off") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") # Check a failed log rotation. admin("set injection ERRINJ_WAL_ROTATE on") @@ -40,7 +40,7 @@ sql("update t0 set k0=2 where k0=1") sql("select * from t0 where k0=1") sql("select * from t0 where k0=2") admin("set injection ERRINJ_WAL_ROTATE on") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") admin("set injection ERRINJ_WAL_ROTATE off") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") # vim: syntax=python diff --git a/test/box/fiber.result b/test/box/fiber.result index 3b49764ee772ca8a9d636ddf2e41055d94050283..289de3b8673940a5b6f410a6d6cb0490354befa8 100644 --- a/test/box/fiber.result +++ b/test/box/fiber.result @@ -1,4 +1,4 @@ -lua box.cfg.rows_per_wal +box.cfg.rows_per_wal --- - 50 ... @@ -10,10 +10,10 @@ insert into t0 values (1, 'testing', 'lua rocks') Insert OK, 1 row affected delete from t0 where k0=1 Delete OK, 1 row affected -lua box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1)) +box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1)) --- ... -lua box.process(22, box.pack('iii', 0, 0, 0)) +box.process(22, box.pack('iii', 0, 0, 0)) --- error: 'box.process(CALL, ...) is not allowed' ... @@ -24,7 +24,7 @@ Found 1 tuple: [1, 'test box delete'] insert into t0 values (1, 'test box delete') Insert OK, 1 row affected -lua box.delete(0, 1) +box.delete(0, 1) --- - 1: {'test box delete'} ... @@ -35,7 +35,7 @@ Found 1 tuple: [1684234849, 'test box delete'] insert into t0 values ('abcd', 'test box delete') Insert OK, 1 row affected -lua box.delete(0, 'abcd') +box.delete(0, 'abcd') --- - 1684234849: {'test box delete'} ... @@ -108,7 +108,7 @@ Found 1 tuple: call box.update('0', 'pass', '-p', 2, '���') Found 1 tuple: [1936941424, 'new', 1684234848] -lua box.update(0, 'pass', '+p', 2, 1) +box.update(0, 'pass', '+p', 2, 1) --- - 1936941424: {'new', 1684234849} ... @@ -119,85 +119,85 @@ reload configuration --- ok ... -lua box.insert(0, 'test') +box.insert(0, 'test') --- - 1953719668: {} ... -lua box.insert(0, 'abcd') +box.insert(0, 'abcd') --- - 1684234849: {} ... -lua box.delete(0, 'test') +box.delete(0, 'test') --- - 1953719668: {} ... -lua box.delete(0, 'abcd') +box.delete(0, 'abcd') --- - 1684234849: {} ... -lua box.space[0]:insert('test', 'hello world') +box.space[0]:insert('test', 'hello world') --- - 1953719668: {'hello world'} ... -lua box.space[0]:update('test', '=p', 1, 'bye, world') +box.space[0]:update('test', '=p', 1, 'bye, world') --- - 1953719668: {'bye, world'} ... -lua box.space[0]:delete('test') +box.space[0]:delete('test') --- - 1953719668: {'bye, world'} ... -lua t=box.space[0]:insert('test') +t=box.space[0]:insert('test') --- ... -lua t=box.space[0]:replace('test', 'another field') +t=box.space[0]:replace('test', 'another field') --- ... -lua t=box.space[0]:replace('test', 'another field', 'one more') +t=box.space[0]:replace('test', 'another field', 'one more') --- ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end +function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end --- ... -lua f = box.fiber.create(y) +f = box.fiber.create(y) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- started ... -lua box.fiber.sleep(0.002) +box.fiber.sleep(0.002) --- ... -lua box.fiber.cancel(f) +box.fiber.cancel(f) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- error: 'fiber.resume(): the fiber is dead' ... -lua for k=1, 1000, 1 do box.fiber.create(function() box.fiber.detach() end) end +for k=1, 1000, 1 do box.fiber.create(function() box.fiber.detach() end) end --- ... -lua collectgarbage('collect') +collectgarbage('collect') --- - 0 ... -lua box.fiber.find(900) +box.fiber.find(900) --- - nil ... -lua box.fiber.find(910) +box.fiber.find(910) --- - nil ... -lua box.fiber.find(920) +box.fiber.find(920) --- - nil ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... diff --git a/test/box/fiber.test b/test/box/fiber.test index 966f2889ab8f753dc997444c76723aac1ce21769..89b1624f1b00e594c02c4b4594cb10a8ae13a37d 100644 --- a/test/box/fiber.test +++ b/test/box/fiber.test @@ -7,23 +7,23 @@ import sys # The test case is dependent on rows_per_wal, since this is when # we reopen the .xlog file and thus wal_scheduler takes a long # pause. -admin("lua box.cfg.rows_per_wal") +admin("box.cfg.rows_per_wal") sql("insert into t0 values (1, 'testing', 'lua rocks')") sql("delete from t0 where k0=1") sql("insert into t0 values (1, 'testing', 'lua rocks')") sql("delete from t0 where k0=1") # check delete: -admin("lua box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1))") -admin("lua box.process(22, box.pack('iii', 0, 0, 0))") +admin("box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1))") +admin("box.process(22, box.pack('iii', 0, 0, 0))") sql("insert into t0 values (1, 'test box delete')") sql("call box.delete('0', '\1\0\0\0')") sql("insert into t0 values (1, 'test box delete')") -admin("lua box.delete(0, 1)") +admin("box.delete(0, 1)") sql("insert into t0 values ('abcd', 'test box delete')") sql("call box.delete('0', 'abcd')") sql("insert into t0 values ('abcd', 'test box delete')") -admin("lua box.delete(0, 'abcd')") +admin("box.delete(0, 'abcd')") sql("insert into t0 values ('abcd', 'test box.select()')") sql("call box.replace('0', 'abcd', 'hello', 'world')") sql("call box.replace('0', 'defc', 'goodbye', 'universe')") @@ -49,34 +49,34 @@ sql("call box.update('0', 'miss', '+p', 2, '\1\0\0\0')") sql("call box.update('0', 'pass', '+p', 2, '\1\0\0\0')") sql("call box.update('0', 'pass', '-p', 2, '\1\0\0\0')") sql("call box.update('0', 'pass', '-p', 2, '\1\0\0\0')") -admin("lua box.update(0, 'pass', '+p', 2, 1)") +admin("box.update(0, 'pass', '+p', 2, 1)") sql("call box.delete('0', 'pass')") admin("reload configuration") # must be read-only -admin("lua box.insert(0, 'test')") -admin("lua box.insert(0, 'abcd')") -admin("lua box.delete(0, 'test')") -admin("lua box.delete(0, 'abcd')") -admin("lua box.space[0]:insert('test', 'hello world')") -admin("lua box.space[0]:update('test', '=p', 1, 'bye, world')") -admin("lua box.space[0]:delete('test')") +admin("box.insert(0, 'test')") +admin("box.insert(0, 'abcd')") +admin("box.delete(0, 'test')") +admin("box.delete(0, 'abcd')") +admin("box.space[0]:insert('test', 'hello world')") +admin("box.space[0]:update('test', '=p', 1, 'bye, world')") +admin("box.space[0]:delete('test')") # test tuple iterators -admin("lua t=box.space[0]:insert('test')") -admin("lua t=box.space[0]:replace('test', 'another field')") -admin("lua t=box.space[0]:replace('test', 'another field', 'one more')") -admin("lua box.space[0]:truncate()") +admin("t=box.space[0]:insert('test')") +admin("t=box.space[0]:replace('test', 'another field')") +admin("t=box.space[0]:replace('test', 'another field', 'one more')") +admin("box.space[0]:truncate()") # test passing arguments in and out created fiber -admin("lua function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end") -admin("lua f = box.fiber.create(y)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.sleep(0.002)") -admin("lua box.fiber.cancel(f)") -admin("lua box.fiber.resume(f)") -admin("lua for k=1, 1000, 1 do box.fiber.create(function() box.fiber.detach() end) end") -admin("lua collectgarbage('collect')") +admin("function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end") +admin("f = box.fiber.create(y)") +admin("box.fiber.resume(f)") +admin("box.fiber.sleep(0.002)") +admin("box.fiber.cancel(f)") +admin("box.fiber.resume(f)") +admin("for k=1, 1000, 1 do box.fiber.create(function() box.fiber.detach() end) end") +admin("collectgarbage('collect')") # check that these newly created fibers are garbage collected -admin("lua box.fiber.find(900)") -admin("lua box.fiber.find(910)") -admin("lua box.fiber.find(920)") -admin("lua box.space[0]:truncate()") +admin("box.fiber.find(900)") +admin("box.fiber.find(910)") +admin("box.fiber.find(920)") +admin("box.space[0]:truncate()") diff --git a/test/box/info.result b/test/box/info.result index 98cf5a6a828562b3932696d68db11a719cb455b7..740d18268d7174c5e4be11bd77742feb809bf2dc 100644 --- a/test/box/info.result +++ b/test/box/info.result @@ -1,72 +1,72 @@ -lua box.info.unknown_variable +box.info.unknown_variable --- - nil ... -lua box.info[23] +box.info[23] --- - nil ... -lua box.info['unknown_variable'] +box.info['unknown_variable'] --- - nil ... -lua string.match(box.info.version, '^[1-9]') ~= nil +string.match(box.info.version, '^[1-9]') ~= nil --- - true ... -lua string.match(box.info.pid, '^[1-9][0-9]*$') ~= nil +string.match(box.info.pid, '^[1-9][0-9]*$') ~= nil --- - true ... -lua string.match(box.info.logger_pid, '^[1-9][0-9]*$') ~= nil +string.match(box.info.logger_pid, '^[1-9][0-9]*$') ~= nil --- - true ... -lua box.info.lsn > 0 +box.info.lsn > 0 --- - true ... -lua box.info.recovery_lag +box.info.recovery_lag --- - 0 ... -lua box.info.recovery_last_update +box.info.recovery_last_update --- - 0 ... -lua box.info.status +box.info.status --- - primary ... -lua string.len(box.info.config) > 0 +string.len(box.info.config) > 0 --- - true ... -lua string.len(box.info.build.target) > 0 +string.len(box.info.build.target) > 0 --- - true ... -lua string.len(box.info.build.compiler) > 0 +string.len(box.info.build.compiler) > 0 --- - true ... -lua string.len(box.info.build.flags) > 0 +string.len(box.info.build.flags) > 0 --- - true ... -lua string.len(box.info.build.options) > 0 +string.len(box.info.build.options) > 0 --- - true ... -lua string.len(box.info.uptime) > 0 +string.len(box.info.uptime) > 0 --- - true ... -lua string.match(box.info.uptime, '^[1-9][0-9]*$') ~= nil +string.match(box.info.uptime, '^[1-9][0-9]*$') ~= nil --- - true ... -lua for k, v in pairs(box.info()) do print(k) end +for k, v in pairs(box.info()) do print(k) end --- version status @@ -80,7 +80,7 @@ build logger_pid config ... -lua box.info.snapshot_pid +box.info.snapshot_pid --- - 0 ... diff --git a/test/box/info.test b/test/box/info.test index 151e1d47b845a88f328579f1c3f610fed22bc8d6..3b3c1ed94bde3236c24b978d8f85932e426dfb56 100644 --- a/test/box/info.test +++ b/test/box/info.test @@ -3,27 +3,27 @@ import os import sys # Test Lua from admin console. Whenever producing output, # make sure it's a valid YAML. -admin("lua box.info.unknown_variable") -admin("lua box.info[23]") -admin("lua box.info['unknown_variable']") -admin("lua string.match(box.info.version, '^[1-9]') ~= nil") -admin("lua string.match(box.info.pid, '^[1-9][0-9]*$') ~= nil") -admin("lua string.match(box.info.logger_pid, '^[1-9][0-9]*$') ~= nil") -# admin("lua box.info.lsn() > 0") -# admin("lua box.info.recovery_lag()") -# admin("lua box.info.recovery_last_update()") -# admin("lua box.info.status()") -admin("lua box.info.lsn > 0") -admin("lua box.info.recovery_lag") -admin("lua box.info.recovery_last_update") -admin("lua box.info.status") -admin("lua string.len(box.info.config) > 0") -admin("lua string.len(box.info.build.target) > 0") -admin("lua string.len(box.info.build.compiler) > 0") -admin("lua string.len(box.info.build.flags) > 0") -admin("lua string.len(box.info.build.options) > 0") -admin("lua string.len(box.info.uptime) > 0") -admin("lua string.match(box.info.uptime, '^[1-9][0-9]*$') ~= nil") +admin("box.info.unknown_variable") +admin("box.info[23]") +admin("box.info['unknown_variable']") +admin("string.match(box.info.version, '^[1-9]') ~= nil") +admin("string.match(box.info.pid, '^[1-9][0-9]*$') ~= nil") +admin("string.match(box.info.logger_pid, '^[1-9][0-9]*$') ~= nil") +# admin("box.info.lsn() > 0") +# admin("box.info.recovery_lag()") +# admin("box.info.recovery_last_update()") +# admin("box.info.status()") +admin("box.info.lsn > 0") +admin("box.info.recovery_lag") +admin("box.info.recovery_last_update") +admin("box.info.status") +admin("string.len(box.info.config) > 0") +admin("string.len(box.info.build.target) > 0") +admin("string.len(box.info.build.compiler) > 0") +admin("string.len(box.info.build.flags) > 0") +admin("string.len(box.info.build.options) > 0") +admin("string.len(box.info.uptime) > 0") +admin("string.match(box.info.uptime, '^[1-9][0-9]*$') ~= nil") -admin("lua for k, v in pairs(box.info()) do print(k) end") -admin("lua box.info.snapshot_pid") +admin("for k, v in pairs(box.info()) do print(k) end") +admin("box.info.snapshot_pid") diff --git a/test/box/ipc.result b/test/box/ipc.result index 943cb85a02dcea5e2aab0463345bfd4b92417f96..0beea46455991997491c341d952ed16cfe5165d6 100644 --- a/test/box/ipc.result +++ b/test/box/ipc.result @@ -1,64 +1,64 @@ -lua ch = box.ipc.channel() +ch = box.ipc.channel() --- ... -lua ch:is_full() +ch:is_full() --- - false ... -lua ch:is_empty() +ch:is_empty() --- - true ... -lua ch:get(.1) +ch:get(.1) --- - nil ... -lua ch:put() +ch:put() --- error: 'usage: channel:put(var [, timeout])' ... -lua ch:put('test') +ch:put('test') --- - true ... -lua ch:get() +ch:get() --- - test ... -lua ch:get('wrong timeout') +ch:get('wrong timeout') --- error: 'timeout must be a number' ... -lua ch:get(-10) +ch:get(-10) --- error: 'wrong timeout' ... -lua ch:put(234) +ch:put(234) --- - true ... -lua ch:put(345, .5) +ch:put(345, .5) --- - false ... -lua ch:is_full() +ch:is_full() --- - true ... -lua ch:is_empty() +ch:is_empty() --- - false ... -lua buffer = {} +buffer = {} --- ... -lua tfbr = box.fiber.create(function() box.fiber.detach() while true do table.insert(buffer, ch:get()) end end) +tfbr = box.fiber.create(function() box.fiber.detach() while true do table.insert(buffer, ch:get()) end end) --- ... -lua box.fiber.resume(tfbr) +box.fiber.resume(tfbr) --- ... -lua for i = 1, 10 do print(i, ' ', ch:put(i, 0.1)) end +for i = 1, 10 do print(i, ' ', ch:put(i, 0.1)) end --- 1 true 2 true @@ -71,42 +71,42 @@ lua for i = 1, 10 do print(i, ' ', ch:put(i, 0.1)) end 9 true 10 true ... -lua ch:has_readers() +ch:has_readers() --- - true ... -lua ch:has_writers() +ch:has_writers() --- - false ... -lua box.fiber.cancel(tfbr) +box.fiber.cancel(tfbr) --- ... -lua ch:has_readers() +ch:has_readers() --- - false ... -lua ch:has_writers() +ch:has_writers() --- - false ... -lua ch:put(box.info.pid) +ch:put(box.info.pid) --- - true ... -lua ch:is_full() +ch:is_full() --- - true ... -lua ch:is_empty() +ch:is_empty() --- - false ... -lua ch:get(box.info.pid) == box.info.pid +ch:get(box.info.pid) == box.info.pid --- - true ... -lua for i, v in pairs(buffer) do print(v) end +for i, v in pairs(buffer) do print(v) end --- 234 1 @@ -120,81 +120,81 @@ lua for i, v in pairs(buffer) do print(v) end 9 10 ... -lua ch:is_empty() +ch:is_empty() --- - true ... -lua ch:broadcast() +ch:broadcast() --- error: 'usage: channel:broadcast(variable)' ... -lua ch:broadcast(123) +ch:broadcast(123) --- - true ... -lua ch:get() +ch:get() --- - 123 ... -lua ch:is_full() +ch:is_full() --- - false ... -lua ch:is_empty() +ch:is_empty() --- - true ... -lua tfbr = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr - ' .. tostring(v)) end end) +tfbr = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr - ' .. tostring(v)) end end) --- ... -lua box.fiber.resume(tfbr) +box.fiber.resume(tfbr) --- ... -lua tfbr2 = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr2 - ' .. tostring(v)) end end) +tfbr2 = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr2 - ' .. tostring(v)) end end) --- ... -lua box.fiber.resume(tfbr2) +box.fiber.resume(tfbr2) --- ... -lua buffer = {} +buffer = {} --- ... -lua for i, v in pairs(buffer) do print(v) end +for i, v in pairs(buffer) do print(v) end --- ... -lua ch:is_full() +ch:is_full() --- - false ... -lua ch:is_empty() +ch:is_empty() --- - true ... -lua ch:put(1) +ch:put(1) --- - true ... -lua ch:put(2) +ch:put(2) --- - true ... -lua ch:put(3) +ch:put(3) --- - true ... -lua ch:put(4) +ch:put(4) --- - true ... -lua ch:put(5) +ch:put(5) --- - true ... -lua ch:broadcast('broadcast message!') +ch:broadcast('broadcast message!') --- - 2 ... -lua for i = 35, 45 do print(ch:put(i)) end +for i = 35, 45 do print(ch:put(i)) end --- true true @@ -208,7 +208,7 @@ true true true ... -lua for i, v in pairs(buffer) do print(v) end +for i, v in pairs(buffer) do print(v) end --- tfbr - 1 tfbr2 - 2 diff --git a/test/box/ipc.test b/test/box/ipc.test index a50d600b79f09cdd37976aaffe6c5004d89a3333..e61fa4d26adedc20449be80cad4a1002cccd8b8d 100644 --- a/test/box/ipc.test +++ b/test/box/ipc.test @@ -2,60 +2,60 @@ # import sys -admin("lua ch = box.ipc.channel()") -admin("lua ch:is_full()") -admin("lua ch:is_empty()") -admin("lua ch:get(.1)") -admin("lua ch:put()") -admin("lua ch:put('test')") -admin("lua ch:get()") -admin("lua ch:get('wrong timeout')") -admin("lua ch:get(-10)") -admin("lua ch:put(234)") -admin("lua ch:put(345, .5)") -admin("lua ch:is_full()") -admin("lua ch:is_empty()") -admin("lua buffer = {}") -admin("lua tfbr = box.fiber.create(function() box.fiber.detach() while true do table.insert(buffer, ch:get()) end end)") -admin("lua box.fiber.resume(tfbr)") -admin("lua for i = 1, 10 do print(i, ' ', ch:put(i, 0.1)) end") -admin("lua ch:has_readers()") -admin("lua ch:has_writers()") -admin("lua box.fiber.cancel(tfbr)") - -admin("lua ch:has_readers()") -admin("lua ch:has_writers()") -admin("lua ch:put(box.info.pid)") -admin("lua ch:is_full()") -admin("lua ch:is_empty()") -admin("lua ch:get(box.info.pid) == box.info.pid") -admin("lua for i, v in pairs(buffer) do print(v) end") - -admin("lua ch:is_empty()") -admin("lua ch:broadcast()") -admin("lua ch:broadcast(123)") -admin("lua ch:get()") - -admin("lua ch:is_full()") -admin("lua ch:is_empty()") -admin("lua tfbr = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr - ' .. tostring(v)) end end)") -admin("lua box.fiber.resume(tfbr)") -admin("lua tfbr2 = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr2 - ' .. tostring(v)) end end)") -admin("lua box.fiber.resume(tfbr2)") - -admin("lua buffer = {}") - -admin("lua for i, v in pairs(buffer) do print(v) end") -admin("lua ch:is_full()") -admin("lua ch:is_empty()") -admin("lua ch:put(1)") -admin("lua ch:put(2)") -admin("lua ch:put(3)") -admin("lua ch:put(4)") -admin("lua ch:put(5)") -admin("lua ch:broadcast('broadcast message!')") -admin("lua for i = 35, 45 do print(ch:put(i)) end") - - -admin("lua for i, v in pairs(buffer) do print(v) end") +admin("ch = box.ipc.channel()") +admin("ch:is_full()") +admin("ch:is_empty()") +admin("ch:get(.1)") +admin("ch:put()") +admin("ch:put('test')") +admin("ch:get()") +admin("ch:get('wrong timeout')") +admin("ch:get(-10)") +admin("ch:put(234)") +admin("ch:put(345, .5)") +admin("ch:is_full()") +admin("ch:is_empty()") +admin("buffer = {}") +admin("tfbr = box.fiber.create(function() box.fiber.detach() while true do table.insert(buffer, ch:get()) end end)") +admin("box.fiber.resume(tfbr)") +admin("for i = 1, 10 do print(i, ' ', ch:put(i, 0.1)) end") +admin("ch:has_readers()") +admin("ch:has_writers()") +admin("box.fiber.cancel(tfbr)") + +admin("ch:has_readers()") +admin("ch:has_writers()") +admin("ch:put(box.info.pid)") +admin("ch:is_full()") +admin("ch:is_empty()") +admin("ch:get(box.info.pid) == box.info.pid") +admin("for i, v in pairs(buffer) do print(v) end") + +admin("ch:is_empty()") +admin("ch:broadcast()") +admin("ch:broadcast(123)") +admin("ch:get()") + +admin("ch:is_full()") +admin("ch:is_empty()") +admin("tfbr = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr - ' .. tostring(v)) end end)") +admin("box.fiber.resume(tfbr)") +admin("tfbr2 = box.fiber.create(function() box.fiber.detach() while true do local v = ch:get() table.insert(buffer, 'tfbr2 - ' .. tostring(v)) end end)") +admin("box.fiber.resume(tfbr2)") + +admin("buffer = {}") + +admin("for i, v in pairs(buffer) do print(v) end") +admin("ch:is_full()") +admin("ch:is_empty()") +admin("ch:put(1)") +admin("ch:put(2)") +admin("ch:put(3)") +admin("ch:put(4)") +admin("ch:put(5)") +admin("ch:broadcast('broadcast message!')") +admin("for i = 35, 45 do print(ch:put(i)) end") + + +admin("for i, v in pairs(buffer) do print(v) end") diff --git a/test/box/lua.result b/test/box/lua.result index 5ce56a2d74e6b9aed990ec87b97778119472a0fd..6a4bd6a44f9569df229cbe2825ebbee35fb49c4b 100644 --- a/test/box/lua.result +++ b/test/box/lua.result @@ -6,11 +6,11 @@ lua 1 --- - 1 ... -lua print(' lua says: hello') +print(' lua says: hello') --- lua says: hello ... -lua local t = {} for n in pairs(box) do table.insert(t, ' - box.' .. tostring(n)) end table.sort(t) for i = 1, #t do print(t[i]) end t = nil +local t = {} for n in pairs(box) do table.insert(t, ' - box.' .. tostring(n)) end table.sort(t) for i = 1, #t do print(t[i]) end t = nil --- - box.auto_increment - box.bless_space @@ -50,148 +50,148 @@ lua local t = {} for n in pairs(box) do table.insert(t, ' - box.' .. tostring(n - box.uuid - box.uuid_hex ... -lua box.pack() +box.pack() --- error: 'bad argument #1 to ''?'' (string expected, got no value)' ... -lua box.pack(1) +box.pack(1) --- error: 'box.pack: argument count does not match the format' ... -lua box.pack('abc') +box.pack('abc') --- error: 'box.pack: argument count does not match the format' ... -lua print(box.pack('a', ' - hello')) +print(box.pack('a', ' - hello')) --- - hello ... -lua print(box.pack('Aa', ' - hello', ' world')) +print(box.pack('Aa', ' - hello', ' world')) --- - hello world ... -lua print(box.pack('w', 0x30)) +print(box.pack('w', 0x30)) --- 0 ... -lua print(box.pack('www', 0x30, 0x30, 0x30)) +print(box.pack('www', 0x30, 0x30, 0x30)) --- 000 ... -lua print(box.pack('www', 0x3030, 0x30)) +print(box.pack('www', 0x3030, 0x30)) --- error: '[string "return print(box.pack(''www'', 0x3030, 0x30))"]:1: box.pack: argument count does not match the format' ... -lua print(string.byte(box.pack('w', 212345), 1, 2)) +print(string.byte(box.pack('w', 212345), 1, 2)) --- 140250 ... -lua print(string.sub(box.pack('p', 1684234849), 2)) +print(string.sub(box.pack('p', 1684234849), 2)) --- abcd ... -lua print(box.pack('p', 'this string is 45 characters long 1234567890 ')) +print(box.pack('p', 'this string is 45 characters long 1234567890 ')) --- -this string is 45 characters long 1234567890 ... -lua print(box.pack('s', 0x4d)) +print(box.pack('s', 0x4d)) --- M ... -lua print(box.pack('ssss', 25940, 29811, 28448, 11883)) +print(box.pack('ssss', 25940, 29811, 28448, 11883)) --- Test ok. ... -lua print(box.pack('SSSS', 25940, 29811, 28448, 11883)) +print(box.pack('SSSS', 25940, 29811, 28448, 11883)) --- Test ok. ... -lua print(box.pack('SSSSSSSS', 28493, 29550, 27680, 27497, 29541, 20512, 29285, 8556)) +print(box.pack('SSSSSSSS', 28493, 29550, 27680, 27497, 29541, 20512, 29285, 8556)) --- Mons likes Perl! ... -lua print(box.pack('bsilww', 84, 29541, 1802444916, 2338318684567380014ULL, 103, 111)) +print(box.pack('bsilww', 84, 29541, 1802444916, 2338318684567380014ULL, 103, 111)) --- Test ok. Let`s go ... -lua print(box.unpack('b', 'T')) +print(box.unpack('b', 'T')) --- 84 ... -lua print(box.unpack('s', 'Te')) +print(box.unpack('s', 'Te')) --- 25940 ... -lua print(box.unpack('i', 'Test')) +print(box.unpack('i', 'Test')) --- 1953719636 ... -lua print(box.unpack('l', 'Test ok.')) +print(box.unpack('l', 'Test ok.')) --- 3344889333436081492 ... -lua box.unpack('bsil', box.pack('bsil', 255, 65535, 4294967295, tonumber64('18446744073709551615'))) +box.unpack('bsil', box.pack('bsil', 255, 65535, 4294967295, tonumber64('18446744073709551615'))) --- - 255 - 65535 - 4294967295 - 18446744073709551615 ... -lua box.unpack('www', box.pack('www', 255, 65535, 4294967295)) +box.unpack('www', box.pack('www', 255, 65535, 4294967295)) --- - 255 - 65535 - 4294967295 ... -lua box.unpack('ppp', box.pack('ppp', 'one', 'two', 'three')) +box.unpack('ppp', box.pack('ppp', 'one', 'two', 'three')) --- - one - two - three ... -lua num, str, num64 = box.unpack('ppp', box.pack('ppp', 666, 'string', tonumber64('666666666666666'))) +num, str, num64 = box.unpack('ppp', box.pack('ppp', 666, 'string', tonumber64('666666666666666'))) --- ... -lua print(box.unpack('i', num), str, box.unpack('l', num64)) +print(box.unpack('i', num), str, box.unpack('l', num64)) --- 666string666666666666666 ... -lua box.unpack('=p', box.pack('=p', 1, '666')) +box.unpack('=p', box.pack('=p', 1, '666')) --- - 1 - 666 ... -lua box.unpack('','') +box.unpack('','') --- ... -lua box.unpack('ii', box.pack('i', 1)) +box.unpack('ii', box.pack('i', 1)) --- error: 'box.unpack(''i''): got 4 bytes (expected: 8+)' ... -lua box.unpack('i', box.pack('ii', 1, 1)) +box.unpack('i', box.pack('ii', 1, 1)) --- error: 'box.unpack(''i''): too many bytes: unpacked 4, total 8' ... -lua box.unpack('+p', box.pack('=p', 1, '666')) +box.unpack('+p', box.pack('=p', 1, '666')) --- error: 'box.unpack(''+p''): unexpected opcode: offset 0, expected ''+'',found ''=''' ... -lua box.process(13, box.pack('iiippp', 0, 1, 3, 1, 'testing', 'lua rocks')) +box.process(13, box.pack('iiippp', 0, 1, 3, 1, 'testing', 'lua rocks')) --- - 1: {'testing', 'lua rocks'} ... -lua box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1)) +box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1)) --- - 1: {'testing', 'lua rocks'} ... -lua box.process(21, box.pack('iiip', 0, 1, 1, 1)) +box.process(21, box.pack('iiip', 0, 1, 1, 1)) --- - 1: {'testing', 'lua rocks'} ... -lua box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1)) +box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1)) --- ... -lua box.process(22, box.pack('iii', 0, 0, 0)) +box.process(22, box.pack('iii', 0, 0, 0)) --- error: 'box.process(CALL, ...) is not allowed' ... @@ -205,10 +205,10 @@ Found 1 tuple: call box.pack('p', 'ascii symbols are visible starting from code 20') Found 1 tuple: ['/ascii symbols are visible starting from code 20'] -lua function f1() return 'testing', 1, false, -1, 1.123, 1e123, nil end +function f1() return 'testing', 1, false, -1, 1.123, 1e123, nil end --- ... -lua f1() +f1() --- - testing - 1 @@ -227,12 +227,12 @@ Found 7 tuples: [1] ['��������'] ['nil'] -lua f1=nil +f1=nil --- ... call f1() An error occurred: ER_NO_SUCH_PROC, 'Procedure 'f1' is not defined' -lua function f1() return f1 end +function f1() return f1 end --- ... call f1() @@ -246,11 +246,11 @@ call box.delete('0', '���') No match insert into t0 values (1, 'test box delete') Insert OK, 1 row affected -lua box.delete(0, 1) +box.delete(0, 1) --- - 1: {'test box delete'} ... -lua box.delete(0, 1) +box.delete(0, 1) --- ... insert into t0 values ('abcd', 'test box delete') @@ -264,11 +264,11 @@ call box.delete('0', 'abcd') No match insert into t0 values ('abcd', 'test box delete') Insert OK, 1 row affected -lua box.delete(0, 'abcd') +box.delete(0, 'abcd') --- - 1684234849: {'test box delete'} ... -lua box.delete(0, 'abcd') +box.delete(0, 'abcd') --- ... call box.select('0', '0', 'abcd') @@ -278,19 +278,19 @@ Insert OK, 1 row affected call box.select('0', '0', 'abcd') Found 1 tuple: [1684234849, 'test box.select()'] -lua box.select(0, 0, 'abcd') +box.select(0, 0, 'abcd') --- - 1684234849: {'test box.select()'} ... -lua box.select(0, 0) +box.select(0, 0) --- error: 'Invalid key part count in an exact match (expected 1, got 0)' ... -lua box.select(0, 1) +box.select(0, 1) --- error: 'No index #1 is defined in space 0' ... -lua box.select(0) +box.select(0) --- error: '[string "-- box.lua (internal file)..."]:13: box.pack: expected 32-bit int' ... @@ -343,14 +343,14 @@ Found 1 tuple: call box.update('0', 'pass', '-p', 2, '���') Found 1 tuple: [1936941424, 'new', 1684234848] -lua box.update(0, 'pass', '+p', 2, 1) +box.update(0, 'pass', '+p', 2, 1) --- - 1936941424: {'new', 1684234849} ... call box.select('0', '0', 'pass') Found 1 tuple: [1936941424, 'new', 1684234849] -lua function field_x(space, key, field_index) return (box.select(space, 0, key))[tonumber(field_index)] end +function field_x(space, key, field_index) return (box.select(space, 0, key))[tonumber(field_index)] end --- ... call field_x('0', 'pass', '0') @@ -362,62 +362,62 @@ Found 1 tuple: call box.delete('0', 'pass') Found 1 tuple: [1936941424, 'new', 1684234849] -lua dofile(...) +dofile(...) --- ... -lua fifo_max +fifo_max --- - nil ... -lua fifo_push('test', 1) +fifo_push('test', 1) --- - 1953719668: {3, 4, 1, 0, 0, 0, 0} ... -lua fifo_push('test', 2) +fifo_push('test', 2) --- - 1953719668: {4, 5, 1, 2, 0, 0, 0} ... -lua fifo_push('test', 3) +fifo_push('test', 3) --- - 1953719668: {5, 6, 1, 2, 3, 0, 0} ... -lua fifo_push('test', 4) +fifo_push('test', 4) --- - 1953719668: {6, 7, 1, 2, 3, 4, 0} ... -lua fifo_push('test', 5) +fifo_push('test', 5) --- - 1953719668: {7, 3, 1, 2, 3, 4, 5} ... -lua fifo_push('test', 6) +fifo_push('test', 6) --- - 1953719668: {3, 4, 6, 2, 3, 4, 5} ... -lua fifo_push('test', 7) +fifo_push('test', 7) --- - 1953719668: {4, 5, 6, 7, 3, 4, 5} ... -lua fifo_push('test', 8) +fifo_push('test', 8) --- - 1953719668: {5, 6, 6, 7, 8, 4, 5} ... -lua fifo_top('test') +fifo_top('test') --- - 8 ... -lua box.delete(0, 'test') +box.delete(0, 'test') --- - 1953719668: {5, 6, 6, 7, 8, 4, 5} ... -lua fifo_top('test') +fifo_top('test') --- - 0 ... -lua box.delete(0, 'test') +box.delete(0, 'test') --- - 1953719668: {3, 3, 0, 0, 0, 0, 0} ... -lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end +for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end --- - io_collect_interval: 0 - pid_file: box.pid @@ -454,7 +454,7 @@ lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end - memcached_space: 23 - memcached_expire: false ... -lua for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end +for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end --- - estimated_rows: 0 - n: 0 @@ -465,7 +465,7 @@ reload configuration --- ok ... -lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end +for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end --- - io_collect_interval: 0 - pid_file: box.pid @@ -502,224 +502,224 @@ lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end - memcached_space: 23 - memcached_expire: false ... -lua for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end +for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end --- - estimated_rows: 0 - n: 0 - enabled: true - arity: 0 ... -lua box.cfg.nosuchoption = 1 +box.cfg.nosuchoption = 1 --- error: '[string "box.cfg = {}..."]:43: Attempt to modify a read-only table' ... -lua box.space[300] = 1 +box.space[300] = 1 --- ... -lua box.index.new('abc', 'cde') +box.index.new('abc', 'cde') --- error: 'bad argument #1 to ''?'' (number expected, got string)' ... -lua box.index.new(1, 2) +box.index.new(1, 2) --- error: 'Space 1 does not exist' ... -lua box.index.new(0, 1) +box.index.new(0, 1) --- error: 'No index #1 is defined in space 0' ... -lua box.index.new(0, 0) +box.index.new(0, 0) --- - index 0 in space 0 ... -lua #box.index.new(0,0) +#box.index.new(0,0) --- - 0 ... -lua #box.space[0].index[0].idx +#box.space[0].index[0].idx --- - 0 ... -lua box.insert(0, 'test') +box.insert(0, 'test') --- - 1953719668: {} ... -lua box.insert(0, 'abcd') +box.insert(0, 'abcd') --- - 1684234849: {} ... -lua #box.index.new(0,0) +#box.index.new(0,0) --- - 2 ... -lua #box.space[0].index[0].idx +#box.space[0].index[0].idx --- - 2 ... -lua box.delete(0, 'test') +box.delete(0, 'test') --- - 1953719668: {} ... -lua #box.index.new(0,0) +#box.index.new(0,0) --- - 1 ... -lua box.delete(0, 'abcd') +box.delete(0, 'abcd') --- - 1684234849: {} ... -lua #box.space[0].index[0].idx +#box.space[0].index[0].idx --- - 0 ... -lua #box.index.new(0,0) +#box.index.new(0,0) --- - 0 ... -lua box.space[0]:insert('test', 'hello world') +box.space[0]:insert('test', 'hello world') --- - 1953719668: {'hello world'} ... -lua box.space[0]:update('test', '=p', 1, 'bye, world') +box.space[0]:update('test', '=p', 1, 'bye, world') --- - 1953719668: {'bye, world'} ... -lua box.space[0]:delete('test') +box.space[0]:delete('test') --- - 1953719668: {'bye, world'} ... -lua t=box.space[0]:insert('test') +t=box.space[0]:insert('test') --- ... -lua t:next('abcd') +t:next('abcd') --- error: 'tuple.next(): bad arguments' ... -lua t:next(1) +t:next(1) --- error: 'tuple.next(): bad arguments' ... -lua t:next(t) +t:next(t) --- error: 'bad argument #2 to ''?'' (box.tuple.iterator expected, got userdata)' ... -lua t:next(t:next()) +t:next(t:next()) --- error: 'tuple.next(): bad arguments' ... -lua for k, v in t:pairs() do print(v) end +for k, v in t:pairs() do print(v) end --- test ... -lua t=box.space[0]:replace('test', 'another field') +t=box.space[0]:replace('test', 'another field') --- ... -lua for k, v in t:pairs() do print(v) end +for k, v in t:pairs() do print(v) end --- test another field ... -lua t=box.space[0]:replace('test', 'another field', 'one more') +t=box.space[0]:replace('test', 'another field', 'one more') --- ... -lua for k, v in t:pairs() do print(v) end +for k, v in t:pairs() do print(v) end --- test another field one more ... -lua t=box.tuple.new({'a', 'b', 'c', 'd'}) +t=box.tuple.new({'a', 'b', 'c', 'd'}) --- ... -lua for it,field in t:pairs() do print(field); end +for it,field in t:pairs() do print(field); end --- a b c d ... -lua it, field = t:next() +it, field = t:next() --- ... -lua getmetatable(it) +getmetatable(it) --- - box.tuple.iterator ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua box.fiber.sleep(0) +box.fiber.sleep(0) --- ... -lua box.fiber.sleep(0.01) +box.fiber.sleep(0.01) --- ... -lua box.fiber.sleep(0.0001) +box.fiber.sleep(0.0001) --- ... -lua box.fiber.sleep('hello') +box.fiber.sleep('hello') --- error: 'fiber.sleep(delay): bad arguments' ... -lua box.fiber.sleep(box, 0.001) +box.fiber.sleep(box, 0.001) --- error: 'fiber.sleep(delay): bad arguments' ... -lua box.fiber.cancel(box.fiber.self()) +box.fiber.cancel(box.fiber.self()) --- error: 'fiber.cancel(): subject fiber does not permit cancel' ... -lua f = box.fiber.self() +f = box.fiber.self() --- ... -lua old_id = f:id() +old_id = f:id() --- ... -lua box.fiber.cancel(f) +box.fiber.cancel(f) --- error: 'fiber.cancel(): subject fiber does not permit cancel' ... -lua box.fiber.self():id() - old_id < 3 +box.fiber.self():id() - old_id < 3 --- - true ... -lua box.fiber.cancel(box.fiber.self()) +box.fiber.cancel(box.fiber.self()) --- error: 'fiber.cancel(): subject fiber does not permit cancel' ... -lua box.fiber.self():id() - old_id < 5 +box.fiber.self():id() - old_id < 5 --- - true ... -lua g = box.fiber.self() +g = box.fiber.self() --- ... -lua f==g +f==g --- - true ... -lua function r() f = box.fiber.create(r) return (box.fiber.resume(f)) end +function r() f = box.fiber.create(r) return (box.fiber.resume(f)) end --- ... -lua r() +r() --- - true ... -lua f = box.fiber.create(print('hello') +f = box.fiber.create(print('hello') --- error: '[string "f = box.fiber.create(print(''hello'')"]:1: '')'' expected near ''<eof>''' ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- error: 'fiber.resume(): the fiber is dead' ... -lua function r(a, b) print(a) print(b) return a, b end +function r(a, b) print(a) print(b) return a, b end --- ... -lua f=box.fiber.create(r) +f=box.fiber.create(r) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- nil nil @@ -727,10 +727,10 @@ nil - nil - nil ... -lua f=box.fiber.create(r) +f=box.fiber.create(r) --- ... -lua box.fiber.resume(f, 'hello') +box.fiber.resume(f, 'hello') --- hello nil @@ -738,10 +738,10 @@ nil - hello - nil ... -lua f=box.fiber.create(r) +f=box.fiber.create(r) --- ... -lua box.fiber.resume(f, 'hello', 'world') +box.fiber.resume(f, 'hello', 'world') --- hello world @@ -749,10 +749,10 @@ world - hello - world ... -lua f=box.fiber.create(r) +f=box.fiber.create(r) --- ... -lua box.fiber.resume(f, 'hello', 'world', 'wide') +box.fiber.resume(f, 'hello', 'world', 'wide') --- hello world @@ -760,94 +760,94 @@ world - hello - world ... -lua function y(a, b) c=box.fiber.yield(a) return box.fiber.yield(b, c) end +function y(a, b) c=box.fiber.yield(a) return box.fiber.yield(b, c) end --- ... -lua f=box.fiber.create(y) +f=box.fiber.create(y) --- ... -lua box.fiber.resume(f, 'hello', 'world') +box.fiber.resume(f, 'hello', 'world') --- - hello ... -lua box.fiber.resume(f, 'wide') +box.fiber.resume(f, 'wide') --- - world - wide ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- - true ... -lua function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end +function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end --- ... -lua f = box.fiber.create(y) +f = box.fiber.create(y) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- started ... -lua box.fiber.sleep(0.002) +box.fiber.sleep(0.002) --- ... -lua box.fiber.cancel(f) +box.fiber.cancel(f) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- error: 'fiber.resume(): the fiber is dead' ... -lua f=nil +f=nil --- ... -lua for k=1, 10000, 1 do box.fiber.create(function() box.fiber.detach() end) end +for k=1, 10000, 1 do box.fiber.create(function() box.fiber.detach() end) end --- ... -lua collectgarbage('collect') +collectgarbage('collect') --- - 0 ... -lua box.fiber.find(900) +box.fiber.find(900) --- - nil ... -lua box.fiber.find(910) +box.fiber.find(910) --- - nil ... -lua box.fiber.find(920) +box.fiber.find(920) --- - nil ... -lua f = function() box.fiber.wrap(f) end +f = function() box.fiber.wrap(f) end --- ... call f() No match -lua f = function(a, b) box.fiber.wrap(function(arg) result = arg end, a..b) end +f = function(a, b) box.fiber.wrap(function(arg) result = arg end, a..b) end --- ... -lua f('hello ', 'world') +f('hello ', 'world') --- ... -lua result +result --- - hello world ... -lua f('bye ', 'world') +f('bye ', 'world') --- ... -lua result +result --- - bye world ... -lua box.fiber.wrap(function() result = box.fiber.status() end) +box.fiber.wrap(function() result = box.fiber.status() end) --- - nil ... -lua result +result --- - running ... @@ -855,7 +855,7 @@ lua result # tarantool crashed during shutdown if non running LUA fiber # was created # -lua f = box.fiber.create(function () return true end) +f = box.fiber.create(function () return true end) --- ... save snapshot @@ -870,54 +870,54 @@ save snapshot --- fail: can't save snapshot, errno 17 (File exists) ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- - true - true ... -lua f = box.fiber.create(function () return true end) +f = box.fiber.create(function () return true end) --- ... # # # -lua box.space[0]:insert('test', 'something to splice') +box.space[0]:insert('test', 'something to splice') --- error: 'Duplicate key exists in unique index 0' ... -lua box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 4, 'no')) +box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 4, 'no')) --- - 1953719668: {28526} ... -lua box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 2, 'every')) +box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 2, 'every')) --- - 1953719668: {'every'} ... -lua box.space[0]:update('test', ':p', 1, box.pack('ppp', 100, 2, 'every')) +box.space[0]:update('test', ':p', 1, box.pack('ppp', 100, 2, 'every')) --- - 1953719668: {'everyevery'} ... -lua box.space[0]:update('test', ':p', 1, box.pack('ppp', -100, 2, 'every')) +box.space[0]:update('test', ':p', 1, box.pack('ppp', -100, 2, 'every')) --- error: 'Field SPLICE error: offset is out of bound' ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua box.space[0]:insert('test', 'hello', 'october', '20th'):unpack() +box.space[0]:insert('test', 'hello', 'october', '20th'):unpack() --- - test - hello - october - 20th ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua function f1(...) return {...} end +function f1(...) return {...} end --- ... -lua function f2(...) return f1({...}) end +function f2(...) return f1({...}) end --- ... call f1('test_', 'test_') @@ -932,41 +932,41 @@ Found 1 tuple: call f2() Found 1 tuple: [] -lua function f3() return {{'hello'}, {'world'}} end +function f3() return {{'hello'}, {'world'}} end --- ... call f3() Found 2 tuples: ['hello'] ['world'] -lua function f3() return {'hello', {'world'}} end +function f3() return {'hello', {'world'}} end --- ... call f3() An error occurred: ER_PROC_RET, 'Return type 'table' is not supported in the binary protocol' -lua function f3() return 'hello', {{'world'}, {'canada'}} end +function f3() return 'hello', {{'world'}, {'canada'}} end --- ... call f3() An error occurred: ER_PROC_RET, 'Return type 'table' is not supported in the binary protocol' -lua function f3() return {}, '123', {{}, {}} end +function f3() return {}, '123', {{}, {}} end --- ... call f3() An error occurred: ER_PROC_RET, 'Return type 'table' is not supported in the binary protocol' -lua function f3() return { {{'hello'}} } end +function f3() return { {{'hello'}} } end --- ... call f3() An error occurred: ER_PROC_RET, 'Return type 'table' is not supported in the binary protocol' -lua function f3() return { box.tuple.new('hello'), {'world'} } end +function f3() return { box.tuple.new('hello'), {'world'} } end --- ... call f3() Found 2 tuples: ['hello'] ['world'] -lua function f3() return { {'world'}, box.tuple.new('hello') } end +function f3() return { {'world'}, box.tuple.new('hello') } end --- ... call f3() @@ -979,23 +979,23 @@ Found 1 tuple: call f1('jason', 1, 'test', 2, 'stewart') Found 1 tuple: ['jason', '1', 1953719668, '2', 'stewart'] -lua function box.crossjoin(space0, space1, limit) space0 = tonumber(space0) space1 = tonumber(space1) limit = tonumber(limit) local result = {} for k0, v0 in box.space[space0]:pairs() do for k1, v1 in box.space[space1]:pairs() do if limit <= 0 then return unpack(result) end newtuple = {v0:unpack()} for _, v in v1:pairs() do table.insert(newtuple, v) end table.insert(result, newtuple) limit = limit - 1 end end return unpack(result) end + function box.crossjoin(space0, space1, limit) space0 = tonumber(space0) space1 = tonumber(space1) limit = tonumber(limit) local result = {} for k0, v0 in box.space[space0]:pairs() do for k1, v1 in box.space[space1]:pairs() do if limit <= 0 then return unpack(result) end newtuple = {v0:unpack()} for _, v in v1:pairs() do table.insert(newtuple, v) end table.insert(result, newtuple) limit = limit - 1 end end return unpack(result) end --- ... -lua box.crossjoin(0, 0, 0) +box.crossjoin(0, 0, 0) --- ... -lua box.crossjoin(0, 0, 10000) +box.crossjoin(0, 0, 10000) --- ... -lua box.space[0]:insert(1) +box.space[0]:insert(1) --- - 1: {} ... call box.crossjoin('0', '0', '10000') Found 1 tuple: [1, 1] -lua box.space[0]:insert(2) +box.space[0]:insert(2) --- - 2: {} ... @@ -1005,7 +1005,7 @@ Found 4 tuples: [1, 2] [2, 1] [2, 2] -lua box.space[0]:insert(3, 'hello') +box.space[0]:insert(3, 'hello') --- - 3: {'hello'} ... @@ -1020,11 +1020,11 @@ Found 9 tuples: [3, 'hello', 1] [3, 'hello', 2] [3, 'hello', 3, 'hello'] -lua box.space[0]:insert(4, 'world') +box.space[0]:insert(4, 'world') --- - 4: {'world'} ... -lua box.space[0]:insert(5, 'hello world') +box.space[0]:insert(5, 'hello world') --- - 5: {'hello world'} ... @@ -1055,39 +1055,39 @@ Found 25 tuples: [5, 'hello world', 3, 'hello'] [5, 'hello world', 4, 'world'] [5, 'hello world', 5, 'hello world'] -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua box.crossjoin = nil +box.crossjoin = nil --- ... # A test case for Bug#901674 # No way to inspect exceptions from Box in Lua -lua pcall(box.insert, 99, 1, 'test') +pcall(box.insert, 99, 1, 'test') --- - false - Space 99 does not exist ... -lua pcall(box.insert, 0, 1, 'hello') +pcall(box.insert, 0, 1, 'hello') --- - true - 1: {'hello'} ... -lua pcall(box.insert, 0, 1, 'hello') +pcall(box.insert, 0, 1, 'hello') --- - false - Duplicate key exists in unique index 0 ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... # A test case for Bug#908094 # Lua provides access to os.execute() -lua os.execute('ls') +os.execute('ls') --- error: '[string "return os.execute(''ls'')"]:1: attempt to call field ''execute'' (a nil value)' ... @@ -1096,28 +1096,28 @@ error: '[string "return os.execute(''ls'')"]:1: attempt to call field ''execute' # box.fiber test (create, resume, yield, status) # -lua dofile(...) +dofile(...) --- ... # test box.fiber.status functions: invalid arguments -lua box.fiber.status(1) +box.fiber.status(1) --- error: 'bad argument #1 to ''?'' (box.fiber expected, got number)' ... -lua box.fiber.status('fafa-gaga') +box.fiber.status('fafa-gaga') --- error: 'bad argument #1 to ''?'' (box.fiber expected, got string)' ... -lua box.fiber.status(nil) +box.fiber.status(nil) --- error: 'bad argument #1 to ''?'' (box.fiber expected, got nil)' ... # run fiber's test -lua box_fiber_run_test() +box_fiber_run_test() --- tester: status(tester) = running tester: status(printer) = suspended @@ -1143,47 +1143,47 @@ count: 5 B: odd 5 status: dead ... -lua tonumber64(123) +tonumber64(123) --- - 123 ... -lua tonumber64('123') +tonumber64('123') --- - 123 ... -lua type(tonumber64('123')) == 'cdata' +type(tonumber64('123')) == 'cdata' --- - true ... -lua tonumber64('9223372036854775807') == tonumber64('9223372036854775807') +tonumber64('9223372036854775807') == tonumber64('9223372036854775807') --- - true ... -lua tonumber64('9223372036854775807') - tonumber64('9223372036854775800') +tonumber64('9223372036854775807') - tonumber64('9223372036854775800') --- - 7 ... -lua tonumber64('18446744073709551615') == tonumber64('18446744073709551615') +tonumber64('18446744073709551615') == tonumber64('18446744073709551615') --- - true ... -lua tonumber64('18446744073709551615') + 1 +tonumber64('18446744073709551615') + 1 --- - 0 ... -lua tonumber64(-1) +tonumber64(-1) --- - 18446744073709551615 ... -lua tonumber64('184467440737095516155') +tonumber64('184467440737095516155') --- error: 'lua_tointeger64: bad argument' ... -lua string.byte(box.pack('p', tonumber64(123))) +string.byte(box.pack('p', tonumber64(123))) --- - 8 ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... call box.insert('0', 'tes1', 'tes2', 'tes3', 'tes4', 'tes5') @@ -1201,59 +1201,59 @@ Found 1 tuple: call box.update('0', 'tes4', '#p', 0, '') Found 1 tuple: [896755060] -lua box.update(0, 'tes5', '#p', 0, '') +box.update(0, 'tes5', '#p', 0, '') --- error: 'Illegal parameters, tuple must have all indexed fields' ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... # test box.update: INSERT field -lua box.insert(0, 1, 3, 6, 9) +box.insert(0, 1, 3, 6, 9) --- - 1: {3, 6, 9} ... -lua box.update(0, 1, '!p', 1, 2) +box.update(0, 1, '!p', 1, 2) --- - 1: {2, 3, 6, 9} ... -lua box.update(0, 1, '!p!p!p!p', 3, 4, 3, 5, 4, 7, 4, 8) +box.update(0, 1, '!p!p!p!p', 3, 4, 3, 5, 4, 7, 4, 8) --- - 1: {2, 3, 5, 8, 7, 4, 6, 9} ... -lua box.update(0, 1, '!p!p!p', 9, 10, 9, 11, 9, 12) +box.update(0, 1, '!p!p!p', 9, 10, 9, 11, 9, 12) --- - 1: {2, 3, 5, 8, 7, 4, 6, 9, 12, 11, 10} ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua box.insert(0, 1, 'tuple') +box.insert(0, 1, 'tuple') --- - 1: {'tuple'} ... -lua box.update(0, 1, '#p!p=p', 1, '', 1, 'inserted tuple', 2, 'set tuple') +box.update(0, 1, '#p!p=p', 1, '', 1, 'inserted tuple', 2, 'set tuple') --- - 1: {'inserted tuple', 'set tuple'} ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua box.insert(0, 1, 'tuple') +box.insert(0, 1, 'tuple') --- - 1: {'tuple'} ... -lua box.update(0, 1, '=p!p#p', 1, 'set tuple', 1, 'inerted tuple', 2, '') +box.update(0, 1, '=p!p#p', 1, 'set tuple', 1, 'inerted tuple', 2, '') --- - 1: {'inerted tuple'} ... -lua box.update(0, 1, '!p!p', 0, 3, 0, 2) +box.update(0, 1, '!p!p', 0, 3, 0, 2) --- - 2: {3, 1, 'inerted tuple'} ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... @@ -1261,7 +1261,7 @@ lua box.space[0]:truncate() # Lua Numbers are passed back wrongly as strings # -lua function foo() return 1, 2, '1', '2' end +function foo() return 1, 2, '1', '2' end --- ... call foo() @@ -1273,50 +1273,50 @@ Found 4 tuples: # test update's assign opearations -lua box.replace(0, 1, 'field string value') +box.replace(0, 1, 'field string value') --- - 1: {'field string value'} ... -lua box.update(0, 1, '=p=p=p', 1, 'new field string value', 2, 42, 3, 0xdeadbeef) +box.update(0, 1, '=p=p=p', 1, 'new field string value', 2, 42, 3, 0xdeadbeef) --- - 1: {'new field string value', 42, 3735928559} ... # test update's arith opearations -lua box.update(0, 1, '+p&p|p^p', 2, 16, 3, 0xffff0000, 3, 0x0000a0a0, 3, 0xffff00aa) +box.update(0, 1, '+p&p|p^p', 2, 16, 3, 0xffff0000, 3, 0x0000a0a0, 3, 0xffff00aa) --- - 1: {'new field string value', 58, 559063050} ... # test update splice operation -lua ops_list = {} +ops_list = {} --- ... -lua table.insert(ops_list, box.upd.splice(1, 0, 3, 'the newest')) +table.insert(ops_list, box.upd.splice(1, 0, 3, 'the newest')) --- error: '[string "return table.insert(ops_list, box.upd.splice(..."]:1: attempt to index field ''upd'' (a nil value)' ... -lua box.update(0, 1, ':p', 1, box.pack('ppp', 0, 3, 'the newest')) +box.update(0, 1, ':p', 1, box.pack('ppp', 0, 3, 'the newest')) --- - 1: {'the newest field string value', 58, 559063050} ... # test update delete operations -lua box.update(0, 1, '#p#p', 3, '', 2, '') +box.update(0, 1, '#p#p', 3, '', 2, '') --- - 1: {'the newest field string value'} ... # test update insert operations -lua box.update(0, 1, '!p!p!p!p', 1, 1, 1, 2, 1, 3, 1, 4) +box.update(0, 1, '!p!p!p!p', 1, 1, 1, 2, 1, 3, 1, 4) --- - 1: {4, 3, 2, 1, 'the newest field string value'} ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... @@ -1324,7 +1324,7 @@ lua box.space[0]:truncate() # test that ffi extension is inaccessible # -lua ffi +ffi --- - nil ... @@ -1339,7 +1339,7 @@ lua ffi # Test asscess to box configuration -lua print_config() +print_config() --- io_collect_interval = 0 pid_file = box.pid @@ -1379,37 +1379,37 @@ wal_dir_rescan_delay = 0.1 # Test bug #977898 -lua box.insert(0, 4, 8, 16) +box.insert(0, 4, 8, 16) --- - 4: {8, 16} ... # Test insert from init.lua -lua box.select(0, 0, 1) +box.select(0, 0, 1) --- - 1: {2, 4, 8} ... -lua box.select(0, 0, 2) +box.select(0, 0, 2) --- - 2: {4, 8, 16} ... -lua box.select(0, 0, 4) +box.select(0, 0, 4) --- - 4: {8, 16} ... # Test bug #1002272 -lua floor(0.5) +floor(0.5) --- - 0 ... -lua floor(0.9) +floor(0.9) --- - 0 ... -lua floor(1.1) +floor(1.1) --- - 1 ... @@ -1419,10 +1419,10 @@ lua floor(1.1) # Test box.tuple:slice() -lua t=box.tuple.new({'0', '1', '2', '3', '4', '5', '6', '7'}) +t=box.tuple.new({'0', '1', '2', '3', '4', '5', '6', '7'}) --- ... -lua t:slice(0) +t:slice(0) --- - 0 - 1 @@ -1433,11 +1433,11 @@ lua t:slice(0) - 6 - 7 ... -lua t:slice(-1) +t:slice(-1) --- - 7 ... -lua t:slice(1) +t:slice(1) --- - 1 - 2 @@ -1447,15 +1447,15 @@ lua t:slice(1) - 6 - 7 ... -lua t:slice(-1, -1) +t:slice(-1, -1) --- error: 'tuple.slice(): start must be less than end' ... -lua t:slice(-1, 1) +t:slice(-1, 1) --- error: 'tuple.slice(): start must be less than end' ... -lua t:slice(1, -1) +t:slice(1, -1) --- - 1 - 2 @@ -1464,52 +1464,52 @@ lua t:slice(1, -1) - 5 - 6 ... -lua t:slice(1, 3) +t:slice(1, 3) --- - 1 - 2 ... -lua t:slice(7) +t:slice(7) --- - 7 ... -lua t:slice(8) +t:slice(8) --- error: 'tuple.slice(): start >= field count' ... -lua t:slice(9) +t:slice(9) --- error: 'tuple.slice(): start >= field count' ... -lua t:slice(100500) +t:slice(100500) --- error: 'tuple.slice(): start >= field count' ... -lua t:slice(9, -1) +t:slice(9, -1) --- error: 'tuple.slice(): start >= field count' ... -lua t:slice(6, -1) +t:slice(6, -1) --- - 6 ... -lua t:slice(4, 4) +t:slice(4, 4) --- error: 'tuple.slice(): start must be less than end' ... -lua t:slice(6, 4) +t:slice(6, 4) --- error: 'tuple.slice(): start must be less than end' ... -lua t:slice(0, 0) +t:slice(0, 0) --- error: 'tuple.slice(): end > field count' ... -lua t:slice(9, 10) +t:slice(9, 10) --- error: 'tuple.slice(): start >= field count' ... -lua t:slice(-7) +t:slice(-7) --- - 1 - 2 @@ -1519,7 +1519,7 @@ lua t:slice(-7) - 6 - 7 ... -lua t:slice(-8) +t:slice(-8) --- - 0 - 1 @@ -1530,205 +1530,205 @@ lua t:slice(-8) - 6 - 7 ... -lua t:slice(-9) +t:slice(-9) --- error: 'tuple.slice(): start >= field count' ... -lua t:slice(-100500) +t:slice(-100500) --- error: 'tuple.slice(): start >= field count' ... -lua t:slice(500, 700) +t:slice(500, 700) --- error: 'tuple.slice(): start >= field count' ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... # A test case for Bug#911641 box.fiber.sleep() works incorrectly if # a fiber is attached. -lua function r() return box.fiber.sleep(0.01) end +function r() return box.fiber.sleep(0.01) end --- ... -lua f = box.fiber.create(r) +f = box.fiber.create(r) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- - true ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- error: 'fiber.resume(): the fiber is dead' ... -lua function r() box.fiber.yield(box.space[0]:insert(0, 0, 1)) box.fiber.yield(box.space[0]:select(0, 0)) box.fiber.yield(box.space[0]:truncate()) end +function r() box.fiber.yield(box.space[0]:insert(0, 0, 1)) box.fiber.yield(box.space[0]:select(0, 0)) box.fiber.yield(box.space[0]:truncate()) end --- ... -lua f = box.fiber.create(r) +f = box.fiber.create(r) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- - 0: {0, 1} ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- - 0: {0, 1} ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- - true ... -lua function r() return box.fiber.yield(box.fiber.create(r)) end +function r() return box.fiber.yield(box.fiber.create(r)) end --- ... -lua f = r() +f = r() --- ... -lua f1 = box.fiber.resume(f) +f1 = box.fiber.resume(f) --- ... -lua f2 = box.fiber.resume(f1) +f2 = box.fiber.resume(f1) --- ... -lua f3 = box.fiber.resume(f2) +f3 = box.fiber.resume(f2) --- ... -lua f4 = box.fiber.resume(f3) +f4 = box.fiber.resume(f3) --- ... -lua f5 = box.fiber.resume(f4) +f5 = box.fiber.resume(f4) --- ... -lua f6 = box.fiber.resume(f5) +f6 = box.fiber.resume(f5) --- ... -lua f7 = box.fiber.resume(f6) +f7 = box.fiber.resume(f6) --- ... -lua f8 = box.fiber.resume(f7) +f8 = box.fiber.resume(f7) --- ... -lua f9 = box.fiber.resume(f8) +f9 = box.fiber.resume(f8) --- ... -lua f10 = box.fiber.resume(f9) +f10 = box.fiber.resume(f9) --- ... -lua f11 = box.fiber.resume(f10) +f11 = box.fiber.resume(f10) --- ... -lua f12 = box.fiber.resume(f11) +f12 = box.fiber.resume(f11) --- ... -lua f13 = box.fiber.resume(f12) +f13 = box.fiber.resume(f12) --- ... -lua f14 = box.fiber.resume(f13) +f14 = box.fiber.resume(f13) --- ... -lua f15 = box.fiber.resume(f14) +f15 = box.fiber.resume(f14) --- ... -lua f16 = box.fiber.resume(f15) +f16 = box.fiber.resume(f15) --- ... -lua f17 = box.fiber.resume(f16) +f17 = box.fiber.resume(f16) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- - true ... -lua box.fiber.resume(f1) +box.fiber.resume(f1) --- - true ... -lua box.fiber.resume(f2) +box.fiber.resume(f2) --- - true ... -lua box.fiber.resume(f3) +box.fiber.resume(f3) --- - true ... -lua box.fiber.resume(f4) +box.fiber.resume(f4) --- - true ... -lua box.fiber.resume(f5) +box.fiber.resume(f5) --- - true ... -lua box.fiber.resume(f6) +box.fiber.resume(f6) --- - true ... -lua box.fiber.resume(f7) +box.fiber.resume(f7) --- - true ... -lua box.fiber.resume(f8) +box.fiber.resume(f8) --- - true ... -lua box.fiber.resume(f9) +box.fiber.resume(f9) --- - true ... -lua box.fiber.resume(f10) +box.fiber.resume(f10) --- - true ... -lua box.fiber.resume(f11) +box.fiber.resume(f11) --- - true ... -lua box.fiber.resume(f12) +box.fiber.resume(f12) --- - true ... -lua box.fiber.resume(f13) +box.fiber.resume(f13) --- - true ... -lua box.fiber.resume(f14) +box.fiber.resume(f14) --- - true ... -lua box.fiber.resume(f15) +box.fiber.resume(f15) --- - true ... -lua box.fiber.resume(f16) +box.fiber.resume(f16) --- - true ... -lua f17 = nil +f17 = nil --- ... -lua function r() box.fiber.detach() box.fiber.sleep(1000) end +function r() box.fiber.detach() box.fiber.sleep(1000) end --- ... -lua f = box.fiber.create(r) +f = box.fiber.create(r) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- error: 'fiber.resume(): can''t resume a detached fiber' ... -lua box.fiber.cancel(f) +box.fiber.cancel(f) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- error: 'fiber.resume(): the fiber is dead' ... @@ -1737,19 +1737,19 @@ error: 'fiber.resume(): the fiber is dead' # server CALL processing bug with name path longer than two # https://bugs.launchpad.net/tarantool/+bug/1034912 -lua f = function() return 'OK' end +f = function() return 'OK' end --- ... -lua test = {} +test = {} --- ... -lua test.f = f +test.f = f --- ... -lua test.test = {} +test.test = {} --- ... -lua test.test.f = f +test.test.f = f --- ... call f() @@ -1764,286 +1764,286 @@ Found 1 tuple: # A test case for box.counter -lua box.counter.inc(0, 1) +box.counter.inc(0, 1) --- - 1 ... -lua box.select(0, 0, 1) +box.select(0, 0, 1) --- - 1: {1} ... -lua box.counter.inc(0, 1) +box.counter.inc(0, 1) --- - 2 ... -lua box.counter.inc(0, 1) +box.counter.inc(0, 1) --- - 3 ... -lua box.select(0, 0, 1) +box.select(0, 0, 1) --- - 1: {3} ... -lua box.counter.dec(0, 1) +box.counter.dec(0, 1) --- - 2 ... -lua box.counter.dec(0, 1) +box.counter.dec(0, 1) --- - 1 ... -lua box.select(0, 0, 1) +box.select(0, 0, 1) --- - 1: {1} ... -lua box.counter.dec(0, 1) +box.counter.dec(0, 1) --- - 0 ... -lua box.select(0, 0, 1) +box.select(0, 0, 1) --- ... # box.dostring() -lua box.dostring('abc') +box.dostring('abc') --- error: '[string "abc"]:1: ''='' expected near ''<eof>''' ... -lua box.dostring('abc=2') +box.dostring('abc=2') --- ... -lua box.dostring('return abc') +box.dostring('return abc') --- - 2 ... -lua box.dostring('return ...', 1, 2, 3) +box.dostring('return ...', 1, 2, 3) --- - 1 - 2 - 3 ... # box.update: push/pop fields -lua box.insert(0, 'abcd') +box.insert(0, 'abcd') --- - 1684234849: {} ... -lua box.update(0, 'abcd', '#p', 1, '') +box.update(0, 'abcd', '#p', 1, '') --- error: 'Field 1 was not found in the tuple' ... -lua box.update(0, 'abcd', '=p', -1, 'push1') +box.update(0, 'abcd', '=p', -1, 'push1') --- - 1684234849: {'push1'} ... -lua box.update(0, 'abcd', '=p', -1, 'push2') +box.update(0, 'abcd', '=p', -1, 'push2') --- - 1684234849: {'push1', 'push2'} ... -lua box.update(0, 'abcd', '=p', -1, 'push3') +box.update(0, 'abcd', '=p', -1, 'push3') --- - 1684234849: {'push1', 'push2', 'push3'} ... -lua box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap1') +box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap1') --- - 1684234849: {'push2', 'push3', 'swap1'} ... -lua box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap2') +box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap2') --- - 1684234849: {'push3', 'swap1', 'swap2'} ... -lua box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap3') +box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap3') --- - 1684234849: {'swap1', 'swap2', 'swap3'} ... -lua box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop1') +box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop1') --- - 1684234849: {'swap1', 'swap2', 'noop1'} ... -lua box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop2') +box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop2') --- - 1684234849: {'swap1', 'swap2', 'noop2'} ... -lua box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop3') +box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop3') --- - 1684234849: {'swap1', 'swap2', 'noop3'} ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... # A test case for Bug#1043804 lua error() -> server crash -lua error() +error() --- error: '' ... # Test box.fiber.name() -lua old_name = box.fiber.name() +old_name = box.fiber.name() --- ... -lua box.fiber.name() == old_name +box.fiber.name() == old_name --- - true ... -lua box.fiber.self():name() == old_name +box.fiber.self():name() == old_name --- - true ... -lua box.fiber.name('hello fiber') +box.fiber.name('hello fiber') --- ... -lua box.fiber.name() +box.fiber.name() --- - hello fiber ... -lua box.fiber.self():name('bye fiber') +box.fiber.self():name('bye fiber') --- ... -lua box.fiber.self():name() +box.fiber.self():name() --- - bye fiber ... -lua box.fiber.self():name(old_name) +box.fiber.self():name(old_name) --- ... # A test case for bitwise operations -lua bit.lshift(1, 32) +bit.lshift(1, 32) --- - 1 ... -lua bit.band(1, 3) +bit.band(1, 3) --- - 1 ... -lua bit.bor(1, 2) +bit.bor(1, 2) --- - 3 ... # A test case for Bug#1061747 'tonumber64 is not transitive' -lua tonumber64(tonumber64(2)) +tonumber64(tonumber64(2)) --- - 2 ... -lua tostring(tonumber64(tonumber64(3))) +tostring(tonumber64(tonumber64(3))) --- - 3ULL ... # box.tuple.new test -lua box.tuple.new() +box.tuple.new() --- error: 'tuple.new(): bad arguments' ... -lua box.tuple.new(1) +box.tuple.new(1) --- - 1: {} ... -lua box.tuple.new('string') +box.tuple.new('string') --- - 'string': {} ... -lua box.tuple.new(tonumber64('18446744073709551615')) +box.tuple.new(tonumber64('18446744073709551615')) --- - 18446744073709551615: {} ... -lua box.tuple.new({tonumber64('18446744073709551615'), 'string', 1}) +box.tuple.new({tonumber64('18446744073709551615'), 'string', 1}) --- - 18446744073709551615: {'string', 1} ... # A test case for the key as an tuple -lua t=box.insert(0, 777, '0', '1', '2', '3') +t=box.insert(0, 777, '0', '1', '2', '3') --- ... -lua t +t --- - 777: {'0', '1', '2', '3'} ... -lua box.replace(0, t) +box.replace(0, t) --- - 777: {'0', '1', '2', '3'} ... -lua box.replace(0, 777, { 'a', 'b', 'c', {'d', 'e', t}}) +box.replace(0, 777, { 'a', 'b', 'c', {'d', 'e', t}}) --- - 777: {'a', 'b', 'c', 'd', 'e', 777, '0', '1', '2', '3'} ... # A test case for tuple:totable() method -lua t=box.select(0, 0, 777):totable() +t=box.select(0, 0, 777):totable() --- ... -lua t[2], t[3], t[4], t[5] +t[2], t[3], t[4], t[5] --- - a - b - c - d ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... # A test case for Bug#1119389 '(lbox_tuple_index) crashes on 'nil' argument' -lua t=box.insert(0, 8989) +t=box.insert(0, 8989) --- ... -lua t[nil] +t[nil] --- error: '[string "return t[nil]"]:1: bad argument #2 to ''__index'' (string expected, got nil)' ... # A test case for Bug#1131108 'tonumber64 from negative int inconsistency' -lua tonumber64(-1) +tonumber64(-1) --- - 18446744073709551615 ... -lua tonumber64(-1LL) +tonumber64(-1LL) --- - 18446744073709551615 ... -lua tonumber64(-1ULL) +tonumber64(-1ULL) --- - 18446744073709551615 ... -lua -1 +-1 --- - -1 ... -lua -1LL +-1LL --- - -1 ... -lua -1ULL +-1ULL --- - 18446744073709551615 ... -lua tonumber64(-1.0) +tonumber64(-1.0) --- - 18446744073709551615 ... -lua 6LL - 7LL +6LL - 7LL --- - -1 ... # A test case for Bug#1131108 'incorrect conversion from boolean lua value to tarantool tuple' -lua function bug1075677() local range = {} table.insert(range, 1>0) return range end +function bug1075677() local range = {} table.insert(range, 1>0) return range end --- ... call bug1075677() Found 1 tuple: [1702195828] -lua bug1075677=nil +bug1075677=nil --- ... -lua box.tuple.new(false) +box.tuple.new(false) --- - 'false': {} ... -lua box.tuple.new({false}) +box.tuple.new({false}) --- - 'false': {} ... -lua t = box.tuple.new('abc') +t = box.tuple.new('abc') --- ... -lua t +t --- - 'abc': {} ... -lua t:bsize() +t:bsize() --- - 4 ... diff --git a/test/box/lua.test b/test/box/lua.test index a3a67af5a998721a7a3348799067e35efb8d6abd..fce7a867b2d69a93272ad262d94c08516e1816e4 100644 --- a/test/box/lua.test +++ b/test/box/lua.test @@ -3,86 +3,86 @@ import os import sys # Test Lua from admin console. Whenever producing output, # make sure it's a valid YAML. -admin("lua") -admin("lua 1") -admin("lua print(' lua says: hello')") +admin("lua", simple=True) +admin("lua 1", simple=True) +admin("print(' lua says: hello')") # What's in the box? -admin("lua local t = {} for n in pairs(box) do table.insert(t, ' - box.' .. tostring(n)) end table.sort(t) for i = 1, #t do print(t[i]) end t = nil") +admin("local t = {} for n in pairs(box) do table.insert(t, ' - box.' .. tostring(n)) end table.sort(t) for i = 1, #t do print(t[i]) end t = nil") # Test box.pack() -admin("lua box.pack()") -admin("lua box.pack(1)") -admin("lua box.pack('abc')") -admin("lua print(box.pack('a', ' - hello'))") -admin("lua print(box.pack('Aa', ' - hello', ' world'))") -admin("lua print(box.pack('w', 0x30))") -admin("lua print(box.pack('www', 0x30, 0x30, 0x30))") -admin("lua print(box.pack('www', 0x3030, 0x30))") -admin("lua print(string.byte(box.pack('w', 212345), 1, 2))") -admin("lua print(string.sub(box.pack('p', 1684234849), 2))") -admin("lua print(box.pack('p', 'this string is 45 characters long 1234567890 '))") -admin("lua print(box.pack('s', 0x4d))") -admin("lua print(box.pack('ssss', 25940, 29811, 28448, 11883))") -admin("lua print(box.pack('SSSS', 25940, 29811, 28448, 11883))") -admin("lua print(box.pack('SSSSSSSS', 28493, 29550, 27680, 27497, 29541, 20512, 29285, 8556))") -admin("lua print(box.pack('bsilww', 84, 29541, 1802444916, 2338318684567380014ULL, 103, 111))") -admin("lua print(box.unpack('b', 'T'))") -admin("lua print(box.unpack('s', 'Te'))") -admin("lua print(box.unpack('i', 'Test'))") -admin("lua print(box.unpack('l', 'Test ok.'))") -admin("lua box.unpack('bsil', box.pack('bsil', 255, 65535, 4294967295, tonumber64('18446744073709551615')))") -admin("lua box.unpack('www', box.pack('www', 255, 65535, 4294967295))") -admin("lua box.unpack('ppp', box.pack('ppp', 'one', 'two', 'three'))") -admin("lua num, str, num64 = box.unpack('ppp', box.pack('ppp', 666, 'string', tonumber64('666666666666666')))") -admin("lua print(box.unpack('i', num), str, box.unpack('l', num64))") -admin("lua box.unpack('=p', box.pack('=p', 1, '666'))") -admin("lua box.unpack('','')") -admin("lua box.unpack('ii', box.pack('i', 1))") -admin("lua box.unpack('i', box.pack('ii', 1, 1))") -admin("lua box.unpack('+p', box.pack('=p', 1, '666'))") +admin("box.pack()") +admin("box.pack(1)") +admin("box.pack('abc')") +admin("print(box.pack('a', ' - hello'))") +admin("print(box.pack('Aa', ' - hello', ' world'))") +admin("print(box.pack('w', 0x30))") +admin("print(box.pack('www', 0x30, 0x30, 0x30))") +admin("print(box.pack('www', 0x3030, 0x30))") +admin("print(string.byte(box.pack('w', 212345), 1, 2))") +admin("print(string.sub(box.pack('p', 1684234849), 2))") +admin("print(box.pack('p', 'this string is 45 characters long 1234567890 '))") +admin("print(box.pack('s', 0x4d))") +admin("print(box.pack('ssss', 25940, 29811, 28448, 11883))") +admin("print(box.pack('SSSS', 25940, 29811, 28448, 11883))") +admin("print(box.pack('SSSSSSSS', 28493, 29550, 27680, 27497, 29541, 20512, 29285, 8556))") +admin("print(box.pack('bsilww', 84, 29541, 1802444916, 2338318684567380014ULL, 103, 111))") +admin("print(box.unpack('b', 'T'))") +admin("print(box.unpack('s', 'Te'))") +admin("print(box.unpack('i', 'Test'))") +admin("print(box.unpack('l', 'Test ok.'))") +admin("box.unpack('bsil', box.pack('bsil', 255, 65535, 4294967295, tonumber64('18446744073709551615')))") +admin("box.unpack('www', box.pack('www', 255, 65535, 4294967295))") +admin("box.unpack('ppp', box.pack('ppp', 'one', 'two', 'three'))") +admin("num, str, num64 = box.unpack('ppp', box.pack('ppp', 666, 'string', tonumber64('666666666666666')))") +admin("print(box.unpack('i', num), str, box.unpack('l', num64))") +admin("box.unpack('=p', box.pack('=p', 1, '666'))") +admin("box.unpack('','')") +admin("box.unpack('ii', box.pack('i', 1))") +admin("box.unpack('i', box.pack('ii', 1, 1))") +admin("box.unpack('+p', box.pack('=p', 1, '666'))") # Test the low-level box.process() call, which takes a binary packet # and passes it to box for execution. # insert: -admin("lua box.process(13, box.pack('iiippp', 0, 1, 3, 1, 'testing', 'lua rocks'))") +admin("box.process(13, box.pack('iiippp', 0, 1, 3, 1, 'testing', 'lua rocks'))") # select: -admin("lua box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1))") +admin("box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1))") # delete: -admin("lua box.process(21, box.pack('iiip', 0, 1, 1, 1))") +admin("box.process(21, box.pack('iiip', 0, 1, 1, 1))") # check delete: -admin("lua box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1))") -admin("lua box.process(22, box.pack('iii', 0, 0, 0))") +admin("box.process(17, box.pack('iiiiiip', 0, 0, 0, 2^31, 1, 1, 1))") +admin("box.process(22, box.pack('iii', 0, 0, 0))") sql("call box.process('abc', 'def')") sql("call box.pack('test')") sql("call box.pack('p', 'this string is 45 characters long 1234567890 ')") sql("call box.pack('p', 'ascii symbols are visible starting from code 20')") -admin("lua function f1() return 'testing', 1, false, -1, 1.123, 1e123, nil end") -admin("lua f1()") +admin("function f1() return 'testing', 1, false, -1, 1.123, 1e123, nil end") +admin("f1()") sql("call f1()") -admin("lua f1=nil") +admin("f1=nil") sql("call f1()") -admin("lua function f1() return f1 end") +admin("function f1() return f1 end") sql("call f1()") sql("insert into t0 values (1, 'test box delete')") sql("call box.delete('0', '\1\0\0\0')") sql("call box.delete('0', '\1\0\0\0')") sql("insert into t0 values (1, 'test box delete')") -admin("lua box.delete(0, 1)") -admin("lua box.delete(0, 1)") +admin("box.delete(0, 1)") +admin("box.delete(0, 1)") sql("insert into t0 values ('abcd', 'test box delete')") sql("call box.delete('0', '\1\0\0\0')") sql("call box.delete('0', 'abcd')") sql("call box.delete('0', 'abcd')") sql("insert into t0 values ('abcd', 'test box delete')") -admin("lua box.delete(0, 'abcd')") -admin("lua box.delete(0, 'abcd')") +admin("box.delete(0, 'abcd')") +admin("box.delete(0, 'abcd')") sql("call box.select('0', '0', 'abcd')") sql("insert into t0 values ('abcd', 'test box.select()')") sql("call box.select('0', '0', 'abcd')") -admin("lua box.select(0, 0, 'abcd')") -admin("lua box.select(0, 0)") -admin("lua box.select(0, 1)") -admin("lua box.select(0)") +admin("box.select(0, 0, 'abcd')") +admin("box.select(0, 0)") +admin("box.select(0, 1)") +admin("box.select(0)") sql("call box.replace('0', 'abcd', 'hello', 'world')") sql("call box.replace('0', 'defc', 'goodbye', 'universe')") sql("call box.select('0', '0', 'abcd')") @@ -101,119 +101,119 @@ sql("call box.update('0', 'miss', '+p', 2, '\1\0\0\0')") sql("call box.update('0', 'pass', '+p', 2, '\1\0\0\0')") sql("call box.update('0', 'pass', '-p', 2, '\1\0\0\0')") sql("call box.update('0', 'pass', '-p', 2, '\1\0\0\0')") -admin("lua box.update(0, 'pass', '+p', 2, 1)") +admin("box.update(0, 'pass', '+p', 2, 1)") sql("call box.select('0', '0', 'pass')") -admin("lua function field_x(space, key, field_index) return (box.select(space, 0, key))[tonumber(field_index)] end") +admin("function field_x(space, key, field_index) return (box.select(space, 0, key))[tonumber(field_index)] end") sql("call field_x('0', 'pass', '0')") sql("call field_x('0', 'pass', '1')") sql("call box.delete('0', 'pass')") fifo_lua = os.path.abspath("box/fifo.lua") # don't log the path name -sys.stdout.push_filter("lua dofile(.*)", "lua dofile(...)") -admin("lua dofile('{0}')".format(fifo_lua)) +sys.stdout.push_filter("dofile(.*)", "dofile(...)") +admin("dofile('{0}')".format(fifo_lua)) sys.stdout.pop_filter() -admin("lua fifo_max") -admin("lua fifo_push('test', 1)") -admin("lua fifo_push('test', 2)") -admin("lua fifo_push('test', 3)") -admin("lua fifo_push('test', 4)") -admin("lua fifo_push('test', 5)") -admin("lua fifo_push('test', 6)") -admin("lua fifo_push('test', 7)") -admin("lua fifo_push('test', 8)") -admin("lua fifo_top('test')") -admin("lua box.delete(0, 'test')") -admin("lua fifo_top('test')") -admin("lua box.delete(0, 'test')") -admin("lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end") -admin("lua for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end") +admin("fifo_max") +admin("fifo_push('test', 1)") +admin("fifo_push('test', 2)") +admin("fifo_push('test', 3)") +admin("fifo_push('test', 4)") +admin("fifo_push('test', 5)") +admin("fifo_push('test', 6)") +admin("fifo_push('test', 7)") +admin("fifo_push('test', 8)") +admin("fifo_top('test')") +admin("box.delete(0, 'test')") +admin("fifo_top('test')") +admin("box.delete(0, 'test')") +admin("for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end") +admin("for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end") admin("reload configuration") -admin("lua for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end") -admin("lua for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end") +admin("for k,v in pairs(box.cfg) do print(' - ', k, ': ', v) end") +admin("for k,v in pairs(box.space[0]) do if type(v) ~= 'table' then print(' - ', k, ': ', v) end end") # must be read-only -admin("lua box.cfg.nosuchoption = 1") -admin("lua box.space[300] = 1") - -admin("lua box.index.new('abc', 'cde')") -admin("lua box.index.new(1, 2)") -admin("lua box.index.new(0, 1)") -admin("lua box.index.new(0, 0)") -admin("lua #box.index.new(0,0)") -admin("lua #box.space[0].index[0].idx") -admin("lua box.insert(0, 'test')") -admin("lua box.insert(0, 'abcd')") -admin("lua #box.index.new(0,0)") -admin("lua #box.space[0].index[0].idx") -admin("lua box.delete(0, 'test')") -admin("lua #box.index.new(0,0)") -admin("lua box.delete(0, 'abcd')") -admin("lua #box.space[0].index[0].idx") -admin("lua #box.index.new(0,0)") -admin("lua box.space[0]:insert('test', 'hello world')") -admin("lua box.space[0]:update('test', '=p', 1, 'bye, world')") -admin("lua box.space[0]:delete('test')") +admin("box.cfg.nosuchoption = 1") +admin("box.space[300] = 1") + +admin("box.index.new('abc', 'cde')") +admin("box.index.new(1, 2)") +admin("box.index.new(0, 1)") +admin("box.index.new(0, 0)") +admin("#box.index.new(0,0)") +admin("#box.space[0].index[0].idx") +admin("box.insert(0, 'test')") +admin("box.insert(0, 'abcd')") +admin("#box.index.new(0,0)") +admin("#box.space[0].index[0].idx") +admin("box.delete(0, 'test')") +admin("#box.index.new(0,0)") +admin("box.delete(0, 'abcd')") +admin("#box.space[0].index[0].idx") +admin("#box.index.new(0,0)") +admin("box.space[0]:insert('test', 'hello world')") +admin("box.space[0]:update('test', '=p', 1, 'bye, world')") +admin("box.space[0]:delete('test')") # test tuple iterators -admin("lua t=box.space[0]:insert('test')") -admin("lua t:next('abcd')") -admin("lua t:next(1)") -admin("lua t:next(t)") -admin("lua t:next(t:next())") -admin("lua for k, v in t:pairs() do print(v) end") -admin("lua t=box.space[0]:replace('test', 'another field')") -admin("lua for k, v in t:pairs() do print(v) end") -admin("lua t=box.space[0]:replace('test', 'another field', 'one more')") -admin("lua for k, v in t:pairs() do print(v) end") -admin("lua t=box.tuple.new({'a', 'b', 'c', 'd'})") -admin("lua for it,field in t:pairs() do print(field); end") -admin("lua it, field = t:next()") -admin("lua getmetatable(it)") -admin("lua box.space[0]:truncate()") -admin("lua box.fiber.sleep(0)") -admin("lua box.fiber.sleep(0.01)") -admin("lua box.fiber.sleep(0.0001)") -admin("lua box.fiber.sleep('hello')") -admin("lua box.fiber.sleep(box, 0.001)") -admin("lua box.fiber.cancel(box.fiber.self())") -admin("lua f = box.fiber.self()") -admin("lua old_id = f:id()") -admin("lua box.fiber.cancel(f)") -admin("lua box.fiber.self():id() - old_id < 3") -admin("lua box.fiber.cancel(box.fiber.self())") -admin("lua box.fiber.self():id() - old_id < 5") -admin("lua g = box.fiber.self()") -admin("lua f==g") -admin("lua function r() f = box.fiber.create(r) return (box.fiber.resume(f)) end") -admin("lua r()") -admin("lua f = box.fiber.create(print('hello')") -admin("lua box.fiber.resume(f)") +admin("t=box.space[0]:insert('test')") +admin("t:next('abcd')") +admin("t:next(1)") +admin("t:next(t)") +admin("t:next(t:next())") +admin("for k, v in t:pairs() do print(v) end") +admin("t=box.space[0]:replace('test', 'another field')") +admin("for k, v in t:pairs() do print(v) end") +admin("t=box.space[0]:replace('test', 'another field', 'one more')") +admin("for k, v in t:pairs() do print(v) end") +admin("t=box.tuple.new({'a', 'b', 'c', 'd'})") +admin("for it,field in t:pairs() do print(field); end") +admin("it, field = t:next()") +admin("getmetatable(it)") +admin("box.space[0]:truncate()") +admin("box.fiber.sleep(0)") +admin("box.fiber.sleep(0.01)") +admin("box.fiber.sleep(0.0001)") +admin("box.fiber.sleep('hello')") +admin("box.fiber.sleep(box, 0.001)") +admin("box.fiber.cancel(box.fiber.self())") +admin("f = box.fiber.self()") +admin("old_id = f:id()") +admin("box.fiber.cancel(f)") +admin("box.fiber.self():id() - old_id < 3") +admin("box.fiber.cancel(box.fiber.self())") +admin("box.fiber.self():id() - old_id < 5") +admin("g = box.fiber.self()") +admin("f==g") +admin("function r() f = box.fiber.create(r) return (box.fiber.resume(f)) end") +admin("r()") +admin("f = box.fiber.create(print('hello')") +admin("box.fiber.resume(f)") # test passing arguments in and out created fiber -admin("lua function r(a, b) print(a) print(b) return a, b end") -admin("lua f=box.fiber.create(r)") -admin("lua box.fiber.resume(f)") -admin("lua f=box.fiber.create(r)") -admin("lua box.fiber.resume(f, 'hello')") -admin("lua f=box.fiber.create(r)") -admin("lua box.fiber.resume(f, 'hello', 'world')") -admin("lua f=box.fiber.create(r)") -admin("lua box.fiber.resume(f, 'hello', 'world', 'wide')") -admin("lua function y(a, b) c=box.fiber.yield(a) return box.fiber.yield(b, c) end") -admin("lua f=box.fiber.create(y)") -admin("lua box.fiber.resume(f, 'hello', 'world')") -admin("lua box.fiber.resume(f, 'wide')") -admin("lua box.fiber.resume(f)") -admin("lua function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end") -admin("lua f = box.fiber.create(y)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.sleep(0.002)") -admin("lua box.fiber.cancel(f)") -admin("lua box.fiber.resume(f)") -admin("lua f=nil") -admin("lua for k=1, 10000, 1 do box.fiber.create(function() box.fiber.detach() end) end") -admin("lua collectgarbage('collect')") +admin("function r(a, b) print(a) print(b) return a, b end") +admin("f=box.fiber.create(r)") +admin("box.fiber.resume(f)") +admin("f=box.fiber.create(r)") +admin("box.fiber.resume(f, 'hello')") +admin("f=box.fiber.create(r)") +admin("box.fiber.resume(f, 'hello', 'world')") +admin("f=box.fiber.create(r)") +admin("box.fiber.resume(f, 'hello', 'world', 'wide')") +admin("function y(a, b) c=box.fiber.yield(a) return box.fiber.yield(b, c) end") +admin("f=box.fiber.create(y)") +admin("box.fiber.resume(f, 'hello', 'world')") +admin("box.fiber.resume(f, 'wide')") +admin("box.fiber.resume(f)") +admin("function y() print('started') box.fiber.detach() while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end") +admin("f = box.fiber.create(y)") +admin("box.fiber.resume(f)") +admin("box.fiber.sleep(0.002)") +admin("box.fiber.cancel(f)") +admin("box.fiber.resume(f)") +admin("f=nil") +admin("for k=1, 10000, 1 do box.fiber.create(function() box.fiber.detach() end) end") +admin("collectgarbage('collect')") # check that these newly created fibers are garbage collected -admin("lua box.fiber.find(900)") -admin("lua box.fiber.find(910)") -admin("lua box.fiber.find(920)") +admin("box.fiber.find(900)") +admin("box.fiber.find(910)") +admin("box.fiber.find(920)") # # Test box.fiber.wrap() @@ -222,69 +222,69 @@ admin("lua box.fiber.find(920)") # but hit the fiber stack size limit and fail # with an error. # -admin("lua f = function() box.fiber.wrap(f) end") +admin("f = function() box.fiber.wrap(f) end") sql("call f()") # # Test argument passing # -admin("lua f = function(a, b) box.fiber.wrap(function(arg) result = arg end, a..b) end") -admin("lua f('hello ', 'world')") -admin("lua result") -admin("lua f('bye ', 'world')") -admin("lua result") +admin("f = function(a, b) box.fiber.wrap(function(arg) result = arg end, a..b) end") +admin("f('hello ', 'world')") +admin("result") +admin("f('bye ', 'world')") +admin("result") # # Test that the created fiber is detached # -admin("lua box.fiber.wrap(function() result = box.fiber.status() end)") -admin("lua result") +admin("box.fiber.wrap(function() result = box.fiber.status() end)") +admin("result") # # print """# A test case for Bug#933487 # tarantool crashed during shutdown if non running LUA fiber # was created #""" -admin("lua f = box.fiber.create(function () return true end)") +admin("f = box.fiber.create(function () return true end)") admin("save snapshot") admin("save snapshot") admin("save snapshot") -admin("lua box.fiber.resume(f)") -admin("lua f = box.fiber.create(function () return true end)") +admin("box.fiber.resume(f)") +admin("f = box.fiber.create(function () return true end)") # # print """# # #""" -admin("lua box.space[0]:insert('test', 'something to splice')") -admin("lua box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 4, 'no'))") -admin("lua box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 2, 'every'))") +admin("box.space[0]:insert('test', 'something to splice')") +admin("box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 4, 'no'))") +admin("box.space[0]:update('test', ':p', 1, box.pack('ppp', 0, 2, 'every'))") # check an incorrect offset -admin("lua box.space[0]:update('test', ':p', 1, box.pack('ppp', 100, 2, 'every'))") -admin("lua box.space[0]:update('test', ':p', 1, box.pack('ppp', -100, 2, 'every'))") -admin("lua box.space[0]:truncate()") -admin("lua box.space[0]:insert('test', 'hello', 'october', '20th'):unpack()") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:update('test', ':p', 1, box.pack('ppp', 100, 2, 'every'))") +admin("box.space[0]:update('test', ':p', 1, box.pack('ppp', -100, 2, 'every'))") +admin("box.space[0]:truncate()") +admin("box.space[0]:insert('test', 'hello', 'october', '20th'):unpack()") +admin("box.space[0]:truncate()") # check how well we can return tables -admin("lua function f1(...) return {...} end") -admin("lua function f2(...) return f1({...}) end") +admin("function f1(...) return {...} end") +admin("function f2(...) return f1({...}) end") sql("call f1('test_', 'test_')") sql("call f2('test_', 'test_')") sql("call f1()") sql("call f2()") # check multi-tuple return -admin("lua function f3() return {{'hello'}, {'world'}} end") +admin("function f3() return {{'hello'}, {'world'}} end") sql("call f3()") -admin("lua function f3() return {'hello', {'world'}} end") +admin("function f3() return {'hello', {'world'}} end") sql("call f3()") -admin("lua function f3() return 'hello', {{'world'}, {'canada'}} end") +admin("function f3() return 'hello', {{'world'}, {'canada'}} end") sql("call f3()") -admin("lua function f3() return {}, '123', {{}, {}} end") +admin("function f3() return {}, '123', {{}, {}} end") sql("call f3()") -admin("lua function f3() return { {{'hello'}} } end") +admin("function f3() return { {{'hello'}} } end") sql("call f3()") -admin("lua function f3() return { box.tuple.new('hello'), {'world'} } end") +admin("function f3() return { box.tuple.new('hello'), {'world'} } end") sql("call f3()") -admin("lua function f3() return { {'world'}, box.tuple.new('hello') } end") +admin("function f3() return { {'world'}, box.tuple.new('hello') } end") sql("call f3()") sql("call f1('jason')") @@ -308,33 +308,33 @@ function box.crossjoin(space0, space1, limit) end return unpack(result) end""" -admin("lua " + lua.replace('\n', ' ')) -admin("lua box.crossjoin(0, 0, 0)") -admin("lua box.crossjoin(0, 0, 10000)") -admin("lua box.space[0]:insert(1)") +admin(lua.replace('\n', ' ')) +admin("box.crossjoin(0, 0, 0)") +admin("box.crossjoin(0, 0, 10000)") +admin("box.space[0]:insert(1)") sql("call box.crossjoin('0', '0', '10000')") -admin("lua box.space[0]:insert(2)") +admin("box.space[0]:insert(2)") sql("call box.crossjoin('0', '0', '10000')") -admin("lua box.space[0]:insert(3, 'hello')") +admin("box.space[0]:insert(3, 'hello')") sql("call box.crossjoin('0', '0', '10000')") -admin("lua box.space[0]:insert(4, 'world')") -admin("lua box.space[0]:insert(5, 'hello world')") +admin("box.space[0]:insert(4, 'world')") +admin("box.space[0]:insert(5, 'hello world')") sql("call box.crossjoin('0', '0', '10000')") -admin("lua box.space[0]:truncate()") -admin("lua box.crossjoin = nil") +admin("box.space[0]:truncate()") +admin("box.crossjoin = nil") print """ # A test case for Bug#901674 # No way to inspect exceptions from Box in Lua """ -admin("lua pcall(box.insert, 99, 1, 'test')") -admin("lua pcall(box.insert, 0, 1, 'hello')") -admin("lua pcall(box.insert, 0, 1, 'hello')") -admin("lua box.space[0]:truncate()") +admin("pcall(box.insert, 99, 1, 'test')") +admin("pcall(box.insert, 0, 1, 'hello')") +admin("pcall(box.insert, 0, 1, 'hello')") +admin("box.space[0]:truncate()") print """ # A test case for Bug#908094 # Lua provides access to os.execute() """ -admin("lua os.execute('ls')") +admin("os.execute('ls')") print """ @@ -345,95 +345,95 @@ print """ box_fiber_lua = os.path.abspath("box/box_fiber.lua") # don't log the path name -sys.stdout.push_filter("lua dofile(.*)", "lua dofile(...)") -admin("lua dofile('{0}')".format(box_fiber_lua)) +sys.stdout.push_filter("dofile(.*)", "dofile(...)") +admin("dofile('{0}')".format(box_fiber_lua)) sys.stdout.pop_filter() print """ # test box.fiber.status functions: invalid arguments """ -admin("lua box.fiber.status(1)") -admin("lua box.fiber.status('fafa-gaga')") -admin("lua box.fiber.status(nil)") +admin("box.fiber.status(1)") +admin("box.fiber.status('fafa-gaga')") +admin("box.fiber.status(nil)") print """ # run fiber's test """ -admin("lua box_fiber_run_test()") +admin("box_fiber_run_test()") # Testing 64bit -admin("lua tonumber64(123)") -admin("lua tonumber64('123')") -admin("lua type(tonumber64('123')) == 'cdata'") -admin("lua tonumber64('9223372036854775807') == tonumber64('9223372036854775807')") -admin("lua tonumber64('9223372036854775807') - tonumber64('9223372036854775800')") -admin("lua tonumber64('18446744073709551615') == tonumber64('18446744073709551615')") -admin("lua tonumber64('18446744073709551615') + 1") -admin("lua tonumber64(-1)") -admin("lua tonumber64('184467440737095516155')") -admin("lua string.byte(box.pack('p', tonumber64(123)))") +admin("tonumber64(123)") +admin("tonumber64('123')") +admin("type(tonumber64('123')) == 'cdata'") +admin("tonumber64('9223372036854775807') == tonumber64('9223372036854775807')") +admin("tonumber64('9223372036854775807') - tonumber64('9223372036854775800')") +admin("tonumber64('18446744073709551615') == tonumber64('18446744073709551615')") +admin("tonumber64('18446744073709551615') + 1") +admin("tonumber64(-1)") +admin("tonumber64('184467440737095516155')") +admin("string.byte(box.pack('p', tonumber64(123)))") # test delete field -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") sql("call box.insert('0', 'tes1', 'tes2', 'tes3', 'tes4', 'tes5')") sql("call box.update('0', 'tes1', '#p', 0, '')") sql("call box.update('0', 'tes2', '#p', 0, '')") sql("call box.update('0', 'tes3', '#p', 0, '')") sql("call box.update('0', 'tes4', '#p', 0, '')") -admin("lua box.update(0, 'tes5', '#p', 0, '')") -admin("lua box.space[0]:truncate()") +admin("box.update(0, 'tes5', '#p', 0, '')") +admin("box.space[0]:truncate()") print """ # test box.update: INSERT field """ -admin("lua box.insert(0, 1, 3, 6, 9)") -admin("lua box.update(0, 1, '!p', 1, 2)") -admin("lua box.update(0, 1, '!p!p!p!p', 3, 4, 3, 5, 4, 7, 4, 8)") -admin("lua box.update(0, 1, '!p!p!p', 9, 10, 9, 11, 9, 12)") -admin("lua box.space[0]:truncate()") -admin("lua box.insert(0, 1, 'tuple')") -admin("lua box.update(0, 1, '#p!p=p', 1, '', 1, 'inserted tuple', 2, 'set tuple')") -admin("lua box.space[0]:truncate()") -admin("lua box.insert(0, 1, 'tuple')") -admin("lua box.update(0, 1, '=p!p#p', 1, 'set tuple', 1, 'inerted tuple', 2, '')") -admin("lua box.update(0, 1, '!p!p', 0, 3, 0, 2)") -admin("lua box.space[0]:truncate()") +admin("box.insert(0, 1, 3, 6, 9)") +admin("box.update(0, 1, '!p', 1, 2)") +admin("box.update(0, 1, '!p!p!p!p', 3, 4, 3, 5, 4, 7, 4, 8)") +admin("box.update(0, 1, '!p!p!p', 9, 10, 9, 11, 9, 12)") +admin("box.space[0]:truncate()") +admin("box.insert(0, 1, 'tuple')") +admin("box.update(0, 1, '#p!p=p', 1, '', 1, 'inserted tuple', 2, 'set tuple')") +admin("box.space[0]:truncate()") +admin("box.insert(0, 1, 'tuple')") +admin("box.update(0, 1, '=p!p#p', 1, 'set tuple', 1, 'inerted tuple', 2, '')") +admin("box.update(0, 1, '!p!p', 0, 3, 0, 2)") +admin("box.space[0]:truncate()") print """ # Test for Bug #955226 # Lua Numbers are passed back wrongly as strings # """ -admin("lua function foo() return 1, 2, '1', '2' end") +admin("function foo() return 1, 2, '1', '2' end") sql("call foo()") print """ # test update's assign opearations """ -admin("lua box.replace(0, 1, 'field string value')") -admin("lua box.update(0, 1, '=p=p=p', 1, 'new field string value', 2, 42, 3, 0xdeadbeef)") +admin("box.replace(0, 1, 'field string value')") +admin("box.update(0, 1, '=p=p=p', 1, 'new field string value', 2, 42, 3, 0xdeadbeef)") print """ # test update's arith opearations """ -admin("lua box.update(0, 1, '+p&p|p^p', 2, 16, 3, 0xffff0000, 3, 0x0000a0a0, 3, 0xffff00aa)") +admin("box.update(0, 1, '+p&p|p^p', 2, 16, 3, 0xffff0000, 3, 0x0000a0a0, 3, 0xffff00aa)") print """ # test update splice operation """ -admin("lua ops_list = {}") -admin("lua table.insert(ops_list, box.upd.splice(1, 0, 3, 'the newest'))") -admin("lua box.update(0, 1, ':p', 1, box.pack('ppp', 0, 3, 'the newest'))") +admin("ops_list = {}") +admin("table.insert(ops_list, box.upd.splice(1, 0, 3, 'the newest'))") +admin("box.update(0, 1, ':p', 1, box.pack('ppp', 0, 3, 'the newest'))") print """ # test update delete operations """ -admin("lua box.update(0, 1, '#p#p', 3, '', 2, '')") +admin("box.update(0, 1, '#p#p', 3, '', 2, '')") print """ # test update insert operations """ -admin("lua box.update(0, 1, '!p!p!p!p', 1, 1, 1, 2, 1, 3, 1, 4)") +admin("box.update(0, 1, '!p!p!p!p', 1, 1, 1, 2, 1, 3, 1, 4)") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") print """ @@ -442,7 +442,7 @@ print """ # """ -admin("lua ffi") +admin("ffi") print """ @@ -460,27 +460,27 @@ server.deploy(init_lua="box/test_init.lua") print """ # Test asscess to box configuration """ -admin("lua print_config()") +admin("print_config()") print """ # Test bug #977898 """ # Run a dummy insert to avoid race conditions under valgrind -admin("lua box.insert(0, 4, 8, 16)") +admin("box.insert(0, 4, 8, 16)") print """ # Test insert from init.lua """ -admin("lua box.select(0, 0, 1)") -admin("lua box.select(0, 0, 2)") -admin("lua box.select(0, 0, 4)") +admin("box.select(0, 0, 1)") +admin("box.select(0, 0, 2)") +admin("box.select(0, 0, 4)") print """ # Test bug #1002272 """ -admin("lua floor(0.5)") -admin("lua floor(0.9)") -admin("lua floor(1.1)") +admin("floor(0.5)") +admin("floor(0.9)") +admin("floor(1.1)") print """ # clean-up after tests @@ -490,195 +490,195 @@ server.deploy(init_lua=None) print """ # Test box.tuple:slice() """ -admin("lua t=box.tuple.new({'0', '1', '2', '3', '4', '5', '6', '7'})") -admin("lua t:slice(0)") -admin("lua t:slice(-1)") -admin("lua t:slice(1)") -admin("lua t:slice(-1, -1)") -admin("lua t:slice(-1, 1)") -admin("lua t:slice(1, -1)") -admin("lua t:slice(1, 3)") -admin("lua t:slice(7)") -admin("lua t:slice(8)") -admin("lua t:slice(9)") -admin("lua t:slice(100500)") -admin("lua t:slice(9, -1)") -admin("lua t:slice(6, -1)") -admin("lua t:slice(4, 4)") -admin("lua t:slice(6, 4)") -admin("lua t:slice(0, 0)") -admin("lua t:slice(9, 10)") -admin("lua t:slice(-7)") -admin("lua t:slice(-8)") -admin("lua t:slice(-9)") -admin("lua t:slice(-100500)") -admin("lua t:slice(500, 700)") -admin("lua box.space[0]:truncate()") +admin("t=box.tuple.new({'0', '1', '2', '3', '4', '5', '6', '7'})") +admin("t:slice(0)") +admin("t:slice(-1)") +admin("t:slice(1)") +admin("t:slice(-1, -1)") +admin("t:slice(-1, 1)") +admin("t:slice(1, -1)") +admin("t:slice(1, 3)") +admin("t:slice(7)") +admin("t:slice(8)") +admin("t:slice(9)") +admin("t:slice(100500)") +admin("t:slice(9, -1)") +admin("t:slice(6, -1)") +admin("t:slice(4, 4)") +admin("t:slice(6, 4)") +admin("t:slice(0, 0)") +admin("t:slice(9, 10)") +admin("t:slice(-7)") +admin("t:slice(-8)") +admin("t:slice(-9)") +admin("t:slice(-100500)") +admin("t:slice(500, 700)") +admin("box.space[0]:truncate()") print """ # A test case for Bug#911641 box.fiber.sleep() works incorrectly if # a fiber is attached. """ -admin("lua function r() return box.fiber.sleep(0.01) end") -admin("lua f = box.fiber.create(r)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.resume(f)") -admin("lua function r() box.fiber.yield(box.space[0]:insert(0, 0, 1)) box.fiber.yield(box.space[0]:select(0, 0)) box.fiber.yield(box.space[0]:truncate()) end") -admin("lua f = box.fiber.create(r)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.resume(f)") -admin("lua function r() return box.fiber.yield(box.fiber.create(r)) end") -admin("lua f = r()") -admin("lua f1 = box.fiber.resume(f)") -admin("lua f2 = box.fiber.resume(f1)") -admin("lua f3 = box.fiber.resume(f2)") -admin("lua f4 = box.fiber.resume(f3)") -admin("lua f5 = box.fiber.resume(f4)") -admin("lua f6 = box.fiber.resume(f5)") -admin("lua f7 = box.fiber.resume(f6)") -admin("lua f8 = box.fiber.resume(f7)") -admin("lua f9 = box.fiber.resume(f8)") -admin("lua f10 = box.fiber.resume(f9)") -admin("lua f11 = box.fiber.resume(f10)") -admin("lua f12 = box.fiber.resume(f11)") -admin("lua f13 = box.fiber.resume(f12)") -admin("lua f14 = box.fiber.resume(f13)") -admin("lua f15 = box.fiber.resume(f14)") -admin("lua f16 = box.fiber.resume(f15)") -admin("lua f17 = box.fiber.resume(f16)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.resume(f1)") -admin("lua box.fiber.resume(f2)") -admin("lua box.fiber.resume(f3)") -admin("lua box.fiber.resume(f4)") -admin("lua box.fiber.resume(f5)") -admin("lua box.fiber.resume(f6)") -admin("lua box.fiber.resume(f7)") -admin("lua box.fiber.resume(f8)") -admin("lua box.fiber.resume(f9)") -admin("lua box.fiber.resume(f10)") -admin("lua box.fiber.resume(f11)") -admin("lua box.fiber.resume(f12)") -admin("lua box.fiber.resume(f13)") -admin("lua box.fiber.resume(f14)") -admin("lua box.fiber.resume(f15)") -admin("lua box.fiber.resume(f16)") -admin("lua f17 = nil") -admin("lua function r() box.fiber.detach() box.fiber.sleep(1000) end") -admin("lua f = box.fiber.create(r)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.resume(f)") -admin("lua box.fiber.cancel(f)") -admin("lua box.fiber.resume(f)") +admin("function r() return box.fiber.sleep(0.01) end") +admin("f = box.fiber.create(r)") +admin("box.fiber.resume(f)") +admin("box.fiber.resume(f)") +admin("function r() box.fiber.yield(box.space[0]:insert(0, 0, 1)) box.fiber.yield(box.space[0]:select(0, 0)) box.fiber.yield(box.space[0]:truncate()) end") +admin("f = box.fiber.create(r)") +admin("box.fiber.resume(f)") +admin("box.fiber.resume(f)") +admin("box.fiber.resume(f)") +admin("box.fiber.resume(f)") +admin("function r() return box.fiber.yield(box.fiber.create(r)) end") +admin("f = r()") +admin("f1 = box.fiber.resume(f)") +admin("f2 = box.fiber.resume(f1)") +admin("f3 = box.fiber.resume(f2)") +admin("f4 = box.fiber.resume(f3)") +admin("f5 = box.fiber.resume(f4)") +admin("f6 = box.fiber.resume(f5)") +admin("f7 = box.fiber.resume(f6)") +admin("f8 = box.fiber.resume(f7)") +admin("f9 = box.fiber.resume(f8)") +admin("f10 = box.fiber.resume(f9)") +admin("f11 = box.fiber.resume(f10)") +admin("f12 = box.fiber.resume(f11)") +admin("f13 = box.fiber.resume(f12)") +admin("f14 = box.fiber.resume(f13)") +admin("f15 = box.fiber.resume(f14)") +admin("f16 = box.fiber.resume(f15)") +admin("f17 = box.fiber.resume(f16)") +admin("box.fiber.resume(f)") +admin("box.fiber.resume(f1)") +admin("box.fiber.resume(f2)") +admin("box.fiber.resume(f3)") +admin("box.fiber.resume(f4)") +admin("box.fiber.resume(f5)") +admin("box.fiber.resume(f6)") +admin("box.fiber.resume(f7)") +admin("box.fiber.resume(f8)") +admin("box.fiber.resume(f9)") +admin("box.fiber.resume(f10)") +admin("box.fiber.resume(f11)") +admin("box.fiber.resume(f12)") +admin("box.fiber.resume(f13)") +admin("box.fiber.resume(f14)") +admin("box.fiber.resume(f15)") +admin("box.fiber.resume(f16)") +admin("f17 = nil") +admin("function r() box.fiber.detach() box.fiber.sleep(1000) end") +admin("f = box.fiber.create(r)") +admin("box.fiber.resume(f)") +admin("box.fiber.resume(f)") +admin("box.fiber.cancel(f)") +admin("box.fiber.resume(f)") print """ # A test case for Bug#103491 # server CALL processing bug with name path longer than two # https://bugs.launchpad.net/tarantool/+bug/1034912 """ -admin("lua f = function() return 'OK' end") -admin("lua test = {}") -admin("lua test.f = f") -admin("lua test.test = {}") -admin("lua test.test.f = f") +admin("f = function() return 'OK' end") +admin("test = {}") +admin("test.f = f") +admin("test.test = {}") +admin("test.test.f = f") sql("call f()") sql("call test.f()") sql("call test.test.f()") print """ # A test case for box.counter """ -admin("lua box.counter.inc(0, 1)") -admin("lua box.select(0, 0, 1)") -admin("lua box.counter.inc(0, 1)") -admin("lua box.counter.inc(0, 1)") -admin("lua box.select(0, 0, 1)") -admin("lua box.counter.dec(0, 1)") -admin("lua box.counter.dec(0, 1)") -admin("lua box.select(0, 0, 1)") -admin("lua box.counter.dec(0, 1)") -admin("lua box.select(0, 0, 1)") +admin("box.counter.inc(0, 1)") +admin("box.select(0, 0, 1)") +admin("box.counter.inc(0, 1)") +admin("box.counter.inc(0, 1)") +admin("box.select(0, 0, 1)") +admin("box.counter.dec(0, 1)") +admin("box.counter.dec(0, 1)") +admin("box.select(0, 0, 1)") +admin("box.counter.dec(0, 1)") +admin("box.select(0, 0, 1)") print """# box.dostring()""" -admin("lua box.dostring('abc')") -admin("lua box.dostring('abc=2')") -admin("lua box.dostring('return abc')") -admin("lua box.dostring('return ...', 1, 2, 3)") +admin("box.dostring('abc')") +admin("box.dostring('abc=2')") +admin("box.dostring('return abc')") +admin("box.dostring('return ...', 1, 2, 3)") print """# box.update: push/pop fields""" -admin("lua box.insert(0, 'abcd')") -admin("lua box.update(0, 'abcd', '#p', 1, '')") -admin("lua box.update(0, 'abcd', '=p', -1, 'push1')") -admin("lua box.update(0, 'abcd', '=p', -1, 'push2')") -admin("lua box.update(0, 'abcd', '=p', -1, 'push3')") -admin("lua box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap1')") -admin("lua box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap2')") -admin("lua box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap3')") -admin("lua box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop1')") -admin("lua box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop2')") -admin("lua box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop3')") -admin("lua box.space[0]:truncate()") +admin("box.insert(0, 'abcd')") +admin("box.update(0, 'abcd', '#p', 1, '')") +admin("box.update(0, 'abcd', '=p', -1, 'push1')") +admin("box.update(0, 'abcd', '=p', -1, 'push2')") +admin("box.update(0, 'abcd', '=p', -1, 'push3')") +admin("box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap1')") +admin("box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap2')") +admin("box.update(0, 'abcd', '#p=p', 1, '', -1, 'swap3')") +admin("box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop1')") +admin("box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop2')") +admin("box.update(0, 'abcd', '#p=p', -1, '', -1, 'noop3')") +admin("box.space[0]:truncate()") print """# A test case for Bug#1043804 lua error() -> server crash""" -admin("lua error()") +admin("error()") print """# Test box.fiber.name()""" -admin("lua old_name = box.fiber.name()") -admin("lua box.fiber.name() == old_name") -admin("lua box.fiber.self():name() == old_name") -admin("lua box.fiber.name('hello fiber')") -admin("lua box.fiber.name()") -admin("lua box.fiber.self():name('bye fiber')") -admin("lua box.fiber.self():name()") -admin("lua box.fiber.self():name(old_name)") +admin("old_name = box.fiber.name()") +admin("box.fiber.name() == old_name") +admin("box.fiber.self():name() == old_name") +admin("box.fiber.name('hello fiber')") +admin("box.fiber.name()") +admin("box.fiber.self():name('bye fiber')") +admin("box.fiber.self():name()") +admin("box.fiber.self():name(old_name)") print """# A test case for bitwise operations """ -admin("lua bit.lshift(1, 32)") -admin("lua bit.band(1, 3)") -admin("lua bit.bor(1, 2)") +admin("bit.lshift(1, 32)") +admin("bit.band(1, 3)") +admin("bit.bor(1, 2)") print """# A test case for Bug#1061747 'tonumber64 is not transitive'""" -admin("lua tonumber64(tonumber64(2))") -admin("lua tostring(tonumber64(tonumber64(3)))") +admin("tonumber64(tonumber64(2))") +admin("tostring(tonumber64(tonumber64(3)))") print """# box.tuple.new test""" -admin("lua box.tuple.new()") -admin("lua box.tuple.new(1)") -admin("lua box.tuple.new('string')") -admin("lua box.tuple.new(tonumber64('18446744073709551615'))") -admin("lua box.tuple.new({tonumber64('18446744073709551615'), 'string', 1})") +admin("box.tuple.new()") +admin("box.tuple.new(1)") +admin("box.tuple.new('string')") +admin("box.tuple.new(tonumber64('18446744073709551615'))") +admin("box.tuple.new({tonumber64('18446744073709551615'), 'string', 1})") print """# A test case for the key as an tuple""" -admin("lua t=box.insert(0, 777, '0', '1', '2', '3')") -admin("lua t") -admin("lua box.replace(0, t)") -admin("lua box.replace(0, 777, { 'a', 'b', 'c', {'d', 'e', t}})") +admin("t=box.insert(0, 777, '0', '1', '2', '3')") +admin("t") +admin("box.replace(0, t)") +admin("box.replace(0, 777, { 'a', 'b', 'c', {'d', 'e', t}})") print """# A test case for tuple:totable() method""" -admin("lua t=box.select(0, 0, 777):totable()") -admin("lua t[2], t[3], t[4], t[5]") -admin("lua box.space[0]:truncate()") +admin("t=box.select(0, 0, 777):totable()") +admin("t[2], t[3], t[4], t[5]") +admin("box.space[0]:truncate()") print """# A test case for Bug#1119389 '(lbox_tuple_index) crashes on 'nil' argument'""" -admin("lua t=box.insert(0, 8989)") -admin("lua t[nil]") +admin("t=box.insert(0, 8989)") +admin("t[nil]") print """# A test case for Bug#1131108 'tonumber64 from negative int inconsistency'""" -admin("lua tonumber64(-1)") -admin("lua tonumber64(-1LL)") -admin("lua tonumber64(-1ULL)") -admin("lua -1") -admin("lua -1LL") -admin("lua -1ULL") -admin("lua tonumber64(-1.0)") -admin("lua 6LL - 7LL") +admin("tonumber64(-1)") +admin("tonumber64(-1LL)") +admin("tonumber64(-1ULL)") +admin("-1") +admin("-1LL") +admin("-1ULL") +admin("tonumber64(-1.0)") +admin("6LL - 7LL") print """# A test case for Bug#1131108 'incorrect conversion from boolean lua value to tarantool tuple' """ -admin("lua function bug1075677() local range = {} table.insert(range, 1>0) return range end") +admin("function bug1075677() local range = {} table.insert(range, 1>0) return range end") sql("call bug1075677()") -admin("lua bug1075677=nil") -admin("lua box.tuple.new(false)") -admin("lua box.tuple.new({false})") +admin("bug1075677=nil") +admin("box.tuple.new(false)") +admin("box.tuple.new({false})") -admin("lua t = box.tuple.new('abc')") -admin("lua t") -admin("lua t:bsize()") -admin("lua box.delete(0, 8989)", silent=True) +admin("t = box.tuple.new('abc')") +admin("t") +admin("t:bsize()") +admin("box.delete(0, 8989)", silent=True) diff --git a/test/box/lua_box_uuid.result b/test/box/lua_box_uuid.result index c1eea1e3bc26f8a3377c37714abda1f203feeb7f..3a052b34faa7d14c5ee49b8f87eba86b0ee6fdfb 100644 --- a/test/box/lua_box_uuid.result +++ b/test/box/lua_box_uuid.result @@ -1,13 +1,13 @@ # box.uuid() -lua string.len(box.uuid()) +string.len(box.uuid()) --- - 16 ... -lua string.len(box.uuid_hex()) +string.len(box.uuid_hex()) --- - 32 ... -lua string.match(box.uuid_hex(), '^[a-f0-9]+$') ~= nil +string.match(box.uuid_hex(), '^[a-f0-9]+$') ~= nil --- - true ... diff --git a/test/box/lua_box_uuid.test b/test/box/lua_box_uuid.test index 38b6471565ac315dd983dec21bac267a23aa6949..255ac85d7cbd608bbedb38cadef76a30ccad78a8 100644 --- a/test/box/lua_box_uuid.test +++ b/test/box/lua_box_uuid.test @@ -3,6 +3,6 @@ import os import sys print """# box.uuid()""" -admin("lua string.len(box.uuid())") -admin("lua string.len(box.uuid_hex())") -admin("lua string.match(box.uuid_hex(), '^[a-f0-9]+$') ~= nil") +admin("string.len(box.uuid())") +admin("string.len(box.uuid_hex())") +admin("string.match(box.uuid_hex(), '^[a-f0-9]+$') ~= nil") diff --git a/test/box/lua_misc.result b/test/box/lua_misc.result index e4a93593306388d349eb4c4dd1fdc46491e72695..42524f07b289ad18322ab53983fa532ee86d0b0a 100644 --- a/test/box/lua_misc.result +++ b/test/box/lua_misc.result @@ -3,19 +3,19 @@ # box.raise # -lua 1 + 1 +1 + 1 --- - 2 ... -lua box.raise(123, 'test') +box.raise(123, 'test') --- error: 'test' ... -lua box.raise(0, 'the other test') +box.raise(0, 'the other test') --- error: 'box.raise(): unknown error code' ... -lua box.raise(12, 345) +box.raise(12, 345) --- error: '345' ... @@ -24,7 +24,7 @@ error: '345' # box.stat # -lua for k, v in pairs(box.stat()) do print(k) end +for k, v in pairs(box.stat()) do print(k) end --- DELETE SELECT @@ -33,12 +33,12 @@ CALL UPDATE DELETE_1_3 ... -lua for k, v in pairs(box.stat().DELETE) do print(k) end +for k, v in pairs(box.stat().DELETE) do print(k) end --- total rps ... -lua for k, v in pairs(box.stat.DELETE) do print(k) end +for k, v in pairs(box.stat.DELETE) do print(k) end --- total rps @@ -48,19 +48,19 @@ rps # box.space # -lua type(box) +type(box) --- - table ... -lua type(box.space) +type(box.space) --- - table ... -lua box.cfg.memcached_space +box.cfg.memcached_space --- - 23 ... -lua for i, v in pairs(box.space[0].index[0].key_field[0]) do print(i, ': ', v) end +for i, v in pairs(box.space[0].index[0].key_field[0]) do print(i, ': ', v) end --- type: NUM fieldno: 0 @@ -70,23 +70,23 @@ fieldno: 0 # box.space # -lua string.match(tostring(box.slab), '^table:') ~= nil +string.match(tostring(box.slab), '^table:') ~= nil --- - true ... -lua box.slab.arena_used >= 0 +box.slab.arena_used >= 0 --- - true ... -lua box.slab.arena_size > 0 +box.slab.arena_size > 0 --- - true ... -lua string.match(tostring(box.slab.slabs), '^table:') ~= nil +string.match(tostring(box.slab.slabs), '^table:') ~= nil --- - true ... -lua for k, v in pairs(box.slab()) do print(k) end +for k, v in pairs(box.slab()) do print(k) end --- slabs arena_size @@ -97,7 +97,7 @@ arena_used # box.error # -lua for k,v in pairs(box.error) do print('box.error.', k, ': ', v) end +for k,v in pairs(box.error) do print('box.error.', k, ': ', v) end --- box.error.ER_ILLEGAL_PARAMS: 514 box.error.ER_KEY_FIELD_TYPE: 9730 diff --git a/test/box/lua_misc.test b/test/box/lua_misc.test index f9ec4e0f2f6ce87241ef1c00e67e0528cef71d44..91b24adf6759b09276de74c11a30eb9974c03afc 100644 --- a/test/box/lua_misc.test +++ b/test/box/lua_misc.test @@ -4,10 +4,10 @@ print """ # box.raise # """ -admin("lua 1 + 1") -admin("lua box.raise(123, 'test')") -admin("lua box.raise(0, 'the other test')") -admin("lua box.raise(12, 345)") +admin("1 + 1") +admin("box.raise(123, 'test')") +admin("box.raise(0, 'the other test')") +admin("box.raise(12, 345)") print """ # @@ -15,9 +15,9 @@ print """ # """ -admin("lua for k, v in pairs(box.stat()) do print(k) end") -admin("lua for k, v in pairs(box.stat().DELETE) do print(k) end") -admin("lua for k, v in pairs(box.stat.DELETE) do print(k) end") +admin("for k, v in pairs(box.stat()) do print(k) end") +admin("for k, v in pairs(box.stat().DELETE) do print(k) end") +admin("for k, v in pairs(box.stat.DELETE) do print(k) end") print """ # @@ -25,10 +25,10 @@ print """ # """ -admin("lua type(box)") -admin("lua type(box.space)") -admin("lua box.cfg.memcached_space") -admin("lua for i, v in pairs(box.space[0].index[0].key_field[0]) do print(i, ': ', v) end") +admin("type(box)") +admin("type(box.space)") +admin("box.cfg.memcached_space") +admin("for i, v in pairs(box.space[0].index[0].key_field[0]) do print(i, ': ', v) end") print """ # @@ -36,15 +36,15 @@ print """ # """ -admin("lua string.match(tostring(box.slab), '^table:') ~= nil") -admin("lua box.slab.arena_used >= 0") -admin("lua box.slab.arena_size > 0") -admin("lua string.match(tostring(box.slab.slabs), '^table:') ~= nil") -admin("lua for k, v in pairs(box.slab()) do print(k) end") +admin("string.match(tostring(box.slab), '^table:') ~= nil") +admin("box.slab.arena_used >= 0") +admin("box.slab.arena_size > 0") +admin("string.match(tostring(box.slab.slabs), '^table:') ~= nil") +admin("for k, v in pairs(box.slab()) do print(k) end") print """ # # box.error # """ -admin("lua for k,v in pairs(box.error) do print('box.error.', k, ': ', v) end") +admin("for k,v in pairs(box.error) do print('box.error.', k, ': ', v) end") diff --git a/test/box/net.box.result b/test/box/net.box.result index 0efdaa77f1fe22fdf0c54d876067c847a3b47bda..639bb6a1068aebc8c5610452c0b48c2e05e26009 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -1,142 +1,142 @@ -lua remote = box.net.box.new('localhost', box.cfg.primary_port, '0.5') +remote = box.net.box.new('localhost', box.cfg.primary_port, '0.5') --- ... -lua type(remote) +type(remote) --- - table ... -lua remote:ping() +remote:ping() --- - true ... -lua remote:ping() +remote:ping() --- - true ... -lua box.net.box.ping(remote) +box.net.box.ping(remote) --- - true ... -lua box.insert(0, 123, 'test1', 'test2') +box.insert(0, 123, 'test1', 'test2') --- - 123: {'test1', 'test2'} ... -lua box.select(0, 0, 123) +box.select(0, 0, 123) --- - 123: {'test1', 'test2'} ... -lua tuple = remote:select(0, 0, 123) +tuple = remote:select(0, 0, 123) --- ... -lua remote:call('box.select', '0', '0', 123) +remote:call('box.select', '0', '0', 123) --- - 123: {'test1', 'test2'} ... -lua tuple +tuple --- - 123: {'test1', 'test2'} ... -lua type(tuple) +type(tuple) --- - userdata ... -lua #tuple +#tuple --- - 3 ... -lua box.update(0, 123, '=p', 1, 'test1-updated') +box.update(0, 123, '=p', 1, 'test1-updated') --- - 123: {'test1-updated', 'test2'} ... -lua remote:update(0, 123, '=p', 2, 'test2-updated') +remote:update(0, 123, '=p', 2, 'test2-updated') --- - 123: {'test1-updated', 'test2-updated'} ... -lua box.insert(0, 123, 'test1', 'test2') +box.insert(0, 123, 'test1', 'test2') --- error: 'Duplicate key exists in unique index 0' ... -lua remote:insert(0, 123, 'test1', 'test2') +remote:insert(0, 123, 'test1', 'test2') --- error: 'Duplicate key exists in unique index 0' ... -lua remote:insert(0, 345, 'test1', 'test2') +remote:insert(0, 345, 'test1', 'test2') --- - 345: {'test1', 'test2'} ... -lua remote:select(0, 0, 345) +remote:select(0, 0, 345) --- - 345: {'test1', 'test2'} ... -lua remote:call('box.select', '0', '0', 345) +remote:call('box.select', '0', '0', 345) --- - 345: {'test1', 'test2'} ... -lua box.select(0, 0, 345) +box.select(0, 0, 345) --- - 345: {'test1', 'test2'} ... -lua remote:replace(0, 345, 'test1-replaced', 'test2-replaced') +remote:replace(0, 345, 'test1-replaced', 'test2-replaced') --- - 345: {'test1-replaced', 'test2-replaced'} ... -lua box.select(0, 0, 345) +box.select(0, 0, 345) --- - 345: {'test1-replaced', 'test2-replaced'} ... -lua remote:select_limit(0, 0, 0, 1000, 345) +remote:select_limit(0, 0, 0, 1000, 345) --- - 345: {'test1-replaced', 'test2-replaced'} ... -lua box.select_range(0, 0, 1000) +box.select_range(0, 0, 1000) --- - 123: {'test1-updated', 'test2-updated'} - 345: {'test1-replaced', 'test2-replaced'} ... -lua remote:select_range(0, 0, 1000) +remote:select_range(0, 0, 1000) --- - 123: {'test1-updated', 'test2-updated'} - 345: {'test1-replaced', 'test2-replaced'} ... -lua box.select(0, 0, 345) +box.select(0, 0, 345) --- - 345: {'test1-replaced', 'test2-replaced'} ... -lua remote:select(0, 0, 345) +remote:select(0, 0, 345) --- - 345: {'test1-replaced', 'test2-replaced'} ... -lua remote:timeout(0.5):select(0, 0, 345) +remote:timeout(0.5):select(0, 0, 345) --- - 345: {'test1-replaced', 'test2-replaced'} ... -lua remote:call('box.fiber.sleep', '.01') +remote:call('box.fiber.sleep', '.01') --- ... -lua remote:timeout(0.01):call('box.fiber.sleep', '10') +remote:timeout(0.01):call('box.fiber.sleep', '10') --- - nil ... -lua pstart = box.time() +pstart = box.time() --- ... -lua parallel = {} +parallel = {} --- ... -lua function parallel_foo(id) box.fiber.sleep(math.random() * .05) return id end +function parallel_foo(id) box.fiber.sleep(math.random() * .05) return id end --- ... -lua parallel_foo('abc') +parallel_foo('abc') --- - abc ... -lua for i = 1, 20 do box.fiber.resume(box.fiber.create(function() box.fiber.detach() local s = string.format('%07d', i) local so = remote:call('parallel_foo', s) table.insert(parallel, tostring(s == so[0]) ) end)) end +for i = 1, 20 do box.fiber.resume(box.fiber.create(function() box.fiber.detach() local s = string.format('%07d', i) local so = remote:call('parallel_foo', s) table.insert(parallel, tostring(s == so[0]) ) end)) end --- ... -lua for i = 1, 20 do if #parallel == 20 then break end box.fiber.sleep(0.1) end +for i = 1, 20 do if #parallel == 20 then break end box.fiber.sleep(0.1) end --- ... -lua unpack(parallel) +unpack(parallel) --- - true - true @@ -159,26 +159,26 @@ lua unpack(parallel) - true - true ... -lua #parallel +#parallel --- - 20 ... -lua box.time() - pstart < 0.5 +box.time() - pstart < 0.5 --- - true ... -lua remote:close() +remote:close() --- - true ... -lua remote:close() +remote:close() --- error: '[string "-- box_net.lua (internal file)..."]:404: box.net.box: already closed' ... -lua remote:ping() +remote:ping() --- error: '[string "-- box_net.lua (internal file)..."]:409: box.net.box: connection was closed' ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... diff --git a/test/box/net.box.test b/test/box/net.box.test index a6810664a432b26b017a425505961e2c99f729b6..87fae4f5db1f22ada4f88ef3847e8f05d4b492cc 100644 --- a/test/box/net.box.test +++ b/test/box/net.box.test @@ -2,65 +2,65 @@ # vim: set ft=python : -# admin("lua iotest()") -# admin("lua iotest()") -# admin("lua box.fiber.sleep(.5)") +# admin("iotest()") +# admin("iotest()") +# admin("box.fiber.sleep(.5)") -admin("lua remote = box.net.box.new('localhost', box.cfg.primary_port, '0.5')") -admin("lua type(remote)") -admin("lua remote:ping()") -admin("lua remote:ping()") -admin("lua box.net.box.ping(remote)") -admin("lua box.insert(0, 123, 'test1', 'test2')") -admin("lua box.select(0, 0, 123)") -admin("lua tuple = remote:select(0, 0, 123)") -admin("lua remote:call('box.select', '0', '0', 123)") -admin("lua tuple") -admin("lua type(tuple)") -admin("lua #tuple") +admin("remote = box.net.box.new('localhost', box.cfg.primary_port, '0.5')") +admin("type(remote)") +admin("remote:ping()") +admin("remote:ping()") +admin("box.net.box.ping(remote)") +admin("box.insert(0, 123, 'test1', 'test2')") +admin("box.select(0, 0, 123)") +admin("tuple = remote:select(0, 0, 123)") +admin("remote:call('box.select', '0', '0', 123)") +admin("tuple") +admin("type(tuple)") +admin("#tuple") -admin("lua box.update(0, 123, '=p', 1, 'test1-updated')") -admin("lua remote:update(0, 123, '=p', 2, 'test2-updated')") +admin("box.update(0, 123, '=p', 1, 'test1-updated')") +admin("remote:update(0, 123, '=p', 2, 'test2-updated')") -admin("lua box.insert(0, 123, 'test1', 'test2')") -admin("lua remote:insert(0, 123, 'test1', 'test2')") +admin("box.insert(0, 123, 'test1', 'test2')") +admin("remote:insert(0, 123, 'test1', 'test2')") -admin("lua remote:insert(0, 345, 'test1', 'test2')") -admin("lua remote:select(0, 0, 345)") -admin("lua remote:call('box.select', '0', '0', 345)") -admin("lua box.select(0, 0, 345)") +admin("remote:insert(0, 345, 'test1', 'test2')") +admin("remote:select(0, 0, 345)") +admin("remote:call('box.select', '0', '0', 345)") +admin("box.select(0, 0, 345)") -admin("lua remote:replace(0, 345, 'test1-replaced', 'test2-replaced')") -admin("lua box.select(0, 0, 345)") -admin("lua remote:select_limit(0, 0, 0, 1000, 345)") +admin("remote:replace(0, 345, 'test1-replaced', 'test2-replaced')") +admin("box.select(0, 0, 345)") +admin("remote:select_limit(0, 0, 0, 1000, 345)") -admin("lua box.select_range(0, 0, 1000)") -admin("lua remote:select_range(0, 0, 1000)") -admin("lua box.select(0, 0, 345)") -admin("lua remote:select(0, 0, 345)") -admin("lua remote:timeout(0.5):select(0, 0, 345)") +admin("box.select_range(0, 0, 1000)") +admin("remote:select_range(0, 0, 1000)") +admin("box.select(0, 0, 345)") +admin("remote:select(0, 0, 345)") +admin("remote:timeout(0.5):select(0, 0, 345)") -admin("lua remote:call('box.fiber.sleep', '.01')") -admin("lua remote:timeout(0.01):call('box.fiber.sleep', '10')") +admin("remote:call('box.fiber.sleep', '.01')") +admin("remote:timeout(0.01):call('box.fiber.sleep', '10')") -admin("lua pstart = box.time()") -admin("lua parallel = {}") -admin("lua function parallel_foo(id) box.fiber.sleep(math.random() * .05) return id end") -admin("lua parallel_foo('abc')") -admin("lua for i = 1, 20 do box.fiber.resume(box.fiber.create(function() box.fiber.detach() local s = string.format('%07d', i) local so = remote:call('parallel_foo', s) table.insert(parallel, tostring(s == so[0]) ) end)) end") -admin("lua for i = 1, 20 do if #parallel == 20 then break end box.fiber.sleep(0.1) end") -admin("lua unpack(parallel)") -admin("lua #parallel") -admin("lua box.time() - pstart < 0.5") +admin("pstart = box.time()") +admin("parallel = {}") +admin("function parallel_foo(id) box.fiber.sleep(math.random() * .05) return id end") +admin("parallel_foo('abc')") +admin("for i = 1, 20 do box.fiber.resume(box.fiber.create(function() box.fiber.detach() local s = string.format('%07d', i) local so = remote:call('parallel_foo', s) table.insert(parallel, tostring(s == so[0]) ) end)) end") +admin("for i = 1, 20 do if #parallel == 20 then break end box.fiber.sleep(0.1) end") +admin("unpack(parallel)") +admin("#parallel") +admin("box.time() - pstart < 0.5") -admin("lua remote:close()") -admin("lua remote:close()") -admin("lua remote:ping()") +admin("remote:close()") +admin("remote:close()") +admin("remote:ping()") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") diff --git a/test/box/net_sql.mysql.result b/test/box/net_sql.mysql.result index 5efafb0d52196f3e9a7fec64480a1d5235d1320c..1968f08130f36c6338b967ada4626c3362d423d7 100644 --- a/test/box/net_sql.mysql.result +++ b/test/box/net_sql.mysql.result @@ -1,20 +1,20 @@ -lua c = box.net.sql.connect('abcd') +c = box.net.sql.connect('abcd') --- error: '[string "-- sql.lua (internal file)..."]:29: Unknown driver ''abcd''' ... -lua dump = function(v) return box.cjson.encode(v) end +dump = function(v) return box.cjson.encode(v) end --- ... -lua connect = {} +connect = {} --- ... -lua for tk in string.gmatch(os.getenv('MYSQL'), '[^:]+') do table.insert(connect, tk) end +for tk in string.gmatch(os.getenv('MYSQL'), '[^:]+') do table.insert(connect, tk) end --- ... -lua c = box.net.sql.connect('mysql', unpack(connect)) +c = box.net.sql.connect('mysql', unpack(connect)) --- ... -lua for k, v in pairs(c) do print(k, ': ', type(v)) end +for k, v in pairs(c) do print(k, ': ', type(v)) end --- raise: boolean processing: boolean @@ -27,55 +27,55 @@ db: string user: string port: string ... -lua c:execute('SEL ECT 1') +c:execute('SEL ECT 1') --- error: '[string "-- sql.lua (internal file)..."]:105: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''SEL ECT 1'' at line 1' ... -lua dump({c:execute('SELECT ? AS bool1, ? AS bool2, ? AS nil, ? AS num, ? AS str', true, false, nil, 123, 'abc')}) +dump({c:execute('SELECT ? AS bool1, ? AS bool2, ? AS nil, ? AS num, ? AS str', true, false, nil, 123, 'abc')}) --- - [[{"bool2":0,"str":"abc","num":123,"bool1":1}],1] ... -lua dump({c:execute('SELECT * FROM (SELECT ?) t WHERE 1 = 0', 2)}) +dump({c:execute('SELECT * FROM (SELECT ?) t WHERE 1 = 0', 2)}) --- - [{},0] ... -lua dump({c:execute('CREATE PROCEDURE p1() BEGIN SELECT 1 AS One; SELECT 2 AS Two, 3 AS Three; END')}) +dump({c:execute('CREATE PROCEDURE p1() BEGIN SELECT 1 AS One; SELECT 2 AS Two, 3 AS Three; END')}) --- - [{},0] ... -lua dump({c:execute('CALL p1')}) +dump({c:execute('CALL p1')}) --- - [[{"One":1},{"Three":3,"Two":2}],2] ... -lua dump({c:execute('DROP PROCEDURE p1')}) +dump({c:execute('DROP PROCEDURE p1')}) --- - [{},0] ... -lua dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2')}) +dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2')}) --- - [[{"one":1},{"one":2}],2] ... -lua dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2; SELECT ? AS two', 'abc')}) +dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2; SELECT ? AS two', 'abc')}) --- - [[{"one":1},{"one":2},{"two":"abc"}],3] ... -lua c:quote('test "abc" test') +c:quote('test "abc" test') --- - test \"abc\" test ... -lua c:begin_work() +c:begin_work() --- - 0 ... -lua c:rollback() +c:rollback() --- - 0 ... -lua c:begin_work() +c:begin_work() --- - 0 ... -lua c:commit() +c:commit() --- - 0 ... diff --git a/test/box/net_sql.mysql.test b/test/box/net_sql.mysql.test index 22ada7b4dfaf4f68bc314e2697e0d8b365339eb6..c9ae7d069b28f63594f4e8232d9ee3d488e8a835 100644 --- a/test/box/net_sql.mysql.test +++ b/test/box/net_sql.mysql.test @@ -1,28 +1,28 @@ # encoding: utf-8 -admin("lua c = box.net.sql.connect('abcd')") -admin("lua dump = function(v) return box.cjson.encode(v) end") +admin("c = box.net.sql.connect('abcd')") +admin("dump = function(v) return box.cjson.encode(v) end") -admin("lua connect = {}") -admin("lua for tk in string.gmatch(os.getenv('MYSQL'), '[^:]+') do table.insert(connect, tk) end") +admin("connect = {}") +admin("for tk in string.gmatch(os.getenv('MYSQL'), '[^:]+') do table.insert(connect, tk) end") # mysql -admin("lua c = box.net.sql.connect('mysql', unpack(connect))") -admin("lua for k, v in pairs(c) do print(k, ': ', type(v)) end") -admin("lua c:execute('SEL ECT 1')") -admin("lua dump({c:execute('SELECT ? AS bool1, ? AS bool2, ? AS nil, ? AS num, ? AS str', true, false, nil, 123, 'abc')})") +admin("c = box.net.sql.connect('mysql', unpack(connect))") +admin("for k, v in pairs(c) do print(k, ': ', type(v)) end") +admin("c:execute('SEL ECT 1')") +admin("dump({c:execute('SELECT ? AS bool1, ? AS bool2, ? AS nil, ? AS num, ? AS str', true, false, nil, 123, 'abc')})") -admin("lua dump({c:execute('SELECT * FROM (SELECT ?) t WHERE 1 = 0', 2)})") -admin("lua dump({c:execute('CREATE PROCEDURE p1() BEGIN SELECT 1 AS One; SELECT 2 AS Two, 3 AS Three; END')})") -admin("lua dump({c:execute('CALL p1')})") -admin("lua dump({c:execute('DROP PROCEDURE p1')})") -admin("lua dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2')})") -admin("lua dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2; SELECT ? AS two', 'abc')})") +admin("dump({c:execute('SELECT * FROM (SELECT ?) t WHERE 1 = 0', 2)})") +admin("dump({c:execute('CREATE PROCEDURE p1() BEGIN SELECT 1 AS One; SELECT 2 AS Two, 3 AS Three; END')})") +admin("dump({c:execute('CALL p1')})") +admin("dump({c:execute('DROP PROCEDURE p1')})") +admin("dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2')})") +admin("dump({c:execute('SELECT 1 AS one UNION ALL SELECT 2; SELECT ? AS two', 'abc')})") -admin("lua c:quote('test \"abc\" test')") +admin("c:quote('test \"abc\" test')") -admin("lua c:begin_work()") -admin("lua c:rollback()") -admin("lua c:begin_work()") -admin("lua c:commit()") +admin("c:begin_work()") +admin("c:rollback()") +admin("c:begin_work()") +admin("c:commit()") diff --git a/test/box/net_sql.pg.result b/test/box/net_sql.pg.result index 091b4e5a659e9a9cd9b0c1908ea8bc719c412b4f..56cdd7ca2e7d3182987b9551bc102b249479099d 100644 --- a/test/box/net_sql.pg.result +++ b/test/box/net_sql.pg.result @@ -1,115 +1,115 @@ -lua c = box.net.sql.connect('abcd') +c = box.net.sql.connect('abcd') --- error: '[string "-- sql.lua (internal file)..."]:29: Unknown driver ''abcd''' ... -lua dump = function(v) return box.cjson.encode(v) end +dump = function(v) return box.cjson.encode(v) end --- ... -lua connect = {} +connect = {} --- ... -lua for tk in string.gmatch(os.getenv('PG'), '[^:]+') do table.insert(connect, tk) end +for tk in string.gmatch(os.getenv('PG'), '[^:]+') do table.insert(connect, tk) end --- ... -lua c = box.net.sql.connect('pg', unpack(connect)) +c = box.net.sql.connect('pg', unpack(connect)) --- ... -lua dump({c:execute('SELECT 123::text AS bla, 345')}) +dump({c:execute('SELECT 123::text AS bla, 345')}) --- - [[{"?column?":345,"bla":"123"}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT -1 AS neg, NULL AS abc')}) +dump({c:execute('SELECT -1 AS neg, NULL AS abc')}) --- - [[{"neg":-1}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT -1.1 AS neg, 1.2 AS pos')}) +dump({c:execute('SELECT -1.1 AS neg, 1.2 AS pos')}) --- - [[{"neg":-1.1,"pos":1.2}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT ARRAY[1,2] AS neg, 1.2 AS pos')}) +dump({c:execute('SELECT ARRAY[1,2] AS neg, 1.2 AS pos')}) --- - [[{"neg":"{1,2}","pos":1.2}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT ? AS val', 'abc')}) +dump({c:execute('SELECT ? AS val', 'abc')}) --- - [[{"val":"abc"}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT ? AS val', 123)}) +dump({c:execute('SELECT ? AS val', 123)}) --- - [[{"val":123}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT ? AS val', true)}) +dump({c:execute('SELECT ? AS val', true)}) --- - [[{"val":true}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT ? AS val', false)}) +dump({c:execute('SELECT ? AS val', false)}) --- - [[{"val":false}],1,"SELECT 1"] ... -lua dump({c:execute('SELECT ? AS val, ? AS num, ? AS str', false, 123, 'abc')}) +dump({c:execute('SELECT ? AS val, ? AS num, ? AS str', false, 123, 'abc')}) --- - [[{"str":"abc","num":123,"val":false}],1,"SELECT 1"] ... -lua dump({c:execute('DROP TABLE IF EXISTS unknown_table')}) +dump({c:execute('DROP TABLE IF EXISTS unknown_table')}) --- - [{},0,"DROP TABLE"] ... -lua dump({c:execute('SELECT * FROM (VALUES (1,2), (2,3)) t')}) +dump({c:execute('SELECT * FROM (VALUES (1,2), (2,3)) t')}) --- - [[{"column1":1,"column2":2},{"column1":2,"column2":3}],2,"SELECT 2"] ... -lua c:ping() +c:ping() --- - true ... -lua dump({c:select('SELECT * FROM (VALUES (1,2), (2,3)) t')}) +dump({c:select('SELECT * FROM (VALUES (1,2), (2,3)) t')}) --- - [[{"column1":1,"column2":2},{"column1":2,"column2":3}]] ... -lua dump({c:single('SELECT * FROM (VALUES (1,2), (2,3)) t')}) +dump({c:single('SELECT * FROM (VALUES (1,2), (2,3)) t')}) --- error: '[string "-- sql.lua (internal file)..."]:156: SQL request returned multiply rows' ... -lua dump({c:single('SELECT * FROM (VALUES (1,2)) t')}) +dump({c:single('SELECT * FROM (VALUES (1,2)) t')}) --- - [{"column1":1,"column2":2}] ... -lua dump({c:perform('SELECT * FROM (VALUES (1,2), (2,3)) t')}) +dump({c:perform('SELECT * FROM (VALUES (1,2), (2,3)) t')}) --- - [2] ... -lua c:execute('SELEC T') +c:execute('SELEC T') --- error: '[string "-- sql.lua (internal file)..."]:105: ERROR: syntax error at or near "SELEC" LINE 1: SELEC T ^ ' ... -lua c = box.net.sql.connect('abcd') +c = box.net.sql.connect('abcd') --- error: '[string "-- sql.lua (internal file)..."]:29: Unknown driver ''abcd''' ... -lua c:quote('abc"cde"def') +c:quote('abc"cde"def') --- - 'abc"cde"def' ... -lua c:begin_work() +c:begin_work() --- - 0 ... -lua c:rollback() +c:rollback() --- - 0 ... -lua c:begin_work() +c:begin_work() --- - 0 ... -lua c:commit() +c:commit() --- - 0 ... -lua c:txn(function(dbi) dbi:single('SELECT 1') end) +c:txn(function(dbi) dbi:single('SELECT 1') end) --- - true ... diff --git a/test/box/net_sql.pg.test b/test/box/net_sql.pg.test index 0bb91578f468d618d50a32220222ab8bc0d93996..568224be69fd2ca9e99531cbd0673ca164a573f5 100644 --- a/test/box/net_sql.pg.test +++ b/test/box/net_sql.pg.test @@ -1,41 +1,41 @@ # encoding: utf-8 -admin("lua c = box.net.sql.connect('abcd')") -admin("lua dump = function(v) return box.cjson.encode(v) end") +admin("c = box.net.sql.connect('abcd')") +admin("dump = function(v) return box.cjson.encode(v) end") -admin("lua connect = {}") -admin("lua for tk in string.gmatch(os.getenv('PG'), '[^:]+') do table.insert(connect, tk) end") +admin("connect = {}") +admin("for tk in string.gmatch(os.getenv('PG'), '[^:]+') do table.insert(connect, tk) end") # postgresql -admin("lua c = box.net.sql.connect('pg', unpack(connect))") -admin("lua dump({c:execute('SELECT 123::text AS bla, 345')})") -admin("lua dump({c:execute('SELECT -1 AS neg, NULL AS abc')})") -admin("lua dump({c:execute('SELECT -1.1 AS neg, 1.2 AS pos')})") -admin("lua dump({c:execute('SELECT ARRAY[1,2] AS neg, 1.2 AS pos')})") -admin("lua dump({c:execute('SELECT ? AS val', 'abc')})") -admin("lua dump({c:execute('SELECT ? AS val', 123)})") -admin("lua dump({c:execute('SELECT ? AS val', true)})") -admin("lua dump({c:execute('SELECT ? AS val', false)})") -admin("lua dump({c:execute('SELECT ? AS val, ? AS num, ? AS str', false, 123, 'abc')})") -admin("lua dump({c:execute('DROP TABLE IF EXISTS unknown_table')})") -admin("lua dump({c:execute('SELECT * FROM (VALUES (1,2), (2,3)) t')})") -admin("lua c:ping()") -admin("lua dump({c:select('SELECT * FROM (VALUES (1,2), (2,3)) t')})") -admin("lua dump({c:single('SELECT * FROM (VALUES (1,2), (2,3)) t')})") -admin("lua dump({c:single('SELECT * FROM (VALUES (1,2)) t')})") -admin("lua dump({c:perform('SELECT * FROM (VALUES (1,2), (2,3)) t')})") -admin("lua c:execute('SELEC T')") - -admin("lua c = box.net.sql.connect('abcd')") - - -admin("lua c:quote('abc\"cde\"def')") - - -admin("lua c:begin_work()") -admin("lua c:rollback()") -admin("lua c:begin_work()") -admin("lua c:commit()") - -admin("lua c:txn(function(dbi) dbi:single('SELECT 1') end)") +admin("c = box.net.sql.connect('pg', unpack(connect))") +admin("dump({c:execute('SELECT 123::text AS bla, 345')})") +admin("dump({c:execute('SELECT -1 AS neg, NULL AS abc')})") +admin("dump({c:execute('SELECT -1.1 AS neg, 1.2 AS pos')})") +admin("dump({c:execute('SELECT ARRAY[1,2] AS neg, 1.2 AS pos')})") +admin("dump({c:execute('SELECT ? AS val', 'abc')})") +admin("dump({c:execute('SELECT ? AS val', 123)})") +admin("dump({c:execute('SELECT ? AS val', true)})") +admin("dump({c:execute('SELECT ? AS val', false)})") +admin("dump({c:execute('SELECT ? AS val, ? AS num, ? AS str', false, 123, 'abc')})") +admin("dump({c:execute('DROP TABLE IF EXISTS unknown_table')})") +admin("dump({c:execute('SELECT * FROM (VALUES (1,2), (2,3)) t')})") +admin("c:ping()") +admin("dump({c:select('SELECT * FROM (VALUES (1,2), (2,3)) t')})") +admin("dump({c:single('SELECT * FROM (VALUES (1,2), (2,3)) t')})") +admin("dump({c:single('SELECT * FROM (VALUES (1,2)) t')})") +admin("dump({c:perform('SELECT * FROM (VALUES (1,2), (2,3)) t')})") +admin("c:execute('SELEC T')") + +admin("c = box.net.sql.connect('abcd')") + + +admin("c:quote('abc\"cde\"def')") + + +admin("c:begin_work()") +admin("c:rollback()") +admin("c:begin_work()") +admin("c:commit()") + +admin("c:txn(function(dbi) dbi:single('SELECT 1') end)") diff --git a/test/box/reconfigure.result b/test/box/reconfigure.result index 90be3947947706b34bec88b7e49f723f7e8517a8..4c796f3ab06d8151cc5da63c4e37d3c725996faf 100644 --- a/test/box/reconfigure.result +++ b/test/box/reconfigure.result @@ -1,4 +1,4 @@ -lua box.cfg.too_long_threshold +box.cfg.too_long_threshold --- - 0.5 ... @@ -18,7 +18,7 @@ fail: - Could not accept read only 'space[0].index[0].key_field[0].fieldno' option - Could not accept read only 'space[0].index[0].key_field[0].type' option ... -lua box.cfg.too_long_threshold +box.cfg.too_long_threshold --- - 0.5 ... @@ -49,15 +49,15 @@ reload configuration --- ok ... -lua box.cfg.too_long_threshold +box.cfg.too_long_threshold --- - 2 ... -lua box.cfg.snap_io_rate_limit +box.cfg.snap_io_rate_limit --- - 10 ... -lua box.cfg.io_collect_interval +box.cfg.io_collect_interval --- - 0.01 ... @@ -66,7 +66,7 @@ reload configuration fail: - empty configuration file 'tarantool.cfg' ... -lua box.cfg.too_long_threshold +box.cfg.too_long_threshold --- - 2 ... @@ -79,7 +79,7 @@ reload configuration --- ok ... -lua box.cfg.too_long_threshold +box.cfg.too_long_threshold --- - 0.5 ... @@ -119,6 +119,6 @@ reload configuration --- ok ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... diff --git a/test/box/reconfigure.test b/test/box/reconfigure.test index c32efb2b9aeea38e60cedc4e4ec8d1b7d0cec601..b3790971b601b969d2ac07633b4dc9185a3d5cf4 100644 --- a/test/box/reconfigure.test +++ b/test/box/reconfigure.test @@ -1,9 +1,9 @@ # encoding: utf-8 # -admin("lua box.cfg.too_long_threshold") +admin("box.cfg.too_long_threshold") # bad1 server.reconfigure("box/tarantool_bad1.cfg") -admin("lua box.cfg.too_long_threshold") +admin("box.cfg.too_long_threshold") # bad2 server.reconfigure("box/tarantool_bad2.cfg") # bad3 @@ -14,12 +14,12 @@ server.reconfigure("box/tarantool_bad4.cfg") server.reconfigure("box/tarantool_bad5.cfg") # good server.reconfigure("box/tarantool_good.cfg") -admin("lua box.cfg.too_long_threshold") -admin("lua box.cfg.snap_io_rate_limit") -admin("lua box.cfg.io_collect_interval") +admin("box.cfg.too_long_threshold") +admin("box.cfg.snap_io_rate_limit") +admin("box.cfg.io_collect_interval") # empty server.reconfigure("box/tarantool_empty.cfg") -admin("lua box.cfg.too_long_threshold") +admin("box.cfg.too_long_threshold") # no config server.reconfigure(None) @@ -27,7 +27,7 @@ server.reconfigure(None) # cleanup # restore default server.reconfigure(self.suite_ini["config"]) -admin("lua box.cfg.too_long_threshold") +admin("box.cfg.too_long_threshold") print """# # A test case for http://bugs.launchpad.net/bugs/712447: @@ -44,6 +44,6 @@ sql("insert into t0 values (3, 'tuple 3')") admin("save snapshot") # Cleanup server.reconfigure(self.suite_ini["config"]) -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") # vim: syntax=python diff --git a/test/box/session.result b/test/box/session.result index 272fc77b977bc8549764ebb1759f77b25f2338b4..b860330e8c27da1a7f70515685e2d9f74d80ecb1 100644 --- a/test/box/session.result +++ b/test/box/session.result @@ -1,171 +1,171 @@ -lua box.session.exists(box.session.id()) +box.session.exists(box.session.id()) --- - 1 ... -lua box.session.exists() +box.session.exists() --- error: 'session.exists(sid): bad arguments' ... -lua box.session.exists(1, 2, 3) +box.session.exists(1, 2, 3) --- error: 'session.exists(sid): bad arguments' ... -lua box.session.exists(1234567890) +box.session.exists(1234567890) --- - 0 ... -lua box.session.id() > 0 +box.session.id() > 0 --- - true ... -lua f = box.fiber.create(function() box.fiber.detach() failed = box.session.id() ~= 0 end) +f = box.fiber.create(function() box.fiber.detach() failed = box.session.id() ~= 0 end) --- ... -lua box.fiber.resume(f) +box.fiber.resume(f) --- ... -lua failed +failed --- - false ... -lua f1 = box.fiber.create(function() if box.session.id() == 0 then failed = true end end) +f1 = box.fiber.create(function() if box.session.id() == 0 then failed = true end end) --- ... -lua box.fiber.resume(f1) +box.fiber.resume(f1) --- - true ... -lua failed +failed --- - false ... -lua box.session.peer() == box.session.peer(box.session.id()) +box.session.peer() == box.session.peer(box.session.id()) --- - true ... -lua box.session.on_connect(function() end) +box.session.on_connect(function() end) --- - nil ... -lua box.session.on_disconnect(function() end) +box.session.on_disconnect(function() end) --- - nil ... -lua type(box.session.on_connect(function() error('hear') end)) +type(box.session.on_connect(function() error('hear') end)) --- - function ... -lua type(box.session.on_disconnect(function() error('hear') end)) +type(box.session.on_disconnect(function() error('hear') end)) --- - function ... -lua box.session.on_connect() +box.session.on_connect() --- error: 'session.on_connect(chunk): bad arguments' ... -lua box.session.on_disconnect() +box.session.on_disconnect() --- error: 'session.on_connect(chunk): bad arguments' ... -lua box.session.on_connect(function() end, function() end) +box.session.on_connect(function() end, function() end) --- error: 'session.on_connect(chunk): bad arguments' ... -lua box.session.on_disconnect(function() end, function() end) +box.session.on_disconnect(function() end, function() end) --- error: 'session.on_connect(chunk): bad arguments' ... -lua box.session.on_connect(1, 2) +box.session.on_connect(1, 2) --- error: 'session.on_connect(chunk): bad arguments' ... -lua box.session.on_disconnect(1, 2) +box.session.on_disconnect(1, 2) --- error: 'session.on_connect(chunk): bad arguments' ... -lua box.session.on_connect(1) +box.session.on_connect(1) --- error: 'session.on_connect(chunk): bad arguments' ... -lua box.session.on_disconnect(1) +box.session.on_disconnect(1) --- error: 'session.on_connect(chunk): bad arguments' ... -lua type(box.session.on_connect(nil)) +type(box.session.on_connect(nil)) --- - function ... -lua type(box.session.on_disconnect(nil)) +type(box.session.on_disconnect(nil)) --- - function ... -lua type(box.session.on_connect(nil)) +type(box.session.on_connect(nil)) --- - nil ... -lua type(box.session.on_disconnect(nil)) +type(box.session.on_disconnect(nil)) --- - nil ... -lua function inc() active_connections = active_connections + 1 end +function inc() active_connections = active_connections + 1 end --- ... -lua function dec() active_connections = active_connections - 1 end +function dec() active_connections = active_connections - 1 end --- ... -lua box.session.on_connect(inc) +box.session.on_connect(inc) --- - nil ... -lua box.session.on_disconnect(dec) +box.session.on_disconnect(dec) --- - nil ... -lua active_connections = 0 +active_connections = 0 --- ... -lua active_connections +active_connections --- - 1 ... -lua active_connections +active_connections --- - 2 ... -lua type(box.session.on_connect(nil)) +type(box.session.on_connect(nil)) --- - function ... -lua type(box.session.on_disconnect(nil)) +type(box.session.on_disconnect(nil)) --- - function ... -lua box.session.on_connect(function() box.insert(0, box.session.id()) end) +box.session.on_connect(function() box.insert(0, box.session.id()) end) --- - nil ... -lua box.session.on_disconnect(function() box.delete(0, box.session.id()) end) +box.session.on_disconnect(function() box.delete(0, box.session.id()) end) --- - nil ... -lua box.unpack('i', box.select(0, 0, box.session.id())[0]) == box.session.id() +box.unpack('i', box.select(0, 0, box.session.id())[0]) == box.session.id() --- - true ... -lua type(box.session.on_connect(function() nosuchfunction() end)) +type(box.session.on_connect(function() nosuchfunction() end)) --- - function ... disconnected -lua type(box.session.on_connect(nil)) +type(box.session.on_connect(nil)) --- - function ... -lua type(box.session.on_disconnect(nil)) +type(box.session.on_disconnect(nil)) --- - function ... -lua active_connections +active_connections --- - 0 ... diff --git a/test/box/session.test b/test/box/session.test index b42beda1dceec8ad76f22de755482c15eb794569..de7c22cbb800d34cc42d439109db67900590f7f9 100644 --- a/test/box/session.test +++ b/test/box/session.test @@ -2,72 +2,72 @@ from lib.admin_connection import AdminConnection from lib.box_connection import BoxConnection -admin("lua box.session.exists(box.session.id())") -admin("lua box.session.exists()") -admin("lua box.session.exists(1, 2, 3)") -admin("lua box.session.exists(1234567890)") +admin("box.session.exists(box.session.id())") +admin("box.session.exists()") +admin("box.session.exists(1, 2, 3)") +admin("box.session.exists(1234567890)") # check session.id() -admin("lua box.session.id() > 0") -admin("lua f = box.fiber.create(function() box.fiber.detach() failed = box.session.id() ~= 0 end)") -admin("lua box.fiber.resume(f)") -admin("lua failed") -admin("lua f1 = box.fiber.create(function() if box.session.id() == 0 then failed = true end end)") -admin("lua box.fiber.resume(f1)") -admin("lua failed") -admin("lua box.session.peer() == box.session.peer(box.session.id())") +admin("box.session.id() > 0") +admin("f = box.fiber.create(function() box.fiber.detach() failed = box.session.id() ~= 0 end)") +admin("box.fiber.resume(f)") +admin("failed") +admin("f1 = box.fiber.create(function() if box.session.id() == 0 then failed = true end end)") +admin("box.fiber.resume(f1)") +admin("failed") +admin("box.session.peer() == box.session.peer(box.session.id())") # check on_connect/on_disconnect triggers -admin("lua box.session.on_connect(function() end)") -admin("lua box.session.on_disconnect(function() end)") +admin("box.session.on_connect(function() end)") +admin("box.session.on_disconnect(function() end)") # check it's possible to reset these triggers # -admin("lua type(box.session.on_connect(function() error('hear') end))") -admin("lua type(box.session.on_disconnect(function() error('hear') end))") +admin("type(box.session.on_connect(function() error('hear') end))") +admin("type(box.session.on_disconnect(function() error('hear') end))") # check on_connect/on_disconnect argument count and type -admin("lua box.session.on_connect()") -admin("lua box.session.on_disconnect()") +admin("box.session.on_connect()") +admin("box.session.on_disconnect()") -admin("lua box.session.on_connect(function() end, function() end)") -admin("lua box.session.on_disconnect(function() end, function() end)") +admin("box.session.on_connect(function() end, function() end)") +admin("box.session.on_disconnect(function() end, function() end)") -admin("lua box.session.on_connect(1, 2)") -admin("lua box.session.on_disconnect(1, 2)") +admin("box.session.on_connect(1, 2)") +admin("box.session.on_disconnect(1, 2)") -admin("lua box.session.on_connect(1)") -admin("lua box.session.on_disconnect(1)") +admin("box.session.on_connect(1)") +admin("box.session.on_disconnect(1)") # use of nil to clear the trigger -admin("lua type(box.session.on_connect(nil))") -admin("lua type(box.session.on_disconnect(nil))") -admin("lua type(box.session.on_connect(nil))") -admin("lua type(box.session.on_disconnect(nil))") +admin("type(box.session.on_connect(nil))") +admin("type(box.session.on_disconnect(nil))") +admin("type(box.session.on_connect(nil))") +admin("type(box.session.on_disconnect(nil))") # check how connect/disconnect triggers work -admin("lua function inc() active_connections = active_connections + 1 end") -admin("lua function dec() active_connections = active_connections - 1 end") -admin("lua box.session.on_connect(inc)") -admin("lua box.session.on_disconnect(dec)") -admin("lua active_connections = 0") +admin("function inc() active_connections = active_connections + 1 end") +admin("function dec() active_connections = active_connections - 1 end") +admin("box.session.on_connect(inc)") +admin("box.session.on_disconnect(dec)") +admin("active_connections = 0") con1 = AdminConnection('localhost', server.admin_port) -con1("lua active_connections") +con1("active_connections") con2 = AdminConnection('localhost', server.admin_port) -con2("lua active_connections") +con2("active_connections") con1.disconnect() con2.disconnect() -admin("lua type(box.session.on_connect(nil))") -admin("lua type(box.session.on_disconnect(nil))") +admin("type(box.session.on_connect(nil))") +admin("type(box.session.on_disconnect(nil))") # write audit trail of connect/disconnect into a space -admin("lua box.session.on_connect(function() box.insert(0, box.session.id()) end)") -admin("lua box.session.on_disconnect(function() box.delete(0, box.session.id()) end)") -con1("lua box.unpack('i', box.select(0, 0, box.session.id())[0]) == box.session.id()") +admin("box.session.on_connect(function() box.insert(0, box.session.id()) end)") +admin("box.session.on_disconnect(function() box.delete(0, box.session.id()) end)") +con1("box.unpack('i', box.select(0, 0, box.session.id())[0]) == box.session.id()") con1.disconnect() # if on_connect() trigger raises an exception, the connection is dropped -admin("lua type(box.session.on_connect(function() nosuchfunction() end))") +admin("type(box.session.on_connect(function() nosuchfunction() end))") con1 = BoxConnection('localhost', server.primary_port) try: con1.execute("select * from t0 where k0=0") @@ -77,8 +77,8 @@ except Exception as e: # cleanup -admin("lua type(box.session.on_connect(nil))") -admin("lua type(box.session.on_disconnect(nil))") -admin("lua active_connections") +admin("type(box.session.on_connect(nil))") +admin("type(box.session.on_disconnect(nil))") +admin("active_connections") # vim: syntax=python diff --git a/test/box/socket.result b/test/box/socket.result index ccf0233e5984c3664afd0386867ecebc5a36bb70..ab9fb22ad1e371efed0f8963268c200b143b6c1b 100644 --- a/test/box/socket.result +++ b/test/box/socket.result @@ -1,354 +1,354 @@ -lua s = box.socket.udp() +s = box.socket.udp() --- ... -lua type(s) +type(s) --- - userdata ... -lua s:close() +s:close() --- ... -lua s = box.socket.tcp() +s = box.socket.tcp() --- ... -lua type(s) +type(s) --- - userdata ... -lua s:close() +s:close() --- ... -lua s:close() +s:close() --- ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:connect('localhost', '30303') +s:connect('localhost', '30303') --- - nil - error - 111 - Connection refused ... -lua s:error() +s:error() --- - 111 - Connection refused ... -lua s:connect('127.0.0.1', '30303') +s:connect('127.0.0.1', '30303') --- - nil - error - 111 - Connection refused ... -lua s:error() +s:error() --- - 111 - Connection refused ... -lua s:connect('127.0.0.1', '30303', 0.01) +s:connect('127.0.0.1', '30303', 0.01) --- - nil - error - 111 - Connection refused ... -lua s:error() +s:error() --- - 111 - Connection refused ... -lua s:connect('127.0.0.1') +s:connect('127.0.0.1') --- error: 'bad argument #3 to ''?'' (string expected, got no value)' ... -lua s:connect() +s:connect() --- error: 'bad argument #2 to ''?'' (string expected, got no value)' ... -lua s:connect(123) +s:connect(123) --- error: 'bad argument #3 to ''?'' (string expected, got no value)' ... -lua s:close() +s:close() --- ... -lua s:close() +s:close() --- ... -lua sr, se = s:connect('somewhereelse', '30303', 0.0001) +sr, se = s:connect('somewhereelse', '30303', 0.0001) --- ... -lua sr == nil and se == 'error' or se == 'timeout' +sr == nil and se == 'error' or se == 'timeout' --- - true ... -lua e = s:error() +e = s:error() --- ... -lua e == -1 or e == 110 +e == -1 or e == 110 --- - true ... -lua s:close() +s:close() --- ... -lua s:send() +s:send() --- error: 'box.socket: socket is not initialized' ... -lua s:send(1) +s:send(1) --- error: 'box.socket: socket is not initialized' ... -lua s = box.socket.tcp() +s = box.socket.tcp() --- ... -lua type(s:connect('127.0.0.1', '30303')) +type(s:connect('127.0.0.1', '30303')) --- - userdata ... -lua s:send('ping') +s:send('ping') --- - 4 ... -lua s:error() +s:error() --- - 0 - Success ... -lua n, status, error_code, error_str = s:send(string.rep('=', 8388608), 0.0000001) +n, status, error_code, error_str = s:send(string.rep('=', 8388608), 0.0000001) --- ... -lua type(n) +type(n) --- - number ... -lua type(status) +type(status) --- - string ... -lua type(error_code) +type(error_code) --- - number ... -lua type(error_str) +type(error_str) --- - string ... -lua status +status --- - timeout ... -lua error_code +error_code --- - 110 ... -lua error_str +error_str --- - Connection timed out ... -lua s:error() +s:error() --- - 110 - Connection timed out ... connected -lua s:send('ping') +s:send('ping') --- - 0 - error - 104 - Connection reset by peer ... -lua s:error() +s:error() --- - 104 - Connection reset by peer ... -lua s:close() +s:close() --- ... -lua s:recv() +s:recv() --- error: 'box.socket: socket is not initialized' ... -lua type(s:connect('127.0.0.1', '30308')) +type(s:connect('127.0.0.1', '30308')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... 12 -lua s:recv(12) +s:recv(12) --- - Hello, World ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:close() +s:close() --- ... -lua type(s:connect('127.0.0.1', '30308')) +type(s:connect('127.0.0.1', '30308')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... 21 -lua s:recv(11) +s:recv(11) --- - Hello World ... -lua s:recv(5) +s:recv(5) --- - Over ... -lua s:recv(5) +s:recv(5) --- - sized ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:close() +s:close() --- ... -lua type(s:connect('127.0.0.1', '30308')) +type(s:connect('127.0.0.1', '30308')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... connected 3 -lua s:recv(4, 0.01) +s:recv(4, 0.01) --- - - timeout - 110 - Connection timed out ... -lua s:error() +s:error() --- - 110 - Connection timed out ... -lua s:recv(4) +s:recv(4) --- - ping ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:close() +s:close() --- ... -lua type(s:connect('127.0.0.1', '30309')) +type(s:connect('127.0.0.1', '30309')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... connected 4 -lua s:recv(6) +s:recv(6) --- - ping - eof ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:close() +s:close() --- ... -lua type(s:connect('127.0.0.1', '30311')) +type(s:connect('127.0.0.1', '30311')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... connected 24 -lua s:recv(5) +s:recv(5) --- - ping ... -lua s:recv(5) +s:recv(5) --- - ping ... -lua s:recv(5) +s:recv(5) --- - ping ... -lua s:recv(5) +s:recv(5) --- - ping ... -lua s:recv(5) +s:recv(5) --- - end - eof ... -lua s:recv(5) +s:recv(5) --- - - eof ... -lua s:recv(5) +s:recv(5) --- - - eof ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:close() +s:close() --- ... -lua type(s:connect('127.0.0.1', '30305')) +type(s:connect('127.0.0.1', '30305')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... 12 -lua s:readline() +s:readline() --- - Hello World @@ -356,33 +356,33 @@ lua s:readline() - ... -lua s:error() +s:error() --- - 0 - Success ... 12 -lua s:readline(5) +s:readline(5) --- - Hello - limit ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(5, 0.01) +s:readline(5, 0.01) --- - Worl - limit ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(6, 0.01) +s:readline(6, 0.01) --- - d @@ -390,546 +390,546 @@ lua s:readline(6, 0.01) - ... -lua s:error() +s:error() --- - 0 - Success ... 9 -lua s:readline({'i', 'D'}) +s:readline({'i', 'D'}) --- - AbcD - nil - D ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'i', 'G'}) +s:readline({'i', 'G'}) --- - efG - nil - G ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'i'}) +s:readline({'i'}) --- - hi - nil - i ... -lua s:error() +s:error() --- - 0 - Success ... 13 -lua s:readline({'Cat', 'Cow', 'Dog', 'Star'}) +s:readline({'Cat', 'Cow', 'Dog', 'Star'}) --- - Cat - nil - Cat ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'Cat', 'Cow', 'Dog', 'Star'}) +s:readline({'Cat', 'Cow', 'Dog', 'Star'}) --- - Cow - nil - Cow ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'Cat', 'Cow', 'Dog', 'Star'}) +s:readline({'Cat', 'Cow', 'Dog', 'Star'}) --- - Dog - nil - Dog ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'Cat', 'Cow', 'Dog', 'Star'}) +s:readline({'Cat', 'Cow', 'Dog', 'Star'}) --- - Star - nil - Star ... -lua s:error() +s:error() --- - 0 - Success ... 15 -lua s:readline(3, {'Cat', 'Coow'}) +s:readline(3, {'Cat', 'Coow'}) --- - Cat - nil - Cat ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(3, {'Cat', 'Coow'}) +s:readline(3, {'Cat', 'Coow'}) --- - Coo - limit ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(3, {'Dogg', 'Star'}) +s:readline(3, {'Dogg', 'Star'}) --- - wDo - limit ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(3, {'Dogg', 'Star'}) +s:readline(3, {'Dogg', 'Star'}) --- - ggS - limit ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(3) +s:readline(3) --- - tar - limit ... -lua s:error() +s:error() --- - 0 - Success ... 23 -lua sl = {'Crown', 'King', 'Kong', 'Cezar'} +sl = {'Crown', 'King', 'Kong', 'Cezar'} --- ... -lua s:readline(sl, 1.0) +s:readline(sl, 1.0) --- - KKong - nil - Kong ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(sl, 1.0) +s:readline(sl, 1.0) --- - King - nil - King ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(sl, 1.0) +s:readline(sl, 1.0) --- - CezaCezar - nil - Cezar ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(sl, 1.0) +s:readline(sl, 1.0) --- - Crown - nil - Crown ... -lua s:error() +s:error() --- - 0 - Success ... 26 -lua sl = {'Agatha', 'Road', 'Corn', 'Drive', 'Pop'} +sl = {'Agatha', 'Road', 'Corn', 'Drive', 'Pop'} --- ... -lua s:readline(64, sl, 1.0) +s:readline(64, sl, 1.0) --- - RoAgatha - nil - Agatha ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(64, sl, 1.0) +s:readline(64, sl, 1.0) --- - Pop - nil - Pop ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(64, sl, 1.0) +s:readline(64, sl, 1.0) --- - PoCorn - nil - Corn ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline(64, sl, 1.0) +s:readline(64, sl, 1.0) --- - Drive - nil - Drive ... -lua s:error() +s:error() --- - 0 - Success ... 21 -lua s:readline({'Canada'}, 0.01) +s:readline({'Canada'}, 0.01) --- - - timeout - 110 - Connection timed out ... -lua s:error() +s:error() --- - 110 - Connection timed out ... 2 -lua s:readline({'Canada'}, 0.01) +s:readline({'Canada'}, 0.01) --- - RoadAfricaCubaRomaniaCanada - nil - Canada ... -lua s:error() +s:error() --- - 0 - Success ... 6 -lua s:readline({'Canada'}, 0.01) +s:readline({'Canada'}, 0.01) --- - Canada - nil - Canada ... -lua s:error() +s:error() --- - 0 - Success ... 19 -lua s:readline({'msg'}) +s:readline({'msg'}) --- - msg - nil - msg ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'msg'}) +s:readline({'msg'}) --- - msg - nil - msg ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'msg'}) +s:readline({'msg'}) --- - msg - nil - msg ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'msg'}) +s:readline({'msg'}) --- - msg - nil - msg ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'msg'}) +s:readline({'msg'}) --- - msg - nil - msg ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'msg'}) +s:readline({'msg'}) --- - - eof ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:readline({'msg'}) +s:readline({'msg'}) --- - - eof ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:close() +s:close() --- ... -lua type(s:connect('127.0.0.1', '30307')) +type(s:connect('127.0.0.1', '30307')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... 29 -lua s:readline({'Z'}) +s:readline({'Z'}) --- - SomelongLongStringStrinString - eof ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:close() +s:close() --- ... -lua type(s:connect('localhost', '30303')) +type(s:connect('localhost', '30303')) --- - userdata ... -lua s:send('ping') +s:send('ping') --- - 4 ... connected -lua s:recv(4) +s:recv(4) --- - ping ... -lua s:send('ping') +s:send('ping') --- - 4 ... -lua s:error() +s:error() --- - 0 - Success ... -lua s:send('ping') +s:send('ping') --- - 0 - error - 32 - Broken pipe ... -lua s:error() +s:error() --- - 32 - Broken pipe ... -lua s:close() +s:close() --- ... -lua type(s:bind('127.0.0.1', '30303')) +type(s:bind('127.0.0.1', '30303')) --- - userdata ... -lua type(s:listen()) +type(s:listen()) --- - userdata ... -lua client, status, addr = s:accept() +client, status, addr = s:accept() --- ... -lua addr +addr --- - 127.0.0.1 ... -lua data = client:recv(4) +data = client:recv(4) --- ... -lua data +data --- - ping ... -lua client:send(data, 4) +client:send(data, 4) --- - 4 ... -lua client:close() +client:close() --- ... -lua s:close() +s:close() --- ... ping -lua s = box.socket.udp() +s = box.socket.udp() --- ... -lua type(s:sendto('ping', '127.0.0.1', '30302')) +type(s:sendto('ping', '127.0.0.1', '30302')) --- - number ... -lua s:error() +s:error() --- - 0 - Success ... ping -lua s:recv(4) +s:recv(4) --- - - error - 107 - Transport endpoint is not connected ... -lua s:close() +s:close() --- ... -lua s = box.socket.udp() +s = box.socket.udp() --- ... -lua type(s:bind('127.0.0.1', '30301')) +type(s:bind('127.0.0.1', '30301')) --- - userdata ... -lua s:error() +s:error() --- - 0 - Success ... -lua data, status, client, port = s:recvfrom(4) +data, status, client, port = s:recvfrom(4) --- ... -lua s:error() +s:error() --- - 0 - Success ... -lua data +data --- - ping ... -lua client +client --- - 127.0.0.1 ... -lua type(s:sendto(data, client, port)) +type(s:sendto(data, client, port)) --- - number ... -lua s:error() +s:error() --- - 0 - Success ... ping -lua s:close() +s:close() --- ... -lua replies = 0 function bug1160869() local s = box.socket.tcp() s:connect('127.0.0.1', box.cfg.primary_port) box.fiber.resume( box.fiber.create(function() box.fiber.detach() while true do s:recv(12) replies = replies + 1 end end) ) return s:send(box.pack('iii', 65280, 0, 1)) end + replies = 0 function bug1160869() local s = box.socket.tcp() s:connect('127.0.0.1', box.cfg.primary_port) box.fiber.resume( box.fiber.create(function() box.fiber.detach() while true do s:recv(12) replies = replies + 1 end end) ) return s:send(box.pack('iii', 65280, 0, 1)) end --- ... -lua bug1160869() +bug1160869() --- - 12 ... -lua bug1160869() +bug1160869() --- - 12 ... -lua bug1160869() +bug1160869() --- - 12 ... -lua replies +replies --- - 3 ... -lua s = nil syncno = 0 reps = 0 function iostart() if s ~= nil then return end s = box.socket.tcp() s:connect('127.0.0.1', box.cfg.primary_port) box.fiber.resume( box.fiber.create(function() box.fiber.detach() while true do s:recv(12) reps = reps + 1 end end)) end function iotest() iostart() syncno = syncno + 1 return s:send(box.pack('iii', 65280, 0, syncno)) end + s = nil syncno = 0 reps = 0 function iostart() if s ~= nil then return end s = box.socket.tcp() s:connect('127.0.0.1', box.cfg.primary_port) box.fiber.resume( box.fiber.create(function() box.fiber.detach() while true do s:recv(12) reps = reps + 1 end end)) end function iotest() iostart() syncno = syncno + 1 return s:send(box.pack('iii', 65280, 0, syncno)) end --- ... -lua iotest() +iotest() --- - 12 ... -lua iotest() +iotest() --- - 12 ... -lua iotest() +iotest() --- - 12 ... -lua reps +reps --- - 3 ... diff --git a/test/box/socket.test b/test/box/socket.test index c4968e3a9c380df900b78b808628123a86857847..5c183b626a61762ed09eae458bdb8a3629141994 100644 --- a/test/box/socket.test +++ b/test/box/socket.test @@ -8,22 +8,22 @@ import socket # # ######################## -admin("lua s = box.socket.udp()") -admin("lua type(s)") -admin("lua s:close()") -admin("lua s = box.socket.tcp()") -admin("lua type(s)") +admin("s = box.socket.udp()") +admin("type(s)") +admin("s:close()") +admin("s = box.socket.tcp()") +admin("type(s)") ### socket:close() # close -admin("lua s:close()") +admin("s:close()") # close (on closed) -admin("lua s:close()") +admin("s:close()") # error -admin("lua s:error()") +admin("s:error()") #################### # # @@ -31,33 +31,33 @@ admin("lua s:error()") # # #################### -admin("lua s:connect('localhost', '30303')") +admin("s:connect('localhost', '30303')") # Connection refused -admin("lua s:error()") +admin("s:error()") -admin("lua s:connect('127.0.0.1', '30303')") +admin("s:connect('127.0.0.1', '30303')") # Connection refused -admin("lua s:error()") +admin("s:error()") -admin("lua s:connect('127.0.0.1', '30303', 0.01)") +admin("s:connect('127.0.0.1', '30303', 0.01)") # connection refused -admin("lua s:error()") +admin("s:error()") # bad args -admin("lua s:connect('127.0.0.1')") -admin("lua s:connect()") -admin("lua s:connect(123)") -admin("lua s:close()") +admin("s:connect('127.0.0.1')") +admin("s:connect()") +admin("s:connect(123)") +admin("s:close()") -admin("lua s:close()") -admin("lua sr, se = s:connect('somewhereelse', '30303', 0.0001)") -admin("lua sr == nil and se == 'error' or se == 'timeout'") +admin("s:close()") +admin("sr, se = s:connect('somewhereelse', '30303', 0.0001)") +admin("sr == nil and se == 'error' or se == 'timeout'") # timedout or hostname resolution failed -admin("lua e = s:error()") -admin("lua e == -1 or e == 110") -admin("lua s:close()") +admin("e = s:error()") +admin("e == -1 or e == 110") +admin("s:close()") ################# # # @@ -66,30 +66,30 @@ admin("lua s:close()") ################# # bad args -admin("lua s:send()") -admin("lua s:send(1)") +admin("s:send()") +admin("s:send(1)") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30303)) s.listen(1) -admin("lua s = box.socket.tcp()") -admin("lua type(s:connect('127.0.0.1', '30303'))") -admin("lua s:send('ping')") -admin("lua s:error()") +admin("s = box.socket.tcp()") +admin("type(s:connect('127.0.0.1', '30303'))") +admin("s:send('ping')") +admin("s:error()") # timedout - try to send 64MB (8388608 * 8 bytes) in 0.0000001 sec -admin("lua n, status, error_code, error_str = s:send(string.rep('=', 8388608), 0.0000001)") -admin("lua type(n)") -admin("lua type(status)") -admin("lua type(error_code)") -admin("lua type(error_str)") -admin("lua status") -admin("lua error_code") -admin("lua error_str") +admin("n, status, error_code, error_str = s:send(string.rep('=', 8388608), 0.0000001)") +admin("type(n)") +admin("type(status)") +admin("type(error_code)") +admin("type(error_str)") +admin("status") +admin("error_code") +admin("error_str") -admin("lua s:error()") +admin("s:error()") conn, addr = s.accept() print('connected') @@ -98,10 +98,10 @@ conn.close() s.close() # connection reset by peer -admin("lua s:send('ping')") -admin("lua s:error()") +admin("s:send('ping')") +admin("s:error()") -admin("lua s:close()") +admin("s:close()") ################# # # @@ -110,7 +110,7 @@ admin("lua s:close()") ################# # bad args -admin("lua s:recv()") +admin("s:recv()") # test for case #1: successful recv # @@ -118,13 +118,13 @@ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30308)) s.listen(1) -admin("lua type(s:connect('127.0.0.1', '30308'))") -admin("lua s:error()") +admin("type(s:connect('127.0.0.1', '30308'))") +admin("s:error()") conn, addr = s.accept() print(conn.send("Hello, World")) -admin("lua s:recv(12)") -admin("lua s:error()") -admin("lua s:close()") +admin("s:recv(12)") +admin("s:error()") +admin("s:close()") conn.close() s.close() @@ -134,15 +134,15 @@ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30308)) s.listen(1) -admin("lua type(s:connect('127.0.0.1', '30308'))") -admin("lua s:error()") +admin("type(s:connect('127.0.0.1', '30308'))") +admin("s:error()") conn, addr = s.accept() print(conn.send("Hello World Oversized")) -admin("lua s:recv(11)") -admin("lua s:recv(5)") -admin("lua s:recv(5)") -admin("lua s:error()") -admin("lua s:close()") +admin("s:recv(11)") +admin("s:recv(5)") +admin("s:recv(5)") +admin("s:error()") +admin("s:close()") conn.close() s.close() @@ -153,24 +153,24 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30308)) s.listen(1) -admin("lua type(s:connect('127.0.0.1', '30308'))") -admin("lua s:error()") +admin("type(s:connect('127.0.0.1', '30308'))") +admin("s:error()") conn, addr = s.accept() print('connected') print(conn.send("pin")) -admin("lua s:recv(4, 0.01)") +admin("s:recv(4, 0.01)") # timedout -admin("lua s:error()") +admin("s:error()") conn.send("g") # ping -admin("lua s:recv(4)") -admin("lua s:error()") +admin("s:recv(4)") +admin("s:error()") -admin("lua s:close()") +admin("s:close()") conn.close() s.close() @@ -181,17 +181,17 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30309)) s.listen(1) -admin("lua type(s:connect('127.0.0.1', '30309'))") -admin("lua s:error()") +admin("type(s:connect('127.0.0.1', '30309'))") +admin("s:error()") conn, addr = s.accept() print('connected') print(conn.send("ping")) conn.close() -admin("lua s:recv(6)") -admin("lua s:error()") -admin("lua s:close()") +admin("s:recv(6)") +admin("s:error()") +admin("s:close()") s.close() # test for case #4: EOF (data is more then recv size) @@ -201,8 +201,8 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30311)) s.listen(1) -admin("lua type(s:connect('127.0.0.1', '30311'))") -admin("lua s:error()") +admin("type(s:connect('127.0.0.1', '30311'))") +admin("s:error()") conn, addr = s.accept() print('connected') @@ -211,20 +211,20 @@ print(conn.send("ping ping ping ping end ")) conn.close() # recv should not say EOF, even if it really happened -admin("lua s:recv(5)") -admin("lua s:recv(5)") -admin("lua s:recv(5)") -admin("lua s:recv(5)") +admin("s:recv(5)") +admin("s:recv(5)") +admin("s:recv(5)") +admin("s:recv(5)") # eof -admin("lua s:recv(5)") +admin("s:recv(5)") # eof (zero) -admin("lua s:recv(5)") +admin("s:recv(5)") # eof (zero) -admin("lua s:recv(5)") +admin("s:recv(5)") -admin("lua s:error()") -admin("lua s:close()") +admin("s:error()") +admin("s:close()") s.close() ##################### @@ -249,130 +249,130 @@ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30305)) s.listen(1) -admin("lua type(s:connect('127.0.0.1', '30305'))") -admin("lua s:error()") +admin("type(s:connect('127.0.0.1', '30305'))") +admin("s:error()") conn, addr = s.accept() # 1. readline() == readline(limit == inf, seplist == {'\n'}, timeout == inf) print(conn.send("Hello World\n")) -admin("lua s:readline()") -admin("lua s:error()") +admin("s:readline()") +admin("s:error()") # 2. readline(limit) print(conn.send("Hello World\n")) -admin("lua s:readline(5)") -admin("lua s:error()") +admin("s:readline(5)") +admin("s:error()") # 3. readline(limit, timeout) (just api check) -admin("lua s:readline(5, 0.01)") -admin("lua s:error()") -admin("lua s:readline(6, 0.01)") -admin("lua s:error()") +admin("s:readline(5, 0.01)") +admin("s:error()") +admin("s:readline(6, 0.01)") +admin("s:error()") # 4. readline({seplist}) print(conn.send("AbcDefGhi")) -admin("lua s:readline({'i', 'D'})") -admin("lua s:error()") -admin("lua s:readline({'i', 'G'})") -admin("lua s:error()") -admin("lua s:readline({'i'})") -admin("lua s:error()") +admin("s:readline({'i', 'D'})") +admin("s:error()") +admin("s:readline({'i', 'G'})") +admin("s:error()") +admin("s:readline({'i'})") +admin("s:error()") print(conn.send("CatCowDogStar")) -admin("lua s:readline({'Cat', 'Cow', 'Dog', 'Star'})") -admin("lua s:error()") -admin("lua s:readline({'Cat', 'Cow', 'Dog', 'Star'})") -admin("lua s:error()") -admin("lua s:readline({'Cat', 'Cow', 'Dog', 'Star'})") -admin("lua s:error()") -admin("lua s:readline({'Cat', 'Cow', 'Dog', 'Star'})") -admin("lua s:error()") +admin("s:readline({'Cat', 'Cow', 'Dog', 'Star'})") +admin("s:error()") +admin("s:readline({'Cat', 'Cow', 'Dog', 'Star'})") +admin("s:error()") +admin("s:readline({'Cat', 'Cow', 'Dog', 'Star'})") +admin("s:error()") +admin("s:readline({'Cat', 'Cow', 'Dog', 'Star'})") +admin("s:error()") # 5. readline(limit, {seplist}) print(conn.send("CatCoowDoggStar")) -admin("lua s:readline(3, {'Cat', 'Coow'})") -admin("lua s:error()") -admin("lua s:readline(3, {'Cat', 'Coow'})") -admin("lua s:error()") -admin("lua s:readline(3, {'Dogg', 'Star'})") -admin("lua s:error()") -admin("lua s:readline(3, {'Dogg', 'Star'})") -admin("lua s:error()") +admin("s:readline(3, {'Cat', 'Coow'})") +admin("s:error()") +admin("s:readline(3, {'Cat', 'Coow'})") +admin("s:error()") +admin("s:readline(3, {'Dogg', 'Star'})") +admin("s:error()") +admin("s:readline(3, {'Dogg', 'Star'})") +admin("s:error()") # read 'tar' part -admin("lua s:readline(3)") -admin("lua s:error()") +admin("s:readline(3)") +admin("s:error()") # 6. readline({seplist}, timeout) print(conn.send("KKongKingCezaCezarCrown")) -admin("lua sl = {'Crown', 'King', 'Kong', 'Cezar'}") -admin("lua s:readline(sl, 1.0)") -admin("lua s:error()") -admin("lua s:readline(sl, 1.0)") -admin("lua s:error()") -admin("lua s:readline(sl, 1.0)") -admin("lua s:error()") -admin("lua s:readline(sl, 1.0)") -admin("lua s:error()") +admin("sl = {'Crown', 'King', 'Kong', 'Cezar'}") +admin("s:readline(sl, 1.0)") +admin("s:error()") +admin("s:readline(sl, 1.0)") +admin("s:error()") +admin("s:readline(sl, 1.0)") +admin("s:error()") +admin("s:readline(sl, 1.0)") +admin("s:error()") # 7. readline(limit, {seplist}, timeout) print(conn.send("RoAgathaPopPoCornDriveRoad")) -admin("lua sl = {'Agatha', 'Road', 'Corn', 'Drive', 'Pop'}") -admin("lua s:readline(64, sl, 1.0)") -admin("lua s:error()") -admin("lua s:readline(64, sl, 1.0)") -admin("lua s:error()") -admin("lua s:readline(64, sl, 1.0)") -admin("lua s:error()") -admin("lua s:readline(64, sl, 1.0)") -admin("lua s:error()") +admin("sl = {'Agatha', 'Road', 'Corn', 'Drive', 'Pop'}") +admin("s:readline(64, sl, 1.0)") +admin("s:error()") +admin("s:readline(64, sl, 1.0)") +admin("s:error()") +admin("s:readline(64, sl, 1.0)") +admin("s:error()") +admin("s:readline(64, sl, 1.0)") +admin("s:error()") # test for case #2-3: timedout, errors # print(conn.send("AfricaCubaRomaniaCana")) -admin("lua s:readline({'Canada'}, 0.01)") +admin("s:readline({'Canada'}, 0.01)") # timedout -admin("lua s:error()") +admin("s:error()") print(conn.send("da")) # should read whole line -admin("lua s:readline({'Canada'}, 0.01)") -admin("lua s:error()") +admin("s:readline({'Canada'}, 0.01)") +admin("s:error()") # to ensure readahead pointer correctness print(conn.send("Canada")) -admin("lua s:readline({'Canada'}, 0.01)") -admin("lua s:error()") +admin("s:readline({'Canada'}, 0.01)") +admin("s:error()") # test for case #5: eof testing # print(conn.send("msg msg msg msg msg")) conn.close() -admin("lua s:readline({'msg'})") -admin("lua s:error()") +admin("s:readline({'msg'})") +admin("s:error()") -admin("lua s:readline({'msg'})") -admin("lua s:error()") +admin("s:readline({'msg'})") +admin("s:error()") -admin("lua s:readline({'msg'})") -admin("lua s:error()") +admin("s:readline({'msg'})") +admin("s:error()") -admin("lua s:readline({'msg'})") -admin("lua s:error()") +admin("s:readline({'msg'})") +admin("s:error()") -admin("lua s:readline({'msg'})") -admin("lua s:error()") +admin("s:readline({'msg'})") +admin("s:error()") # eof (zero) -admin("lua s:readline({'msg'})") -admin("lua s:error()") +admin("s:readline({'msg'})") +admin("s:error()") # eof (zero) -admin("lua s:readline({'msg'})") -admin("lua s:error()") +admin("s:readline({'msg'})") +admin("s:error()") -admin("lua s:close()") +admin("s:close()") s.close() @@ -383,18 +383,18 @@ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30307)) s.listen(1) -admin("lua type(s:connect('127.0.0.1', '30307'))") -admin("lua s:error()") +admin("type(s:connect('127.0.0.1', '30307'))") +admin("s:error()") conn, addr = s.accept() print(conn.send("SomelongLongStringStrinString")) conn.close() # should be returned with eof flag -admin("lua s:readline({'Z'})") -admin("lua s:error()") +admin("s:readline({'Z'})") +admin("s:error()") -admin("lua s:close()") +admin("s:close()") s.close() @@ -412,47 +412,47 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30303)) s.listen(1) -admin("lua type(s:connect('localhost', '30303'))") -admin("lua s:send('ping')") +admin("type(s:connect('localhost', '30303'))") +admin("s:send('ping')") conn, addr = s.accept() print('connected') data = conn.recv(4) conn.sendall(data) -admin("lua s:recv(4)") +admin("s:recv(4)") conn.close() s.close() -admin("lua s:send('ping')") -admin("lua s:error()") +admin("s:send('ping')") +admin("s:error()") # broken pipe -admin("lua s:send('ping')") -admin("lua s:error()") +admin("s:send('ping')") +admin("s:error()") -admin("lua s:close()") +admin("s:close()") # echo server (box is server) (TCP). # # connect from test to echo server implemented in # stored procedure and do send/recv. # -admin("lua type(s:bind('127.0.0.1', '30303'))") -admin("lua type(s:listen())") +admin("type(s:bind('127.0.0.1', '30303'))") +admin("type(s:listen())") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.connect(('127.0.0.1', 30303)) s.sendall('ping') -admin("lua client, status, addr = s:accept()") -admin("lua addr") -admin("lua data = client:recv(4)") -admin("lua data") -admin("lua client:send(data, 4)") -admin("lua client:close()") -admin("lua s:close()") +admin("client, status, addr = s:accept()") +admin("addr") +admin("data = client:recv(4)") +admin("data") +admin("client:send(data, 4)") +admin("client:close()") +admin("s:close()") data = s.recv(4) s.close() @@ -468,44 +468,44 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30302)) # SOCK_DGRAM -admin("lua s = box.socket.udp()") -admin("lua type(s:sendto('ping', '127.0.0.1', '30302'))") -admin("lua s:error()") +admin("s = box.socket.udp()") +admin("type(s:sendto('ping', '127.0.0.1', '30302'))") +admin("s:error()") data, addr = s.recvfrom(4) print(data) s.sendto(data, addr) -admin("lua s:recv(4)") +admin("s:recv(4)") s.close() -admin("lua s:close()") +admin("s:close()") # echo server (box is server) (UDP). # # connect from test to echo server implemented in # stored procedure and do send/recv. # -admin("lua s = box.socket.udp()") -admin("lua type(s:bind('127.0.0.1', '30301'))") -admin("lua s:error()") +admin("s = box.socket.udp()") +admin("type(s:bind('127.0.0.1', '30301'))") +admin("s:error()") s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.sendto('ping', ('127.0.0.1', 30301)) -admin("lua data, status, client, port = s:recvfrom(4)") -admin("lua s:error()") -admin("lua data") -admin("lua client") +admin("data, status, client, port = s:recvfrom(4)") +admin("s:error()") +admin("data") +admin("client") -admin("lua type(s:sendto(data, client, port))") -admin("lua s:error()") +admin("type(s:sendto(data, client, port))") +admin("s:error()") data = s.recv(4) print(data) s.close() -admin("lua s:close()") +admin("s:close()") # Bug #1160869: incorrect fiber call order. # (https://bugs.launchpad.net/tarantool/+bug/1160869) @@ -525,11 +525,11 @@ function bug1160869() return s:send(box.pack('iii', 65280, 0, 1)) end """ -admin("lua " + test.replace('\n', ' ')) -admin("lua bug1160869()") -admin("lua bug1160869()") -admin("lua bug1160869()") -admin("lua replies") +admin(test.replace('\n', ' ')) +admin("bug1160869()") +admin("bug1160869()") +admin("bug1160869()") +admin("replies") test=""" s = nil @@ -556,8 +556,8 @@ function iotest() return s:send(box.pack('iii', 65280, 0, syncno)) end """ -admin("lua " + test.replace('\n', ' ')) -admin("lua iotest()") -admin("lua iotest()") -admin("lua iotest()") -admin("lua reps") +admin(test.replace('\n', ' ')) +admin("iotest()") +admin("iotest()") +admin("iotest()") +admin("reps") diff --git a/test/box/sql.result b/test/box/sql.result index 510f39df71b992ca5fdd4f80365f276fdcfc8f5d..a3df48998643b5319cd0c043853a19f1eee1af22 100644 --- a/test/box/sql.result +++ b/test/box/sql.result @@ -96,7 +96,7 @@ select * from t65537 where k0 = 0 An error occurred: ER_NO_SUCH_SPACE, 'Space 65537 does not exist' select * from t4294967295 where k0 = 0 An error occurred: ER_NO_SUCH_SPACE, 'Space 4294967295 does not exist' -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... # diff --git a/test/box/sql.test b/test/box/sql.test index eea66b9ec1e1cd9c6ea908dfc3339eb93a2cb32b..81bc0ed15106652b339be15e7eb673b0077af59d 100644 --- a/test/box/sql.test +++ b/test/box/sql.test @@ -57,12 +57,12 @@ print """# sql("select * from t1 where k0 = 0") sql("select * from t65537 where k0 = 0") sql("select * from t4294967295 where k0 = 0") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") print """# # A test case for: http://bugs.launchpad.net/bugs/716683 # Admin console should not stall on unknown command. """ -admin("show status") +admin("show status", simple=True) # vim: syntax=python diff --git a/test/box/suite.ini b/test/box/suite.ini index a4883826b11489422e8aacdeae2ca3d17513907d..b8ec610cd69dc88f31363833b0a76e923e79d4dd 100644 --- a/test/box/suite.ini +++ b/test/box/suite.ini @@ -1,4 +1,5 @@ [default] +core = python tarantool description = tarantool/box, minimal configuration config = tarantool.cfg # put disabled tests here diff --git a/test/box/xlog.result b/test/box/xlog.result index c5f0407f8f435f0f5138788fc343864c89fc7fec..7d1bd9234a9e3c0ff96ff331f379843e07cebc09 100644 --- a/test/box/xlog.result +++ b/test/box/xlog.result @@ -36,15 +36,15 @@ Stopping the server... A test case for https://bugs.launchpad.net/tarantool/+bug/1052018 panic_on_wal_error doens't work for duplicate key errors -lua box.space[0]:select(0, 1) +box.space[0]:select(0, 1) --- - 1: {} ... -lua box.space[0]:select(0, 2) +box.space[0]:select(0, 2) --- - 2: {} ... -lua #box.space[0] +#box.space[0] --- - 0 ... diff --git a/test/box/xlog.test b/test/box/xlog.test index b99118452f5dd281d5060bd84b77b6e03aeb97c2..e7a81ba914c2ba44eb1314727ba8ecdb1f6c8066 100644 --- a/test/box/xlog.test +++ b/test/box/xlog.test @@ -119,9 +119,9 @@ shutil.copy(abspath("box/dup_key1.xlog"), shutil.copy(abspath("box/dup_key2.xlog"), os.path.join(vardir, "00000000000000000004.xlog")) server.start() -admin("lua box.space[0]:select(0, 1)") -admin("lua box.space[0]:select(0, 2)") -admin("lua #box.space[0]") +admin("box.space[0]:select(0, 1)") +admin("box.space[0]:select(0, 2)") +admin("#box.space[0]") # cleanup server.stop() diff --git a/test/connector_c/suite.ini b/test/connector_c/suite.ini index 104f0eb71333232dfb1b19648128ee68fdcc64d0..018e816cf351135f7474dcd7c638f579d514c6bd 100644 --- a/test/connector_c/suite.ini +++ b/test/connector_c/suite.ini @@ -1,4 +1,5 @@ [default] +core = python tarantool description = tarantool/box connector C config = cfg/tarantool.cfg # put disabled tests here diff --git a/test/lib/admin_connection.py b/test/lib/admin_connection.py index 3b2aa8eb764667cc2a98057b2d692449cf4f02b7..c861a18f48c1612279226185b5d7eb182ad94a88 100644 --- a/test/lib/admin_connection.py +++ b/test/lib/admin_connection.py @@ -27,13 +27,46 @@ import sys import re from tarantool_connection import TarantoolConnection -is_admin_re = re.compile("^\s*(show|set|save|lua|exit|reload|help)", re.I) +#generation of "optional end" regexp +def re_optional_end(begin, opt_end): + return begin + ''.join(map(lambda x: '(' + x, opt_end)) + (')?'*len(opt_end)) +cr = re_optional_end + +#generation of "two mandatory word, but second word may differ" regexp +def re_compose(begin, end): + if end == None: + return begin + return begin+'\s*('+'|'.join(end)+')' + +#simple server cmd's regexp generation +re_is_sim_admin_cmd = '\s*('+'|'.join([ + re_compose(cr('e', 'xit'), None), + re_compose(cr('h', 'elp'), None), + re_compose(cr('sh','ow'), [cr('in', 'fo'), cr('fi', 'ber'), + cr('co', 'nfiguration'), 'plugins', cr('sl', 'ab'), + cr('pa', 'lloc'), cr('st', 'at'), 'injections'] + ), + re_compose(cr('re', 'load'), [cr('co', 'nfiguration')]), + re_compose(cr('sa', 've'), [cr('co', 'redump'), cr('sn', 'apshot')]) +])+')\s*$' + +#beginnig of complex server cmd's regexp generation +re_is_com_admin_cmd = '\s*('+'|'.join([ + re_compose(cr('lu', 'a'), None), + re_compose(cr('se', 't'), [cr('in', 'jection')]) +]) +')\s*' + +#simple+complex admin cmd's regexp objects +is_admin_re_1 = re.compile(re_is_sim_admin_cmd, re.I) +is_admin_re_2 = re.compile(re_is_com_admin_cmd, re.I) ADMIN_SEPARATOR = '\n' class AdminConnection(TarantoolConnection): - def execute_no_reconnect(self, command, silent): - self.socket.sendall(command + ADMIN_SEPARATOR) + def execute_simple(self, command, silent, lua=False): + if not command: + return + self.socket.sendall(('lua ' if lua else '') + command.replace('\n', ' ') + ADMIN_SEPARATOR) bufsiz = 4096 res = "" @@ -53,6 +86,11 @@ class AdminConnection(TarantoolConnection): if not silent: sys.stdout.write(command + ADMIN_SEPARATOR) sys.stdout.write(res.replace("\r\n", "\n")) - return res + def execute_no_reconnect(self, command, silent): + add_lua = False + rg1, rg2 = is_admin_re_1.match(command), is_admin_re_2.match(command) + if (not rg1 or len(rg1.group()) != len(command)) and not rg2: + add_lua=True + return self.execute_simple(command, silent, lua=add_lua) diff --git a/test/lib/lua_tarantool_server.py b/test/lib/lua_tarantool_server.py new file mode 100644 index 0000000000000000000000000000000000000000..a5e1f4526f21ffa15178a9c7efbd8cb98d1374cb --- /dev/null +++ b/test/lib/lua_tarantool_server.py @@ -0,0 +1,28 @@ +import os +import sys +import glob +from pprint import pprint + +from server import Server +from test_suite import Test +from tarantool_server import TarantoolServer, FuncTest + +class LuaTest(FuncTest): + def execute(self, server): + pprint('test lua',sys.stderr) + for i in open(self.name, 'r').read().replace('\n\n', '\n').split(';\n'): + server.admin(i) + +class LuaTarantoolServer(TarantoolServer): + def __new__(cls, core="lua tarantool"): + return TarantoolServer.__new__(cls) + + def __init__(self, core="lua tarantool"): + TarantoolServer.__init__(self, core) + + def find_tests(self, test_suite, suite_path): + for test_name in sorted(glob.glob(os.path.join(suite_path, "*.test"))): + for test_pattern in test_suite.args.tests: + if test_name.find(test_pattern) != -1: + test_suite.tests.append(LuaTest(test_name, test_suite.args, test_suite.ini)) + diff --git a/test/lib/python_tarantool_server.py b/test/lib/python_tarantool_server.py new file mode 100644 index 0000000000000000000000000000000000000000..beb325513a4f15ed683d43aeabf76f5213679cbe --- /dev/null +++ b/test/lib/python_tarantool_server.py @@ -0,0 +1,26 @@ +import os +import sys +import glob +from pprint import pprint + +from server import Server +from test_suite import Test +from tarantool_server import TarantoolServer, FuncTest + +class PythonTest(FuncTest): + def execute(self, server): + execfile(self.name, dict(locals(), **server.__dict__)) + +class PythonTarantoolServer(TarantoolServer): + def __new__(cls, core="python tarantool"): + return TarantoolServer.__new__(cls) + + def __init__(self, core="python tarantool"): + TarantoolServer.__init__(self, core) + + def find_tests(self, test_suite, suite_path): + for test_name in sorted(glob.glob(os.path.join(suite_path, "*.test"))): + for test_pattern in test_suite.args.tests: + if test_name.find(test_pattern) != -1: + test_suite.tests.append(PythonTest(test_name, test_suite.args, test_suite.ini)) + diff --git a/test/lib/server.py b/test/lib/server.py index dfd2c224865726db34cb420e979bda97d72530b5..b38ac49d5629dd4815d70d03f9f866fcff73c9a1 100644 --- a/test/lib/server.py +++ b/test/lib/server.py @@ -50,300 +50,39 @@ class Server(object): def __new__(cls, core=None): if core == None: return super(Server, cls).__new__(cls) - mdlname = "lib.{0}_server".format(core) - clsname = "{0}Server".format(core.title()) - corecls = __import__(mdlname, fromlist=clsname).__dict__[clsname] + core = core.lower().strip() + cls.mdlname = "lib.{0}_server".format(core.replace(' ', '_')) + cls.clsname = "{0}Server".format(core.title().replace(' ', '')) + corecls = __import__(cls.mdlname, fromlist=cls.clsname).__dict__[cls.clsname] return corecls.__new__(corecls, core) def __init__(self, core): self.core = core - self.re_vardir_cleanup = ['*.core.*', 'core'] - self.process = None - self.default_config_name = None - self.default_init_lua_name = None - self.config = None self.vardir = None - self.valgrind_log = "valgrind.log" - self.valgrind_sup = os.path.join("share/", "%s.sup" % (core)) - self.init_lua = None - self.default_suppression_name = "valgrind.sup" - self.pidfile = None - self.port = None - self.binary = None - self.is_started = False - self.mem = False - self.start_and_exit = False - self.gdb = False - self.valgrind = False - - def find_exe(self, builddir, silent=True): - "Locate server executable in the build dir or in the PATH." - path = builddir + os.pathsep + os.environ["PATH"] - - if not silent: - print " Looking for server binary in {0} ...".format(path) - - for dir in path.split(os.pathsep): - exe = os.path.join(dir, self.default_bin_name) - if os.access(exe, os.X_OK): - return exe + self.re_vardir_cleanup = ['*.core.*', 'core'] - raise RuntimeError("Can't find server executable in " + path) + def prepare_args(self): + return [] def cleanup(self, full=False): - trash = [] - - for re in self.re_vardir_cleanup: - trash += glob.glob(os.path.join(self.vardir, re)) - - for filename in trash: - os.remove(filename) - if full: shutil.rmtree(self.vardir) + return + for re in self.re_vardir_cleanup: + for f in glob.glob(os.path.join(self.vardir, re)): + os.remove(f) def configure(self, config): - self.config = os.path.abspath(config) - + pass def install(self, binary=None, vardir=None, mem=None, silent=True): - """Install server instance: create necessary directories and files. - The server working directory is taken from 'vardir', - specified in the program options.""" - - if vardir != None: self.vardir = vardir - if binary != None: self.binary = os.path.abspath(binary) - if mem != None: self.mem = mem - - self.pidfile = os.path.abspath(os.path.join(self.vardir, self.pidfile)) - self.valgrind_log = os.path.abspath(os.path.join(self.vardir, self.valgrind_log)) - - if not silent: - print "Installing the server..." - print " Found executable at " + self.binary - print " Creating and populating working directory in " + self.vardir + "..." - - if os.access(self.vardir, os.F_OK): - if not silent: - print " Found old vardir, deleting..." - self.kill_old_server() - self.cleanup() - else: - if (self.mem == True and check_tmpfs_exists() and - os.path.basename(self.vardir) == self.vardir): - create_tmpfs_vardir(self.vardir) - else: - os.makedirs(self.vardir) - - shutil.copy(self.config, os.path.join(self.vardir, - self.default_config_name)) - shutil.copy(self.valgrind_sup, - os.path.join(self.vardir, self.default_suppression_name)) - - var_init_lua = os.path.join(self.vardir, self.default_init_lua_name) - if self.init_lua != None: - shutil.copy(self.init_lua, var_init_lua) - elif os.path.exists(var_init_lua): - # We must delete old init.lua if it exists - os.remove(var_init_lua) - + pass def init(self): pass - - def _start_and_exit(self, args, gdb=None, valgrind=None): - if gdb != None: self.gdb = gdb - if valgrind != None: self.valgrind = valgrind - - if self.gdb == True: - raise RuntimeError("'--gdb' and '--start-and-exit' can't be defined together") - with daemon.DaemonContext(working_directory = self.vardir): - os.execvp(args[0], args) - - def prepare_args(self): - return [] - - def start(self, start_and_exit=None, gdb=None, valgrind=None, silent=True): - if start_and_exit != None: self.start_and_exit = start_and_exit - if gdb != None: self.gdb = gdb - if valgrind != None: self.valgrind = valgrind - self.debug = self.test_debug() - - if self.is_started: - if not silent: - print "The server is already started." - return - - if not silent: - print "Starting the server..." - version = self.version() - print "Starting {0} {1}.".format(os.path.basename(self.binary), version) - - check_port(self.port) - args = self.prepare_args() - - if self.gdb: - args = prepare_gdb(self.binary, args) - print "You started the server in gdb mode." - print "To attach, use `screen -r tnt-gdb`" - elif self.valgrind: - args = prepare_valgrind([self.binary] + args, self.valgrind_log, - os.path.abspath(os.path.join(self.vardir, - self.default_suppression_name))) - else: - args = [self.binary] + args - - if self.start_and_exit: - self._start_and_exit(args) - return - - self.process = subprocess.Popen(args, cwd = self.vardir) - - # wait until the server is connected - self.wait_until_started() - # Set is_started flag, to nicely support cleanup during an exception. - self.is_started = True - - + def find_exe(self, builddir, silent=True): + pass + def start(self, silent=True): + pass def stop(self, silent=True): - """Stop server instance. Do nothing if the server is not started, - to properly shut down the server in case of an exception during - start up.""" - if not self.is_started: - if not silent: - print "The server is not started." - return - - if not silent: - print "Stopping the server..." - - if self.process == None: - self.kill_old_server() - return - - # kill process - pid = self.read_pidfile(); - if pid != -1: - os.kill(pid, signal.SIGTERM) - #self.process.kill(signal.SIGTERM) - if self.gdb or self.valgrind: - time = 0 - while time < (1<<30) : - if self.process.poll() != None: - break - time += 1 - sleep(1) - else: - self.process.wait() - - self.wait_until_stopped() - # clean-up processs flags - self.is_started = False - self.process = None - - def deploy(self, config=None, binary=None, vardir=None, - mem=None, start_and_exit=None, gdb=None, valgrind=None, - valgrind_sup=None, init_lua=None, silent=True, need_init=True): - if config != None: self.config = config - if binary != None: self.binary = binary - if vardir != None: self.vardir = vardir - if mem != None: self.mem = mem - if start_and_exit != None: self.start_and_exit = start_and_exit - if gdb != None: self.gdb = gdb - if valgrind != None: self.valgrind = valgrind - - if init_lua != None: - self.init_lua = os.path.abspath(init_lua) - else: - self.init_lua = None; - - self.configure(self.config) - self.install(self.binary, self.vardir, self.mem, silent) - if need_init: - self.init() - self.start(self.start_and_exit, self.gdb, self.valgrind, silent) - + pass def restart(self): - self.stop(silent=True) - self.start(silent=True) - - def test_option_get(self, show, option_list_str): - args = [self.binary] + option_list_str.split() - if show: - print " ".join([os.path.basename(self.binary)] + args[1:]) - output = subprocess.Popen(args, - cwd = self.vardir, - stdout = subprocess.PIPE, - stderr = subprocess.STDOUT).stdout.read() - return output - - def test_option(self, option_list_str): - print self.test_option_get(True, option_list_str) - - def test_debug(self): - output = self.test_option_get(False, "-V") - if re.search("-Debug", output): - return True - return False - - def kill_old_server(self, silent=True): - """Kill old server instance if it exists.""" - pid = self.read_pidfile() - if pid == -1: - return # Nothing to do - - if not silent: - print " Found old server, pid {0}, killing...".format(pid) - - try: - os.kill(pid, signal.SIGTERM) - while os.kill(pid, 0) != -1: - time.sleep(0.001) - except OSError: - pass - - def read_pidfile(self): - if os.access(self.pidfile, os.F_OK) == False: - # file is inaccessible (not exist or permission denied) - return -1 - - pid = -1 - try: - with open(self.pidfile) as f: - pid = int(f.read()) - except: - pass - return pid - - def wait_until_started(self): - """Wait until the server is started and accepting connections""" - - while self.read_pidfile() == -1: - time.sleep(0.001) - - is_connected = False - while not is_connected: - try: - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect(("localhost", self.port)) - is_connected = True - sock.close() - except socket.error as e: - time.sleep(0.001) - - def wait_until_stopped(self): - """Wait until the server is stoped and has closed sockets""" - - while self.read_pidfile() != -1: - time.sleep(0.001) - - is_connected = False - while not is_connected: - try: - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect(("localhost", self.port)) - is_connected = True - sock.close() - time.sleep(0.001) - continue - except socket.error as e: - break - + pass diff --git a/test/lib/tarantool_connection.py b/test/lib/tarantool_connection.py index f60ad3de6cf69f19f4f657c263dc336bd48854b2..88fa0b6fe1d3d6fc684beaf708dc8caebf3b82cf 100644 --- a/test/lib/tarantool_connection.py +++ b/test/lib/tarantool_connection.py @@ -75,5 +75,8 @@ class TarantoolConnection(object): def __exit__(self, type, value, tb): self.disconnect() - def __call__(self, command, silent=False): - return self.execute(command, silent) + def __call__(self, command, silent=False, simple=False): + if not simple: + return self.execute(command, silent) + else: + return self.execute_simple(command, silent) diff --git a/test/lib/tarantool_server.py b/test/lib/tarantool_server.py index bfedd1fa78aea12c0db28ba24e4b216dddd3ba0f..ec447709023cb855c5194ea469724b445280f806 100644 --- a/test/lib/tarantool_server.py +++ b/test/lib/tarantool_server.py @@ -1,8 +1,11 @@ import os +import re import sys import glob import time import yaml +import socket +import signal import shutil import pexpect import traceback @@ -16,50 +19,38 @@ from test_suite import FilteredStream, Test from admin_connection import AdminConnection from memcached_connection import MemcachedConnection +def check_port(port): + """Check if the port we're connecting to is available""" + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect(("localhost", port)) + except socket.error as e: + return + raise RuntimeError("The server is already running on port {0}".format(port)) -class FuncTest(Test): - def __init__(self, name, args, suite_ini): - Test.__init__(self, name, args, suite_ini) - self.name = name - self.result = name.replace(".test", ".result") - self.skip_cond = name.replace(".test", ".skipcond") - self.tmp_result = os.path.join(self.args.vardir, - os.path.basename(self.result)) - self.reject = "{0}/test/{1}".format(self.args.builddir, - name.replace(".test", ".reject")) +def prepare_gdb(binary, args): + """Prepare server startup arguments to run under gdb.""" + args = shlex.split('screen -dmS tnt-gdb gdb %s -ex \'b main\' -ex run' % binary) + args + return args - def execute(self, server): - diagnostics = "unknown" - builddir = self.args.builddir - save_stdout = sys.stdout - try: - self.skip = 0 - if os.path.exists(self.skip_cond): - sys.stdout = FilteredStream(self.tmp_result) - stdout_fileno = sys.stdout.stream.fileno() - execfile(self.skip_cond, dict(locals(), **server.__dict__)) - sys.stdout.close() - sys.stdout = save_stdout - if not self.skip: - sys.stdout = FilteredStream(self.tmp_result) - stdout_fileno = sys.stdout.stream.fileno() - execfile(self.name, dict(locals(), **server.__dict__)) - self.is_executed_ok = True - except Exception as e: - traceback.print_exc(e) - diagnostics = str(e) - finally: - if sys.stdout and sys.stdout != save_stdout: - sys.stdout.close() - sys.stdout = save_stdout; - self.is_executed = True - - def __repr__(self): - return str([self.name, self.result, self.skip_cond, self.tmp_result, - self.reject]) - - __str__ = __repr__ +def prepare_valgrind(args, valgrind_log, valgrind_sup): + "Prepare server startup arguments to run under valgrind." + args = [ "valgrind", "--log-file={0}".format(valgrind_log), + "--suppressions={0}".format(valgrind_sup), + "--gen-suppressions=all", "--show-reachable=yes", "--leak-check=full", + "--read-var-info=yes", "--quiet" ] + args + return args + +def check_tmpfs_exists(): + return os.uname()[0] in 'Linux' and os.path.isdir("/dev/shm") +def create_tmpfs_vardir(vardir): + os.makedirs(os.path.join("/dev/shm", vardir)) + os.symlink(os.path.join("/dev/shm", vardir), vardir) + +class FuncTest(Test): + def execute(self, server): + execfile(self.name, dict(locals(), **server.__dict__)) class TarantoolConfigFile: """ConfigParser can't read files without sections, work it around""" @@ -91,22 +82,95 @@ class TarantoolServer(Server): '*.cfg', '*.sup', '*.lua'] + self.process = None + self.config = None + self.vardir = None + self.valgrind_log = "valgrind.log" + self.valgrind_sup = os.path.join("share/", "%s.sup" % ('tarantool')) + self.init_lua = None + self.default_suppression_name = "valgrind.sup" + self.pidfile = None + self.port = None + self.binary = None + self.is_started = False + self.mem = False + self.start_and_exit = False + self.gdb = False + self.valgrind = False def find_exe(self, builddir, silent=True): - return Server.find_exe(self, "{0}/src/box/".format(builddir), silent) + "Locate server executable in the build dir or in the PATH." + self.builddir = builddir + builddir = os.path.join(builddir, "src/box") + path = builddir + os.pathsep + os.environ["PATH"] + if not silent: + print "Looking for server binary in {0} ...".format(path) + for dir in path.split(os.pathsep): + exe = os.path.join(dir, self.default_bin_name) + if os.access(exe, os.X_OK): + return exe + raise RuntimeError("Can't find server executable in " + path) + + def install(self, binary=None, vardir=None, mem=None, silent=True): + """Install server instance: create necessary directories and files. + The server working directory is taken from 'vardir', + specified in the program options.""" + + if vardir != None: self.vardir = vardir + if binary != None: self.binary = os.path.abspath(binary) + if mem != None: self.mem = mem + + self.pidfile = os.path.abspath(os.path.join(self.vardir, self.pidfile)) + self.valgrind_log = os.path.abspath(os.path.join(self.vardir, self.valgrind_log)) + + if not silent: + print "Installing the server..." + print " Found executable at " + self.binary + print " Creating and populating working directory in " + self.vardir + "..." + + if os.access(self.vardir, os.F_OK): + if not silent: + print " Found old vardir, deleting..." + self.kill_old_server() + self.cleanup() + else: + if (self.mem == True and check_tmpfs_exists() and + os.path.basename(self.vardir) == self.vardir): + create_tmpfs_vardir(self.vardir) + else: + os.makedirs(self.vardir) + + shutil.copy(self.config, + os.path.join(self.vardir, self.default_config_name)) + shutil.copy(self.valgrind_sup, + os.path.join(self.vardir, self.default_suppression_name)) + + var_init_lua = os.path.join(self.vardir, self.default_init_lua_name) + if self.init_lua != None: + if os.path.exists(var_init_lua): + os.remove(var_init_lua) + shutil.copy(self.init_lua, var_init_lua) + def configure(self, config): - Server.configure(self, config) + def get_option(config, section, key): + if not config.has_option(section, key): + return None + value = config.get(section, key) + if value.isdigit(): + value = int(value) + return value + self.config = os.path.abspath(config) # now read the server config, we need some properties from it with open(self.config) as fp: dummy_section_name = "tarantool" config = ConfigParser.ConfigParser() config.readfp(TarantoolConfigFile(fp, dummy_section_name)) - - self.pidfile = config.get(dummy_section_name, "pid_file") - self.primary_port = self.get_option_int(config, dummy_section_name, "primary_port") - self.admin_port = self.get_option_int(config, dummy_section_name, "admin_port") - self.memcached_port = self.get_option_int(config, dummy_section_name, "memcached_port") + + self.pidfile = get_option(config, dummy_section_name, "pid_file") + self.primary_port = get_option(config, dummy_section_name, "primary_port") + self.admin_port = get_option(config, dummy_section_name, "admin_port") + self.memcached_port = get_option(config, dummy_section_name, "memcached_port") self.port = self.admin_port self.admin = AdminConnection("localhost", self.admin_port) @@ -115,12 +179,6 @@ class TarantoolServer(Server): # Run memcached client self.memcached = MemcachedConnection('localhost', self.memcached_port) - def find_tests(self, test_suite, suite_path): - for test_name in sorted(glob.glob(os.path.join(suite_path, "*.test"))): - for test_pattern in test_suite.args.tests: - if test_name.find(test_pattern) != -1: - test_suite.tests.append(FuncTest(test_name, test_suite.args, test_suite.ini)) - def reconfigure(self, config, silent=False): if config == None: os.unlink(os.path.join(self.vardir, self.default_config_name)) @@ -129,12 +187,6 @@ class TarantoolServer(Server): shutil.copy(self.config, os.path.join(self.vardir, self.default_config_name)) self.admin.execute("reload configuration", silent=silent) - def get_option_int(self, config, section, option): - if config.has_option(section, option): - return config.getint(section, option) - else: - return 0 - def init(self): # init storage subprocess.check_call([self.binary, "--init-storage"], @@ -144,9 +196,11 @@ class TarantoolServer(Server): stderr = subprocess.PIPE) def get_param(self, param): - data = self.admin.execute("show info", silent = True) - info = yaml.load(data)["info"] - return info[param] + if param: + data = yaml.load(self.admin("box.info." + param, silent=True))[0] + else: + data = yaml.load(self.admin("show info", silent=True))[info] + return data def wait_lsn(self, lsn): while True: @@ -168,7 +222,8 @@ class TarantoolServer(Server): if valgrind != None: self.valgrind = valgrind if self.valgrind: - Server._start_and_exit(self, args) + with daemon.DaemonContext(working_directory = self.vardir): + subprocess.check_call(args) else: if not self.gdb: args.append("--background") @@ -176,3 +231,190 @@ class TarantoolServer(Server): raise RuntimeError("'--gdb' and '--start-and-exit' can't be defined together") self.server = subprocess.Popen(args, cwd = self.vardir) self.server.wait() + + def start(self, start_and_exit=None, gdb=None, valgrind=None, silent=True): + if start_and_exit != None: self.start_and_exit = start_and_exit + if gdb != None: self.gdb = gdb + if valgrind != None: self.valgrind = valgrind + self.debug = self.test_debug() + + if self.is_started: + if not silent: + print "The server is already started." + return + + if not silent: + print "Starting the server..." + version = self.version() + print "Starting {0} {1}.".format(os.path.basename(self.binary), version) + + check_port(self.port) + args = self.prepare_args() + + if self.gdb: + args = prepare_gdb(self.binary, args) + print "You started the server in gdb mode." + print "To attach, use `screen -r tnt-gdb`" + elif self.valgrind: + args = prepare_valgrind([self.binary] + args, self.valgrind_log, + os.path.abspath(os.path.join(self.vardir, + self.default_suppression_name))) + else: + args = [self.binary] + args + + if self.start_and_exit: + self._start_and_exit(args) + return + + self.process = subprocess.Popen(args, cwd = self.vardir) + + # wait until the server is connected + self.wait_until_started() + # Set is_started flag, to nicely support cleanup during an exception. + self.is_started = True + + + def stop(self, silent=True): + """Stop server instance. Do nothing if the server is not started, + to properly shut down the server in case of an exception during + start up.""" + if not self.is_started: + if not silent: + print "The server is not started." + return + + if not silent: + print "Stopping the server..." + + if self.process == None: + self.kill_old_server() + return + + # kill process + pid = self.read_pidfile(); + if pid != -1: + os.kill(pid, signal.SIGTERM) + #self.process.kill(signal.SIGTERM) + if self.gdb or self.valgrind: + time = 0 + while time < (1<<30) : + if self.process.poll() != None: + break + time += 1 + sleep(1) + else: + self.process.wait() + + self.wait_until_stopped() + # clean-up processs flags + self.is_started = False + self.process = None + + def deploy(self, config=None, binary=None, vardir=None, + mem=None, start_and_exit=None, gdb=None, valgrind=None, + valgrind_sup=None, init_lua=None, silent=True, need_init=True): + if config != None: self.config = config + if binary != None: self.binary = binary + if vardir != None: self.vardir = vardir + if mem != None: self.mem = mem + if start_and_exit != None: self.start_and_exit = start_and_exit + if gdb != None: self.gdb = gdb + if valgrind != None: self.valgrind = valgrind + + if init_lua != None: + self.init_lua = os.path.abspath(init_lua) + else: + self.init_lua = None; + + self.configure(self.config) + self.install(self.binary, self.vardir, self.mem, silent) + if need_init: + self.init() + self.start(self.start_and_exit, self.gdb, self.valgrind, silent) + + def restart(self): + self.stop(silent=True) + self.start(silent=True) + + def test_option_get(self, show, option_list_str): + args = [self.binary] + option_list_str.split() + if show: + print " ".join([os.path.basename(self.binary)] + args[1:]) + output = subprocess.Popen(args, + cwd = self.vardir, + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT).stdout.read() + return output + + def test_option(self, option_list_str): + print self.test_option_get(True, option_list_str) + + def test_debug(self): + output = self.test_option_get(False, "-V") + if re.search("-Debug", output): + return True + return False + + def kill_old_server(self, silent=True): + """Kill old server instance if it exists.""" + pid = self.read_pidfile() + if pid == -1: + return # Nothing to do + + if not silent: + print " Found old server, pid {0}, killing...".format(pid) + + try: + os.kill(pid, signal.SIGTERM) + while os.kill(pid, 0) != -1: + time.sleep(0.001) + except OSError: + pass + + def read_pidfile(self): + if os.access(self.pidfile, os.F_OK) == False: + # file is inaccessible (not exist or permission denied) + return -1 + + pid = -1 + try: + with open(self.pidfile) as f: + pid = int(f.read()) + except: + pass + return pid + + def wait_until_started(self): + """Wait until the server is started and accepting connections""" + + while self.read_pidfile() == -1: + time.sleep(0.001) + + is_connected = False + while not is_connected: + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect(("localhost", self.port)) + is_connected = True + sock.close() + except socket.error as e: + time.sleep(0.001) + + def wait_until_stopped(self): + """Wait until the server is stoped and has closed sockets""" + + while self.read_pidfile() != -1: + time.sleep(0.001) + + is_connected = False + while not is_connected: + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect(("localhost", self.port)) + is_connected = True + sock.close() + time.sleep(0.001) + continue + except socket.error as e: + break + diff --git a/test/lib/test_suite.py b/test/lib/test_suite.py index ff24e2850840417a77b13805773b4d7cfff53511..ad93a42c27d83204b56af6a733f1d7df63aee6f9 100644 --- a/test/lib/test_suite.py +++ b/test/lib/test_suite.py @@ -18,7 +18,6 @@ import string import traceback class FilteredStream: - """Helper class to filter .result file output""" def __init__(self, filename): self.stream = open(filename, "w+") @@ -96,7 +95,6 @@ class Test: def passed(self): """Return true if this test was run successfully.""" - return self.is_executed and self.is_executed_ok and self.is_equal_result def run(self, server): @@ -106,11 +104,28 @@ class Test: If there is a difference, print it to stdout and raise an exception. The exception is raised only if is_force flag is not set.""" - - diagnostics = "unknown" - builddir = self.args.builddir - self.execute(server) + save_stdout = sys.stdout + try: + self.skip = 0 + if os.path.exists(self.skip_cond): + sys.stdout = FilteredStream(self.tmp_result) + stdout_fileno = sys.stdout.stream.fileno() + execfile(self.skip_cond, dict(locals(), **server.__dict__)) + sys.stdout.close() + sys.stdout = save_stdout + if not self.skip: + sys.stdout = FilteredStream(self.tmp_result) + stdout_fileno = sys.stdout.stream.fileno() + self.execute(server) + self.is_executed_ok = True + except Exception as e: + traceback.print_exc(e) + diagnostics = str(e) + finally: + if sys.stdout and sys.stdout != save_stdout: + sys.stdout.close() + sys.stdout = save_stdout; self.is_executed = True if not self.skip: diff --git a/test/lib/unittest_server.py b/test/lib/unittest_server.py index cba7afc1ba9acc9ca88811cb7aecf857b1e7cd31..de9cd169075afd6846524a3ef1202edadb7634d8 100644 --- a/test/lib/unittest_server.py +++ b/test/lib/unittest_server.py @@ -1,88 +1,36 @@ import os import re import sys +import glob import traceback import subprocess - from subprocess import Popen, PIPE - from server import Server from test_suite import FilteredStream, Test - class UnitTest(Test): - def __init__(self, name, args, suite_ini): - Test.__init__(self, name, args, suite_ini) - self.name = name + ".test" - self.result = name + ".result" - self.skip_cond = name + ".skipcond" - self.tmp_result = os.path.join(self.args.vardir, - os.path.basename(self.result)) - self.reject = "{0}/test/{1}".format(self.args.builddir, name + ".reject") - def execute(self, server): - diagnostics = "unknown" - builddir = self.args.builddir - save_stdout = sys.stdout - try: - self.skip = 0 - if os.path.exists(self.skip_cond): - sys.stdout = FilteredStream(self.tmp_result) - stdout_fileno = sys.stdout.stream.fileno() - execfile(self.skip_cond, dict(locals(), **server.__dict__)) - sys.stdout.close() - sys.stdout = save_stdout - if not self.skip: - sys.stdout = FilteredStream(self.tmp_result) - stdout_fileno = sys.stdout.stream.fileno() - execs = [os.path.join(server.builddir, "test", self.name)] - proc = Popen(execs, stdout=PIPE) - sys.stdout.write(proc.communicate()[0]) - self.is_executed_ok = True - except Exception as e: - traceback.print_exc(e) - diagnostics = str(e) - finally: - if sys.stdout and sys.stdout != save_stdout: - sys.stdout.close() - sys.stdout = save_stdout; - self.is_executed = True - - def __repr__(self): - return str([self.name, self.result, self.skip_cond, self.tmp_result, - self.reject]) - - __str__ = __repr__ - + execs = [os.path.join(server.builddir, "test", self.name)] + proc = Popen(execs, stdout=PIPE) + sys.stdout.write(proc.communicate()[0]) class UnittestServer(Server): """A dummy server implementation for unit test suite""" def __new__(cls, core="unittest"): return Server.__new__(cls) - def __init__(self, core="unittest"): Server.__init__(self, core) self.debug = False - def configure(self, config): - pass def deploy(self, config=None, binary=None, vardir=None, mem=None, start_and_exit=None, gdb=None, valgrind=None, valgrind_sup=None, init_lua=None, silent=True, need_init=True): - self.vardir = vardir if not os.access(self.vardir, os.F_OK): - if (self.mem == True and check_tmpfs_exists() and - os.path.basename(self.vardir) == self.vardir): - create_tmpfs_vardir(self.vardir) - else: - os.makedirs(self.vardir) - + os.makedirs(self.vardir) - def start(self): - pass def find_exe(self, builddir, silent=False): self.builddir = builddir @@ -92,15 +40,7 @@ class UnittestServer(Server): if name.find(i) != -1: return True return False - - regexp = re.compile('([a-zA-Z0-9_]*).test') - for f in sorted(os.listdir(suite_path)): - if regexp.match(f): - f = os.path.join(suite_path, regexp.match(f).groups()[0]) + '.test' - if os.access(f, os.X_OK) and os.path.isfile(f) and patterned(f): - test_suite.tests.append(UnitTest(f[:-5], test_suite.args, - test_suite.ini)); - - - def init(self): - pass + for f in sorted(glob.glob(os.path.join(suite_path, '*.test'))): + if os.access(f, os.X_OK) and os.path.isfile(f) and patterned(f): + test_suite.tests.append(UnitTest(f, test_suite.args, + test_suite.ini)); diff --git a/test/memcached/expirations.test b/test/memcached/expirations.test index d9981072afc239eba92e66e81b6bb57168b5b139..ac3df7e71c17418102a9a62f0994cb6d1a2f43aa 100644 --- a/test/memcached/expirations.test +++ b/test/memcached/expirations.test @@ -12,7 +12,7 @@ def wait_for_next_lsn(lsn, serv): def get_lsn(serv): serv_admin = serv.admin - resp = serv_admin("lua box.info.lsn", silent=True) + resp = serv_admin("box.info.lsn", silent=True) return yaml.load(resp)[0] def wait(serv = server): diff --git a/test/memcached/flush-all.test b/test/memcached/flush-all.test index 17d07d38d263e4550ed1367578d2864321df1efc..c0ee28eb8ca2bf069ba53c14f9b427a9e9862ff4 100644 --- a/test/memcached/flush-all.test +++ b/test/memcached/flush-all.test @@ -5,7 +5,7 @@ import yaml ################################### def get_memcached_len(serv): serv_admin = serv.admin - resp = serv_admin("lua box.space[box.cfg.memcached_space]:len()", silent=True) + resp = serv_admin("box.space[box.cfg.memcached_space]:len()", silent=True) return yaml.load(resp)[0] def wait_for_empty_space(serv = server): diff --git a/test/memcached/lua.result b/test/memcached/lua.result index d1e437fddb06a7e04b0ad866b04525e0b3a8d6d1..4e20d9146282d3aaa3d162c95679ebb9781155f4 100644 --- a/test/memcached/lua.result +++ b/test/memcached/lua.result @@ -1,20 +1,20 @@ -lua box.space[box.cfg.memcached_space].arity +box.space[box.cfg.memcached_space].arity --- - 4 ... -lua box.space[box.cfg.memcached_space].estimated_rows +box.space[box.cfg.memcached_space].estimated_rows --- - 0 ... -lua box.space[box.cfg.memcached_space].n +box.space[box.cfg.memcached_space].n --- - 2 ... -lua box.space[box.cfg.memcached_space].index[0].idx +box.space[box.cfg.memcached_space].index[0].idx --- - index 0 in space 2 ... -lua box.space[box.cfg.memcached_space].index[0].type +box.space[box.cfg.memcached_space].index[0].type --- - HASH ... diff --git a/test/memcached/lua.test b/test/memcached/lua.test index feb3dfda828db16f9e03adf5952c300c3f9a86b4..d89ae0c5fbf39ea9d5169e38b7a59ebfdba039ba 100644 --- a/test/memcached/lua.test +++ b/test/memcached/lua.test @@ -1,6 +1,6 @@ # encoding: utf-8 -admin("lua box.space[box.cfg.memcached_space].arity") -admin("lua box.space[box.cfg.memcached_space].estimated_rows") -admin("lua box.space[box.cfg.memcached_space].n") -admin("lua box.space[box.cfg.memcached_space].index[0].idx") -admin("lua box.space[box.cfg.memcached_space].index[0].type") +admin("box.space[box.cfg.memcached_space].arity") +admin("box.space[box.cfg.memcached_space].estimated_rows") +admin("box.space[box.cfg.memcached_space].n") +admin("box.space[box.cfg.memcached_space].index[0].idx") +admin("box.space[box.cfg.memcached_space].index[0].type") diff --git a/test/memcached/suite.ini b/test/memcached/suite.ini index 3c8a675998a5d0f4ceb239807d7756b892380f4d..ef26f4885c102f830f864d06a8281f8d066abdf4 100644 --- a/test/memcached/suite.ini +++ b/test/memcached/suite.ini @@ -1,4 +1,5 @@ [default] +core = python tarantool description = tarantool/box memcached tests config = cfg/master.cfg disabled = cas.test diff --git a/test/replication/memcached.test b/test/replication/memcached.test index aaaabd2505f54749eaabef74dcf5e2e6807e618a..215be41d2a576003da81ad226a6bd30e8e9fe83d 100644 --- a/test/replication/memcached.test +++ b/test/replication/memcached.test @@ -24,7 +24,7 @@ replica_memcached = replica.memcached ################################### def get_lsn(serv): serv_admin = serv.admin - resp = serv_admin("lua box.info.lsn", silent=True) + resp = serv_admin("box.info.lsn", silent=True) return yaml.load(resp)[0] def wait(serv_master = master, serv_replica = replica): @@ -34,7 +34,7 @@ def wait(serv_master = master, serv_replica = replica): def get_memcached_len(serv): serv_admin = serv.admin - resp = serv_admin("lua box.space[box.cfg.memcached_space]:len()", silent=True) + resp = serv_admin("box.space[box.cfg.memcached_space]:len()", silent=True) return yaml.load(resp)[0] def wait_for_empty_space(serv): diff --git a/test/replication/suite.ini b/test/replication/suite.ini index 36347eb4e521d1525142ef41e1c85e062363608a..7adfbc2352f728d25d8cfb351b5281cf39f99dc1 100644 --- a/test/replication/suite.ini +++ b/test/replication/suite.ini @@ -1,4 +1,5 @@ [default] +core = python tarantool description = tarantool/box, replication config = cfg/master.cfg # put disabled in valgrind test here diff --git a/test/wal/lua.result b/test/wal/lua.result index 20ffe6a0d952e719ec82d6ec021a6d028dcc3ebd..cc5c394bf6eb3d15f6b00ad8dda9fa5920301e89 100644 --- a/test/wal/lua.result +++ b/test/wal/lua.result @@ -3,23 +3,23 @@ # https://bugs.launchpad.net/tarantool/+bug/1042738 # Iteration over a non-unique TREE index # -lua for i=1, 1000 do box.space[1]:truncate() for j=1, 30 do box.insert(1, j, os.time(), 1) end; index = box.space[1].index[1]; count = 0; for k,v in index.next, index, nil do count = count+1; end; if count ~= 30 then print("bug at iteration ", i, ", count is ", count) end end +for i=1, 1000 do box.space[1]:truncate() for j=1, 30 do box.insert(1, j, os.time(), 1) end; index = box.space[1].index[1]; count = 0; for k,v in index.next, index, nil do count = count+1; end; if count ~= 30 then print('bug at iteration ', i, ', count is ', count) end end --- ... -lua box.space[1]:truncate() +box.space[1]:truncate() --- ... # A test case for Bug#1043858 server crash on lua stack overflow on CentOS # 5.4 # -lua for i = 1, 100000, 1 do box.space[1]:insert(i,i) end +for i = 1, 100000, 1 do box.space[1]:insert(i,i) end --- ... -lua local t1 = {box.select(1, 1)} +local t1 = {box.select(1, 1)} --- error: 'Lua error: stack overflow' ... -lua box.space[1]:truncate() +box.space[1]:truncate() --- ... diff --git a/test/wal/lua.test b/test/wal/lua.test index a3b3060e518faeeb7f8134397ce50bdaf097c054..90236b6b092d21b50b5d9712e6e1b5932da50ff9 100644 --- a/test/wal/lua.test +++ b/test/wal/lua.test @@ -6,13 +6,13 @@ print """ # Iteration over a non-unique TREE index #""" -admin('lua for i=1, 1000 do box.space[1]:truncate() for j=1, 30 do box.insert(1, j, os.time(), 1) end; index = box.space[1].index[1]; count = 0; for k,v in index.next, index, nil do count = count+1; end; if count ~= 30 then print("bug at iteration ", i, ", count is ", count) end end') -admin("lua box.space[1]:truncate()") +admin("for i=1, 1000 do box.space[1]:truncate() for j=1, 30 do box.insert(1, j, os.time(), 1) end; index = box.space[1].index[1]; count = 0; for k,v in index.next, index, nil do count = count+1; end; if count ~= 30 then print('bug at iteration ', i, ', count is ', count) end end") +admin("box.space[1]:truncate()") print """ # A test case for Bug#1043858 server crash on lua stack overflow on CentOS # 5.4 #""" -admin("lua for i = 1, 100000, 1 do box.space[1]:insert(i,i) end") -admin("lua local t1 = {box.select(1, 1)}") -admin("lua box.space[1]:truncate()") +admin("for i = 1, 100000, 1 do box.space[1]:insert(i,i) end") +admin("local t1 = {box.select(1, 1)}") +admin("box.space[1]:truncate()") diff --git a/test/wal/oom.result b/test/wal/oom.result index dc37ffacf1479709e6a45267d33fca1b2bb0dc7e..220288935c1b5464b93b51fe9f4e4d9d0f118279 100644 --- a/test/wal/oom.result +++ b/test/wal/oom.result @@ -1,48 +1,48 @@ -lua i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end +i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end --- error: 'Failed to allocate 19436 bytes in slab allocator for tuple' ... -lua box.space[0]:len() +box.space[0]:len() --- - 4853 ... -lua i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end +i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end --- error: 'Failed to allocate 4095 bytes in slab allocator for tuple' ... -lua box.space[0]:len() +box.space[0]:len() --- - 5871 ... -lua i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end +i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end --- error: 'Failed to allocate 2051 bytes in slab allocator for tuple' ... -lua box.space[0]:len() +box.space[0]:len() --- - 6378 ... -lua box.space[0]:select(0, 0) +box.space[0]:select(0, 0) --- - 0: {1953719668} ... -lua box.space[0]:select(0, 5) +box.space[0]:select(0, 5) --- - 5: {'testtesttesttesttesttest'} ... -lua box.space[0]:select(0, 9) +box.space[0]:select(0, 9) --- - 9: {'testtesttesttesttesttesttesttesttesttest'} ... -lua box.space[0]:select(0, 11) +box.space[0]:select(0, 11) --- - 11: {'testtesttesttesttesttesttesttesttesttesttesttest'} ... -lua box.space[0]:select(0, 15) +box.space[0]:select(0, 15) --- - 15: {'testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest'} ... -lua i = 0 for k,v in box.space[0]:pairs() do print(v) i = i + 1 if i == 50 then break end end +i = 0 for k,v in box.space[0]:pairs() do print(v) i = i + 1 if i == 50 then break end end --- 0: {1953719668} 1: {8391162081565697396} @@ -95,13 +95,13 @@ lua i = 0 for k,v in box.space[0]:pairs() do print(v) i = i + 1 if i == 50 then 48: {'testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest'} 49: {'testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest'} ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... -lua box.space[0]:insert(0, 'test') +box.space[0]:insert(0, 'test') --- - 0: {1953719668} ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... diff --git a/test/wal/oom.test b/test/wal/oom.test index 38c79b027dfb0df4c80175584efd4008b08aabc5..2c961cddccf385951caeb39d4b2f721624a3151c 100644 --- a/test/wal/oom.test +++ b/test/wal/oom.test @@ -1,17 +1,17 @@ # encoding: utf-8 -admin("lua i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end") -admin("lua box.space[0]:len()") -admin("lua i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end") -admin("lua box.space[0]:len()") -admin("lua i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end") -admin("lua box.space[0]:len()") -admin("lua box.space[0]:select(0, 0)") -admin("lua box.space[0]:select(0, 5)") -admin("lua box.space[0]:select(0, 9)") -admin("lua box.space[0]:select(0, 11)") -admin("lua box.space[0]:select(0, 15)") +admin("i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end") +admin("box.space[0]:len()") +admin("i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end") +admin("box.space[0]:len()") +admin("i = 1 while true do box.insert(0, box.space[0]:len(), string.rep('test', i)) i = i + 1 end") +admin("box.space[0]:len()") +admin("box.space[0]:select(0, 0)") +admin("box.space[0]:select(0, 5)") +admin("box.space[0]:select(0, 9)") +admin("box.space[0]:select(0, 11)") +admin("box.space[0]:select(0, 15)") # check that iterators work -admin("lua i = 0 for k,v in box.space[0]:pairs() do print(v) i = i + 1 if i == 50 then break end end") -admin("lua box.space[0]:truncate()") -admin("lua box.space[0]:insert(0, 'test')") -admin("lua box.space[0]:truncate()") +admin("i = 0 for k,v in box.space[0]:pairs() do print(v) i = i + 1 if i == 50 then break end end") +admin("box.space[0]:truncate()") +admin("box.space[0]:insert(0, 'test')") +admin("box.space[0]:truncate()") diff --git a/test/wal/suite.ini b/test/wal/suite.ini index 4e6e1ac3b279ef8d018b780017de1bb4ec13fc21..ceb5086273c431c4fd5297ac968646339f66cb60 100644 --- a/test/wal/suite.ini +++ b/test/wal/suite.ini @@ -1,4 +1,5 @@ [default] +core = python tarantool description = tarantool/box, wal_mode = none config = tarantool.cfg # put disabled tests here diff --git a/test/wal/wal_mode.result b/test/wal/wal_mode.result index 645227c03fed9bf022227f75bd553e3b88d82a55..893a14387d04f6667b7aafd5b481c7f0f0749052 100644 --- a/test/wal/wal_mode.result +++ b/test/wal/wal_mode.result @@ -1,4 +1,4 @@ -lua box.cfg.wal_mode +box.cfg.wal_mode --- - none ... @@ -27,7 +27,7 @@ save snapshot --- fail: can't save snapshot, errno 17 (File exists) ... -lua box.space[0]:truncate() +box.space[0]:truncate() --- ... save snapshot diff --git a/test/wal/wal_mode.test b/test/wal/wal_mode.test index 0d17cca4d01ef77177262fa15646600e7a9d8d2a..eb22f71b6a7a7fb17c00d3b53fd52289f75197a3 100644 --- a/test/wal/wal_mode.test +++ b/test/wal/wal_mode.test @@ -1,5 +1,5 @@ # encoding: utf-8 -admin("lua box.cfg.wal_mode") +admin("box.cfg.wal_mode") sql("insert into t0 values (1)") sql("insert into t0 values (2)") sql("insert into t0 values (3)") @@ -9,5 +9,5 @@ sql("select * from t0 where k0 = 3") sql("select * from t0 where k0 = 4") admin("save snapshot") admin("save snapshot") -admin("lua box.space[0]:truncate()") +admin("box.space[0]:truncate()") admin("save snapshot")