riak-client 2.5.0 → 2.6.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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/RELNOTES.md +3 -0
  4. data/lib/riak/bucket.rb +1 -1
  5. data/lib/riak/client.rb +14 -7
  6. data/lib/riak/client/beefcake/messages.rb +13 -0
  7. data/lib/riak/multi.rb +101 -0
  8. data/lib/riak/multiexist.rb +14 -0
  9. data/lib/riak/multiget.rb +7 -107
  10. data/lib/riak/version.rb +1 -1
  11. metadata +12 -234
  12. data/.document +0 -5
  13. data/.gitignore +0 -44
  14. data/.rspec +0 -2
  15. data/Gemfile +0 -17
  16. data/Guardfile +0 -20
  17. data/Rakefile +0 -124
  18. data/riak-client.gemspec +0 -71
  19. data/spec/failover/failover.rb +0 -59
  20. data/spec/fixtures/bitcask.txt +0 -25
  21. data/spec/fixtures/cat.jpg +0 -0
  22. data/spec/fixtures/multipart-basic-conflict.txt +0 -15
  23. data/spec/fixtures/multipart-blank.txt +0 -7
  24. data/spec/fixtures/multipart-mapreduce.txt +0 -10
  25. data/spec/fixtures/multipart-with-body.txt +0 -16
  26. data/spec/fixtures/multipart-with-marked-tombstones.txt +0 -17
  27. data/spec/fixtures/multipart-with-unmarked-tombstone.txt +0 -16
  28. data/spec/fixtures/server.cert.crt +0 -15
  29. data/spec/fixtures/server.cert.key +0 -15
  30. data/spec/fixtures/test.pem +0 -1
  31. data/spec/fixtures/yz_schema_template.xml +0 -18
  32. data/spec/integration/riak/bucket_types_spec.rb +0 -308
  33. data/spec/integration/riak/conflict_resolution_spec.rb +0 -96
  34. data/spec/integration/riak/counters_spec.rb +0 -36
  35. data/spec/integration/riak/crdt/configuration_spec.rb +0 -38
  36. data/spec/integration/riak/crdt_search_spec.rb +0 -176
  37. data/spec/integration/riak/crdt_spec.rb +0 -332
  38. data/spec/integration/riak/crdt_validation/map_spec.rb +0 -63
  39. data/spec/integration/riak/crdt_validation/set_spec.rb +0 -122
  40. data/spec/integration/riak/encodings/crdt_spec.rb +0 -122
  41. data/spec/integration/riak/encodings/kv_spec.rb +0 -87
  42. data/spec/integration/riak/encodings/yz_spec.rb +0 -142
  43. data/spec/integration/riak/preflist_spec.rb +0 -43
  44. data/spec/integration/riak/properties_spec.rb +0 -69
  45. data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +0 -33
  46. data/spec/integration/riak/protobuffs/timeouts_spec.rb +0 -178
  47. data/spec/integration/riak/protobuffs_backends_spec.rb +0 -40
  48. data/spec/integration/riak/search_spec.rb +0 -104
  49. data/spec/integration/riak/secondary_index_spec.rb +0 -72
  50. data/spec/integration/riak/security_spec.rb +0 -105
  51. data/spec/integration/riak/threading_spec.rb +0 -154
  52. data/spec/integration/riak/time_series_spec.rb +0 -212
  53. data/spec/integration/yokozuna/index_spec.rb +0 -61
  54. data/spec/integration/yokozuna/queries_spec.rb +0 -115
  55. data/spec/integration/yokozuna/schema_spec.rb +0 -49
  56. data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +0 -247
  57. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +0 -244
  58. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +0 -53
  59. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +0 -189
  60. data/spec/riak/beefcake_protobuffs_backend/ts_cell_codec_spec.rb +0 -124
  61. data/spec/riak/beefcake_protobuffs_backend_spec.rb +0 -162
  62. data/spec/riak/bucket_properties_spec.rb +0 -135
  63. data/spec/riak/bucket_spec.rb +0 -275
  64. data/spec/riak/bucket_type_spec.rb +0 -50
  65. data/spec/riak/bucket_typed/bucket_spec.rb +0 -78
  66. data/spec/riak/client_spec.rb +0 -304
  67. data/spec/riak/core_ext/to_param_spec.rb +0 -15
  68. data/spec/riak/counter_spec.rb +0 -122
  69. data/spec/riak/crdt/counter_spec.rb +0 -55
  70. data/spec/riak/crdt/hyper_log_log_spec.rb +0 -56
  71. data/spec/riak/crdt/inner_counter_spec.rb +0 -21
  72. data/spec/riak/crdt/inner_flag_spec.rb +0 -39
  73. data/spec/riak/crdt/inner_map_spec.rb +0 -47
  74. data/spec/riak/crdt/inner_register_spec.rb +0 -40
  75. data/spec/riak/crdt/inner_set_spec.rb +0 -33
  76. data/spec/riak/crdt/map_spec.rb +0 -78
  77. data/spec/riak/crdt/set_spec.rb +0 -61
  78. data/spec/riak/crdt/shared_examples.rb +0 -88
  79. data/spec/riak/crdt/typed_collection_spec.rb +0 -225
  80. data/spec/riak/escape_spec.rb +0 -72
  81. data/spec/riak/feature_detection_spec.rb +0 -77
  82. data/spec/riak/index_collection_spec.rb +0 -53
  83. data/spec/riak/instrumentation_spec.rb +0 -124
  84. data/spec/riak/link_spec.rb +0 -85
  85. data/spec/riak/list_buckets_spec.rb +0 -41
  86. data/spec/riak/map_reduce/filter_builder_spec.rb +0 -32
  87. data/spec/riak/map_reduce/phase_spec.rb +0 -142
  88. data/spec/riak/map_reduce_spec.rb +0 -434
  89. data/spec/riak/multiget_spec.rb +0 -81
  90. data/spec/riak/node_spec.rb +0 -26
  91. data/spec/riak/robject_spec.rb +0 -542
  92. data/spec/riak/search/index_spec.rb +0 -72
  93. data/spec/riak/search/query_spec.rb +0 -88
  94. data/spec/riak/search/result_collection_spec.rb +0 -89
  95. data/spec/riak/search/result_document_spec.rb +0 -106
  96. data/spec/riak/search/schema_spec.rb +0 -63
  97. data/spec/riak/search_spec.rb +0 -107
  98. data/spec/riak/secondary_index_spec.rb +0 -225
  99. data/spec/riak/serializers_spec.rb +0 -121
  100. data/spec/riak/stamp_spec.rb +0 -54
  101. data/spec/riak/time_series/deletion_spec.rb +0 -33
  102. data/spec/riak/time_series/listing_spec.rb +0 -51
  103. data/spec/riak/time_series/submission_spec.rb +0 -35
  104. data/spec/riak/util/gzip_spec.rb +0 -49
  105. data/spec/riak/walk_spec_spec.rb +0 -203
  106. data/spec/spec_helper.rb +0 -67
  107. data/spec/support/certs/README.md +0 -13
  108. data/spec/support/certs/ca.crt +0 -21
  109. data/spec/support/certs/client.crl +0 -13
  110. data/spec/support/certs/client.crt +0 -94
  111. data/spec/support/certs/client.csr +0 -18
  112. data/spec/support/certs/client.key +0 -27
  113. data/spec/support/certs/empty_ca.crt +0 -21
  114. data/spec/support/certs/server.crl +0 -13
  115. data/spec/support/certs/server.crt +0 -94
  116. data/spec/support/certs/server.key +0 -27
  117. data/spec/support/crdt_search_config.rb +0 -112
  118. data/spec/support/crdt_search_fixtures.rb +0 -42
  119. data/spec/support/integration_setup.rb +0 -10
  120. data/spec/support/search_config.rb +0 -83
  121. data/spec/support/search_corpus_setup.rb +0 -39
  122. data/spec/support/test_client.rb +0 -52
  123. data/spec/support/test_client.yml.example +0 -10
  124. data/spec/support/unified_backend_examples.rb +0 -402
  125. data/spec/support/version_filter.rb +0 -12
  126. data/spec/support/wait_until.rb +0 -20
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
- require 'riak/bucket_type'
3
-
4
- describe Riak::BucketType do
5
- let(:client){ Riak::Client.allocate }
6
- let(:name){ 'bucket_type_spec' }
7
- let(:backend) do
8
- double('Backend').tap do |backend|
9
- allow(client).to receive(:backend).and_yield(backend)
10
- end
11
- end
12
-
13
- subject{ described_class.new client, name }
14
-
15
- it 'is created with a client and name' do
16
- expect{ described_class.new client, name }.to_not raise_error
17
- end
18
-
19
- it 'returns a typed bucket' do
20
- typed_bucket = subject.bucket 'empanadas'
21
- expect(typed_bucket).to be_a Riak::Bucket
22
- expect(typed_bucket).to be_a Riak::BucketTyped::Bucket
23
- expect(typed_bucket.name).to eq 'empanadas'
24
- expect(typed_bucket.type).to eq subject
25
- end
26
-
27
- describe 'equality' do
28
- let(:same){ described_class.new client, name }
29
- let(:different_client){ described_class.new Riak::Client.allocate, name }
30
- let(:different_name){ described_class.new client, 'different name' }
31
- it { is_expected.to eq same }
32
- it { is_expected.to_not eq different_client }
33
- it { is_expected.to_not eq different_name }
34
- end
35
-
36
- describe 'properties' do
37
- let(:props_expectation){ expect(backend).to receive(:get_bucket_type_props).with(name) }
38
-
39
- it 'is queryable' do
40
- props_expectation.and_return(allow_mult: true)
41
- expect(props = subject.properties).to be_a Hash
42
- expect(props[:allow_mult]).to be
43
- end
44
-
45
- it 'asks for data type' do
46
- props_expectation.and_return(datatype: 'set')
47
- expect(subject.data_type_class).to eq Riak::Crdt::Set
48
- end
49
- end
50
- end
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
- require 'riak/bucket_typed/bucket'
3
-
4
- describe Riak::BucketTyped::Bucket do
5
- let(:client){ Riak::Client.allocate }
6
- let(:type){ client.bucket_type 'type' }
7
- let(:name){ 'bucket_typed_bucket_spec' }
8
-
9
- subject{ described_class.new client, name, type }
10
-
11
- it 'initializes a typed RObject' do
12
- typed_robject = subject.new 'panther'
13
- expect(typed_robject).to be_a Riak::RObject
14
- expect(typed_robject.key).to eq 'panther'
15
- expect(typed_robject.bucket.type).to eq type
16
- end
17
-
18
- it 'has a bucket type' do
19
- expect(subject.type).to eq type
20
- expect(subject.type.name).to eq 'type'
21
- end
22
-
23
- describe 'equality' do
24
- let(:same){ described_class.new client, name, type }
25
- let(:different){ described_class.new client, 'other', type }
26
- let(:untyped){ Riak::Bucket.new client, name }
27
- it { is_expected.to eq subject }
28
- it { is_expected.to eq same }
29
- it { is_expected.to_not eq untyped }
30
- it { is_expected.to_not eq different }
31
- end
32
-
33
- describe 'bucket properties' do
34
- it 'returns properties scoped by bucket and type' do
35
- expect(client).to receive(:get_bucket_props).
36
- with(subject, { type: subject.type.name }).
37
- and_return('allow_mult' => true)
38
-
39
- expect(props = subject.props).to be_a Hash
40
- expect(props['allow_mult']).to be
41
- end
42
-
43
- it 'clears properties scoped by bucket and type' do
44
- expect(client).to receive(:clear_bucket_props).
45
- with(subject, { type: subject.type.name })
46
-
47
- expect{ subject.clear_props }.to_not raise_error
48
- end
49
-
50
- it 'sets properties scoped by bucket and type' do
51
- expect(client).to receive(:get_bucket_props).
52
- with(subject, { type: subject.type.name }).
53
- and_return('allow_mult' => false)
54
- expect(client).to receive(:set_bucket_props).
55
- with(subject,
56
- { 'allow_mult' => true },
57
- subject.type.name)
58
-
59
- expect{ subject.props = { 'allow_mult' => true } }.to_not raise_error
60
- end
61
- end
62
-
63
- describe "querying an index" do
64
- it "attaches the bucket type" do
65
- expect(client).
66
- to receive(:get_index).
67
- with(subject, 'test_bin', 'testing', { type: 'type' }).
68
- and_return(
69
- Riak::IndexCollection.new_from_json({
70
- keys: ['asdf']
71
- }.to_json))
72
-
73
- result = subject.get_index('test_bin', 'testing')
74
- expect(result).to be_a Riak::IndexCollection
75
- expect(result.to_a).to eq %w{asdf}
76
- end
77
- end
78
- end
@@ -1,304 +0,0 @@
1
- require 'spec_helper'
2
- require 'riak/errors/protobuffs_error'
3
-
4
- describe Riak::Client, test_client: true do
5
- describe "when initializing" do
6
- it "defaults to a single local node" do
7
- client = Riak::Client.new
8
- expect(client.nodes).to eq([Riak::Client::Node.new(client)])
9
- end
10
-
11
- it "accepts a host" do
12
- client = Riak::Client.new :host => "riak.basho.com"
13
- expect(client.nodes.size).to eq(1)
14
- expect(client.nodes.first.host).to eq("riak.basho.com")
15
- end
16
-
17
- it "accepts a Protobuffs port" do
18
- client = Riak::Client.new :pb_port => 9000
19
- expect(client.nodes.size).to eq(1)
20
- expect(client.nodes.first.host).to eq('127.0.0.1')
21
- expect(client.nodes.first.pb_port).to eq(9000)
22
- end
23
-
24
- it "accepts a client ID" do
25
- client = Riak::Client.new :client_id => "AAAAAA=="
26
- expect(client.client_id).to eq("AAAAAA==")
27
- end
28
-
29
- it "creates a client ID if not specified", :integration => true do
30
- expect(Riak::Client.new(pb_port: test_client.nodes.first.pb_port).
31
- client_id).to_not be_nil
32
- end
33
-
34
- it "accepts multiple nodes" do
35
- client = Riak::Client.new nodes: [
36
- {host: 'riak1.basho.com'},
37
- {host: 'riak2.basho.com', pb_port: 1234},
38
- {host: 'riak3.basho.com', pb_port: 5678}
39
- ]
40
- expect(client.nodes.size).to eq(3)
41
- expect(client.nodes.first.host).to eq("riak1.basho.com")
42
- end
43
-
44
- it "maps port to unset nodes, and does not create localhost node" do
45
- client = Riak::Client.new nodes: [
46
- {host: 'riak1.basho.com'},
47
- {host: 'riak2.basho.com', pb_port: 1234},
48
- {host: 'riak3.basho.com', pb_port: 5678}
49
- ], pb_port: 4321
50
- expect(client.nodes.size).to eq(3)
51
- expect(client.nodes[0].host).to eq("riak1.basho.com")
52
- expect(client.nodes[0].pb_port).to eq(4321)
53
- expect(client.nodes[1].host).to eq("riak2.basho.com")
54
- expect(client.nodes[1].pb_port).to eq(1234)
55
- end
56
-
57
- it "defaults to max_retries = 2" do
58
- client = Riak::Client.new
59
- expect(client.max_retries).to eq(2)
60
- end
61
-
62
- it "accepts max_retries option" do
63
- client = Riak::Client.new :max_retries => 42
64
- expect(client.max_retries).to eq(42)
65
- end
66
-
67
- it "accepts timeouts" do
68
- client = Riak::Client.new(
69
- :connect_timeout => 1,
70
- :read_timeout => 2,
71
- :write_timeout => 3
72
- )
73
- expect(client.connect_timeout).to eq(1)
74
- expect(client.read_timeout).to eq(2)
75
- expect(client.write_timeout).to eq(3)
76
- end
77
-
78
- it "accepts convert_timestamp" do
79
- client = Riak::Client.new(
80
- :convert_timestamp => true
81
- )
82
- expect(client.convert_timestamp).to be
83
- end
84
-
85
- it "has default convert_timestamp of false" do
86
- client = Riak::Client.new
87
- expect(client.convert_timestamp).to_not be
88
- end
89
- end
90
-
91
- it "exposes a Stamp object" do
92
- expect(subject).to respond_to(:stamp)
93
- expect(subject.stamp).to be_kind_of(Riak::Stamp)
94
- end
95
-
96
- it 'exposes bucket types' do
97
- bucket_type = nil
98
- expect{ bucket_type = subject.bucket_type('example') }.to_not raise_error
99
- expect(bucket_type).to be_a Riak::BucketType
100
- expect(bucket_type.name).to eq 'example'
101
- end
102
-
103
- describe "reconfiguring" do
104
- before :each do
105
- @client = Riak::Client.new
106
- end
107
-
108
- describe "setting the client id" do
109
- it "accepts a string unmodified" do
110
- @client.client_id = "foo"
111
- expect(@client.client_id).to eq("foo")
112
- end
113
-
114
- it "rejects an integer equal to the maximum client id" do
115
- expect do
116
- @client.client_id = Riak::Client::MAX_CLIENT_ID
117
- end.to raise_error(ArgumentError)
118
- end
119
-
120
- it "rejects an integer larger than the maximum client id" do
121
- expect do
122
- @client.client_id = Riak::Client::MAX_CLIENT_ID + 1
123
- end.to raise_error(ArgumentError)
124
- end
125
- end
126
- end
127
-
128
- describe "choosing a Protobuffs backend" do
129
- before :each do
130
- @client = Riak::Client.new
131
- end
132
-
133
- it "chooses the selected backend" do
134
- @client.protobuffs_backend = :Beefcake
135
- @client.protobuffs do |p|
136
- expect(p).to be_instance_of(Riak::Client::BeefcakeProtobuffsBackend)
137
- end
138
- end
139
-
140
- it "tears down the existing Protobuffs connections when changed" do
141
- expect(@client.protobuffs_pool).to receive(:clear)
142
- @client.protobuffs_backend = :Beefcake
143
- end
144
-
145
- it "raises an error when the chosen backend is not valid" do
146
- expect(Riak::Client::BeefcakeProtobuffsBackend).to receive(:configured?).
147
- and_return(false)
148
- expect do
149
- @client.protobuffs { |x| }
150
- end.to raise_error Riak::BackendCreationError
151
- end
152
- end
153
-
154
- describe "choosing a unified backend" do
155
- before :each do
156
- @client = Riak::Client.new
157
- end
158
-
159
- it "uses Protobuffs when the protocol is pbc" do
160
- @client.backend do |b|
161
- expect(b).to be_kind_of(Riak::Client::ProtobuffsBackend)
162
- end
163
- end
164
- end
165
-
166
- describe "retrieving many values" do
167
- before :each do
168
- @client = Riak::Client.new
169
- @bucket = @client.bucket('foo')
170
- expect(@bucket).to receive(:[]).
171
- with('value1').
172
- and_return(double('robject'))
173
- expect(@bucket).to receive(:[]).
174
- with('value2').
175
- and_return(double('robject'))
176
- @pairs = [
177
- [@bucket, 'value1'],
178
- [@bucket, 'value2']
179
- ]
180
- end
181
-
182
- it 'accepts an array of bucket and key pairs' do
183
- expect{ @client.get_many(@pairs) }.not_to raise_error
184
- end
185
-
186
- it 'returns a hash of bucket/key pairs and robjects' do
187
- @results = @client.get_many(@pairs)
188
- expect(@results).to be_a Hash
189
- expect(@results.length).to be(@pairs.length)
190
- end
191
- end
192
-
193
- describe "retrieving a bucket" do
194
- before :each do
195
- @client = Riak::Client.new
196
- @backend = double("Backend")
197
- allow(@client).to receive(:backend).and_yield(@backend)
198
- end
199
-
200
- it "returns a bucket object" do
201
- expect(@client.bucket("foo")).to be_kind_of(Riak::Bucket)
202
- end
203
-
204
- it "fetches bucket properties if asked" do
205
- expect(@backend).to receive(:get_bucket_props) do |b|
206
- expect(b.name).to eq("foo")
207
- {}
208
- end
209
- @client.bucket("foo", :props => true)
210
- end
211
-
212
- it "memoizes bucket parameters" do
213
- @bucket = double("Bucket")
214
- expect(Riak::Bucket).to receive(:new).
215
- with(@client, "baz").
216
- once.
217
- and_return(@bucket)
218
- expect(@client.bucket("baz")).to eq(@bucket)
219
- expect(@client.bucket("baz")).to eq(@bucket)
220
- end
221
-
222
- it "rejects buckets with zero-length names" do
223
- expect { @client.bucket('') }.to raise_error(ArgumentError)
224
- end
225
- end
226
-
227
- describe "listing buckets" do
228
- before do
229
- @client = Riak::Client.new
230
- @backend = double("Backend")
231
- allow(@client).to receive(:backend).and_yield(@backend)
232
- end
233
-
234
- after { Riak.disable_list_keys_warnings = true }
235
-
236
- it "lists buckets" do
237
- expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
238
- buckets = @client.buckets
239
- expect(buckets.size).to eq(2)
240
- expect(buckets).to be_all {|b| b.is_a?(Riak::Bucket) }
241
- expect(buckets[0].name).to eq("test")
242
- expect(buckets[1].name).to eq("test2")
243
- end
244
-
245
- it "warns about the expense of list-buckets when warnings are not disabled" do
246
- Riak.disable_list_keys_warnings = false
247
- allow(@backend).to receive(:list_buckets).and_return(%w{test test2})
248
- expect(@client).to receive(:warn)
249
- @client.buckets
250
- end
251
-
252
- it "supports a timeout option" do
253
- expect(@backend).to receive(:list_buckets).with(timeout: 1234).and_return(%w{test test2})
254
-
255
- buckets = @client.buckets timeout: 1234
256
- expect(buckets.size).to eq(2)
257
- end
258
- end
259
-
260
- describe "when receiving errors from the backend" do
261
- before do
262
- @client = Riak::Client.new
263
- end
264
-
265
- it "retries on recoverable errors" do
266
- call_count = 0
267
-
268
- begin
269
- @client.backend do |b|
270
- call_count += 1
271
- raise Riak::ProtobuffsFailedHeader
272
- end
273
- rescue RuntimeError
274
- end
275
-
276
- expect(call_count).to eq(@client.max_retries + 1)
277
- end
278
-
279
- it "throws a RuntimeError if it runs out of retries" do
280
- error = nil
281
- begin
282
- @client.backend do |b|
283
- raise Riak::ProtobuffsFailedHeader
284
- end
285
- rescue RuntimeError => e
286
- error = e
287
- end
288
-
289
- expect(error).not_to be_nil
290
- expect(error).to be_instance_of(RuntimeError)
291
- end
292
-
293
- it "logs the error" do
294
- expect(Riak.logger).to receive(:warn).with(/Riak::ProtobuffsFailedHeader/).at_least(:once)
295
-
296
- begin
297
- @client.backend do |b|
298
- raise Riak::ProtobuffsFailedHeader
299
- end
300
- rescue RuntimeError
301
- end
302
- end
303
- end
304
- end
@@ -1,15 +0,0 @@
1
-
2
- describe Riak do
3
- require 'riak/core_ext/to_param'
4
-
5
- it "converts params correctly" do
6
- expect({ :name => 'David', :nationality => 'Danish' }.to_param).to eq("name=David&nationality=Danish")
7
- end
8
-
9
- # Based on the activesupport implementation.
10
- # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/to_param.rb
11
- it "converts namespaced params correctly" do
12
- expect({ :name => 'David', :nationality => 'Danish' }.to_param('user')).to eq("user%5Bname%5D=David&user%5Bnationality%5D=Danish")
13
- end
14
-
15
- end