Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: "v.shpilevoy@tarantool.org" <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 2/2] Fixed lost format on update and upsert operations.
Date: Mon, 16 Apr 2018 10:47:56 +0300	[thread overview]
Message-ID: <8a909d97-3f64-207d-fe25-a4462f814d38@tarantool.org> (raw)
In-Reply-To: <b8687ad4-4d77-449b-08cb-1d63737d1ef2@tarantool.org>

I've fixed tests and wrong code style with tabs. 

From f9803f8d0b411abac02e35d5e4120ff0ce7e9341 Mon Sep 17 00:00:00 2001
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Date: Mon, 16 Apr 2018 10:44:10 +0300
Subject: [PATCH] Fixed tests and spaces

---
 src/box/lua/tuple.c         | 10 +++---
 test/box/update.result      | 84 ---------------------------------------------
 test/box/update.test.lua    | 31 -----------------
 test/engine/update.result   | 61 ++++++++++++++++++++++++++++++++
 test/engine/update.test.lua | 24 +++++++++++++
 5 files changed, 90 insertions(+), 120 deletions(-)

diff --git a/src/box/lua/tuple.c b/src/box/lua/tuple.c
index c40bdb7..566cbec 100644
--- a/src/box/lua/tuple.c
+++ b/src/box/lua/tuple.c
@@ -397,13 +397,13 @@ lbox_tuple_transform(struct lua_State *L)
 	size_t used = region_used(region);
 	struct tuple *new_tuple = NULL;
 	const char *new_data = tuple_update_execute(region_aligned_alloc_cb,
-	                                            region, buf->buf,
-	                                            buf->buf + ibuf_used(buf),
-	                                            old_data, old_data + bsize,
-	                                            &new_size, 1, NULL);
+						    region, buf->buf,
+						    buf->buf + ibuf_used(buf),
+						    old_data, old_data + bsize,
+						    &new_size, 1, NULL);
 	if (new_data != NULL)
 		new_tuple = tuple_new(box_tuple_format_default(),
-		                      new_data, new_data + new_size);
+				      new_data, new_data + new_size);
 	region_truncate(region, used);
 
 	if (new_tuple == NULL)
diff --git a/test/box/update.result b/test/box/update.result
index c71cbd8..a3f731b 100644
--- a/test/box/update.result
+++ b/test/box/update.result
@@ -849,87 +849,3 @@ s:update(1, {{'=', 3, map}})
 s:drop()
 ---
 ...
---
--- gh-3051 Lost format while tuple update
---
-test_run = require('test_run')
----
-...
-inspector = test_run.new()
----
-...
-engine = inspector:get_cfg('engine')
----
-...
-format = {}
----
-...
-format[1] = {name = 'KEY', type = 'unsigned'}
----
-...
-format[2] = {name = 'VAL', type = 'string'}
----
-...
-s = box.schema.space.create('tst_sample', {engine = engine, format = format})
----
-...
-pk = s:create_index('pk')
----
-...
-s:insert({1, 'sss'})
----
-- [1, 'sss']
-...
-aa = box.space.tst_sample:get(1)
----
-...
-aa.VAL
----
-- sss
-...
-aa = aa:update({{'=',2,'ssss'}})
----
-...
-aa.VAL
----
-- ssss
-...
-s:drop()
----
-...
-aa = nil
----
-...
--- test transform integrity
-space = box.schema.space.create('tweedledum')
----
-...
-tmp = space:create_index('primary', { type = 'hash', parts = {1, 'string'}, unique = true })
----
-...
-t = space:insert{'1', '2', '3', '4', '5', '6', '7'}
----
-...
-t:transform(-1, 1)
----
-- ['1', '2', '3', '4', '5', '6']
-...
-n = 2000
----
-...
-tab = {}; for i=1,n,1 do table.insert(tab, i) end
----
-...
-t = box.tuple.new(tab)
----
-...
-t:transform(1, n - 1)
----
-- [2000]
-...
-t = nil
----
-...
-space:drop()
----
-...
diff --git a/test/box/update.test.lua b/test/box/update.test.lua
index b6271a6..c455bc1 100644
--- a/test/box/update.test.lua
+++ b/test/box/update.test.lua
@@ -269,34 +269,3 @@ t:update({{'=', 3, map}})
 s:update(1, {{'=', 3, map}})
 
 s:drop()
