| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
5
|
|
|
5
|
|
1610
|
use utf8; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
32
|
|
|
2
|
5
|
|
|
5
|
|
150
|
use strict; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
118
|
|
|
3
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
232
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package DR::TarantoolQueue::Tnt; |
|
6
|
5
|
|
|
5
|
|
24
|
use Mouse::Role; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
34
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'fake_in_test'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has _fake_msgpack_tnt => |
|
11
|
|
|
|
|
|
|
is => 'rw', |
|
12
|
|
|
|
|
|
|
isa => 'Maybe[Object]', |
|
13
|
|
|
|
|
|
|
lazy => 1, |
|
14
|
|
|
|
|
|
|
builder => sub { |
|
15
|
|
|
|
|
|
|
my ($self) = @_; |
|
16
|
|
|
|
|
|
|
return undef unless $self->fake_in_test; |
|
17
|
|
|
|
|
|
|
return undef unless $0 =~ /\.t$/; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require DR::Tnt::Test; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $t = DR::Tnt::Test::start_tarantool( |
|
22
|
|
|
|
|
|
|
-port => DR::Tnt::Test::free_port(), |
|
23
|
|
|
|
|
|
|
-make_lua => q{ |
|
24
|
|
|
|
|
|
|
require('log').info('Fake Queue starting') |
|
25
|
|
|
|
|
|
|
box.cfg{ |
|
26
|
|
|
|
|
|
|
listen = os.getenv('PRIMARY_PORT'), |
|
27
|
|
|
|
|
|
|
readahead = 101024 |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
box.schema.user.create('test', { password = 'test' }) |
|
30
|
|
|
|
|
|
|
box.schema.user.grant('test', 'read,write,execute', 'universe') |
|
31
|
|
|
|
|
|
|
_G.queue = require('megaqueue') |
|
32
|
|
|
|
|
|
|
queue:init() |
|
33
|
|
|
|
|
|
|
require('log').info('Fake Queue started') |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
unless ($t->is_started) { |
|
38
|
|
|
|
|
|
|
warn $t->log; |
|
39
|
|
|
|
|
|
|
die "Can't start fake tarantool\n"; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
return $t; |
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has _fake_lts_tnt => |
|
45
|
|
|
|
|
|
|
is => 'rw', |
|
46
|
|
|
|
|
|
|
isa => 'Maybe[Object]', |
|
47
|
|
|
|
|
|
|
lazy => 1, |
|
48
|
|
|
|
|
|
|
builder => sub { |
|
49
|
|
|
|
|
|
|
my ($self) = @_; |
|
50
|
|
|
|
|
|
|
return undef unless $self->fake_in_test; |
|
51
|
|
|
|
|
|
|
return undef unless $0 =~ /\.t$/; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
require DR::Tarantool::StartTest; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
die "'/etc/tarantool/instances.available/queue.cfg' is not found" |
|
56
|
|
|
|
|
|
|
unless -r '/etc/tarantool/instances.available/queue.cfg'; |
|
57
|
|
|
|
|
|
|
die "dir '/usr/lib/dr-tarantool-queue' is absent" |
|
58
|
|
|
|
|
|
|
unless -d '/usr/lib/dr-tarantool-queue'; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $t = DR::Tarantool::StartTest->run( |
|
61
|
|
|
|
|
|
|
script_dir => '/usr/lib/dr-tarantool-queue', |
|
62
|
|
|
|
|
|
|
cfg => '/etc/tarantool/instances.available/queue.cfg', |
|
63
|
|
|
|
|
|
|
slab_alloc_arena => 0.3 |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
unless ($t->started) { |
|
67
|
|
|
|
|
|
|
warn $t->log; |
|
68
|
|
|
|
|
|
|
die "Can't start fake tarantool\n"; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
return $t; |
|
71
|
|
|
|
|
|
|
}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has tnt => |
|
75
|
|
|
|
|
|
|
is => 'rw', |
|
76
|
|
|
|
|
|
|
isa => 'Object', |
|
77
|
|
|
|
|
|
|
lazy => 1, |
|
78
|
|
|
|
|
|
|
builder => sub { |
|
79
|
|
|
|
|
|
|
my ($self) = @_; |
|
80
|
|
|
|
|
|
|
return $self->_build_msgpack_tnt if $self->msgpack; |
|
81
|
|
|
|
|
|
|
return $self->_build_lts_tnt; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _build_msgpack_tnt { |
|
86
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
87
|
0
|
|
|
|
|
|
require DR::Tnt; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $driver = 'sync'; |
|
90
|
0
|
0
|
|
|
|
|
$driver = 'coro' if $self->coro; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my ($host, $port, $user, $password) = |
|
94
|
|
|
|
|
|
|
($self->host, $self->port, $self->user, $self->password); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# in test |
|
97
|
0
|
0
|
|
|
|
|
if ($self->_fake_msgpack_tnt) { |
|
98
|
0
|
|
|
|
|
|
$host = '127.0.0.1'; |
|
99
|
0
|
|
|
|
|
|
$port = $self->_fake_msgpack_tnt->port; |
|
100
|
0
|
|
|
|
|
|
$user = 'test'; |
|
101
|
0
|
|
|
|
|
|
$password = 'test'; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
return DR::Tnt::tarantool( |
|
105
|
|
|
|
|
|
|
host => $host, |
|
106
|
|
|
|
|
|
|
port => $port, |
|
107
|
|
|
|
|
|
|
user => $user, |
|
108
|
|
|
|
|
|
|
password => $password, |
|
109
|
|
|
|
|
|
|
raise_error => 1, |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
%{ $self->connect_opts }, |
|
|
0
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
driver => $driver, |
|
115
|
|
|
|
|
|
|
hashify_tuples => 1, |
|
116
|
|
|
|
|
|
|
utf8 => 0, |
|
117
|
|
|
|
|
|
|
) |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _build_lts_tnt { |
|
121
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
122
|
0
|
|
|
|
|
|
require DR::Tarantool; |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
my ($host, $port) = ($self->host, $self->port); |
|
125
|
0
|
0
|
|
|
|
|
if ($self->_fake_lts_tnt) { |
|
126
|
0
|
|
|
|
|
|
$host = '127.0.0.1'; |
|
127
|
0
|
|
|
|
|
|
$port = $self->_fake_lts_tnt->primary_port; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
unless ($self->coro) { |
|
131
|
0
|
0
|
|
|
|
|
if (DR::Tarantool->can('rsync_tarantool')) { |
|
132
|
|
|
|
|
|
|
return DR::Tarantool::rsync_tarantool( |
|
133
|
|
|
|
|
|
|
port => $port, |
|
134
|
|
|
|
|
|
|
host => $host, |
|
135
|
|
|
|
|
|
|
spaces => {}, |
|
136
|
0
|
|
|
|
|
|
%{ $self->connect_opts } |
|
|
0
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
); |
|
138
|
|
|
|
|
|
|
} else { |
|
139
|
|
|
|
|
|
|
return DR::Tarantool::tarantool( |
|
140
|
|
|
|
|
|
|
port => $port, |
|
141
|
|
|
|
|
|
|
host => $host, |
|
142
|
|
|
|
|
|
|
spaces => {}, |
|
143
|
0
|
|
|
|
|
|
%{ $self->connect_opts } |
|
|
0
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
return DR::Tarantool::coro_tarantool( |
|
149
|
|
|
|
|
|
|
port => $port, |
|
150
|
|
|
|
|
|
|
host => $host, |
|
151
|
|
|
|
|
|
|
spaces => {}, |
|
152
|
0
|
|
|
|
|
|
%{ $self->connect_opts } |
|
|
0
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |