Skip to content

Commit d3ec7c1

Browse files
oleg-jukovecLeonidVas
authored andcommitted
abstract: throw an error if failed to create a temp tube
The create_tube method returns a tube or throws an error in almost all cases. It is unexpected that only in one case it returns nil and writes an error message into a log. The patch unifies the behavior of this method.
1 parent 8f1ddbb commit d3ec7c1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

queue/abstract.lua

+1-2
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,7 @@ function method.create_tube(tube_name, tube_type, opts)
579579

580580
local replicaset_mode = queue.cfg['in_replicaset'] or false
581581
if replicaset_mode and opts.temporary then
582-
log.error("Cannot create temporary tube in replicaset mode")
583-
return
582+
error("Cannot create temporary tube in replicaset mode")
584583
end
585584

586585
local driver = queue.driver[tube_type]

t/200-master-replica.t

100644100755
+14-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
2121
-- Replica connection handler.
2222
local conn = {}
2323

24-
test:plan(7)
24+
test:plan(8)
2525

2626
test:test('Check master-replica setup', function(test)
2727
test:plan(8)
@@ -46,6 +46,19 @@ test:test('Check master-replica setup', function(test)
4646
test:ok(tube, 'test tube created')
4747
end)
4848

49+
test:test('Check error create temporary tube', function(test)
50+
test:plan(2)
51+
local engine = os.getenv('ENGINE') or 'memtx'
52+
53+
queue.cfg{ttr = 0.5, in_replicaset = true}
54+
local opts = {temporary = true, engine = engine}
55+
local status, err = pcall(queue.create_tube, 'test', 'fifo', opts)
56+
test:is(status, false, 'test tube should not be created')
57+
local founded = string.find(err,
58+
'Cannot create temporary tube in replicaset mode')
59+
test:ok(founded, 'unexpected error')
60+
end)
61+
4962
test:test('Check queue state switching', function(test)
5063
test:plan(4)
5164
box.cfg{read_only = true}

0 commit comments

Comments
 (0)