[PATCH 2/3] test: check that is_local flag has no effect on temporary spaces

Vladimir Davydov vdavydov.dev at gmail.com
Tue Jul 10 16:43:26 MSK 2018


Follow-up #3443
---
 test/replication/local_spaces.result   | 59 ++++++++++++++++++++++++++++++++++
 test/replication/local_spaces.test.lua | 18 +++++++++++
 2 files changed, 77 insertions(+)

diff --git a/test/replication/local_spaces.result b/test/replication/local_spaces.result
index 1ee04803..06782788 100644
--- a/test/replication/local_spaces.result
+++ b/test/replication/local_spaces.result
@@ -52,12 +52,31 @@ box.space._space:insert{9000, 1, 'test', 'memtx', 0, {group_id = 2}, {}} -- erro
 ---
 - error: Replication group '2' does not exist
 ...
+-- Temporary local spaces should behave in the same fashion as
+-- plain temporary spaces, i.e. neither replicated nor persisted.
+s3 = box.schema.space.create('test3', {is_local = true, temporary = true})
+---
+...
+_ = s3:create_index('pk')
+---
+...
+s3.is_local
+---
+- true
+...
+s3.temporary
+---
+- true
+...
 _ = s1:insert{1}
 ---
 ...
 _ = s2:insert{1}
 ---
 ...
+_ = s3:insert{1}
+---
+...
 box.snapshot()
 ---
 - ok
@@ -68,6 +87,9 @@ _ = s1:insert{2}
 _ = s2:insert{2}
 ---
 ...
+_ = s3:insert{2}
+---
+...
 box.schema.user.grant('guest', 'replication')
 ---
 ...
@@ -91,6 +113,14 @@ box.space.test2.is_local
 ---
 - true
 ...
+box.space.test3.is_local
+---
+- true
+...
+box.space.test3.temporary
+---
+- true
+...
 box.space.test1:select()
 ---
 - - [1]
@@ -100,12 +130,19 @@ box.space.test2:select()
 ---
 - []
 ...
+box.space.test3:select()
+---
+- []
+...
 box.cfg{read_only = true} -- local spaces ignore read_only
 ---
 ...
 for i = 1, 3 do box.space.test2:insert{i, i} end
 ---
 ...
+for i = 1, 3 do box.space.test3:insert{i, i, i} end
+---
+...
 test_run:cmd("switch default")
 ---
 - true
@@ -116,6 +153,9 @@ _ = s1:insert{3}
 _ = s2:insert{3}
 ---
 ...
+_ = s3:insert{3}
+---
+...
 vclock = test_run:get_vclock('default')
 ---
 ...
@@ -138,6 +178,12 @@ box.space.test2:select()
   - [2, 2]
   - [3, 3]
 ...
+box.space.test3:select()
+---
+- - [1, 1, 1]
+  - [2, 2, 2]
+  - [3, 3, 3]
+...
 test_run:cmd("restart server replica")
 box.space.test1:select()
 ---
@@ -151,6 +197,10 @@ box.space.test2:select()
   - [2, 2]
   - [3, 3]
 ...
+box.space.test3:select()
+---
+- []
+...
 test_run:cmd("switch default")
 ---
 - true
@@ -178,9 +228,18 @@ s2:select()
   - [2]
   - [3]
 ...
+s3:select()
+---
+- - [1]
+  - [2]
+  - [3]
+...
 s1:drop()
 ---
 ...
 s2:drop()
 ---
 ...
+s3:drop()
+---
+...
diff --git a/test/replication/local_spaces.test.lua b/test/replication/local_spaces.test.lua
index 40cb6f97..ec676a18 100644
--- a/test/replication/local_spaces.test.lua
+++ b/test/replication/local_spaces.test.lua
@@ -25,11 +25,20 @@ box.space._space:update(s2.id, {{'=', 6, {group_id = 0}}}) -- error
 -- 0 (global) and 1 (local)
 box.space._space:insert{9000, 1, 'test', 'memtx', 0, {group_id = 2}, {}} -- error
 
+-- Temporary local spaces should behave in the same fashion as
+-- plain temporary spaces, i.e. neither replicated nor persisted.
+s3 = box.schema.space.create('test3', {is_local = true, temporary = true})
+_ = s3:create_index('pk')
+s3.is_local
+s3.temporary
+
 _ = s1:insert{1}
 _ = s2:insert{1}
+_ = s3:insert{1}
 box.snapshot()
 _ = s1:insert{2}
 _ = s2:insert{2}
+_ = s3:insert{2}
 
 box.schema.user.grant('guest', 'replication')
 test_run:cmd("create server replica with rpl_master=default, script='replication/replica.lua'")
@@ -38,23 +47,30 @@ test_run:cmd("start server replica")
 test_run:cmd("switch replica")
 box.space.test1.is_local
 box.space.test2.is_local
+box.space.test3.is_local
+box.space.test3.temporary
 box.space.test1:select()
 box.space.test2:select()
+box.space.test3:select()
 box.cfg{read_only = true} -- local spaces ignore read_only
 for i = 1, 3 do box.space.test2:insert{i, i} end
+for i = 1, 3 do box.space.test3:insert{i, i, i} end
 
 test_run:cmd("switch default")
 _ = s1:insert{3}
 _ = s2:insert{3}
+_ = s3:insert{3}
 vclock = test_run:get_vclock('default')
 _ = test_run:wait_vclock('replica', vclock)
 
 test_run:cmd("switch replica")
 box.space.test1:select()
 box.space.test2:select()
+box.space.test3:select()
 test_run:cmd("restart server replica")
 box.space.test1:select()
 box.space.test2:select()
+box.space.test3:select()
 
 test_run:cmd("switch default")
 test_run:cmd("stop server replica")
@@ -63,6 +79,8 @@ box.schema.user.revoke('guest', 'replication')
 
 s1:select()
 s2:select()
+s3:select()
 
 s1:drop()
 s2:drop()
+s3:drop()
-- 
2.11.0




More information about the Tarantool-patches mailing list