couchbase-jruby-client 0.2.2-java → 1.0.4-java
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 +4 -4
- data/.rubocop.yml +103 -0
- data/.ruby-version +1 -1
- data/Rakefile +13 -2
- data/couchbase-jruby-client.gemspec +7 -6
- data/lib/couchbase/bucket.rb +11 -338
- data/lib/couchbase/cluster.rb +10 -88
- data/lib/couchbase/configuration.rb +39 -0
- data/lib/couchbase/design_doc.rb +18 -73
- data/lib/couchbase/document.rb +34 -0
- data/lib/couchbase/error.rb +0 -35
- data/lib/couchbase/operations.rb +60 -40
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase/view.rb +55 -345
- data/lib/couchbase.rb +37 -141
- data/lib/jars/couchbase-core-io-1.1.4.jar +0 -0
- data/lib/jars/couchbase-java-client-2.1.4.jar +0 -0
- data/lib/jars/rxjava-1.0.8.jar +0 -0
- data/lib/jars/rxjruby-0.0.1.jar +0 -0
- data/test/{test_cas.rb → helper.rb} +15 -10
- data/test/test_bucket.rb +14 -228
- data/test/test_cluster.rb +1 -29
- data/test/test_configuration.rb +51 -0
- data/test/test_couchbase.rb +28 -28
- data/test/test_design_doc.rb +29 -0
- data/test/test_document.rb +51 -0
- data/test/test_operations.rb +49 -0
- data/test/test_view.rb +62 -116
- metadata +43 -125
- data/lib/couchbase/async/callback.rb +0 -38
- data/lib/couchbase/async/queue.rb +0 -26
- data/lib/couchbase/async.rb +0 -32
- data/lib/couchbase/constants.rb +0 -29
- data/lib/couchbase/operations/arithmetic.rb +0 -290
- data/lib/couchbase/operations/delete.rb +0 -115
- data/lib/couchbase/operations/design_docs.rb +0 -99
- data/lib/couchbase/operations/fetch.rb +0 -33
- data/lib/couchbase/operations/get.rb +0 -303
- data/lib/couchbase/operations/stats.rb +0 -42
- data/lib/couchbase/operations/store.rb +0 -463
- data/lib/couchbase/operations/touch.rb +0 -140
- data/lib/couchbase/operations/unlock.rb +0 -209
- data/lib/couchbase/operations/utils.rb +0 -68
- data/lib/couchbase/query.rb +0 -76
- data/lib/couchbase/result.rb +0 -60
- data/lib/couchbase/transcoder.rb +0 -81
- data/lib/couchbase/utils.rb +0 -62
- data/lib/couchbase/view_row.rb +0 -227
- data/lib/jars/commons-codec-1.5.jar +0 -0
- data/lib/jars/couchbase-client-1.3.2-javadoc.jar +0 -0
- data/lib/jars/couchbase-client-1.3.2-sources.jar +0 -0
- data/lib/jars/couchbase-client-1.3.2.jar +0 -0
- data/lib/jars/httpcore-4.3.1.jar +0 -0
- data/lib/jars/httpcore-nio-4.3.1.jar +0 -0
- data/lib/jars/jettison-1.1.jar +0 -0
- data/lib/jars/netty-3.5.5.Final.jar +0 -0
- data/lib/jars/spymemcached-2.10.5-javadoc.jar +0 -0
- data/lib/jars/spymemcached-2.10.5-sources.jar +0 -0
- data/lib/jars/spymemcached-2.10.5.jar +0 -0
- data/tasks/benchmark.rake +0 -6
- data/tasks/test.rake +0 -36
- data/tasks/util.rake +0 -21
- data/test/mock.rb +0 -85
- data/test/profile/.gitignore +0 -1
- data/test/profile/.jrubyrc +0 -722
- data/test/profile/Gemfile +0 -7
- data/test/profile/benchmark.rb +0 -177
- data/test/profile/profile.rb +0 -59
- data/test/setup.rb +0 -74
- data/test/test_arithmetic.rb +0 -155
- data/test/test_async.rb +0 -24
- data/test/test_couchbase_rails_cache_store.rb +0 -341
- data/test/test_delete.rb +0 -139
- data/test/test_design_docs.rb +0 -67
- data/test/test_errors.rb +0 -74
- data/test/test_fetch.rb +0 -71
- data/test/test_format.rb +0 -142
- data/test/test_get.rb +0 -363
- data/test/test_query.rb +0 -23
- data/test/test_result.rb +0 -15
- data/test/test_stats.rb +0 -44
- data/test/test_store.rb +0 -203
- data/test/test_touch.rb +0 -90
- data/test/test_unlock.rb +0 -89
- data/test/test_utils.rb +0 -67
- data/test/test_version.rb +0 -28
- data/test/test_view_row.rb +0 -74
data/test/profile/benchmark.rb
DELETED
@@ -1,177 +0,0 @@
|
|
1
|
-
# Useful environment variables:
|
2
|
-
#
|
3
|
-
# LOOPS (50000)
|
4
|
-
# how many time run exercises
|
5
|
-
#
|
6
|
-
# HOST (127.0.0.1)
|
7
|
-
# the host where cluster is running. benchmark will use default ports to
|
8
|
-
# connect to it (11211 and 8091)
|
9
|
-
#
|
10
|
-
# STACK_DEPTH (0)
|
11
|
-
# the depth of stack where exercises are run. the benchmark will
|
12
|
-
# recursively go to given depth before run
|
13
|
-
#
|
14
|
-
# TEST ('')
|
15
|
-
# use to run specific test (possible values are: set, get, get-multi,
|
16
|
-
# append, prepend, delete, get-missing, append-missing, prepend-missing,
|
17
|
-
# set-large, get-large)
|
18
|
-
#
|
19
|
-
# CLIENT ('')
|
20
|
-
# use to run with specific client (possible values are: couchbase, dalli,
|
21
|
-
# memcached, memcached:buffer)
|
22
|
-
#
|
23
|
-
# DEBUG ('')
|
24
|
-
# show exceptions
|
25
|
-
#
|
26
|
-
|
27
|
-
require 'rubygems'
|
28
|
-
require 'bundler/setup'
|
29
|
-
|
30
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "..", "lib")
|
31
|
-
require 'couchbase'
|
32
|
-
require 'benchmark/ips'
|
33
|
-
|
34
|
-
puts `uname -a`
|
35
|
-
puts File.readlines('/proc/cpuinfo').sort.uniq.grep(/model name|cpu cores/) rescue nil
|
36
|
-
puts RUBY_DESCRIPTION
|
37
|
-
|
38
|
-
class Bench
|
39
|
-
|
40
|
-
def initialize
|
41
|
-
|
42
|
-
puts "PID is #{Process.pid}"
|
43
|
-
|
44
|
-
@value = { 'im' => [ 'testing', 'stuff' ] }
|
45
|
-
|
46
|
-
puts "Raw value size is: #{@value.size} bytes"
|
47
|
-
|
48
|
-
@keys = [
|
49
|
-
@k1 = "Short",
|
50
|
-
@k2 = "Sym1-2-3::45" * 8,
|
51
|
-
@k3 = "Long" * 40,
|
52
|
-
@k4 = "Medium" * 8,
|
53
|
-
@k5 = "Medium2" * 8,
|
54
|
-
@k6 = "Long3" * 40]
|
55
|
-
|
56
|
-
@cb = Couchbase.new
|
57
|
-
@cl = @cb.client
|
58
|
-
|
59
|
-
# Ensure it is JITed
|
60
|
-
2_000.times do
|
61
|
-
@cb.set(@k1, 'a')
|
62
|
-
@cb.get(@k1)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def run
|
67
|
-
Benchmark.ips do |x|
|
68
|
-
x.report('jruby set') do
|
69
|
-
@cb.set @k1, @value
|
70
|
-
@cb.set @k2, @value
|
71
|
-
@cb.set @k3, @value
|
72
|
-
end
|
73
|
-
|
74
|
-
x.report('java set') do
|
75
|
-
@cl.set(@k1, MultiJson.dump(@value)).get
|
76
|
-
@cl.set(@k2, MultiJson.dump(@value)).get
|
77
|
-
@cl.set(@k3, MultiJson.dump(@value)).get
|
78
|
-
end
|
79
|
-
|
80
|
-
x.report('jruby get') do
|
81
|
-
@cb.get @k1
|
82
|
-
@cb.get @k2
|
83
|
-
@cb.get @k3
|
84
|
-
end
|
85
|
-
|
86
|
-
x.report('java get') do
|
87
|
-
MultiJson.load @cl.get(@k1)
|
88
|
-
MultiJson.load @cl.get(@k2)
|
89
|
-
MultiJson.load @cl.get(@k3)
|
90
|
-
end
|
91
|
-
|
92
|
-
x.report('jruby get multi') do
|
93
|
-
@cb.get([@k1, @k2, @k3])
|
94
|
-
end
|
95
|
-
|
96
|
-
x.report('java get multi') do
|
97
|
-
@cl.getBulk([@k1, @k2, @k3])
|
98
|
-
end
|
99
|
-
|
100
|
-
x.report('jruby delete') do
|
101
|
-
@cb.set @k1, ''
|
102
|
-
@cb.set @k2, ''
|
103
|
-
@cb.set @k3, ''
|
104
|
-
@cb.delete(@k1)
|
105
|
-
@cb.delete(@k2)
|
106
|
-
@cb.delete(@k3)
|
107
|
-
end
|
108
|
-
|
109
|
-
x.report('java delete') do
|
110
|
-
@cl.set @k1, ''
|
111
|
-
@cl.set @k2, ''
|
112
|
-
@cl.set @k3, ''
|
113
|
-
@cl.delete @k1
|
114
|
-
@cl.delete @k2
|
115
|
-
@cl.delete @k3
|
116
|
-
end
|
117
|
-
|
118
|
-
x.report('jruby get missing') do
|
119
|
-
@cb.get(@k1, quiet: true)
|
120
|
-
@cb.get(@k2, quiet: true)
|
121
|
-
@cb.get(@k3, quiet: true)
|
122
|
-
end
|
123
|
-
|
124
|
-
x.report('java get missing') do
|
125
|
-
@cl.get @k1
|
126
|
-
@cl.get @k2
|
127
|
-
@cl.get @k3
|
128
|
-
end
|
129
|
-
|
130
|
-
# x.report('jruby async set') do
|
131
|
-
# @cb.run do
|
132
|
-
# 100.times do
|
133
|
-
# @cb.set @k1, @value
|
134
|
-
# @cb.set @k2, @value
|
135
|
-
# @cb.set @k3, @value
|
136
|
-
# end
|
137
|
-
# end
|
138
|
-
# end
|
139
|
-
|
140
|
-
# x.report('java async set') do
|
141
|
-
# futures = []
|
142
|
-
# 100.times do
|
143
|
-
# futures << @cb.client.set(@k1, MultiJson.dump(@value))
|
144
|
-
# futures << @cb.client.set(@k2, MultiJson.dump(@value))
|
145
|
-
# futures << @cb.client.set(@k3, MultiJson.dump(@value))
|
146
|
-
# end
|
147
|
-
# futures.each(&:get)
|
148
|
-
# end
|
149
|
-
|
150
|
-
# x.report('jruby async get') do
|
151
|
-
# @cb.run do
|
152
|
-
# 100.times do
|
153
|
-
# @cb.get @k1
|
154
|
-
# @cb.get @k2
|
155
|
-
# @cb.get @k3
|
156
|
-
# end
|
157
|
-
# end
|
158
|
-
# end
|
159
|
-
|
160
|
-
# x.report('java async get') do
|
161
|
-
# futures = []
|
162
|
-
# 100.times do
|
163
|
-
# futures << @cb.client.asyncGet(@k1)
|
164
|
-
# futures << @cb.client.asyncGet(@k2)
|
165
|
-
# futures << @cb.client.asyncGet(@k3)
|
166
|
-
# end
|
167
|
-
# futures.each(&:get)
|
168
|
-
# end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
@cb.disconnect
|
173
|
-
end
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
Bench.new.run
|
data/test/profile/profile.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler/setup'
|
4
|
-
|
5
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "..", "lib")
|
6
|
-
require 'couchbase'
|
7
|
-
require 'jruby/profiler'
|
8
|
-
|
9
|
-
puts `uname -a`
|
10
|
-
puts File.readlines('/proc/cpuinfo').sort.uniq.grep(/model name|cpu cores/) rescue nil
|
11
|
-
puts RUBY_DESCRIPTION
|
12
|
-
|
13
|
-
class Profile
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
|
17
|
-
puts "PID is #{Process.pid}"
|
18
|
-
|
19
|
-
@value = { 'im' => [ 'testing', 'stuff' ] }
|
20
|
-
|
21
|
-
puts "Raw value size is: #{@value.size} bytes"
|
22
|
-
|
23
|
-
@keys = [
|
24
|
-
@k1 = "Short",
|
25
|
-
@k2 = "Sym1-2-3::45" * 8,
|
26
|
-
@k3 = "Long" * 40,
|
27
|
-
@k4 = "Medium" * 8,
|
28
|
-
@k5 = "Medium2" * 8,
|
29
|
-
@k6 = "Long3" * 40]
|
30
|
-
|
31
|
-
@cb = Couchbase.new
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def run
|
37
|
-
profile_data = JRuby::Profiler.profile do
|
38
|
-
2_000.times do
|
39
|
-
@cb.set(@k1, @value)
|
40
|
-
@cb.set(@k2, @value)
|
41
|
-
@cb.set(@k3, @value)
|
42
|
-
end
|
43
|
-
|
44
|
-
2_000.times do
|
45
|
-
@cb.get(@k1)
|
46
|
-
@cb.get(@k2)
|
47
|
-
@cb.get(@k3)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data)
|
52
|
-
profile_printer.printProfile(STDOUT)
|
53
|
-
|
54
|
-
@cb.disconnect
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
Profile.new.run
|
data/test/setup.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Author:: Couchbase <info@couchbase.com>
|
2
|
-
# Copyright:: 2011, 2012 Couchbase, Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
gem 'minitest'
|
19
|
-
require 'coveralls'
|
20
|
-
Coveralls.wear!
|
21
|
-
require 'minitest'
|
22
|
-
gem 'mocha'
|
23
|
-
require 'mocha/setup'
|
24
|
-
require 'couchbase'
|
25
|
-
require 'open-uri'
|
26
|
-
require 'ostruct'
|
27
|
-
require_relative 'mock'
|
28
|
-
require 'pry'
|
29
|
-
|
30
|
-
# Surpress connection logging
|
31
|
-
# java_import java.lang.System
|
32
|
-
# java_import java.util.logging.Logger
|
33
|
-
# java_import java.util.logging.Level
|
34
|
-
|
35
|
-
# properties = System.getProperties
|
36
|
-
# properties.put("net.spy.log.LoggerImpl", "net.spy.memcached.compat.log.Log4JLogger")
|
37
|
-
# System.setProperties(properties)
|
38
|
-
|
39
|
-
# Logger.getLogger('net.spy.memcached').setLevel(Level::SEVERE)
|
40
|
-
# Logger.getLogger('com.couchbase.client').setLevel(Level::SEVERE)
|
41
|
-
# Logger.getLogger('com.couchbase.client.vbucket').setLevel(Level::SEVERE)
|
42
|
-
|
43
|
-
# $stderr = StringIO.new
|
44
|
-
|
45
|
-
class Minitest::Test
|
46
|
-
|
47
|
-
def cb
|
48
|
-
Couchbase.bucket
|
49
|
-
end
|
50
|
-
|
51
|
-
def with_configs(configs = {})
|
52
|
-
configs = Couchbase::Bucket::DEFAULT_OPTIONS.merge(configs)
|
53
|
-
if configs[:host].nil?
|
54
|
-
configs[:host] = configs[:hostname]
|
55
|
-
end
|
56
|
-
yield OpenStruct.new(configs)
|
57
|
-
end
|
58
|
-
|
59
|
-
def uniq_id(*suffixes)
|
60
|
-
test_id = [caller.first[/.*[` ](.*)'/, 1], suffixes].compact.join("_")
|
61
|
-
@ids ||= {}
|
62
|
-
@ids[test_id] ||= Time.now.to_f
|
63
|
-
[test_id, @ids[test_id]].join("_")
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
at_exit {
|
69
|
-
$mock = start_mock
|
70
|
-
exit_code = Minitest.run(ARGV)
|
71
|
-
Couchbase.disconnect
|
72
|
-
$mock.stop
|
73
|
-
java.lang.System.exit(exit_code ? 0 : 1)
|
74
|
-
}
|
data/test/test_arithmetic.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
# Author:: Couchbase <info@couchbase.com>
|
2
|
-
# Copyright:: 2011, 2012 Couchbase, Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__), 'setup')
|
19
|
-
|
20
|
-
class TestArithmetic < Minitest::Test
|
21
|
-
|
22
|
-
def test_trivial_incr_decr
|
23
|
-
cb.set(uniq_id, 1)
|
24
|
-
val = cb.incr(uniq_id)
|
25
|
-
assert_equal 2, val
|
26
|
-
val = cb.get(uniq_id)
|
27
|
-
assert_equal 2, val
|
28
|
-
|
29
|
-
cb.set(uniq_id, 7)
|
30
|
-
val = cb.decr(uniq_id)
|
31
|
-
assert_equal 6, val
|
32
|
-
val = cb.get(uniq_id)
|
33
|
-
assert_equal 6, val
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_it_fails_to_incr_decr_missing_key
|
37
|
-
assert_raises(Couchbase::Error::NotFound) do
|
38
|
-
cb.incr(uniq_id(:missing))
|
39
|
-
end
|
40
|
-
assert_raises(Couchbase::Error::NotFound) do
|
41
|
-
cb.decr(uniq_id(:missing))
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_it_allows_to_make_increments_less_verbose_by_forcing_create_by_default
|
46
|
-
cb.default_arithmetic_init = true
|
47
|
-
assert_raises(Couchbase::Error::NotFound) do
|
48
|
-
cb.get(uniq_id)
|
49
|
-
end
|
50
|
-
assert_equal 0, cb.incr(uniq_id), "return value"
|
51
|
-
assert_equal 0, cb.get(uniq_id), "via get command"
|
52
|
-
ensure
|
53
|
-
cb.default_arithmetic_init = 0
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_it_allows_to_setup_initial_value_during_connection
|
57
|
-
cb.default_arithmetic_init = 10
|
58
|
-
assert_raises(Couchbase::Error::NotFound) do
|
59
|
-
cb.get(uniq_id)
|
60
|
-
end
|
61
|
-
|
62
|
-
assert_equal 10, cb.incr(uniq_id), "return value"
|
63
|
-
assert_equal 10, cb.get(uniq_id), "via get command"
|
64
|
-
ensure
|
65
|
-
cb.default_arithmetic_init = 0
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_it_allows_to_change_default_initial_value_after_connection
|
69
|
-
assert_equal 0, cb.default_arithmetic_init
|
70
|
-
assert_raises(Couchbase::Error::NotFound) do
|
71
|
-
cb.incr(uniq_id)
|
72
|
-
end
|
73
|
-
|
74
|
-
cb.default_arithmetic_init = 10
|
75
|
-
assert_equal 10, cb.default_arithmetic_init
|
76
|
-
assert_raises(Couchbase::Error::NotFound) do
|
77
|
-
cb.get(uniq_id)
|
78
|
-
end
|
79
|
-
assert_equal 10, cb.incr(uniq_id), "return value"
|
80
|
-
assert_equal 10, cb.get(uniq_id), "via get command"
|
81
|
-
ensure
|
82
|
-
cb.default_arithmetic_init = 0
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_it_creates_missing_key_when_initial_value_specified
|
86
|
-
val = cb.incr(uniq_id(:missing), :initial => 5)
|
87
|
-
assert_equal 5, val
|
88
|
-
val = cb.incr(uniq_id(:missing), :initial => 5)
|
89
|
-
assert_equal 6, val
|
90
|
-
val = cb.get(uniq_id(:missing))
|
91
|
-
assert_equal 6, val
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_it_uses_zero_as_default_value_for_missing_keys
|
95
|
-
val = cb.incr(uniq_id(:missing), :create => true)
|
96
|
-
assert_equal 0, val
|
97
|
-
val = cb.incr(uniq_id(:missing), :create => true)
|
98
|
-
assert_equal 1, val
|
99
|
-
val = cb.get(uniq_id(:missing))
|
100
|
-
assert_equal 1, val
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_it_allows_custom_ttl
|
104
|
-
val = cb.incr(uniq_id(:missing), :create => true, :ttl => 1)
|
105
|
-
assert_equal 0, val
|
106
|
-
val = cb.incr(uniq_id(:missing), :create => true)
|
107
|
-
assert_equal 1, val
|
108
|
-
sleep(2)
|
109
|
-
assert_raises(Couchbase::Error::NotFound) do
|
110
|
-
cb.get(uniq_id(:missing))
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_decrement_with_absolute_ttl
|
115
|
-
skip unless $mock.real?
|
116
|
-
# absolute TTL: one second from now
|
117
|
-
exp = Time.now.to_i + 1
|
118
|
-
val = cb.decr(uniq_id, 12, :initial => 0, :ttl => exp)
|
119
|
-
assert_equal 0, val
|
120
|
-
assert_equal 0, cb.get(uniq_id)
|
121
|
-
sleep(3)
|
122
|
-
assert_raises(Couchbase::Error::NotFound) do
|
123
|
-
cb.get(uniq_id)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_it_allows_custom_delta
|
128
|
-
cb.set(uniq_id, 12)
|
129
|
-
val = cb.incr(uniq_id, 10)
|
130
|
-
assert_equal 22, val
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_it_allows_to_specify_delta_in_options
|
134
|
-
cb.set(uniq_id, 12)
|
135
|
-
options = {:delta => 10}
|
136
|
-
val = cb.incr(uniq_id, options)
|
137
|
-
assert_equal 22, val
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_multi_incr
|
141
|
-
cb.set(uniq_id(:foo) => 1, uniq_id(:bar) => 1)
|
142
|
-
|
143
|
-
assert_equal [2, 2], cb.incr(uniq_id(:foo), uniq_id(:bar)).values.sort
|
144
|
-
assert_equal [12, 12], cb.incr(uniq_id(:foo), uniq_id(:bar), :delta => 10).values.sort
|
145
|
-
assert_equal [14, 15], cb.incr(uniq_id(:foo) => 2, uniq_id(:bar) => 3).values.sort
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_multi_decr
|
149
|
-
cb.set(uniq_id(:foo) => 14, uniq_id(:bar) => 15)
|
150
|
-
|
151
|
-
assert_equal [12, 12], cb.decr(uniq_id(:foo) => 2, uniq_id(:bar) => 3).values.sort
|
152
|
-
assert_equal [2, 2], cb.decr(uniq_id(:foo), uniq_id(:bar), :delta => 10).values.sort
|
153
|
-
assert_equal [1, 1], cb.decr(uniq_id(:foo), uniq_id(:bar)).values.sort
|
154
|
-
end
|
155
|
-
end
|
data/test/test_async.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Author:: Couchbase <info@couchbase.com>
|
2
|
-
# Copyright:: 2011, 2012 Couchbase, Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__), 'setup')
|
19
|
-
|
20
|
-
class TestAsync < Minitest::Test
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|