-
---
--- gh-3051 Lost format while tuple update
---
-test_run = require('test_run')
-inspector = test_run.new()
-engine = inspector:get_cfg('engine')
-format = {}
-format[1] = {name = 'KEY', type = 'unsigned'}
-format[2] = {name = 'VAL', type = 'string'}
-s = box.schema.space.create('tst_sample', {engine = engine, format = format})
-pk = s:create_index('pk')
-s:insert({1, 'sss'})
-aa = box.space.tst_sample:get(1)
-aa.VAL
-aa = aa:update({{'=',2,'ssss'}})
-aa.VAL
-s:drop()
-aa = nil
-
--- test transform integrity
-space = box.schema.space.create('tweedledum')
-tmp = space:create_index('primary', { type = 'hash', parts = {1, 'string'}, unique = true })
-t = space:insert{'1', '2', '3', '4', '5', '6', '7'}
-t:transform(-1, 1)
-n = 2000
-tab = {}; for i=1,n,1 do table.insert(tab, i) end
-t = box.tuple.new(tab)
-t:transform(1, n - 1)
-t = nil
-space:drop()
diff --git a/test/engine/update.result b/test/engine/update.result
index 653ebec..48398d2 100644
--- a/test/engine/update.result
+++ b/test/engine/update.result
@@ -683,3 +683,64 @@ space:select{}
 space:drop()
 ---
 ...
+--
+-- gh-3051 Lost format while tuple update
+--
+format = {}
+---
+...
+format[1] = {name = 'KEY', type = 'unsigned'}
+---
+...
+format[2] = {name = 'VAL', type = 'string'}
+---
+...
+s = box.schema.space.create('tst_sample', {engine = engine, format = format})
+---
+...
+pk = s:create_index('pk')
+---
+...
+s:insert({1, 'sss', '3', '4', '5', '6', '7'})
+---
+- [1, 'sss', '3', '4', '5', '6', '7']
+...
+aa = box.space.tst_sample:get(1)
+---
+...
+aa.VAL
+---
+- sss
+...
+aa = aa:update({{'=',2,'ssss'}})
+---
+...
+aa.VAL
+---
+- ssss
+...
+-- test transform integrity
+aa:transform(-1, 1)
+---
+- [1, 'ssss', '3', '4', '5', '6']
+...
+aa = nil
+---
+...
+s:upsert({2, 'wwwww'}, {{'=', 2, 'wwwww'}})
+---
+...
+box.space.tst_sample:get(2).VAL
+---
+- wwwww
+...
+s:upsert({2, 'wwwww2'}, {{'=', 2, 'wwwww2'}})
+---
+...
+box.space.tst_sample:get(2).VAL
+---
+- wwwww2
+...
+s:drop()
+---
+...
diff --git a/test/engine/update.test.lua b/test/engine/update.test.lua
index 0252b8a..c53e458 100644
--- a/test/engine/update.test.lua
+++ b/test/engine/update.test.lua
@@ -94,3 +94,27 @@ space:select{}
 space:update({2}, {})
 space:select{}
 space:drop()
+
+--
+-- gh-3051 Lost format while tuple update
+--
+format = {}
+format[1] = {name = 'KEY', type = 'unsigned'}
+format[2] = {name = 'VAL', type = 'string'}
+s = box.schema.space.create('tst_sample', {engine = engine, format = format})
+pk = s:create_index('pk')
+s:insert({1, 'sss', '3', '4', '5', '6', '7'})
+aa = box.space.tst_sample:get(1)
+aa.VAL
+aa = aa:update({{'=',2,'ssss'}})
+aa.VAL
+-- test transform integrity
+aa:transform(-1, 1)
+aa = nil
+
+s:upsert({2, 'wwwww'}, {{'=', 2, 'wwwww'}})
+box.space.tst_sample:get(2).VAL
+s:upsert({2, 'wwwww2'}, {{'=', 2, 'wwwww2'}})
+box.space.tst_sample:get(2).VAL
+
+s:drop()
-- 
2.7.4



