tarantool16 0.0.8 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 63c6f3dd4aa811b1cb867865472ca56c2ebafb90
4
- data.tar.gz: 009fceed5451625228f289889a4b000d6595e6ea
2
+ SHA256:
3
+ metadata.gz: 63754d46ed07662ab888812c32e83af56392c9e0e7793c6cc2c9d0eef8d380b8
4
+ data.tar.gz: 88d78ada3ee0d7f25accb2467a08e6c136196e8dfbf8df30029a077f141d6298
5
5
  SHA512:
6
- metadata.gz: 52ec4a7a31e37024fc0aac40f23812d6fa0a153526fd4eb5ca017c5d8bc4ea084a590e9ed0c1c6f043a85ff7485de956657ede835f81e89cc54cbc6907b04fc8
7
- data.tar.gz: 2a82a91c5288ced4bdbe9f0e878464cc07aff7704314f398025b21785ee7a40291e5088c88144eac1f29b0a55a8864ee5900ff7a2bfe36c620c95d8a395b65fa
6
+ metadata.gz: d1405326f3ee82b5ee9e18208fa80539e03b654646e7b2e2a505bb1c600ae3da4b4752309555623d05c5817797fa14fc39cf74c961968408b16fde0aa6e2abb6
7
+ data.tar.gz: bf92e1697011c27853b6d954766d97a1a2a970a042c9777a917b68d4bf6d0dca6de93d9991c0f553a6dad92e527874467c9d4216ca9ef7b65fe5ec281f3ea87d
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Sokolov Yura aka funny_falcon
1
+ Copyright (c) 2014-2016 Sokolov Yura aka funny_falcon
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Tarantool16
2
2
 
