[Tarantool-patches] [PATCH vshard 1/1] test: fix tests on the latest Tarantool

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Nov 23 01:43:00 MSK 2021


In the commit tarantool/39a462e09572df238b9a651447289e7fab87b9fd
("error: report ER_READONLY reason in message") the error message
for the `box.error.READONLY` error was changed but vshard tests
were not updated. This patch fixes them so they don't depend on
this particular error message anymore.
---
Branch: http://github.com/tarantool/vshard/tree/gerold103/fix-read_only-error

 test/storage/demote_sync_errinj.result   |  7 +++++--
 test/storage/demote_sync_errinj.test.lua |  3 ++-
 test/storage/read_only_slave.result      | 12 +++++++-----
 test/storage/read_only_slave.test.lua    |  5 +++--
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/test/storage/demote_sync_errinj.result b/test/storage/demote_sync_errinj.result
index d40878c..cc104d9 100644
--- a/test/storage/demote_sync_errinj.result
+++ b/test/storage/demote_sync_errinj.result
@@ -52,9 +52,12 @@ f:status()
 - suspended
 ...
 -- Can not write - read only mode is already on.
-s:replace{1}
+ok, err = pcall(s.replace, s, {1})
 ---
-- error: Can't modify data because this instance is in read-only mode.
+...
+assert(not ok and err.code == box.error.READONLY)
+---
+- true
 ...
 test_run:switch('storage_1_b')
 ---
diff --git a/test/storage/demote_sync_errinj.test.lua b/test/storage/demote_sync_errinj.test.lua
index 15b951d..7109ac5 100644
--- a/test/storage/demote_sync_errinj.test.lua
+++ b/test/storage/demote_sync_errinj.test.lua
@@ -17,7 +17,8 @@ cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master
 f = fiber.create(function() vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_a) end)
 f:status()
 -- Can not write - read only mode is already on.
-s:replace{1}
+ok, err = pcall(s.replace, s, {1})
+assert(not ok and err.code == box.error.READONLY)
 
 test_run:switch('storage_1_b')
 cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master = true
diff --git a/test/storage/read_only_slave.result b/test/storage/read_only_slave.result
index a42807b..c863836 100644
--- a/test/storage/read_only_slave.result
+++ b/test/storage/read_only_slave.result
@@ -68,9 +68,12 @@ box.cfg.read_only
 ---
 - true
 ...
-box.schema.create_space('test3')
+ok, err = pcall(box.schema.create_space, 'test3')
 ---
-- error: Can't modify data because this instance is in read-only mode.
+...
+assert(not ok and err.code == box.error.READONLY)
+---
+- true
 ...
 fiber = require('fiber')
 ---
@@ -129,10 +132,9 @@ box.cfg.read_only
 ---
 - true
 ...
-ok, err
+assert(not ok and err.code == box.error.READONLY)
 ---
-- false
-- Can't modify data because this instance is in read-only mode.
+- true
 ...
 fiber = require('fiber')
 ---
diff --git a/test/storage/read_only_slave.test.lua b/test/storage/read_only_slave.test.lua
index c7f08ed..98efe03 100644
--- a/test/storage/read_only_slave.test.lua
+++ b/test/storage/read_only_slave.test.lua
@@ -23,7 +23,8 @@ box.space.test:select{}
 
 _ = test_run:switch('storage_1_b')
 box.cfg.read_only
-box.schema.create_space('test3')
+ok, err = pcall(box.schema.create_space, 'test3')
+assert(not ok and err.code == box.error.READONLY)
 fiber = require('fiber')
 function on_master_enable() box.space.test:replace{3, 3} end
 function on_master_disable() if not box.cfg.read_only then box.space.test:replace{4, 4} end end
@@ -46,7 +47,7 @@ cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b].master
 cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_a].master = false
 vshard.storage.cfg(cfg, util.name_to_uuid.storage_1_a)
 box.cfg.read_only
-ok, err
+assert(not ok and err.code == box.error.READONLY)
 fiber = require('fiber')
 while box.space.test:count() ~= 2 do fiber.sleep(0.1) end
 box.space.test:select{}
-- 
2.24.3 (Apple Git-128)



More information about the Tarantool-patches mailing list