[Tarantool-patches] [PATCH v3 0/2] vinyl: rework upsert operation

Nikita Pettik korablev at tarantool.org
Tue Oct 13 13:18:39 MSK 2020


On 11 Oct 17:35, Vladislav Shpilevoy wrote:
> The patchset looks good except for not having a backward compatibility test.

Here's a test:

diff --git a/test/vinyl/upgrade/upsert/00000000000000000000.vylog b/test/vinyl/upgrade/upsert/00000000000000000000.vylog
new file mode 100644
index 000000000..581ad9b53
Binary files /dev/null and b/test/vinyl/upgrade/upsert/00000000000000000000.vylog differ
diff --git a/test/vinyl/upgrade/upsert/00000000000000000004.vylog b/test/vinyl/upgrade/upsert/00000000000000000004.vylog
new file mode 100644
index 000000000..5194b1457
Binary files /dev/null and b/test/vinyl/upgrade/upsert/00000000000000000004.vylog differ
diff --git a/test/vinyl/upgrade/upsert/00000000000000000004.xlog b/test/vinyl/upgrade/upsert/00000000000000000004.xlog
new file mode 100644
index 000000000..5725d09ce
Binary files /dev/null and b/test/vinyl/upgrade/upsert/00000000000000000004.xlog differ
diff --git a/test/vinyl/upgrade/upsert/00000000000000000010.vylog b/test/vinyl/upgrade/upsert/00000000000000000010.vylog
new file mode 100644
index 000000000..954a51a4c
Binary files /dev/null and b/test/vinyl/upgrade/upsert/00000000000000000010.vylog differ
diff --git a/test/vinyl/upgrade/upsert/00000000000000000010.xlog b/test/vinyl/upgrade/upsert/00000000000000000010.xlog
new file mode 100644
index 000000000..f5921223d
--- /dev/null
+++ b/test/vinyl/upgrade/upsert/00000000000000000010.xlog
@@ -0,0 +1,8 @@
+XLOG
+0.13
+Version: 2.6.0-153-g3bc455f7d
+Instance: 4b1aba36-0cbc-4d51-9968-53da3908a43d
+VClock: {1: 10}
+PrevVClock: {1: 4}
+
+<D5>^P<AD><ED>
\ No newline at end of file
diff --git a/test/vinyl/upgrade/upsert/512/0/00000000000000000002.index b/test/vinyl/upgrade/upsert/512/0/00000000000000000002.index
new file mode 100644
index 000000000..156c23dd7
Binary files /dev/null and b/test/vinyl/upgrade/upsert/512/0/00000000000000000002.index differ
diff --git a/test/vinyl/upgrade/upsert/512/0/00000000000000000002.run b/test/vinyl/upgrade/upsert/512/0/00000000000000000002.run
new file mode 100644
index 000000000..9757ea341
Binary files /dev/null and b/test/vinyl/upgrade/upsert/512/0/00000000000000000002.run differ
diff --git a/test/vinyl/upgrade/upsert/512/0/00000000000000000004.index b/test/vinyl/upgrade/upsert/512/0/00000000000000000004.index
new file mode 100644
index 000000000..1c3896547
Binary files /dev/null and b/test/vinyl/upgrade/upsert/512/0/00000000000000000004.index differ
diff --git a/test/vinyl/upgrade/upsert/512/0/00000000000000000004.run b/test/vinyl/upgrade/upsert/512/0/00000000000000000004.run
new file mode 100644
index 000000000..469e2abab
Binary files /dev/null and b/test/vinyl/upgrade/upsert/512/0/00000000000000000004.run differ
diff --git a/test/vinyl/upgrade/upsert/512/0/00000000000000000006.index b/test/vinyl/upgrade/upsert/512/0/00000000000000000006.index
new file mode 100644
index 000000000..9202ec7e7
Binary files /dev/null and b/test/vinyl/upgrade/upsert/512/0/00000000000000000006.index differ
diff --git a/test/vinyl/upgrade/upsert/512/0/00000000000000000006.run b/test/vinyl/upgrade/upsert/512/0/00000000000000000006.run
new file mode 100644
index 000000000..d4fcd7599
Binary files /dev/null and b/test/vinyl/upgrade/upsert/512/0/00000000000000000006.run differ
diff --git a/test/vinyl/upsert_upgrade.result b/test/vinyl/upsert_upgrade.result
new file mode 100644
index 000000000..8882a8b63
--- /dev/null
+++ b/test/vinyl/upsert_upgrade.result
@@ -0,0 +1,59 @@
+-- test-run result file version 2
+test_run = require('test_run').new()
+ | ---
+ | ...
+
+-- Upsert's internal format have changed: now update operations are stored
+-- with additional map package. Let's test backward compatibility.
+-- Snapshot (i.e. run files) contain following statements:
+
+-- s = box.schema.create_space('test', {engine = 'vinyl'})
+-- pk = s:create_index('pk')
+-- s:insert({1, 2})
+-- box.snapshot()
+-- s:upsert({1, 0}, {{'+', 2, 1}})
+-- s:upsert({1, 0}, {{'-', 2, 2}})
+-- s:upsert({2, 0}, {{'+', 2, 1}})
+-- s:upsert({2, 0}, {{'-', 2, 2}})
+-- s:upsert({1, 0}, {{'=', 2, 2}})
+-- s:upsert({1, 0}, {{'-', 2, 2}})
+-- box.snapshot()
+--
+-- Make sure that upserts will be parsed and squashed correctly.
+--
+
+dst_dir = 'vinyl/upgrade/upsert/'
+ | ---
+ | ...
+
+test_run:cmd('create server upgrade with script="vinyl/upgrade.lua", workdir="' .. dst_dir .. '"')
+ | ---
+ | - true
+ | ...
+test_run:cmd('start server upgrade')
+ | ---
+ | - true
+ | ...
+test_run:switch('upgrade')
+ | ---
+ | - true
+ | ...
+
+box.space.test:select()
+ | ---
+ | - - [1, 0]
+ |   - [2, -2]
+ | ...
+
+test_run:switch('default')
+ | ---
+ | - true
+ | ...
+test_run:cmd('stop server upgrade')
+ | ---
+ | - true
+ | ...
+test_run:cmd('cleanup server upgrade')
+ | ---
+ | - true
+ | ...
diff --git a/test/vinyl/upsert_upgrade.test.lua b/test/vinyl/upsert_upgrade.test.lua
new file mode 100644
index 000000000..db409e2dd
--- /dev/null
+++ b/test/vinyl/upsert_upgrade.test.lua
@@ -0,0 +1,32 @@
+test_run = require('test_run').new()
+
+-- Upsert's internal format have changed: now update operations are stored
+-- with additional map package. Let's test backward compatibility.
+-- Snapshot (i.e. run files) contain following statements:
+
+-- s = box.schema.create_space('test', {engine = 'vinyl'})
+-- pk = s:create_index('pk')
+-- s:insert({1, 2})
+-- box.snapshot()
+-- s:upsert({1, 0}, {{'+', 2, 1}})
+-- s:upsert({1, 0}, {{'-', 2, 2}})
+-- s:upsert({2, 0}, {{'+', 2, 1}})
+-- s:upsert({2, 0}, {{'-', 2, 2}})
+-- s:upsert({1, 0}, {{'=', 2, 2}})
+-- s:upsert({1, 0}, {{'-', 2, 2}})
+-- box.snapshot()
+--
+-- Make sure that upserts will be parsed and squashed correctly.
+--
+
+dst_dir = 'vinyl/upgrade/upsert/'
+
+test_run:cmd('create server upgrade with script="vinyl/upgrade.lua", workdir="' .. dst_dir .. '"')
+test_run:cmd('start server upgrade')
+test_run:switch('upgrade')
+
+box.space.test:select()
+
+test_run:switch('default')
+test_run:cmd('stop server upgrade')
+test_run:cmd('cleanup server upgrade')



More information about the Tarantool-patches mailing list