3
- This is adapter for [tarantool](http://tarantool.org) version 1.6.
3
+ This is adapter for [tarantool](http://tarantool.org) version 1.6 and 1.7.
4
4
 
5
5
  (adapter for version <=1.5 is called [tarantool](https://github.org/tarantoool/tarantool-ruby))
6
6
 
@@ -29,6 +29,9 @@ require 'tarantool16'
29
29
 
30
30
  db = Tarantool16.new host:'localhost:33013'
31
31
  #db = Tarantool16.new host:'localhost:33013', user:'tester', password:'testpass'
32
+ #db = Tarantool16.new host:['tcp','localhost:33013']
33
+ #db = Tarantool16.new host:['unix','path/to.sock']
34
+ #db = Tarantool16.new unix:'path/to.sock'
32
35
 
33
36
  # select from '_space' space info about 'test' table
34
37
  # returns array of tuples as an array
@@ -71,6 +74,15 @@ tar.update(:_space, {name: 'test'}, {format: [:=, [{name: :id, type: :num}, {nam
71
74
 
72
75
  ## Changelog
73
76
 
77
+ 0.1.0 - breaking change: call now issues request in Tarantool17 format.
78
+ use call16 to issue `call` request to Tarantool16.
79
+ see tests for difference in returned results.
80
+ 0.0.11 - change a way of unix socket option.
81
+ since previos scheme were introduced 12 hours ago,
82
+ i think it is still safe to change it.
83
+ 0.0.10 - a bit of fixes
84
+ 0.0.9 - Fix detection of update operation shape
85
+ Add unix socket connection.
74
86
  0.0.8 - Fix schema read from new tarantool versions
75
87
  Implement UPSERT
76
88
  0.0.7 - Implement EVAL, fix REPLACE
@@ -5,7 +5,19 @@ module Tarantool16
5
5
  autoload :DumbDB, 'tarantool16/dumb_db'
6
6
  def self.new(opts = {})
7
7
  opts = opts.dup
8
- hosts = [opts[:host], opts[:port]].compact.join(':')
8
+ if opts[:unix] && opts[:host]
9
+ raise "`:host` and `:unix` options are mutually exclusive"
10
+ elsif opts[:unix]
11
+ hosts = ["unix", opts[:unix]]
12
+ elsif opts[:host]
13
+ host = opts[:host]
14
+ if Array === host
15
+ hosts = host
16
+ else
17
+ host = [host, opts[:port]].compact.join(':')
18
+ hosts = ["tcp", host]
19
+ end
20
+ end
9
21
  type = opts[:type] && opts[:type].to_s || 'dumb'
10
22
  case type
11
23
  when 'dumb'
@@ -144,13 +144,25 @@ module Tarantool16
144
144
  Option.error(sync, e, nil)
145
145
  end
146
146
 
147
+ def _unix?
148
+ @host[0] == 'unix' || @host[0] == :unix
149
+ end
150
+
151
+ def _tcp?
152
+ @host[0] == 'tcp' || @host[0] == :tcp
153
+ end
154
+
155
+ def _unix_sock_path
156
+ @host[1]
157
+ end
158
+
147
159
  def host_port
148
- @host =~ /^(.*):([^:]+)$/
160
+ @host[1] =~ /^(.*):([^:]+)$/
149
161
  [$1, $2.to_i]
150
162
  end
151
163
 
152
164
  def _ipv6?
153
- @host.count(':') > 1
165
+ @host[1].count(':') > 1
154
166
  end
155
167
 
156
168
  def _insert(space_no, tuple, cb)
@@ -205,7 +217,13 @@ module Tarantool16
205
217
  def _call(name, args, cb)
206
218
  req = {IPROTO_FUNCTION_NAME => name,
207
219
  IPROTO_TUPLE => args}
208
- send_request(REQUEST_TYPE_CALL, req, cb)
220
+ send_request(REQUEST_TYPE_CALL17, req, cb)
221
+ end
222
+
223
+ def _call16(name, args, cb)
224
+ req = {IPROTO_FUNCTION_NAME => name,
225
+ IPROTO_TUPLE => args}
226
+ send_request(REQUEST_TYPE_CALL16, req, cb)
209
227
  end
210
228
 
211
229
  def _eval(expr, args, cb)
@@ -68,16 +68,23 @@ module Tarantool16
68
68
  unless could_be_connected?
69
69
  raise Disconnected, "connection is closed"
70
70
  end
71
- @socket = Socket.new((_ipv6? ? Socket::AF_INET6 : Socket::AF_INET), Socket::SOCK_STREAM)
72
- @socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
73
- @socket.sync = true
74
- sockaddr = Socket.pack_sockaddr_in(*host_port.reverse)
75
- @retry = @reconnect
76
- if @timeout
77
- _connect_nonblock(sockaddr)
71
+ if _unix?
72
+ @socket = Socket.unix(_unix_sock_path)
73
+ elsif _tcp?
74
+ @socket = Socket.new((_ipv6? ? Socket::AF_INET6 : Socket::AF_INET), Socket::SOCK_STREAM)
75
+ @socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
76
+ @socket.sync = true
77
+ sockaddr = Socket.pack_sockaddr_in(*host_port.reverse)
78
+ @retry = @reconnect
79
+ if @timeout
80
+ _connect_nonblock(sockaddr)
81
+ else
82
+ @socket.connect(sockaddr)
83
+ end
78
84
  else
79
- @socket.connect(sockaddr)
85
+ raise "unsupported host option: #{@host.inspect}"
80
86
  end
87
+
81
88
  greeting = _read(IPROTO_GREETING_SIZE)
82
89
  unless greeting && greeting.bytesize == IPROTO_GREETING_SIZE
83
90
  raise Disconnected, "mailformed greeting #{greeting.inspect}"
@@ -124,7 +131,13 @@ module Tarantool16
124
131
  req = req[n..-1]
125
132
  end
126
133
  rescue IO::WaitWritable
127
- _wait_writable(expire - now_f)
134
+ nf = now_f
135
+ if expire <= nf
136
+ raise Timeout, "response timeouted"
137
+ else
138
+ _wait_writable(expire - nf)
139
+ retry
140
+ end
128
141
  rescue Errno::EINTR
129
142
  retry
130
143
  end
@@ -192,7 +205,16 @@ module Tarantool16
192
205
  end
193
206
  end
194
207
 
195
- if defined?(Kgio)
208
+ if (RUBY_VERSION.split('.').map(&:to_i) <=> [2,1]) >= 0
209
+ EXCEPTION_FALSE = {exception: false}.freeze
210
+ def _read_nonblock(n, buf)
211
+ if buf
212
+ @socket.read_nonblock(n, buf, EXCEPTION_FALSE)
213
+ else
214
+ @socket.read_nonblock(n, EXCEPTION_FALSE)
215
+ end
216
+ end
217
+ elsif defined?(Kgio)
196
218
  def _read_nonblock(n, buf)
197
219
  return buf ? Kgio.tryread(@socket, n, buf) : Kgio.tryread(@socket, n)
198
220
  end
@@ -23,7 +23,7 @@ module Tarantool16
23
23
  if code == 0
24
24
  new(sync, nil, data)
25
25
  else
26
- new(sync, ::Tarantool16::DBError.with_code_message(code, data), nil)
26
+ new(sync, ::Tarantool16::DBError.with_code_message(code&(REQUEST_TYPE_ERROR-1), data), nil)
27
27
  end
28
28
  end
29
29
 
@@ -24,16 +24,19 @@ module Tarantool16
24
24
  REQUEST_TYPE_REPLACE = 3
25
25
  REQUEST_TYPE_UPDATE = 4
26
26
  REQUEST_TYPE_DELETE = 5
27
- REQUEST_TYPE_CALL = 6
27
+ REQUEST_TYPE_CALL16 = 6
28
28
  REQUEST_TYPE_AUTHENTICATE = 7
29
29
  REQUEST_TYPE_EVAL = 8
30
30
  REQUEST_TYPE_UPSERT = 9
31
+ REQUEST_TYPE_CALL17 = 10
31
32
  REQUEST_TYPE_ERROR = 1 << 15
32
33
 
33
34
 
34
35
  SPACE_SCHEMA = 272
35
36
  SPACE_SPACE = 280
37
+ SPACE_VSPACE = 281
36
38
  SPACE_INDEX = 288
39
+ SPACE_VINDEX = 289
37
40
  SPACE_FUNC = 296
38
41
  SPACE_USER = 304
39
42
  SPACE_PRIV = 312
@@ -9,7 +9,6 @@ module Tarantool16
9
9
  @future = nil
10
10
  @spaces = nil
11
11
  @defined_fields = {}
12
- _fill_standard_spaces
13
12
  @conn = self.class::Connection.new(@host, @opts)
14
13
  end
15
14
 
@@ -28,14 +27,6 @@ module Tarantool16
28
27
  end
29
28
  end
30
29
 
31
- def _fill_standard_spaces
32
- rf = @defined_fields
33
- rf[SPACE_INDEX] =
34
- [%w{sid num}, %w{iid num}, %w{name str},
35
- %w{type str}, %w{unique num}, %w{part_count num},
36
- {name: 'parts', type: [:num, :str], tail: true}]
37
- end
38
-
39
30
  def _synchronized
40
31
  raise "Override #_synchronized"
41
32
  end
@@ -78,7 +69,7 @@ module Tarantool16
78
69
  _synchronized do
79
70
  _fill_spaces(r.data)
80
71
  spaces = @spaces
81
- _select(SPACE_INDEX, 0, [], 0, 2**30, :all, false, fill_indexes)
72
+ _select(SPACE_VINDEX, 0, [], 0, 2**30, :all, false, fill_indexes)
82
73
  end
83
74
  end
84
75
  end
@@ -96,7 +87,7 @@ module Tarantool16
96
87
  end
97
88
  end
98
89
  end
99
- _select(SPACE_SPACE, 0, [], 0, 2**30, :all, false, fill_spaces)
90
+ _select(SPACE_VSPACE, 0, [], 0, 2**30, :all, false, fill_spaces)
100
91
  return future
101
92
  end
102
93
  end
@@ -187,7 +178,7 @@ module Tarantool16
187
178
 
188
179
  def _update(sno, ino, key, ops, need_hash, cb)
189
180
  ino = 0 if ino.nil? && key.is_a?(Array)
190
- ops_good = ops.is_a?(Array) && ops.all?{|a| ops[1].is_a?(Integer)}
181
+ ops_good = ops.is_a?(Array) && ops.all?{|a| a[1].is_a?(Integer)}
191
182
  if sno.is_a?(Integer) && ino.is_a?(Integer) && key.is_a?(Array) && ops_good
192
183
  return conn._update(sno, ino, key, ops, cb)
193
184
  end
@@ -202,7 +193,7 @@ module Tarantool16
202
193
 
203
194
  def _upsert(sno, ino, tuple_key, ops, need_hash, cb)
204
195
  ino = 0 if ino.nil?
205
- ops_good = ops.is_a?(Array) && ops.all?{|a| ops[1].is_a?(Integer)}
196
+ ops_good = ops.is_a?(Array) && ops.all?{|a| a[1].is_a?(Integer)}
206
197
  if sno.is_a?(Integer) && ino.is_a?(Integer) && tuple_key.is_a?(Array) && ops_good
207
198
  return conn._upsert(sno, ino, tuple_key, ops, cb)
208
199
  end
@@ -220,6 +211,10 @@ module Tarantool16
220
211
  conn._call(name, args, cb)
221
212
  end
222
213
 
214
+ def _call16(name, args, cb)
215
+ conn._call16(name, args, cb)
216
+ end
217
+
223
218
  def _eval(expr, args, cb)
224
219
  conn._eval(expr, args, cb)
225
220
  end
@@ -69,6 +69,10 @@ module Tarantool16
69
69
  _call(name, args, RETURN_OR_RAISE)
70
70
  end
71
71
 
72
+ def call16(name, args)
73
+ _call16(name, args, RETURN_OR_RAISE)
74
+ end
75
+
72
76
  def eval(expr, args)
73
77
  _eval(expr, args, RETURN_OR_RAISE)
74
78
  end
@@ -92,34 +96,23 @@ module Tarantool16
92
96
  UNDEF = Object.new.freeze
93
97
  def initialize
94
98
  @r = UNDEF
95
- @cb = nil
96
99
  end
97
100
  def then(cb)
98
101
  unless @r.equal? UNDEF
99
102
  return cb.call(@r)
100
103
  end
101
- if @cb
102
- raise "Blocking future accepts only 1 callback"
103
- end
104
- @cb = cb
104
+ raise "DumbDB::ShemaFuture future is not real future :-("
105
105
  end
106
106
 
107
107
  def then_blk
108
108
  unless @r.equal? UNDEF
109
109
  return yield @r
110
110
  end
111
- if @cb
112
- raise "Blocking future accepts only 1 callback"
113
- end
114
- @cb = lambda{|r| yield r}
111
+ raise "DumbDB::ShemaFuture future is not real future :-("
115
112
  end
116
113
 
117
114
  def set(r)
118
115
  @r = r
119
- if cb = @cb
120
- @cb = nil
121
- cb.call(r)
122
- end
123
116
  end
124
117
  end
125
118
 
@@ -24,7 +24,7 @@ module Tarantool16
24
24
  4=> :ER_TUPLE_NOT_FOUND,
25
25
  5=> :ER_UNSUPPORTED,
26
26
  6=> :ER_NONMASTER,
27
- 7=> :ER_SECONDARY,
27
+ 7=> :ER_READONLY,
28
28
  8=> :ER_INJECTION,
29
29
  9=> :ER_CREATE_SPACE,
30
30
  10=> :ER_SPACE_EXISTS,
@@ -35,7 +35,7 @@ module Tarantool16
35
35
  15=> :ER_LAST_DROP,
36
36
  16=> :ER_TUPLE_FORMAT_LIMIT,
37
37
  17=> :ER_DROP_PRIMARY_KEY,
38
- 18=> :ER_KEY_FIELD_TYPE,
38
+ 18=> :ER_KEY_PART_TYPE,
39
39
  19=> :ER_EXACT_MATCH,
40
40
  20=> :ER_INVALID_MSGPACK,
41
41
  21=> :ER_PROC_RET,
@@ -55,10 +55,82 @@ module Tarantool16
55
55
  35=> :ER_NO_SUCH_INDEX,
56
56
  36=> :ER_NO_SUCH_SPACE,
57
57
  37=> :ER_NO_SUCH_FIELD,
58
- 38=> :ER_SPACE_ARITY,
59
- 39=> :ER_INDEX_ARITY,
58
+ 38=> :ER_SPACE_FIELD_COUNT,
59
+ 39=> :ER_INDEX_FIELD_COUNT,
60
60
  40=> :ER_WAL_IO,
61
61
  41=> :ER_MORE_THAN_ONE_TUPLE,
62
+ 42=> :ER_ACCESS_DENIED,
63
+ 43=> :ER_CREATE_USER,
64
+ 44=> :ER_DROP_USER,
65
+ 45=> :ER_NO_SUCH_USER,
66
+ 46=> :ER_USER_EXISTS,
67
+ 47=> :ER_PASSWORD_MISMATCH,
68
+ 48=> :ER_UNKNOWN_REQUEST_TYPE,
69
+ 49=> :ER_UNKNOWN_SCHEMA_OBJECT,
70
+ 50=> :ER_CREATE_FUNCTION,
71
+ 51=> :ER_NO_SUCH_FUNCTION,
72
+ 52=> :ER_FUNCTION_EXISTS,
73
+ 53=> :ER_FUNCTION_ACCESS_DENIED,
74
+ 54=> :ER_FUNCTION_MAX,
75
+ 55=> :ER_SPACE_ACCESS_DENIED,
76
+ 56=> :ER_USER_MAX,
77
+ 57=> :ER_NO_SUCH_ENGINE,
78
+ 58=> :ER_RELOAD_CFG,
79
+ 59=> :ER_CFG,
80
+ 60=> :ER_SOPHIA,
81
+ 61=> :ER_LOCAL_SERVER_IS_NOT_ACTIVE,
82
+ 62=> :ER_UNKNOWN_SERVER,
83
+ 63=> :ER_CLUSTER_ID_MISMATCH,
84
+ 64=> :ER_INVALID_UUID,
85
+ 65=> :ER_CLUSTER_ID_IS_RO,
86
+ 66=> :ER_RESERVED66,
87
+ 67=> :ER_SERVER_ID_IS_RESERVED,
88
+ 68=> :ER_INVALID_ORDER,
89
+ 69=> :ER_MISSING_REQUEST_FIELD,
90
+ 70=> :ER_IDENTIFIER,
91
+ 71=> :ER_DROP_FUNCTION,
92
+ 72=> :ER_ITERATOR_TYPE,
93
+ 73=> :ER_REPLICA_MAX,
94
+ 74=> :ER_INVALID_XLOG,
95
+ 75=> :ER_INVALID_XLOG_NAME,
96
+ 76=> :ER_INVALID_XLOG_ORDER,
97
+ 77=> :ER_NO_CONNECTION,
98
+ 78=> :ER_TIMEOUT,
99
+ 79=> :ER_ACTIVE_TRANSACTION,
100
+ 80=> :ER_NO_ACTIVE_TRANSACTION,
101
+ 81=> :ER_CROSS_ENGINE_TRANSACTION,
102
+ 82=> :ER_NO_SUCH_ROLE,
103
+ 83=> :ER_ROLE_EXISTS,
104
+ 84=> :ER_CREATE_ROLE,
105
+ 85=> :ER_INDEX_EXISTS,
106
+ 86=> :ER_TUPLE_REF_OVERFLOW,
107
+ 87=> :ER_ROLE_LOOP,
108
+ 88=> :ER_GRANT,
109
+ 89=> :ER_PRIV_GRANTED,
110
+ 90=> :ER_ROLE_GRANTED,
111
+ 91=> :ER_PRIV_NOT_GRANTED,
112
+ 92=> :ER_ROLE_NOT_GRANTED,
113
+ 93=> :ER_MISSING_SNAPSHOT,
114
+ 94=> :ER_CANT_UPDATE_PRIMARY_KEY,
115
+ 95=> :ER_UPDATE_INTEGER_OVERFLOW,
116
+ 96=> :ER_GUEST_USER_PASSWORD,
117
+ 97=> :ER_TRANSACTION_CONFLICT,
118
+ 98=> :ER_UNSUPPORTED_ROLE_PRIV,
119
+ 99=> :ER_LOAD_FUNCTION,
120
+ 100=> :ER_FUNCTION_LANGUAGE,
121
+ 101=> :ER_RTREE_RECT,
122
+ 102=> :ER_PROC_C,
123
+ 103=> :ER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPE,
124
+ 104=> :ER_PROTOCOL,
125
+ 105=> :ER_UPSERT_UNIQUE_SECONDARY_KEY,
126
+ 106=> :ER_WRONG_INDEX_RECORD,
127
+ 107=> :ER_WRONG_INDEX_PARTS,
128
+ 108=> :ER_WRONG_INDEX_OPTIONS,
129
+ 109=> :ER_WRONG_SCHEMA_VERSION,
130
+ 110=> :ER_SLAB_ALLOC_MAX,
131
+ 111=> :ER_WRONG_SPACE_OPTIONS,
132
+ 112=> :ER_UNSUPPORTED_INDEX_FEATURE,
133
+ 113=> :ER_VIEW_IS_RO,
62
134
  }.each do |n, s|
63
135
  klass = Class.new(KnownDBError)
64
136
  klass.return_code = n
@@ -18,9 +18,10 @@ module Tarantool16
18
18
  @field_names = {}
19
19
  @fields = []
20
20
  @has_tail = false
21
- flds.each_with_index do |fld, i|
21
+ flds.each_with_index do |fld, i; name|
22
22
  if @has_tail
23
- raise "no fields allowed after tail: #{flds}"
23
+ $stderr.puts "no fields allowed after tail: #{flds}"
24
+ break
24
25
  end
25
26
  case fld
26
27
  when String, Symbol
@@ -33,7 +34,12 @@ module Tarantool16
33
34
  type = fld['type'] || fld[:type]
34
35
  tail = fld['tail'] || fld[:tail]
35
36
  end
37
+ unless name.is_a?(String) || name.is_a?(Symbol)
38
+ $stderr.puts "no field name found for field_#{i} in #{flds}"
39
+ name = "field_#{i}"
40
+ end
36
41
  name_s = name.to_sym
42
+ name = name.to_s
37
43
  field = Field.new(name_s, i, type)
38
44
  @field_names[name] = field
39
45
  @field_names[name_s] = field
@@ -41,6 +47,7 @@ module Tarantool16
41
47
  @fields << field
42
48
  @has_tail = true if tail
43
49
  end
50
+ # refresh indices ?
44
51
  if @index_defs
45
52
  self.indices= @index_defs
46
53
  end
@@ -182,12 +189,12 @@ module Tarantool16
182
189
 
183
190
  def map_ops(ops)
184
191
  ops.map do |op|
185
- case _1 = op[1]
192
+ case op1 = op[1]
186
193
  when Integer
187
194
  op
188
195
  when Symbol, String
189
196
  _op = op.dup
190
- _op[1] = @field_names[_1].pos
197
+ _op[1] = @field_names[op1].pos
191
198
  _op
192
199
  when Array
193
200
  fld_pos = case op[0]
@@ -198,7 +205,7 @@ module Tarantool16
198
205
  else
199
206
  raise "No field #{op[0].inspect} in #{name_sid}"
200
207
  end
201
- _1.dup.insert(1, fld_pos)
208
+ op1.dup.insert(1, fld_pos)
202
209
  end
203
210
  end
204
211
  end
@@ -1,3 +1,3 @@
1
1
  module Tarantool16
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", ">= 0.0.0"
23
24
 
24
25
  spec.add_dependency "msgpack", ">= 0.5.11"
25
26
  end
@@ -1,20 +1,23 @@
1
1
  local log = require 'log'
2
2
  box.cfg{
3
3
  listen = 33013,
4
- wal_dir='.',
5
- snap_dir='.',
4
+ memtx_dir='.',
5
+ wal_mode='none',
6
6
  }
7
- if not box.space.test then
8
- local s1 = box.schema.space.create('test', {id = 513, if_not_exists = true})
9
- local ip = s1:create_index('primary', {type = 'hash', parts = {1, 'NUM'}, if_not_exists = true})
10
- local iname = s1:create_index('name', {type = 'tree', parts = {2, 'STR'}, if_not_exists = true})
11
- local irtree = s1:create_index('point', {type = 'rtree', unique=false, parts = {3, 'ARRAY'}, if_not_exists = true})
12
- local ipname = s1:create_index('id_name', {type = 'tree', parts = {1, 'NUM', 2, 'STR'}})
13
- end
14
- if not box.space.test1 then
15
- local s2 = box.schema.space.create('test1', {id = 514, if_not_exists = true})
16
- local ip = s2:create_index('primary', {type = 'hash', parts = {1, 'NUM'}, if_not_exists = true})
17
- end
7
+ box.once('initbox', function()
8
+ local s1 = box.schema.space.create('test', {id = 513, if_not_exists = true})
9
+ local ip = s1:create_index('primary', {type = 'hash', parts = {1, 'unsigned'}, if_not_exists = true})
10
+ local iname = s1:create_index('name', {type = 'tree', parts = {2, 'STR'}, if_not_exists = true})
11
+ local irtree = s1:create_index('point', {type = 'rtree', unique=false, parts = {3, 'ARRAY'}, if_not_exists = true})
12
+ local ipname = s1:create_index('id_name', {type = 'tree', parts = {1, 'unsigned', 2, 'STR'}})
13
+ local s2 = box.schema.space.create('test1', {id = 514, if_not_exists = true})
14
+ local ip = s2:create_index('primary', {type = 'hash', parts = {1, 'unsigned'}, if_not_exists = true})
15
+
16
+ box.schema.user.create('tester', {password='testpass'})
17
+ box.schema.user.grant('tester', 'read,write,execute', 'universe')
18
+ box.schema.func.create('reseed')
19
+ box.schema.func.create('func1')
20
+ end)
18
21
 
19
22
  function reseed()
20
23
  local s1 = box.space.test
@@ -27,15 +30,11 @@ function reseed()
27
30
  s2:insert{2, "world", {3, 4}, 200}
28
31
  end
29
32
 
30
- pcall(function()
31
- box.schema.user.grant('guest', 'read,write,execute', 'universe')
32
- end)
33
-
34
- if not box.schema.user.exists('tester') then
35
- box.schema.user.create('tester', {password='testpass'})
36
- box.schema.user.grant('tester', 'read,write,execute', 'universe')
33
+ function func1(i)
34
+ return i+1
37
35
  end
38
36
 
37
+ box.schema.user.grant('guest', 'read,write,execute', 'universe')
39
38
  local console = require 'console'
40
39
  console.listen '0.0.0.0:33015'
41
40
 
@@ -3,7 +3,7 @@ require 'minitest/spec'
3
3
  require 'fileutils'
4
4
  require 'tarantool16'
5
5
  require 'socket'
6
-
6
+ Tarantool16::DumbDB # make sure to autoload before running tests
7
7
 
8
8
  class Spawn
9
9
  DIR = File.expand_path('..', __FILE__)
@@ -71,6 +71,11 @@ describe 'DumbConnection' do
71
71
  db.delete(:test, "world", index: 1).must_equal [r2]
72
72
  end
73
73
 
74
+ it "should call" do
75
+ db.call("func1", [1]).must_equal [2]
76
+ db.call16("func1", [1]).must_equal [[2]]
77
+ end
78
+
74
79
  it "should eval" do
75
80
  db.eval("local a, b = ... ; return a + b", [1, 2]).must_equal [3]
76
81
  end
@@ -118,7 +123,7 @@ describe 'DumbConnection' do
118
123
  Spawn.with_pause do
119
124
  proc {
120
125
  db.get(:test, 1)
121
- }.must_raise Tarantool16::Connection::CouldNotConnect
126
+ }.must_raise ::Tarantool16::Connection::CouldNotConnect
122
127
  end
123
128
  end
124
129
 
@@ -127,7 +132,7 @@ describe 'DumbConnection' do
127
132
  Spawn.with_pause do
128
133
  proc {
129
134
  db.get(:test, 1)
130
- }.must_raise Tarantool16::Connection::Timeout
135
+ }.must_raise ::Tarantool16::Connection::Timeout
131
136
  end
132
137
  end
133
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarantool16
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sokolov Yura aka funny_falcon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: msgpack
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
114
  - !ruby/object:Gem::Version
101
115
  version: '0'
102
116
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.4.3
117
+ rubygems_version: 3.1.2
105
118
  signing_key:
106
119
  specification_version: 4
107
120
  summary: adapter for Tarantool 1.6