From 462b20dc105897411473679ab68fb6ba28b3a45a Mon Sep 17 00:00:00 2001 From: Igor Munkin Date: Wed, 23 Aug 2023 17:19:54 +0300 Subject: [PATCH] test: rewrite engine/uuid.test.lua with luatest NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring --- test/engine-luatest/uuid_test.lua | 44 +++++++++++++++++++++++++ test/engine/uuid.result | 55 ------------------------------- test/engine/uuid.test.lua | 27 --------------- 3 files changed, 44 insertions(+), 82 deletions(-) create mode 100644 test/engine-luatest/uuid_test.lua delete mode 100644 test/engine/uuid.result delete mode 100644 test/engine/uuid.test.lua diff --git a/test/engine-luatest/uuid_test.lua b/test/engine-luatest/uuid_test.lua new file mode 100644 index 000000000000..bfcb7c8da3d1 --- /dev/null +++ b/test/engine-luatest/uuid_test.lua @@ -0,0 +1,44 @@ +local server = require('luatest.server') +local t = require('luatest') + +local g = t.group('UUID tests', { + {engine = 'memtx'}, + {engine = 'vinyl'}, +}) + +g.before_all(function(cg) + cg.server = server:new({ + alias = 'default', + }) + cg.server:start() +end) + +g.after_all(function(cg) + cg.server:drop() +end) + +g.before_each(function(cg) + cg.server:exec(function(engine) + local uuid = require('uuid') + box.schema.space.create('test', {engine = engine}) + box.space.test:create_index('pk', {parts={1, 'uuid'}}) + for _ = 1, 16 do + box.space.test:insert({uuid.new()}) + end + end, {cg.params.engine}) +end) + +g.after_each(function(cg) + cg.server:exec(function() + box.space.test:drop() + end) +end) + +g.test_uuid_order = function(cg) + cg.server:exec(function() + local tuples = box.space.test:select({}) + for i = 1, #tuples - 1 do + t.assert(tostring(tuples[i][1]) < tostring(tuples[i + 1][1])) + end + end) +end diff --git a/test/engine/uuid.result b/test/engine/uuid.result deleted file mode 100644 index c7c0bdceb2a1..000000000000 --- a/test/engine/uuid.result +++ /dev/null @@ -1,55 +0,0 @@ --- test-run result file version 2 -env = require('test_run') - | --- - | ... -test_run = env.new() - | --- - | ... -engine = test_run:get_cfg('engine') - | --- - | ... - -uuid = require('uuid') - | --- - | ... -ffi = require('ffi') - | --- - | ... - --- Check uuid indices (gh-4268). -_ = box.schema.space.create('test', {engine=engine}) - | --- - | ... -_ = box.space.test:create_index('pk', {parts={1,'uuid'}}) - | --- - | ... - -for i = 1,16 do\ - box.space.test:insert{uuid.new()}\ -end - | --- - | ... - -a = box.space.test:select{} - | --- - | ... -err = nil - | --- - | ... -for i = 1, #a - 1 do\ - if tostring(a[i][1]) >= tostring(a[i+1][1]) then\ - err = {a[i][1], a[i+1][1]}\ - break\ - end\ -end - | --- - | ... - -err - | --- - | - null - | ... - -box.space.test:drop() - | --- - | ... diff --git a/test/engine/uuid.test.lua b/test/engine/uuid.test.lua deleted file mode 100644 index 34e74e68b335..000000000000 --- a/test/engine/uuid.test.lua +++ /dev/null @@ -1,27 +0,0 @@ -env = require('test_run') -test_run = env.new() -engine = test_run:get_cfg('engine') - -uuid = require('uuid') -ffi = require('ffi') - --- Check uuid indices (gh-4268). -_ = box.schema.space.create('test', {engine=engine}) -_ = box.space.test:create_index('pk', {parts={1,'uuid'}}) - -for i = 1,16 do\ - box.space.test:insert{uuid.new()}\ -end - -a = box.space.test:select{} -err = nil -for i = 1, #a - 1 do\ - if tostring(a[i][1]) >= tostring(a[i+1][1]) then\ - err = {a[i][1], a[i+1][1]}\ - break\ - end\ -end - -err - -box.space.test:drop()