From 7e9ccd77c0cd76bc899a4d76c42741ca8a4d5b61 Mon Sep 17 00:00:00 2001 From: Sulverus <sulverus@gmail.com> Date: Mon, 6 Jul 2015 21:50:30 +0300 Subject: [PATCH] replication catch.test error injection --- src/box/replication.cc | 5 +++++ src/errinj.h | 3 ++- test/replication/catch.result | 37 +++++++++++++++++++-------------- test/replication/catch.test.lua | 25 +++++++++++++--------- test/replication/suite.ini | 1 + 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/box/replication.cc b/src/box/replication.cc index d376f44b96..a54a1593b4 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -43,6 +43,7 @@ #include "coio.h" #include "cfg.h" #include "trigger.h" +#include "errinj.h" void replication_send_row(struct recovery_state *r, void *param, @@ -227,6 +228,10 @@ relay_send(Relay *relay, struct xrow_header *packet) struct iovec iov[XROW_IOVMAX]; int iovcnt = xrow_to_iovec(packet, iov); coio_writev(&relay->io, iov, iovcnt, 0); + ERROR_INJECT(ERRINJ_RELAY, + { + sleep(1000); + }); } /** Send a single row to the client. */ diff --git a/src/errinj.h b/src/errinj.h index e0b2dec8ee..d35f64179e 100644 --- a/src/errinj.h +++ b/src/errinj.h @@ -45,7 +45,8 @@ struct errinj { _(ERRINJ_WAL_ROTATE, false) \ _(ERRINJ_WAL_WRITE, false) \ _(ERRINJ_INDEX_ALLOC, false) \ - _(ERRINJ_TUPLE_ALLOC, false) + _(ERRINJ_TUPLE_ALLOC, false) \ + _(ERRINJ_RELAY, false) ENUM0(errinj_enum, ERRINJ_LIST); extern struct errinj errinjs[]; diff --git a/test/replication/catch.result b/test/replication/catch.result index 05f896e9c1..f91675a1ee 100644 --- a/test/replication/catch.result +++ b/test/replication/catch.result @@ -1,6 +1,9 @@ net_box = require('net.box') --- ... +errinj = box.error.injection +--- +... box.schema.user.grant('guest', 'replication') --- ... @@ -11,18 +14,12 @@ box.schema.user.grant('guest', 'read,write,execute', 'universe') --- ... --# set connection default ---# stop server replica s = box.schema.space.create('test'); --- ... index = s:create_index('primary', {type = 'hash'}) --- ... --- insert values -for i=1,100000 do s:insert{i, 'this is test message12345'} end ---- -... ---# start server replica --# set connection replica fiber = require('fiber') --- @@ -30,21 +27,30 @@ fiber = require('fiber') while box.space.test == nil do fiber.sleep(0.01) end --- ... --- try to delete localy -box.space.test:len() > 0 +--# set connection default +--# stop server replica +-- insert values +for i=1,100 do s:insert{i, 'this is test message12345'} end --- -- true ... -box.space.test:len() < 100000 +-- sleep after every tuple +errinj.set("ERRINJ_RELAY", true) --- -- true +- ok +... +--# start server replica +--# set connection replica +-- try to delete +box.space.test:len() +--- +- 1 ... d = box.space.test:delete{1} --- ... box.space.test:get(1) ~= nil --- -- true +- false ... -- try to delete by net.box --# set connection default @@ -57,13 +63,12 @@ d = c.space.test:delete{1} ... c.space.test:get(1) ~= nil --- -- true +- false ... -- check sync ---# set connection replica -box.space.test:len() < 100000 +errinj.set("ERRINJ_RELAY", false) --- -- true +- ok ... -- cleanup --# stop server replica diff --git a/test/replication/catch.test.lua b/test/replication/catch.test.lua index 2046447003..edaed75278 100644 --- a/test/replication/catch.test.lua +++ b/test/replication/catch.test.lua @@ -1,4 +1,6 @@ net_box = require('net.box') +errinj = box.error.injection + box.schema.user.grant('guest', 'replication') --# create server replica with rpl_master=default, script='replication/replica.lua' --# start server replica @@ -6,22 +8,26 @@ box.schema.user.grant('guest', 'replication') box.schema.user.grant('guest', 'read,write,execute', 'universe') --# set connection default ---# stop server replica - s = box.schema.space.create('test'); index = s:create_index('primary', {type = 'hash'}) +--# set connection replica +fiber = require('fiber') +while box.space.test == nil do fiber.sleep(0.01) end +--# set connection default +--# stop server replica + -- insert values -for i=1,100000 do s:insert{i, 'this is test message12345'} end +for i=1,100 do s:insert{i, 'this is test message12345'} end + +-- sleep after every tuple +errinj.set("ERRINJ_RELAY", true) --# start server replica --# set connection replica -fiber = require('fiber') -while box.space.test == nil do fiber.sleep(0.01) end --- try to delete localy -box.space.test:len() > 0 -box.space.test:len() < 100000 +-- try to delete +box.space.test:len() d = box.space.test:delete{1} box.space.test:get(1) ~= nil @@ -33,8 +39,7 @@ d = c.space.test:delete{1} c.space.test:get(1) ~= nil -- check sync ---# set connection replica -box.space.test:len() < 100000 +errinj.set("ERRINJ_RELAY", false) -- cleanup --# stop server replica diff --git a/test/replication/suite.ini b/test/replication/suite.ini index c0a179cce9..1841d9fb39 100644 --- a/test/replication/suite.ini +++ b/test/replication/suite.ini @@ -3,3 +3,4 @@ core = tarantool script = master.lua description = tarantool/box, replication disabled = consistent.test.lua status.test.py +release_disabled = catch.test.lua -- GitLab