Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, vdavydov.dev@gmail.com
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [PATCH v1 1/1] test: check hints corner cases
Date: Thu, 21 Mar 2019 14:40:51 +0300	[thread overview]
Message-ID: <a9a1f69b5dedf4b923bef6480d5b69d635d4aede.1553168411.git.kshcherbatov@tarantool.org> (raw)

We must to enshure that hints don't broke tuple comparison.
As different field_types use different routines to calculate hint,
we must to ensure that the calculated values are compatible with
each other.

Also tested the corner cases for large double numbers, due to the
fact that there may be additional difficulties in hint construction.

Follow-up
    9fba29abb4e0 memtx: introduce tuple compare hint
---
 test/engine/hints.result   | 191 +++++++++++++++++++++++++++++++++++++
 test/engine/hints.test.lua |  62 ++++++++++++
 2 files changed, 253 insertions(+)
 create mode 100644 test/engine/hints.result
 create mode 100644 test/engine/hints.test.lua

diff --git a/test/engine/hints.result b/test/engine/hints.result
new file mode 100644
index 000000000..946f82039
--- /dev/null
+++ b/test/engine/hints.result
@@ -0,0 +1,191 @@
+--
+-- gh-3961: Introduce tuple comparison hints
+-- We must to enshure that hints don't broke
+-- tuple comparison.
+--
+ffi = require('ffi')
+---
+...
+test_run = require('test_run')
+---
+...
+inspector = test_run.new()
+---
+...
+engine = inspector:get_cfg('engine')
+---
+...
+inspector:cmd("setopt delimiter ';'");
+---
+- true
+...
+function insert_values(type)
+        local x = 54
+        while (x <= 64) do
+                local val = ffi.new(type, 2^x-1)
+                s:replace({val})
+                x = x + 1
+        end
+end;
+---
+...
+inspector:cmd("setopt delimiter ''");
+---
+- true
+...
+-- Test that hints does not violate the correct order of
+-- big numeric fields.
+s = box.schema.space.create('test', {engine = engine})
+---
+...
+i1 = s:create_index('i1', {parts = {1, 'unsigned'}})
+---
+...
+insert_values('uint64_t')
+---
+...
+s:select()
+---
+- - [0]
+  - [18014398509481984]
+  - [36028797018963968]
+  - [72057594037927936]
+  - [144115188075855872]
+  - [288230376151711744]
+  - [576460752303423488]
+  - [1152921504606846976]
+  - [2305843009213693952]
+  - [4611686018427387904]
+  - [9223372036854775808]
+...
+i1:alter{parts = {1, 'integer'}}
+---
+...
+insert_values('int64_t')
+---
+...
+s:select()
+---
+- - [-9223372036854775808]
+  - [0]
+  - [18014398509481984]
+  - [36028797018963968]
+  - [72057594037927936]
+  - [144115188075855872]
+  - [288230376151711744]
+  - [576460752303423488]
+  - [1152921504606846976]
+  - [2305843009213693952]
+  - [4611686018427387904]
+  - [9223372036854775808]
+...
+i1:alter{parts = {1, 'number'}}
+---
+...
+insert_values('double')
+---
+...
+s:select()
+---
+- - [-9223372036854775808]
+  - [0]
+  - [18014398509481984]
+  - [36028797018963968]
+  - [72057594037927936]
+  - [144115188075855872]
+  - [288230376151711744]
+  - [576460752303423488]
+  - [1152921504606846976]
+  - [2305843009213693952]
+  - [4611686018427387904]
+  - [9223372036854775808]
+  - [1.844674407371e+19]
+...
+s:drop()
+---
+...
+-- Test that the use of hint(s) does not violate alter between
+-- scalar and string.
+s = box.schema.space.create('test', {engine = engine})
+---
+...
+i1 = s:create_index('i1', {parts = {1, 'string'}})
+---
+...
+s:insert({"bbb"})
+---
+- ['bbb']
+...
+s:insert({"ccc"})
+---
+- ['ccc']
+...
+i1:alter{parts = {1, 'scalar'}}
+---
+...
+s:insert({"aaa"})
+---
+- ['aaa']
+...
+s:insert({"ddd"})
+---
+- ['ddd']
+...
+s:select()
+---
+- - ['aaa']
+  - ['bbb']
+  - ['ccc']
+  - ['ddd']
+...
+s:drop()
+---
+...
+-- Test that hints does not violate the correct order of
+-- numeric fields (on alter).
+s = box.schema.space.create('test', {engine = engine})
+---
+...
+i1 = s:create_index('i1', {parts = {1, 'unsigned'}})
+---
+...
+s:insert({11})
+---
+- [11]
+...
+i1:alter{parts = {1, 'integer'}}
+---
+...
+s:insert({-22})
+---
+- [-22]
+...
+i1:alter{parts = {1, 'number'}}
+---
+...
+s:insert({-33.33})
+---
+- [-33.33]
+...
+i1:alter{parts = {1, 'scalar'}}
+---
+...
+s:insert({44.44})
+---
+- [44.44]
+...
+s:insert({"Hello world"})
+---
+- ['Hello world']
+...
+s:select()
+---
+- - [-33.33]
+  - [-22]
+  - [11]
+  - [44.44]
+  - ['Hello world']
+...
+s:drop()
+---
+...
diff --git a/test/engine/hints.test.lua b/test/engine/hints.test.lua
new file mode 100644
index 000000000..266516ec9
--- /dev/null
+++ b/test/engine/hints.test.lua
@@ -0,0 +1,62 @@
+--
+-- gh-3961: Introduce tuple comparison hints
+-- We must to enshure that hints don't broke
+-- tuple comparison.
+--
+ffi = require('ffi')
+
+test_run = require('test_run')
+inspector = test_run.new()
+engine = inspector:get_cfg('engine')
+
+inspector:cmd("setopt delimiter ';'");
+function insert_values(type)
+        local x = 54
+        while (x <= 64) do
+                local val = ffi.new(type, 2^x-1)
+                s:replace({val})
+                x = x + 1
+        end
+end;
+inspector:cmd("setopt delimiter ''");
+
+-- Test that hints does not violate the correct order of
+-- big numeric fields.
+s = box.schema.space.create('test', {engine = engine})
+i1 = s:create_index('i1', {parts = {1, 'unsigned'}})
+insert_values('uint64_t')
+s:select()
+i1:alter{parts = {1, 'integer'}}
+insert_values('int64_t')
+s:select()
+i1:alter{parts = {1, 'number'}}
+insert_values('double')
+s:select()
+s:drop()
+
+-- Test that the use of hint(s) does not violate alter between
+-- scalar and string.
+s = box.schema.space.create('test', {engine = engine})
+i1 = s:create_index('i1', {parts = {1, 'string'}})
+s:insert({"bbb"})
+s:insert({"ccc"})
+i1:alter{parts = {1, 'scalar'}}
+s:insert({"aaa"})
+s:insert({"ddd"})
+s:select()
+s:drop()
+
+-- Test that hints does not violate the correct order of
+-- numeric fields (on alter).
+s = box.schema.space.create('test', {engine = engine})
+i1 = s:create_index('i1', {parts = {1, 'unsigned'}})
+s:insert({11})
+i1:alter{parts = {1, 'integer'}}
+s:insert({-22})
+i1:alter{parts = {1, 'number'}}
+s:insert({-33.33})
+i1:alter{parts = {1, 'scalar'}}
+s:insert({44.44})
+s:insert({"Hello world"})
+s:select()
+s:drop()
-- 
2.21.0

             reply	other threads:[~2019-03-21 11:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 11:40 Kirill Shcherbatov [this message]
2019-03-26 16:23 ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9a1f69b5dedf4b923bef6480d5b69d635d4aede.1553168411.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH v1 1/1] test: check hints corner cases' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox