diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71c82e68f54c8024669db10032d5fb11a2091c80..8c52093b1d6abc07b46af905238933829228ac3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,6 +75,7 @@ set (common_sources tt_uuid.c ffisyms.cc uri.cc + lua/digest.cc lua/init.cc lua/fiber.cc lua/trigger.cc diff --git a/src/box/lua/info.cc b/src/box/lua/info.cc index 455a5d784da3841e99169ecd4865cc50ab87b65c..ec13926417ad5f5ae6fd001d809b03f2394dbe47 100644 --- a/src/box/lua/info.cc +++ b/src/box/lua/info.cc @@ -57,7 +57,7 @@ lbox_info_recovery_last_update_tstamp(struct lua_State *L) } static int -lbox_info_node(struct lua_State *L) +lbox_info_server(struct lua_State *L) { if (recovery->server_id == 0) { lua_pushnil(L); @@ -127,7 +127,7 @@ lbox_info_dynamic_meta [] = {"recovery_lag", lbox_info_recovery_lag}, {"recovery_last_update", lbox_info_recovery_last_update_tstamp}, {"vclock", lbox_info_vclock}, - {"node", lbox_info_node}, + {"server", lbox_info_server}, {"status", lbox_info_status}, {"uptime", lbox_info_uptime}, {"snapshot_pid", lbox_info_snapshot_pid}, diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 359fc40c44ffd4cf3f5b9f8d26ec222676361727..7e6798a1c9bad38380145a3c553fd68a7659fc39 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -284,6 +284,7 @@ local function normalize_update_ops(ops) end return ops end +internal.normalize_update_ops = normalize_update_ops -- export for net.box local iterator_t = ffi.typeof('struct iterator') ffi.metatype(iterator_t, { diff --git a/src/ffisyms.cc b/src/ffisyms.cc index 2112a20b00182338f748b664a71d89eb52425f96..c37248260ba6bc719dcfbef1c7d14a35fdb4ad09 100644 --- a/src/ffisyms.cc +++ b/src/ffisyms.cc @@ -8,6 +8,7 @@ #include <lua/init.h> #include <tarantool.h> #include "lua/bsdsocket.h" +#include "lua/digest.h" #include "base64.h" /* @@ -43,5 +44,6 @@ void *ffi_symbols[] = { (void *) box_set_too_long_threshold, (void *) bsdsocket_local_resolve, (void *) bsdsocket_nonblock, - (void *) base64_decode + (void *) base64_decode, + (void *) SHA1internal }; diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua index bd9e1463147bab2edc770468a6055e65f3d19ad0..b176a93eab7e3c0621dbeb714ef3d9e217acb7ee 100644 --- a/src/lua/box_net_box.lua +++ b/src/lua/box_net_box.lua @@ -158,6 +158,7 @@ local proto = { -- update update = function(sync, spaceno, key, oplist) + oplist = require('box.internal').normalize_update_ops(oplist) return request( { [SYNC] = sync, [TYPE] = UPDATE }, { [KEY] = keyfy(key), [TUPLE] = oplist, [SPACE_ID] = spaceno } diff --git a/src/lua/bsdsocket.lua b/src/lua/bsdsocket.lua index 54c27e7f289f4c8bd982c23e6bb57bf35d097584..45b3a246eeedf4b3e79ea4cd942bdd3458bebd5d 100644 --- a/src/lua/bsdsocket.lua +++ b/src/lua/bsdsocket.lua @@ -131,7 +131,7 @@ socket_methods.syswrite = function(self, octets) self._errno = boxerrno() return nil end - return done + return tonumber(done) end socket_methods.sysread = function(self, len) @@ -417,7 +417,7 @@ socket_methods.getsockopt = function(self, level, name) if len[0] ~= 4 then error(sprintf("Internal error: unexpected optlen: %d", len[0])) end - return value[0] + return tonumber(value[0]) end if info.type == 2 then @@ -428,7 +428,7 @@ socket_methods.getsockopt = function(self, level, name) self._errno = boxerrno() return nil end - return ffi.string(value, len[0]) + return ffi.string(value, tonumber(len[0])) end if name == 'SO_LINGER' then @@ -493,6 +493,8 @@ socket_methods.accept = function(self) return nil end + fh = tonumber(fh) + -- Make socket to be non-blocked by default -- ignore result ffi.C.bsdsocket_nonblock(fh, 1) @@ -782,6 +784,8 @@ local function create_socket(domain, stype, proto) return nil end + fh = tonumber(fh) + -- Make socket to be non-blocked by default if ffi.C.bsdsocket_nonblock(fh, 1) < 0 then local errno = boxerrno() diff --git a/src/lua/digest.cc b/src/lua/digest.cc new file mode 100644 index 0000000000000000000000000000000000000000..1d3721af86cb66cfcd3099efaafec87ed03073ab --- /dev/null +++ b/src/lua/digest.cc @@ -0,0 +1,48 @@ +/* + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <string.h> +#include <lua/digest.h> +extern "C" { +#include <third_party/sha1.h> +} + +unsigned char * +SHA1internal(const unsigned char *d, size_t n, unsigned char *md) +{ + static __thread unsigned char result[20]; + SHA1_CTX ctx; + SHA1Init(&ctx); + SHA1Update(&ctx, d, n); + SHA1Final(result, &ctx); + + if (md) + memcpy(md, result, 20); + return result; +} diff --git a/src/lua/digest.h b/src/lua/digest.h new file mode 100644 index 0000000000000000000000000000000000000000..2ff67d8b5baa0b2c07a3951e43efe65ac875b686 --- /dev/null +++ b/src/lua/digest.h @@ -0,0 +1,46 @@ +#ifndef INCLUDES_TARANTOOL_LUA_DIGEST_H +#define INCLUDES_TARANTOOL_LUA_DIGEST_H +/* + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/types.h> + +#if defined(__cplusplus) +extern "C" { +#endif + +unsigned char * +SHA1internal(const unsigned char *d, size_t n, unsigned char *md); + + +#if defined(__cplusplus) +} +#endif + +#endif /* INCLUDES_TARANTOOL_LUA_DIGEST_H */ diff --git a/src/lua/digest.lua b/src/lua/digest.lua index 7ff658fb28c44e14b7d4661f683a687b8a9d1e77..41b28f30b69c3ea537d2596b396e8f351e90e647 100644 --- a/src/lua/digest.lua +++ b/src/lua/digest.lua @@ -13,6 +13,7 @@ ffi.cdef[[ unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md); unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); + unsigned char *SHA1internal(const unsigned char *d, size_t n, unsigned char *md); /* from openssl/md5.h */ unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); @@ -28,13 +29,25 @@ ffi.cdef[[ local ssl if ssl == nil then - pcall(function() ssl = ffi.load('ssl') end) + local variants = { + 'libssl.so.1.0.0', + 'libssl.so.0.9.8', + 'libssl.so', + 'ssl', + } + + for _, libname in pairs(variants) do + pcall(function() ssl = ffi.load(libname) end) + if ssl ~= nil then + break + end + end end local def = { sha = { 'SHA', 20 }, - sha1 = { 'SHA1', 20 }, +-- sha1 = { 'SHA1', 20 }, sha224 = { 'SHA224', 28 }, sha256 = { 'SHA256', 32 }, sha384 = { 'SHA384', 48 }, @@ -43,6 +56,16 @@ local def = { md4 = { 'MD4', 16 } } +local hexres = ffi.new('char[129]') + +local function tohex(r, size) + for i = 0, size - 1 do + ffi.C.snprintf(hexres + i * 2, 3, "%02x", + ffi.cast('unsigned int', r[i])) + end + return ffi.string(hexres, size * 2) +end + local m = { crc32 = function(str) if str == nil then @@ -60,11 +83,30 @@ local m = { str = tostring(str) end return ffi.C.crc32_calc(tonumber(crc), str, string.len(str)) + end, + + sha1 = function(str) + if str == nil then + str = '' + else + str = tostring(str) + end + local r = ffi.C.SHA1internal(str, #str, nil) + return ffi.string(r, 20) + end, + + sha1_hex = function(str) + if str == nil then + str = '' + else + str = tostring(str) + end + local r = ffi.C.SHA1internal(str, #str, nil) + return tohex(r, 20) end } if ssl ~= nil then - local hexres = ffi.new('char[129]') for pname, df in pairs(def) do local hfunction = df[1] @@ -87,12 +129,7 @@ if ssl ~= nil then str = tostring(str) end local r = ssl[hfunction](str, string.len(str), nil) - - for i = 0, hsize - 1 do - ffi.C.snprintf(hexres + i * 2, 3, "%02x", - ffi.cast('unsigned int', r[i])) - end - return ffi.string(hexres, hsize * 2) + return tohex(r, hsize) end end else diff --git a/src/lua/msgpackffi.lua b/src/lua/msgpackffi.lua index 4429bbcb4fbd9eb6111f6595c1baabffbc885b65..3293d269880032abdc0da2b01443e8c07ff8c8d9 100644 --- a/src/lua/msgpackffi.lua +++ b/src/lua/msgpackffi.lua @@ -109,7 +109,7 @@ end local function encode_u64(buf, code, num) buf:reserve(9) buf.p[0] = code - ffi.cast(uint64_ptr_t, buf.p + 1)[0] = bswap_u64(num) + ffi.cast(uint64_ptr_t, buf.p + 1)[0] = bswap_u64(ffi.cast('uint64_t', num)) buf.p = buf.p + 9 end @@ -137,10 +137,8 @@ local function encode_int(buf, num) encode_u16(buf, 0xcd, num) elseif num <= 0xffffffff then encode_u32(buf, 0xce, num) - elseif num <= 18446744073709551615ULL then - encode_u64(buf, 0xcf, num) else - encode_double(buf, num) + encode_u64(buf, 0xcf, 0ULL + num) end else if num >= -0x20 then @@ -151,10 +149,8 @@ local function encode_int(buf, num) encode_u16(buf, 0xd1, num) elseif num >= -0x7fffffff then encode_u32(buf, 0xd2, num) - elseif num >= -9223372036854775807LL then - encode_u64(buf, 0xd3, num) else - encode_double(buf, num) + encode_u64(buf, 0xd3, 0LL + num) end end end @@ -211,7 +207,8 @@ end local function encode_r(buf, obj, level) if type(obj) == "number" then - if obj % 1 == 0 then -- Lua-way to check that number is an integer + -- Lua-way to check that number is an integer + if obj % 1 == 0 and obj > -1e63 and obj < 1e64 then encode_int(buf, obj) else encode_double(buf, obj) diff --git a/test/big/iterator.result b/test/big/iterator.result index e9c2812e2d78892a2a047e279ac8c9e1dcf1d259..b8f720cbd9bb8fff2fb062a0e0e06e3d0199a64d 100644 --- a/test/big/iterator.result +++ b/test/big/iterator.result @@ -891,7 +891,7 @@ space.index['primary']:pairs({}, {iterator = -666 }) -- Test cases for #123: box.index.count does not check arguments properly space.index['primary']:pairs(function() end, { iterator = box.index.EQ }) --- -- error: 'builtin/msgpackffi.lua:261: can not encode Lua type: ''function''' +- error: 'builtin/msgpackffi.lua:258: can not encode Lua type: ''function''' ... space:drop() --- diff --git a/test/big/lua.result b/test/big/lua.result index 9476a6d404ef1dfbe36db1bd2a5fbd6fee436353..f3c93cd1a55f619d6db16ae560bd582178058a8a 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -574,7 +574,7 @@ space.index['i1']:count() -- Test cases for #123: box.index.count does not check arguments properly space.index['i1']:count(function() end) --- -- error: 'builtin/msgpackffi.lua:261: can not encode Lua type: ''function''' +- error: 'builtin/msgpackffi.lua:258: can not encode Lua type: ''function''' ... space:drop() --- diff --git a/test/box/admin.result b/test/box/admin.result index 02e4c5578323e6031d586f74dca68496334072fd..717155b1c129d3a2ec15f484fbba8c965ab0da88 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -62,10 +62,10 @@ function test_box_info() local buildstr = {'flags', 'target', 'compiler', 'options'} local str = {'version', 'status' } local failed = {} - if check_type(tmp.node, 'table') == false then - table.insert(failed1, 'box.info().node') + if check_type(tmp.server, 'table') == false then + table.insert(failed1, 'box.info().server') else - tmp.node = nil + tmp.server = nil end for k, v in ipairs(num) do if check_type(tmp[v], 'number') == false then diff --git a/test/box/admin.test.lua b/test/box/admin.test.lua index 26964d4187f4a2f445c33bfdfbfbe466215fc2b0..0564a4bdbd85c35a12821f2187f0840278c2da52 100644 --- a/test/box/admin.test.lua +++ b/test/box/admin.test.lua @@ -23,10 +23,10 @@ function test_box_info() local buildstr = {'flags', 'target', 'compiler', 'options'} local str = {'version', 'status' } local failed = {} - if check_type(tmp.node, 'table') == false then - table.insert(failed1, 'box.info().node') + if check_type(tmp.server, 'table') == false then + table.insert(failed1, 'box.info().server') else - tmp.node = nil + tmp.server = nil end for k, v in ipairs(num) do if check_type(tmp[v], 'number') == false then diff --git a/test/box/box.net.box.result b/test/box/box.net.box.result index 9b6c3126cd93586a66972d49a01f363ba48072e2..16a4131fdc8bf6ce764589e4b029168da7e88dfc 100644 --- a/test/box/box.net.box.result +++ b/test/box/box.net.box.result @@ -138,7 +138,7 @@ cn.space.net_box_test_space:insert{234, 1,2,3} ... cn.space.net_box_test_space.insert{234, 1,2,3} --- -- error: 'builtin/net.box.lua:236: Use space:method(...) instead space.method(...)' +- error: 'builtin/net.box.lua:237: Use space:method(...) instead space.method(...)' ... cn.space.net_box_test_space:replace{354, 1,2,3} --- @@ -181,11 +181,11 @@ cn.space.net_box_test_space:select{123} --- - - [123, 345] ... -cn.space.net_box_test_space:update({123}, { { '+', 1, 1 } }) +cn.space.net_box_test_space:update({123}, { { '+', 2, 1 } }) --- - [123, 346] ... -cn.space.net_box_test_space:update(123, { { '+', 1, 1 } }) +cn.space.net_box_test_space:update(123, { { '+', 2, 1 } }) --- - [123, 347] ... @@ -193,7 +193,7 @@ cn.space.net_box_test_space:select{123} --- - - [123, 347] ... -cn.space.net_box_test_space:update({123}, { { '=', 0, 2 } }) +cn.space.net_box_test_space:update({123}, { { '=', 1, 2 } }) --- - [2, 347] ... @@ -205,7 +205,7 @@ cn.space.net_box_test_space:select({234}, { iterator = 'LT' }) --- - - [2, 347] ... -cn.space.net_box_test_space:update({1}, { { '+', 1, 2 } }) +cn.space.net_box_test_space:update({1}, { { '+', 2, 2 } }) --- ... cn.space.net_box_test_space:delete{1} @@ -218,6 +218,35 @@ cn.space.net_box_test_space:delete{2} cn.space.net_box_test_space:delete{2} --- ... +-- test one-based indexing in splice operation (see update.test.lua) +cn.space.net_box_test_space:replace({10, 'abcde'}) +--- +- [10, 'abcde'] +... +cn.space.net_box_test_space:update(10, {{':', 2, 0, 0, '!'}}) +--- +- error: 'SPLICE error on field 2: offset is out of bound' +... +cn.space.net_box_test_space:update(10, {{':', 2, 1, 0, '('}}) +--- +- [10, '(abcde'] +... +cn.space.net_box_test_space:update(10, {{':', 2, 2, 0, '({'}}) +--- +- [10, '(({abcde'] +... +cn.space.net_box_test_space:update(10, {{':', 2, -1, 0, ')'}}) +--- +- [10, '(({abcde)'] +... +cn.space.net_box_test_space:update(10, {{':', 2, -2, 0, '})'}}) +--- +- [10, '(({abcde}))'] +... +cn.space.net_box_test_space:delete{10} +--- +- [10, '(({abcde}))'] +... cn.space.net_box_test_space:select({}, { iterator = 'ALL' }) --- - - [234, 1, 2, 3] diff --git a/test/box/box.net.box.test.lua b/test/box/box.net.box.test.lua index 7c8aaf6518d8befbad48511c4009d6baaa7e0e2d..2df3b8f6aae33da5b6f488636ec6b1c69d2aa73c 100644 --- a/test/box/box.net.box.test.lua +++ b/test/box/box.net.box.test.lua @@ -62,20 +62,29 @@ cn.space.net_box_test_space:select({123}, { iterator = 'GT', limit = 1 }) cn.space.net_box_test_space:select({123}, { iterator = 'GT', limit = 1, offset = 1 }) cn.space.net_box_test_space:select{123} -cn.space.net_box_test_space:update({123}, { { '+', 1, 1 } }) -cn.space.net_box_test_space:update(123, { { '+', 1, 1 } }) +cn.space.net_box_test_space:update({123}, { { '+', 2, 1 } }) +cn.space.net_box_test_space:update(123, { { '+', 2, 1 } }) cn.space.net_box_test_space:select{123} -cn.space.net_box_test_space:update({123}, { { '=', 0, 2 } }) +cn.space.net_box_test_space:update({123}, { { '=', 1, 2 } }) cn.space.net_box_test_space:select{2} cn.space.net_box_test_space:select({234}, { iterator = 'LT' }) -cn.space.net_box_test_space:update({1}, { { '+', 1, 2 } }) +cn.space.net_box_test_space:update({1}, { { '+', 2, 2 } }) cn.space.net_box_test_space:delete{1} cn.space.net_box_test_space:delete{2} cn.space.net_box_test_space:delete{2} +-- test one-based indexing in splice operation (see update.test.lua) +cn.space.net_box_test_space:replace({10, 'abcde'}) +cn.space.net_box_test_space:update(10, {{':', 2, 0, 0, '!'}}) +cn.space.net_box_test_space:update(10, {{':', 2, 1, 0, '('}}) +cn.space.net_box_test_space:update(10, {{':', 2, 2, 0, '({'}}) +cn.space.net_box_test_space:update(10, {{':', 2, -1, 0, ')'}}) +cn.space.net_box_test_space:update(10, {{':', 2, -2, 0, '})'}}) +cn.space.net_box_test_space:delete{10} + cn.space.net_box_test_space:select({}, { iterator = 'ALL' }) cn.space.net_box_test_space.index.primary:min() diff --git a/test/box/info.result b/test/box/info.result index a015c6c0f638c5af5ddbc55d840af997b622b31f..1d16a79083f05db0f50d3dfee0b0caf5509d3029 100644 --- a/test/box/info.result +++ b/test/box/info.result @@ -24,7 +24,7 @@ string.match(box.info.logger_pid, '^[0-9]+$') ~= nil --- - true ... -#box.info.node > 0 +#box.info.server > 0 --- - false ... @@ -77,10 +77,10 @@ t --- - - build - logger_pid - - node - pid - recovery_lag - recovery_last_update + - server - snapshot_pid - status - uptime diff --git a/test/box/info.test.lua b/test/box/info.test.lua index d1025edce8a9ddbf9b24901569b3be47e711fdc3..ca75f0d8491d9224507294bee8406d1466a114b1 100644 --- a/test/box/info.test.lua +++ b/test/box/info.test.lua @@ -6,7 +6,7 @@ box.info['unknown_variable'] string.match(box.info.version, '^[1-9]') ~= nil string.match(box.info.pid, '^[1-9][0-9]*$') ~= nil string.match(box.info.logger_pid, '^[0-9]+$') ~= nil -#box.info.node > 0 +#box.info.server > 0 box.info.recovery_lag box.info.recovery_last_update box.info.status diff --git a/test/box/msgpack.result b/test/box/msgpack.result index 34b33ed46be390868f04166da80d7ce4047a9062..7d3d684d31046da475517c9c7fa77c30ba5e4597 100644 --- a/test/box/msgpack.result +++ b/test/box/msgpack.result @@ -224,6 +224,39 @@ test(-2147483647LL) --- - -2147483647LL ok ... +-- 1e53 - maximum integer that can be stored to double without losing precision +test(9007199254740991) +--- +- 9.007199254741e+15 ok +... +test(9007199254740991ULL) +--- +- 9007199254740991ULL ok +... +test(9007199254740991LL) +--- +- 9007199254740991LL ok +... +test(9007199254740992) +--- +- 9.007199254741e+15 ok +... +test(9007199254740992ULL) +--- +- 9007199254740992ULL ok +... +test(9007199254740992LL) +--- +- 9007199254740992LL ok +... +test(-9007199254740991) +--- +- -9.007199254741e+15 ok +... +test(-9007199254740991LL) +--- +- -9007199254740991LL ok +... test(-9007199254740992) --- - -9.007199254741e+15 ok @@ -639,5 +672,5 @@ offset ... a, offset = msgpackffi.decode_unchecked(dump, offset) --- -- error: 'builtin/msgpackffi.lua:460: offset = 9 is out of bounds [1..8]' +- error: 'builtin/msgpackffi.lua:457: offset = 9 is out of bounds [1..8]' ... diff --git a/test/box/msgpack.test.lua b/test/box/msgpack.test.lua index 7d97dcdc9821a2134b352cfd90edb2917440efd9..04bea83c7d924dc43c35aecd7df45768a1469ca2 100644 --- a/test/box/msgpack.test.lua +++ b/test/box/msgpack.test.lua @@ -129,6 +129,18 @@ test(-1LL) test(-2147483647) test(-2147483647LL) +-- 1e53 - maximum integer that can be stored to double without losing precision + +test(9007199254740991) +test(9007199254740991ULL) +test(9007199254740991LL) + +test(9007199254740992) +test(9007199254740992ULL) +test(9007199254740992LL) + +test(-9007199254740991) +test(-9007199254740991LL) test(-9007199254740992) test(-9007199254740992LL) diff --git a/test/box/snapshot.test.py b/test/box/snapshot.test.py index 1257cf72f8b69e126580ee1a3bce4bd1c8009798..f7f66c6c930ed819532cfbe2465edf8793627d4b 100644 --- a/test/box/snapshot.test.py +++ b/test/box/snapshot.test.py @@ -49,7 +49,7 @@ print """ admin("space:insert{1, 'Test tuple'}") pid = int(yaml.load(admin("box.info.pid", silent=True))[0]) -lsn = int(yaml.load(admin("box.info.node.lsn", silent=True))[0]) +lsn = int(yaml.load(admin("box.info.server.lsn", silent=True))[0]) snapshot = str(lsn).zfill(20) + ".snap" snapshot = os.path.join(server.vardir, snapshot) diff --git a/test/box/xlog.test.py b/test/box/xlog.test.py index 0d73c074f8f70b8d921e3677460bf615691896be..3b93d72c37710cdd2295ed6181b5589b8700b699 100644 --- a/test/box/xlog.test.py +++ b/test/box/xlog.test.py @@ -8,7 +8,7 @@ from os.path import abspath # cleanup server.vardir server.stop() server.deploy() -lsn = int(yaml.load(server.admin("box.info.node.lsn", silent=True))[0]) +lsn = int(yaml.load(server.admin("box.info.server.lsn", silent=True))[0]) server.stop() print """ @@ -138,7 +138,7 @@ lsn += 1 server.stop() server.deploy() -lsn = int(yaml.load(server.admin("box.info.node.lsn", silent=True))[0]) +lsn = int(yaml.load(server.admin("box.info.server.lsn", silent=True))[0]) filename = str(lsn).zfill(20) + ".xlog" wal_old = os.path.join(server.vardir, "old_" + filename) wal = os.path.join(server.vardir, filename) @@ -210,7 +210,7 @@ server.admin("space = box.schema.create_space('test')") server.admin("box.space.test:create_index('primary')") server.admin("box.space.test:insert{1, 'first tuple'}") server.admin("box.space.test:insert{2, 'second tuple'}") -lsn = int(yaml.load(server.admin("box.info.node.lsn", silent=True))[0]) +lsn = int(yaml.load(server.admin("box.info.server.lsn", silent=True))[0]) wal = os.path.join(server.vardir, str(lsn).zfill(20) + ".xlog") server.stop() server.start() diff --git a/test/replication/hot_standby.result b/test/replication/hot_standby.result index 85e0d55086e4b2422a2a1d95ab27602087f46aee..db5c16770d21238ef6e39f1f89d44fe984f41b32 100644 --- a/test/replication/hot_standby.result +++ b/test/replication/hot_standby.result @@ -12,7 +12,7 @@ box.schema.user.grant('guest', 'read,write,execute', 'universe') fiber = require('fiber'); --- ... -while box.info.node == nil do fiber.sleep(0.01) end; +while box.info.server == nil do fiber.sleep(0.01) end; --- ... while box.space['_priv']:len() < 1 do fiber.sleep(0.001) end; @@ -67,7 +67,7 @@ end; a = (require 'net.box'):new('127.0.0.1', replica_port) --- ... -a:call('_set_pri_lsn', box.info.node.id, box.info.node.lsn) +a:call('_set_pri_lsn', box.info.server.id, box.info.server.lsn) --- - [] ... @@ -135,7 +135,7 @@ while box.info.status ~= 'running' do fiber.sleep(0.001) end a = (require 'net.box'):new('127.0.0.1', hot_standby_port) --- ... -a:call('_set_pri_lsn', box.info.node.id, box.info.node.lsn) +a:call('_set_pri_lsn', box.info.server.id, box.info.server.lsn) --- - [] ... diff --git a/test/replication/hot_standby.test.lua b/test/replication/hot_standby.test.lua index 05ce41a9f6e3dd0f333a19ab9b34671f68a05ae9..8acb7ebdff1e7903ebdb3074051b59b3fa5d48f2 100644 --- a/test/replication/hot_standby.test.lua +++ b/test/replication/hot_standby.test.lua @@ -9,7 +9,7 @@ box.schema.user.grant('guest', 'read,write,execute', 'universe') --# setopt delimiter ';' --# set connection default, hot_standby, replica fiber = require('fiber'); -while box.info.node == nil do fiber.sleep(0.01) end; +while box.info.server == nil do fiber.sleep(0.01) end; while box.space['_priv']:len() < 1 do fiber.sleep(0.001) end; do local pri_id = '' @@ -57,7 +57,7 @@ end; -- set begin lsn on master, replica and hot_standby. --# set variable replica_port to 'replica.listen' a = (require 'net.box'):new('127.0.0.1', replica_port) -a:call('_set_pri_lsn', box.info.node.id, box.info.node.lsn) +a:call('_set_pri_lsn', box.info.server.id, box.info.server.lsn) a:close() space = box.schema.create_space('tweedledum') @@ -79,7 +79,7 @@ while box.info.status ~= 'running' do fiber.sleep(0.001) end -- uses MASTER environment variable for its listen --# set variable hot_standby_port to 'hot_standby.master' a = (require 'net.box'):new('127.0.0.1', hot_standby_port) -a:call('_set_pri_lsn', box.info.node.id, box.info.node.lsn) +a:call('_set_pri_lsn', box.info.server.id, box.info.server.lsn) a:close() --# set connection hot_standby diff --git a/test/replication/init_storage.test.py b/test/replication/init_storage.test.py index 27b8b9699f3dae09ef026be25b3baa64d71043c5..d623b5eb6fde1f1c02bbeba0f7af9eb390cac14c 100644 --- a/test/replication/init_storage.test.py +++ b/test/replication/init_storage.test.py @@ -32,7 +32,7 @@ replica.cleanup(True) master.admin('box.snapshot()') master.restart() master.admin('for k = 10, 19 do box.space[42]:insert{k, k*k*k} end') -master_id = master.get_param('node')['id'] +master_id = master.get_param('server')['id'] lsn = master.get_lsn(master_id) print '-------------------------------------------------------------' print 'replica test 2 (must be ok)' diff --git a/test/replication/swap.result b/test/replication/swap.result index 4e493238af23f3c8f1a7af05edeba1edaeba343c..5badc7052d0fff463c4f1fca6ffc8953d3e48e84 100644 --- a/test/replication/swap.result +++ b/test/replication/swap.result @@ -4,7 +4,7 @@ box.schema.user.create('test', { password = 'pass123456'}) box.schema.user.grant('test', 'read,write,execute', 'universe') --- ... -while box.info.node == nil do require('fiber').sleep(0.01) end +while box.info.server == nil do require('fiber').sleep(0.01) end --- ... while box.space['_priv']:len() < 1 do require('fiber').sleep(0.01) end diff --git a/test/replication/swap.test.py b/test/replication/swap.test.py index 2bf1ea58c9421f55f50734ca41f7898fddb27351..49088df3f94ba61fb7a623c70903340463802149 100644 --- a/test/replication/swap.test.py +++ b/test/replication/swap.test.py @@ -32,7 +32,7 @@ replica = TarantoolServer() replica.script = "replication/replica.lua" replica.vardir = os.path.join(server.vardir, 'replica') replica.deploy() -replica.admin("while box.info.node == nil do require('fiber').sleep(0.01) end") +replica.admin("while box.info.server == nil do require('fiber').sleep(0.01) end") replica.uri = '%s:%s@%s:%s' % (LOGIN, PASSWORD, HOST, replica.sql.port) replica.admin("while box.space['_priv']:len() < 1 do require('fiber').sleep(0.01) end") replica.sql.py_con.authenticate(LOGIN, PASSWORD) @@ -47,8 +47,8 @@ master.admin("s:create_index('primary', {type = 'hash'})") #if not m or m.group(1) != host_port: # print 'invalid box.info.status', status, 'expected host:port', host_port -master_id = master.get_param('node')['id'] -replica_id = replica.get_param('node')['id'] +master_id = master.get_param('server')['id'] +replica_id = replica.get_param('server')['id'] id = ID_BEGIN for i in range(REPEAT): diff --git a/test/unit/matras.cc b/test/unit/matras.cc index 2c56c56fdc2681b13ba872226a6124397de04a5a..4970cb7a1de98f39dbbb62efeebca09b08157048 100644 --- a/test/unit/matras.cc +++ b/test/unit/matras.cc @@ -66,7 +66,6 @@ void matras_alloc_test() unsigned int maxCapacity = PROV_EXTENT_SIZE / PROV_BLOCK_SIZE; maxCapacity *= PROV_EXTENT_SIZE / sizeof(void *); maxCapacity *= PROV_EXTENT_SIZE / sizeof(void *); - std::cout << "matras capacity : " << maxCapacity << std::endl; struct matras pta; diff --git a/test/unit/matras.result b/test/unit/matras.result index b559e206fca76a1704be4d9c81ad70a6ccb5a89f..862dd816368ed437298f25c2c42179a8a8e4d806 100644 --- a/test/unit/matras.result +++ b/test/unit/matras.result @@ -1,3 +1,2 @@ Testing matras_alloc... -matras capacity : 256 Testing matras_alloc successfully finished