On 15.04.2018 16:18, Vladislav Shpilevoy wrote:
> Hello. See below 6 comments.
> 
> 1. I fixed some of my comments, and pushed them with --force.
> You can see them using diff your local and remote changes. After
> this do pull. Please, try to investigate, why your text editor
> uses spaces for multiline statements alignment, and fix it.
> 
> 2. I do not see a test on upsert - please, add.
> 
> 3. Please, add a test on incorrect update.
> 
> 4. In the previous letter I have asked you to move the test into
> engine/ suite. You can not get different engines on box/ suite:
> 
> [001] Test failed! Result content mismatch:
> [001] --- box/update.result	Sun Apr 15 15:55:23 2018
> [001] +++ box/update.reject	Sun Apr 15 16:07:40 2018
> [001] @@ -861,6 +861,10 @@
> [001]  engine = inspector:get_cfg('engine')
> [001]  ---
> [001]  ...
> [001] +engine
> [001] +---
> [001] +- null
> [001] +...
> [001]  format = {}
> [001]  ---
> [001]  ...
> [001]
> 
> 
> As you can see, I printed engine variable in you test and 1) it is null,
> 2) the test is not run 2 times - with engine = memtx and engine = vinyl.
> For this you must use engine/ suite, not box/.
> 
> 
> 
>> +test_run = require('test_run')
>> +inspector = test_run.new()
> 
> 5. It is not needed to create a new test run each time when you need to
> get a variable from environment. Here the test run already is created.
> 
>> +engine = inspector:get_cfg('engine')
>>   format = {}
> 
> 
>> -s = box.schema.space.create('tst_sample', {engine = 'vinyl', format = format} > -pk = s:create_index('pk')
>> -s:insert({1, 'sss'})
>> -aa = box.space.tst_sample:get(1)
>> -aa.VAL
>> -aa = aa:update({{'=',2,'ssss'}})
>> -collectgarbage()
>> -aa.VAL
>> -s:drop()
>> -aa = nil
>> -collectgarbage()
>>   
>>   -- test transform integrity
>>   space = box.schema.space.create('tweedledum')
> 
> 6. Try to do not create a new space to test each tuple. You can create
> one space, and test on it transform, correct update, correct upsert,
> incorrect update, incorrect upsert.
> 
> Too many actions for such simple test is not good, because test count
> grows every day, and running all of them is already too long.
> 

  reply	other threads:[~2018-04-16  7:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 16:24 [tarantool-patches] [PATCH v2 0/2] Fix lost format on update operation Kirill Shcherbatov
2018-04-06 16:24 ` [tarantool-patches] [PATCH v2 1/2] Fixed invalid check in lbox_tuple_transform Kirill Shcherbatov
2018-04-06 16:24 ` [tarantool-patches] [PATCH v2 2/2] Fixed lost format on update and upsert operations Kirill Shcherbatov
2018-04-08 13:56   ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-10 10:23     ` Kirill Shcherbatov
2018-04-10 10:44       ` Vladislav Shpilevoy
2018-04-15 10:03         ` Kirill Shcherbatov
2018-04-15 13:18           ` Vladislav Shpilevoy
2018-04-16  7:47             ` Kirill Shcherbatov [this message]
2018-04-16 10:07               ` Vladislav Shpilevoy
2018-04-16 16:51                 ` Kirill Shcherbatov
2018-04-16 17:14                   ` Vladislav Shpilevoy
2018-04-18 12:28                     ` Vladimir Davydov
2018-04-18 12:55                       ` Kirill Shcherbatov
2018-04-22 15:15                         ` Vladislav Shpilevoy
2018-04-28  6:56                           ` Kirill Shcherbatov
2018-04-28  9:29 ` [tarantool-patches] Re: [PATCH v2 0/2] Fix lost format on update operation Vladislav Shpilevoy

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=8a909d97-3f64-207d-fe25-a4462f814d38@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH v2 2/2] Fixed lost format on update and upsert operations.' \
    /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