[PATCH 2/2] test: move vinyl space format test case to engine suite
Serge Petrenko
sergepetrenko at tarantool.org
Mon Jun 3 18:51:06 MSK 2019
After making memtx space format check non-blocking, move the appropriate
vinyl test case to engine suite. Introduce a new errinj,
ERRINJ_CHECK_FORMAT_DELAY, to unify the test case for both engines.
Follow-up #3976
---
src/box/memtx_space.c | 15 +++++++
src/box/vinyl.c | 6 +++
src/lib/core/errinj.h | 1 +
test/box/errinj.result | 36 ++++++++--------
test/engine/errinj_ddl.result | 68 ++++++++++++++++++++++++++++++
test/engine/errinj_ddl.test.lua | 33 +++++++++++++++
test/vinyl/errinj_ddl.result | 75 ---------------------------------
test/vinyl/errinj_ddl.test.lua | 35 ---------------
8 files changed, 142 insertions(+), 127 deletions(-)
diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c
index a370c038a..54d08b531 100644
--- a/src/box/memtx_space.c
+++ b/src/box/memtx_space.c
@@ -916,6 +916,21 @@ memtx_space_check_format(struct space *space, struct tuple_format *format)
break;
}
}
+
+ struct errinj *inj = errinj(ERRINJ_CHECK_FORMAT_DELAY, ERRINJ_BOOL);
+ if (inj != NULL && inj->bparam && count == 1) {
+ state.cursor = tuple;
+ tuple_ref(state.cursor);
+ do {
+ fiber_sleep(0);
+ } while (inj->bparam);
+ tuple_unref(state.cursor);
+ if (state.rc != 0) {
+ rc = -1;
+ diag_move(&state.diag, diag_get());
+ break;
+ }
+ }
}
iterator_delete(it);
diag_destroy(&state.diag);
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 9b4bc53bf..0c80496d9 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1156,6 +1156,12 @@ vinyl_space_check_format(struct space *space, struct tuple_format *format)
*/
if (++loops % VY_YIELD_LOOPS == 0)
fiber_sleep(0);
+ struct errinj *inj = errinj(ERRINJ_CHECK_FORMAT_DELAY, ERRINJ_BOOL);
+ if (inj != NULL && inj->bparam && loops == 1) {
+ do {
+ fiber_sleep(0);
+ } while (inj->bparam);
+ }
if (ctx.is_failed) {
diag_move(&ctx.diag, diag_get());
rc = -1;
diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h
index 796d3a194..787836514 100644
--- a/src/lib/core/errinj.h
+++ b/src/lib/core/errinj.h
@@ -107,6 +107,7 @@ struct errinj {
_(ERRINJ_XLOG_READ, ERRINJ_INT, {.iparam = -1}) \
_(ERRINJ_VYRUN_INDEX_GARBAGE, ERRINJ_BOOL, {.bparam = false}) \
_(ERRINJ_VYRUN_DATA_READ, ERRINJ_BOOL, {.bparam = false}) \
+ _(ERRINJ_CHECK_FORMAT_DELAY, ERRINJ_BOOL, {.bparam = false}) \
_(ERRINJ_BUILD_INDEX, ERRINJ_INT, {.iparam = -1}) \
_(ERRINJ_BUILD_INDEX_DELAY, ERRINJ_BOOL, {.bparam = false}) \
_(ERRINJ_VY_POINT_ITER_WAIT, ERRINJ_BOOL, {.bparam = false}) \
diff --git a/test/box/errinj.result b/test/box/errinj.result
index 5759e7494..f24bf7813 100644
--- a/test/box/errinj.result
+++ b/test/box/errinj.result
@@ -36,32 +36,34 @@ errinj.info()
state: -1
ERRINJ_WAL_WRITE_EOF:
state: false
+ ERRINJ_COIO_SENDFILE_CHUNK:
+ state: -1
ERRINJ_VYRUN_INDEX_GARBAGE:
state: false
ERRINJ_BUILD_INDEX_DELAY:
state: false
- ERRINJ_COIO_SENDFILE_CHUNK:
- state: -1
- ERRINJ_VY_INDEX_FILE_RENAME:
- state: false
- ERRINJ_VY_POINT_ITER_WAIT:
+ ERRINJ_VY_RUN_FILE_RENAME:
state: false
+ ERRINJ_BUILD_INDEX:
+ state: -1
+ ERRINJ_RELAY_BREAK_LSN:
+ state: -1
ERRINJ_VY_DELAY_PK_LOOKUP:
state: false
ERRINJ_VY_TASK_COMPLETE:
state: false
ERRINJ_PORT_DUMP:
state: false
- ERRINJ_WAL_BREAK_LSN:
- state: -1
+ ERRINJ_CHECK_FORMAT_DELAY:
+ state: false
ERRINJ_WAL_IO:
state: false
ERRINJ_WAL_FALLOCATE:
state: 0
- ERRINJ_LOG_ROTATE:
- state: false
ERRINJ_VY_DUMP_DELAY:
state: false
+ ERRINJ_WAL_BREAK_LSN:
+ state: -1
ERRINJ_TUPLE_FORMAT_COUNT:
state: -1
ERRINJ_TUPLE_ALLOC:
@@ -72,25 +74,25 @@ errinj.info()
state: false
ERRINJ_RELAY_REPORT_INTERVAL:
state: 0
- ERRINJ_RELAY_BREAK_LSN:
- state: -1
+ ERRINJ_VY_INDEX_FILE_RENAME:
+ state: false
ERRINJ_VY_READ_PAGE_TIMEOUT:
state: 0
ERRINJ_XLOG_META:
state: false
ERRINJ_SIO_READ_MAX:
state: -1
- ERRINJ_VY_RUN_FILE_RENAME:
+ ERRINJ_VY_LOG_FILE_RENAME:
state: false
ERRINJ_WAL_WRITE_DISK:
state: false
- ERRINJ_VY_LOG_FILE_RENAME:
- state: false
ERRINJ_HTTP_RESPONSE_ADD_WAIT:
state: false
+ ERRINJ_SNAP_COMMIT_DELAY:
+ state: false
ERRINJ_VY_RUN_WRITE:
state: false
- ERRINJ_SNAP_COMMIT_DELAY:
+ ERRINJ_LOG_ROTATE:
state: false
ERRINJ_VY_LOG_FLUSH_DELAY:
state: false
@@ -104,10 +106,10 @@ errinj.info()
state: false
ERRINJ_WAL_ROTATE:
state: false
- ERRINJ_BUILD_INDEX:
- state: -1
ERRINJ_RELAY_EXIT_DELAY:
state: 0
+ ERRINJ_VY_POINT_ITER_WAIT:
+ state: false
ERRINJ_MEMTX_DELAY_GC:
state: false
ERRINJ_IPROTO_TX_DELAY:
diff --git a/test/engine/errinj_ddl.result b/test/engine/errinj_ddl.result
index 7396de7c6..5f4043005 100644
--- a/test/engine/errinj_ddl.result
+++ b/test/engine/errinj_ddl.result
@@ -10,6 +10,74 @@ engine = test_run:get_cfg('engine')
errinj = box.error.injection
---
...
+--
+-- Check that ALTER is abroted if a tuple inserted during space
+-- format change does not conform to the new format.
+--
+format = {}
+---
+...
+format[1] = {name = 'field1', type = 'unsigned'}
+---
+...
+format[2] = {name = 'field2', type = 'string', is_nullable = true}
+---
+...
+s = box.schema.space.create('test', {engine = engine, format = format})
+---
+...
+_ = s:create_index('pk')
+---
+...
+pad = string.rep('x', 16)
+---
+...
+for i = 101, 200 do s:replace{i, pad} end
+---
+...
+ch = fiber.channel(1)
+---
+...
+test_run:cmd("setopt delimiter ';'")
+---
+- true
+...
+_ = fiber.create(function()
+ fiber.sleep(0.01)
+ for i = 1, 100 do
+ s:replace{i, box.NULL}
+ end
+ errinj.set("ERRINJ_CHECK_FORMAT_DELAY", false)
+ ch:put(true)
+end);
+---
+...
+test_run:cmd("setopt delimiter ''");
+---
+- true
+...
+format[2].is_nullable = false
+---
+...
+errinj.set("ERRINJ_CHECK_FORMAT_DELAY", true)
+---
+- ok
+...
+s:format(format) -- must fail
+---
+- error: 'Tuple field 2 type does not match one required by operation: expected string'
+...
+ch:get()
+---
+- true
+...
+s:count() -- 200
+---
+- 200
+...
+s:drop()
+---
+...
t = box.schema.space.create("space", {engine = engine})
---
...
diff --git a/test/engine/errinj_ddl.test.lua b/test/engine/errinj_ddl.test.lua
index f67ca5055..a382daa44 100644
--- a/test/engine/errinj_ddl.test.lua
+++ b/test/engine/errinj_ddl.test.lua
@@ -3,6 +3,39 @@ fiber = require('fiber')
engine = test_run:get_cfg('engine')
errinj = box.error.injection
+--
+-- Check that ALTER is abroted if a tuple inserted during space
+-- format change does not conform to the new format.
+--
+format = {}
+format[1] = {name = 'field1', type = 'unsigned'}
+format[2] = {name = 'field2', type = 'string', is_nullable = true}
+s = box.schema.space.create('test', {engine = engine, format = format})
+_ = s:create_index('pk')
+
+pad = string.rep('x', 16)
+for i = 101, 200 do s:replace{i, pad} end
+
+ch = fiber.channel(1)
+test_run:cmd("setopt delimiter ';'")
+_ = fiber.create(function()
+ fiber.sleep(0.01)
+ for i = 1, 100 do
+ s:replace{i, box.NULL}
+ end
+ errinj.set("ERRINJ_CHECK_FORMAT_DELAY", false)
+ ch:put(true)
+end);
+test_run:cmd("setopt delimiter ''");
+
+format[2].is_nullable = false
+errinj.set("ERRINJ_CHECK_FORMAT_DELAY", true)
+s:format(format) -- must fail
+ch:get()
+
+s:count() -- 200
+s:drop()
+
t = box.schema.space.create("space", {engine = engine})
_ = t:create_index("pk")
for i = 1,1000 do t:insert{i, i} end
diff --git a/test/vinyl/errinj_ddl.result b/test/vinyl/errinj_ddl.result
index 4c3df3acd..8fe9064b8 100644
--- a/test/vinyl/errinj_ddl.result
+++ b/test/vinyl/errinj_ddl.result
@@ -8,81 +8,6 @@ errinj = box.error.injection
---
...
--
--- Check that ALTER is abroted if a tuple inserted during space
--- format change does not conform to the new format.
---
-format = {}
----
-...
-format[1] = {name = 'field1', type = 'unsigned'}
----
-...
-format[2] = {name = 'field2', type = 'string', is_nullable = true}
----
-...
-s = box.schema.space.create('test', {engine = 'vinyl', format = format})
----
-...
-_ = s:create_index('pk', {page_size = 16})
----
-...
-pad = string.rep('x', 16)
----
-...
-for i = 101, 200 do s:replace{i, pad} end
----
-...
-box.snapshot()
----
-- ok
-...
-ch = fiber.channel(1)
----
-...
-test_run:cmd("setopt delimiter ';'")
----
-- true
-...
-_ = fiber.create(function()
- fiber.sleep(0.01)
- for i = 1, 100 do
- s:replace{i, box.NULL}
- end
- ch:put(true)
-end);
----
-...
-test_run:cmd("setopt delimiter ''");
----
-- true
-...
-errinj.set("ERRINJ_VY_READ_PAGE_TIMEOUT", 0.001)
----
-- ok
-...
-format[2].is_nullable = false
----
-...
-s:format(format) -- must fail
----
-- error: 'Tuple field 2 type does not match one required by operation: expected string'
-...
-errinj.set("ERRINJ_VY_READ_PAGE_TIMEOUT", 0)
----
-- ok
-...
-ch:get()
----
-- true
-...
-s:count() -- 200
----
-- 200
-...
-s:drop()
----
-...
---
-- Check that modifications done to the space during the final dump
-- of a newly built index are recovered properly.
--
diff --git a/test/vinyl/errinj_ddl.test.lua b/test/vinyl/errinj_ddl.test.lua
index 830d1d1be..3bc8bed80 100644
--- a/test/vinyl/errinj_ddl.test.lua
+++ b/test/vinyl/errinj_ddl.test.lua
@@ -2,41 +2,6 @@ test_run = require('test_run').new()
fiber = require('fiber')
errinj = box.error.injection
---
--- Check that ALTER is abroted if a tuple inserted during space
--- format change does not conform to the new format.
---
-format = {}
-format[1] = {name = 'field1', type = 'unsigned'}
-format[2] = {name = 'field2', type = 'string', is_nullable = true}
-s = box.schema.space.create('test', {engine = 'vinyl', format = format})
-_ = s:create_index('pk', {page_size = 16})
-
-pad = string.rep('x', 16)
-for i = 101, 200 do s:replace{i, pad} end
-box.snapshot()
-
-ch = fiber.channel(1)
-test_run:cmd("setopt delimiter ';'")
-_ = fiber.create(function()
- fiber.sleep(0.01)
- for i = 1, 100 do
- s:replace{i, box.NULL}
- end
- ch:put(true)
-end);
-test_run:cmd("setopt delimiter ''");
-
-errinj.set("ERRINJ_VY_READ_PAGE_TIMEOUT", 0.001)
-format[2].is_nullable = false
-s:format(format) -- must fail
-errinj.set("ERRINJ_VY_READ_PAGE_TIMEOUT", 0)
-
-ch:get()
-
-s:count() -- 200
-s:drop()
-
--
-- Check that modifications done to the space during the final dump
-- of a newly built index are recovered properly.
--
2.20.1 (Apple Git-117)
More information about the Tarantool-patches
mailing list