couchbase 1.0.0 → 1.1.0
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.
- data/.gitignore +2 -0
- data/.travis.yml +11 -0
- data/HISTORY.markdown +17 -0
- data/README.markdown +99 -59
- data/couchbase.gemspec +1 -0
- data/ext/couchbase_ext/couchbase_ext.c +1557 -425
- data/ext/couchbase_ext/extconf.rb +60 -49
- data/lib/couchbase.rb +41 -7
- data/lib/couchbase/bucket.rb +5 -3
- data/lib/couchbase/version.rb +1 -1
- data/tasks/compile.rake +72 -0
- data/tasks/test.rake +2 -2
- data/test/setup.rb +52 -2
- data/test/test_arithmetic.rb +37 -26
- data/test/test_async.rb +68 -44
- data/test/test_bucket.rb +130 -45
- data/test/test_cas.rb +8 -8
- data/test/test_couchbase.rb +1 -1
- data/test/test_delete.rb +15 -15
- data/test/test_errors.rb +6 -6
- data/test/test_flush.rb +3 -3
- data/test/test_format.rb +14 -14
- data/test/test_get.rb +144 -69
- data/test/test_stats.rb +18 -14
- data/test/test_store.rb +40 -40
- data/test/test_touch.rb +26 -14
- data/test/test_version.rb +30 -2
- metadata +34 -17
data/test/test_stats.rb
CHANGED
@@ -28,26 +28,30 @@ class TestStats < MiniTest::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_trivial_stats_without_argument
|
31
|
-
connection = Couchbase.new(:port => @mock.port)
|
31
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
32
32
|
stats = connection.stats
|
33
33
|
assert stats.is_a?(Hash)
|
34
|
-
|
35
|
-
|
36
|
-
assert
|
34
|
+
assert stats.has_key?("pid")
|
35
|
+
key, info = stats.first
|
36
|
+
assert key.is_a?(String)
|
37
37
|
assert info.is_a?(Hash)
|
38
|
-
|
38
|
+
assert_equal @mock.num_nodes, info.size
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_stats_with_argument
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
if @mock.real?
|
43
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
44
|
+
stats = connection.stats("memory")
|
45
|
+
assert stats.is_a?(Hash)
|
46
|
+
assert stats.has_key?("mem_used")
|
47
|
+
key, info = stats.first
|
48
|
+
assert key.is_a?(String)
|
49
|
+
assert info.is_a?(Hash)
|
50
|
+
assert_equal @mock.num_nodes, info.size
|
51
|
+
else
|
52
|
+
# FIXME
|
53
|
+
skip("make CouchbaseMock.jar STATS more real-life")
|
54
|
+
end
|
51
55
|
end
|
52
56
|
|
53
57
|
end
|
data/test/test_store.rb
CHANGED
@@ -28,66 +28,66 @@ class TestStore < MiniTest::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_trivial_set
|
31
|
-
connection = Couchbase.new(:port => @mock.port)
|
32
|
-
cas = connection.set(
|
31
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
32
|
+
cas = connection.set(uniq_id, "bar")
|
33
33
|
assert(cas > 0)
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_set_with_cas
|
37
|
-
connection = Couchbase.new(:port => @mock.port)
|
37
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
38
38
|
|
39
|
-
cas1 = connection.set(
|
39
|
+
cas1 = connection.set(uniq_id, "bar1")
|
40
40
|
assert cas1 > 0
|
41
41
|
|
42
42
|
assert_raises(Couchbase::Error::KeyExists) do
|
43
|
-
connection.set(
|
43
|
+
connection.set(uniq_id, "bar2", :cas => cas1+1)
|
44
44
|
end
|
45
45
|
|
46
|
-
cas2 = connection.set(
|
46
|
+
cas2 = connection.set(uniq_id, "bar2", :cas => cas1)
|
47
47
|
assert cas2 > 0
|
48
48
|
refute_equal cas2, cas1
|
49
49
|
|
50
|
-
cas3 = connection.set(
|
50
|
+
cas3 = connection.set(uniq_id, "bar3")
|
51
51
|
assert cas3 > 0
|
52
52
|
refute_equal cas3, cas2
|
53
53
|
refute_equal cas3, cas1
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_add
|
57
|
-
connection = Couchbase.new(:port => @mock.port)
|
57
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
58
58
|
|
59
|
-
cas1 = connection.add(
|
59
|
+
cas1 = connection.add(uniq_id, "bar")
|
60
60
|
assert cas1 > 0
|
61
61
|
|
62
62
|
assert_raises(Couchbase::Error::KeyExists) do
|
63
|
-
connection.add(
|
63
|
+
connection.add(uniq_id, "bar")
|
64
64
|
end
|
65
65
|
|
66
66
|
assert_raises(Couchbase::Error::KeyExists) do
|
67
|
-
connection.add(
|
67
|
+
connection.add(uniq_id, "bar", :cas => cas1)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_replace
|
72
|
-
connection = Couchbase.new(:port => @mock.port)
|
72
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
73
73
|
|
74
74
|
assert_raises(Couchbase::Error::NotFound) do
|
75
|
-
connection.replace(
|
75
|
+
connection.replace(uniq_id, "bar")
|
76
76
|
end
|
77
77
|
|
78
|
-
cas1 = connection.set(
|
78
|
+
cas1 = connection.set(uniq_id, "bar")
|
79
79
|
assert cas1 > 0
|
80
80
|
|
81
|
-
connection.replace(
|
81
|
+
connection.replace(uniq_id, "bar")
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_acceptable_keys
|
85
|
-
connection = Couchbase.new(:port => @mock.port)
|
85
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
86
86
|
|
87
|
-
cas = connection.set(
|
87
|
+
cas = connection.set(uniq_id.to_sym, "bar")
|
88
88
|
assert cas > 0
|
89
89
|
|
90
|
-
cas = connection.set(
|
90
|
+
cas = connection.set(uniq_id.to_s, "bar")
|
91
91
|
assert cas > 0
|
92
92
|
|
93
93
|
assert_raises(TypeError) do
|
@@ -108,76 +108,76 @@ class TestStore < MiniTest::Unit::TestCase
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_asynchronous_set
|
111
|
-
connection = Couchbase.new(:port => @mock.port)
|
111
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
112
112
|
ret = nil
|
113
113
|
connection.run do |conn|
|
114
|
-
conn.set(
|
115
|
-
conn.set(
|
114
|
+
conn.set(uniq_id("1"), "foo1") {|res| ret = res}
|
115
|
+
conn.set(uniq_id("2"), "foo2") # ignore result
|
116
116
|
assert_equal 2, conn.seqno
|
117
117
|
end
|
118
118
|
assert ret.is_a?(Couchbase::Result)
|
119
119
|
assert ret.success?
|
120
|
-
assert_equal
|
120
|
+
assert_equal uniq_id("1"), ret.key
|
121
121
|
assert_equal :set, ret.operation
|
122
122
|
assert ret.cas.is_a?(Numeric)
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_it_raises_error_when_appending_or_prepending_to_missing_key
|
126
|
-
connection = Couchbase.new(:port => @mock.port)
|
126
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
127
127
|
|
128
128
|
assert_raises(Couchbase::Error::NotStored) do
|
129
|
-
connection.append(
|
129
|
+
connection.append(uniq_id(:missing), "foo")
|
130
130
|
end
|
131
131
|
|
132
132
|
assert_raises(Couchbase::Error::NotStored) do
|
133
|
-
connection.prepend(
|
133
|
+
connection.prepend(uniq_id(:missing), "foo")
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
def test_append
|
138
|
-
connection = Couchbase.new(:port => @mock.port, :default_format => :plain)
|
138
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
|
139
139
|
|
140
|
-
cas1 = connection.set(
|
140
|
+
cas1 = connection.set(uniq_id, "foo")
|
141
141
|
assert cas1 > 0
|
142
|
-
cas2 = connection.append(
|
142
|
+
cas2 = connection.append(uniq_id, "bar")
|
143
143
|
assert cas2 > 0
|
144
144
|
refute_equal cas2, cas1
|
145
145
|
|
146
|
-
val = connection.get(
|
146
|
+
val = connection.get(uniq_id)
|
147
147
|
assert_equal "foobar", val
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_prepend
|
151
|
-
connection = Couchbase.new(:port => @mock.port, :default_format => :plain)
|
151
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_format => :plain)
|
152
152
|
|
153
|
-
cas1 = connection.set(
|
153
|
+
cas1 = connection.set(uniq_id, "foo")
|
154
154
|
assert cas1 > 0
|
155
|
-
cas2 = connection.prepend(
|
155
|
+
cas2 = connection.prepend(uniq_id, "bar")
|
156
156
|
assert cas2 > 0
|
157
157
|
refute_equal cas2, cas1
|
158
158
|
|
159
|
-
val = connection.get(
|
159
|
+
val = connection.get(uniq_id)
|
160
160
|
assert_equal "barfoo", val
|
161
161
|
end
|
162
162
|
|
163
163
|
ArbitraryData = Struct.new(:baz)
|
164
164
|
|
165
165
|
def test_set_using_brackets
|
166
|
-
connection = Couchbase.new(:port => @mock.port)
|
166
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
167
167
|
|
168
|
-
connection[
|
169
|
-
val = connection.get(
|
168
|
+
connection[uniq_id(1)] = "foo"
|
169
|
+
val = connection.get(uniq_id(1))
|
170
170
|
assert_equal "foo", val
|
171
171
|
|
172
172
|
if RUBY_VERSION =~ /^1\.9/
|
173
173
|
eval <<-EOC
|
174
|
-
connection[
|
175
|
-
val, flags = connection.get(
|
174
|
+
connection[uniq_id(2), :flags => 0x1100] = "bar"
|
175
|
+
val, flags = connection.get(uniq_id(2), :extended => true)
|
176
176
|
assert_equal "bar", val
|
177
177
|
assert_equal 0x1100, flags
|
178
178
|
|
179
|
-
connection[
|
180
|
-
val = connection.get(
|
179
|
+
connection[uniq_id(3), :format => :marshal] = ArbitraryData.new("thing")
|
180
|
+
val = connection.get(uniq_id(3))
|
181
181
|
assert val.is_a?(ArbitraryData)
|
182
182
|
assert_equal "thing", val.baz
|
183
183
|
EOC
|
data/test/test_touch.rb
CHANGED
@@ -28,30 +28,42 @@ class TestTouch < MiniTest::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_trivial_touch
|
31
|
-
connection = Couchbase.new(:port => @mock.port)
|
32
|
-
connection.set(
|
33
|
-
connection.touch(
|
34
|
-
sleep(1)
|
35
|
-
assert connection.get(test_id)
|
31
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
32
|
+
connection.set(uniq_id, "bar", :ttl => 1)
|
33
|
+
connection.touch(uniq_id, :ttl => 2)
|
36
34
|
sleep(1)
|
37
|
-
|
35
|
+
assert connection.get(uniq_id)
|
36
|
+
sleep(2)
|
37
|
+
refute connection.get(uniq_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_multi_touch
|
41
|
+
connection = Couchbase.new(:port => @mock.port)
|
42
|
+
connection.set(uniq_id(1), "bar")
|
43
|
+
connection.set(uniq_id(2), "baz")
|
44
|
+
ret = connection.touch(uniq_id(1) => 1, uniq_id(2) => 1)
|
45
|
+
assert ret[uniq_id(1)]
|
46
|
+
assert ret[uniq_id(2)]
|
47
|
+
sleep(2)
|
48
|
+
refute connection.get(uniq_id(1))
|
49
|
+
refute connection.get(uniq_id(2))
|
38
50
|
end
|
39
51
|
|
40
52
|
def test_it_uses_default_ttl_for_touch
|
41
|
-
connection = Couchbase.new(:port => @mock.port, :default_ttl => 1)
|
42
|
-
connection.set(
|
43
|
-
connection.touch(
|
53
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port, :default_ttl => 1)
|
54
|
+
connection.set(uniq_id, "bar", :ttl => 10)
|
55
|
+
connection.touch(uniq_id)
|
44
56
|
sleep(2)
|
45
|
-
refute connection.get(
|
57
|
+
refute connection.get(uniq_id)
|
46
58
|
end
|
47
59
|
|
48
60
|
def test_it_accepts_ttl_for_get_command
|
49
|
-
connection = Couchbase.new(:port => @mock.port)
|
50
|
-
connection.set(
|
51
|
-
val = connection.get(
|
61
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
62
|
+
connection.set(uniq_id, "bar", :ttl => 10)
|
63
|
+
val = connection.get(uniq_id, :ttl => 1)
|
52
64
|
assert_equal "bar", val
|
53
65
|
sleep(2)
|
54
|
-
refute connection.get(
|
66
|
+
refute connection.get(uniq_id)
|
55
67
|
end
|
56
68
|
|
57
69
|
end
|
data/test/test_version.rb
CHANGED
@@ -18,7 +18,35 @@
|
|
18
18
|
require File.join(File.dirname(__FILE__), 'setup')
|
19
19
|
|
20
20
|
class TestVersion < MiniTest::Unit::TestCase
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
def setup
|
23
|
+
@mock = start_mock
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
stop_mock(@mock)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_sync_version
|
31
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
32
|
+
ver = connection.version
|
33
|
+
assert ver.is_a?(Hash)
|
34
|
+
assert_equal @mock.num_nodes, ver.size
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_async_version
|
38
|
+
connection = Couchbase.new(:hostname => @mock.host, :port => @mock.port)
|
39
|
+
ver = {}
|
40
|
+
connection.run do |conn|
|
41
|
+
conn.version do |ret|
|
42
|
+
assert ret.success?
|
43
|
+
ver[ret.node] = ret.value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
assert_equal @mock.num_nodes, ver.size
|
47
|
+
ver.each do |node, v|
|
48
|
+
assert v.is_a?(String)
|
49
|
+
end
|
23
50
|
end
|
51
|
+
|
24
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-07 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &12069760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *12069760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &12068240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.8.7
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *12068240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: minitest
|
38
|
-
requirement: &
|
38
|
+
requirement: &12067280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *12067280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake-compiler
|
49
|
-
requirement: &
|
49
|
+
requirement: &12056580 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.7.5
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *12056580
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdiscount
|
60
|
-
requirement: &
|
60
|
+
requirement: &12055480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *12055480
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &12054260 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,21 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *12054260
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: mini_portile
|
82
|
+
requirement: &12053280 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *12053280
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: ruby-debug19
|
82
|
-
requirement: &
|
93
|
+
requirement: &12052340 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,7 +98,7 @@ dependencies:
|
|
87
98
|
version: '0'
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *12052340
|
91
102
|
description: The official client library for use with Couchbase Server.
|
92
103
|
email: support@couchbase.com
|
93
104
|
executables: []
|
@@ -96,6 +107,7 @@ extensions:
|
|
96
107
|
extra_rdoc_files: []
|
97
108
|
files:
|
98
109
|
- .gitignore
|
110
|
+
- .travis.yml
|
99
111
|
- .yardopts
|
100
112
|
- Gemfile
|
101
113
|
- HISTORY.markdown
|
@@ -144,12 +156,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
156
|
- - ! '>='
|
145
157
|
- !ruby/object:Gem::Version
|
146
158
|
version: '0'
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
hash: -2404392778258139925
|
147
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
163
|
none: false
|
149
164
|
requirements:
|
150
165
|
- - ! '>='
|
151
166
|
- !ruby/object:Gem::Version
|
152
167
|
version: '0'
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
hash: -2404392778258139925
|
153
171
|
requirements: []
|
154
172
|
rubyforge_project:
|
155
173
|
rubygems_version: 1.8.10
|
@@ -175,4 +193,3 @@ test_files:
|
|
175
193
|
- test/test_store.rb
|
176
194
|
- test/test_touch.rb
|
177
195
|
- test/test_version.rb
|
178
|
-
has_rdoc:
|