riak-client 2.2.0.pre1 → 2.2.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 (119) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +0 -2
  4. data/README.markdown +11 -7
  5. data/RELEASE_NOTES.md +29 -2
  6. data/Rakefile +5 -3
  7. data/lib/riak/bucket.rb +55 -23
  8. data/lib/riak/bucket_properties.rb +8 -1
  9. data/lib/riak/bucket_type.rb +29 -0
  10. data/lib/riak/bucket_typed/bucket.rb +15 -7
  11. data/lib/riak/client.rb +24 -8
  12. data/lib/riak/client/beefcake/bucket_properties_operator.rb +8 -8
  13. data/lib/riak/client/beefcake/crdt/set_loader.rb +1 -1
  14. data/lib/riak/client/beefcake/crdt_loader.rb +1 -1
  15. data/lib/riak/client/beefcake/crdt_operator.rb +9 -9
  16. data/lib/riak/client/beefcake/message_codes.rb +4 -0
  17. data/lib/riak/client/beefcake/message_overlay.rb +4 -0
  18. data/lib/riak/client/beefcake/messages.rb +35 -5
  19. data/lib/riak/client/beefcake/object_methods.rb +21 -13
  20. data/lib/riak/client/beefcake/protocol.rb +7 -7
  21. data/lib/riak/client/beefcake/socket.rb +2 -2
  22. data/lib/riak/client/beefcake_protobuffs_backend.rb +58 -33
  23. data/lib/riak/client/protobuffs_backend.rb +5 -5
  24. data/lib/riak/client/yokozuna.rb +3 -3
  25. data/lib/riak/core_ext/deep_dup.rb +1 -1
  26. data/lib/riak/counter.rb +10 -10
  27. data/lib/riak/crdt/base.rb +39 -21
  28. data/lib/riak/crdt/batch_counter.rb +5 -5
  29. data/lib/riak/crdt/batch_map.rb +2 -2
  30. data/lib/riak/crdt/counter.rb +7 -7
  31. data/lib/riak/crdt/inner_counter.rb +4 -4
  32. data/lib/riak/crdt/inner_flag.rb +3 -3
  33. data/lib/riak/crdt/inner_map.rb +1 -1
  34. data/lib/riak/crdt/inner_register.rb +1 -1
  35. data/lib/riak/crdt/inner_set.rb +5 -5
  36. data/lib/riak/crdt/map.rb +9 -9
  37. data/lib/riak/crdt/set.rb +10 -10
  38. data/lib/riak/crdt/typed_collection.rb +39 -36
  39. data/lib/riak/errors/base.rb +1 -1
  40. data/lib/riak/errors/crdt_error.rb +20 -0
  41. data/lib/riak/errors/search_error.rb +6 -0
  42. data/lib/riak/index_collection.rb +1 -1
  43. data/lib/riak/link.rb +5 -3
  44. data/lib/riak/locale/en.yml +5 -1
  45. data/lib/riak/map_reduce.rb +7 -7
  46. data/lib/riak/map_reduce/filter_builder.rb +2 -2
  47. data/lib/riak/map_reduce/phase.rb +2 -2
  48. data/lib/riak/preflist_item.rb +7 -0
  49. data/lib/riak/rcontent.rb +8 -8
  50. data/lib/riak/robject.rb +27 -14
  51. data/lib/riak/search.rb +1 -0
  52. data/lib/riak/search/index.rb +17 -3
  53. data/lib/riak/search/query.rb +14 -6
  54. data/lib/riak/search/result_collection.rb +56 -3
  55. data/lib/riak/search/result_document.rb +71 -1
  56. data/lib/riak/search/schema.rb +6 -6
  57. data/lib/riak/secondary_index.rb +20 -12
  58. data/lib/riak/serializers.rb +0 -1
  59. data/lib/riak/util/escape.rb +2 -2
  60. data/lib/riak/util/translation.rb +1 -2
  61. data/lib/riak/version.rb +1 -1
  62. data/lib/riak/walk_spec.rb +67 -32
  63. data/riak-client.gemspec +5 -4
  64. data/spec/integration/riak/bucket_types_spec.rb +35 -5
  65. data/spec/integration/riak/conflict_resolution_spec.rb +1 -1
  66. data/spec/integration/riak/counters_spec.rb +1 -1
  67. data/spec/integration/riak/crdt/configuration_spec.rb +37 -0
  68. data/spec/integration/riak/crdt_search_spec.rb +176 -0
  69. data/spec/integration/riak/crdt_spec.rb +9 -33
  70. data/spec/integration/riak/crdt_validation/map_spec.rb +4 -4
  71. data/spec/integration/riak/crdt_validation/set_spec.rb +13 -13
  72. data/spec/integration/riak/preflist_spec.rb +31 -0
  73. data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +2 -2
  74. data/spec/integration/riak/protobuffs_backends_spec.rb +9 -2
  75. data/spec/integration/riak/search_spec.rb +3 -3
  76. data/spec/integration/riak/secondary_index_spec.rb +3 -3
  77. data/spec/integration/riak/security_spec.rb +7 -7
  78. data/spec/integration/yokozuna/queries_spec.rb +1 -1
  79. data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +9 -9
  80. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +9 -9
  81. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +5 -5
  82. data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
  83. data/spec/riak/bucket_properties_spec.rb +27 -6
  84. data/spec/riak/bucket_spec.rb +5 -5
  85. data/spec/riak/bucket_type_spec.rb +21 -5
  86. data/spec/riak/bucket_typed/bucket_spec.rb +62 -0
  87. data/spec/riak/client_spec.rb +36 -18
  88. data/spec/riak/counter_spec.rb +4 -4
  89. data/spec/riak/crdt/counter_spec.rb +2 -2
  90. data/spec/riak/crdt/inner_flag_spec.rb +2 -2
  91. data/spec/riak/crdt/inner_map_spec.rb +4 -4
  92. data/spec/riak/crdt/inner_register_spec.rb +1 -1
  93. data/spec/riak/crdt/map_spec.rb +4 -4
  94. data/spec/riak/crdt/shared_examples.rb +5 -5
  95. data/spec/riak/crdt/typed_collection_spec.rb +21 -21
  96. data/spec/riak/map_reduce/filter_builder_spec.rb +2 -2
  97. data/spec/riak/map_reduce/phase_spec.rb +4 -4
  98. data/spec/riak/map_reduce_spec.rb +60 -42
  99. data/spec/riak/multiget_spec.rb +2 -2
  100. data/spec/riak/robject_spec.rb +55 -14
  101. data/spec/riak/search/index_spec.rb +12 -2
  102. data/spec/riak/search/query_spec.rb +4 -4
  103. data/spec/riak/search/result_collection_spec.rb +6 -4
  104. data/spec/riak/search/result_document_spec.rb +52 -9
  105. data/spec/riak/search/schema_spec.rb +2 -2
  106. data/spec/riak/secondary_index_spec.rb +6 -6
  107. data/spec/riak/serializers_spec.rb +27 -10
  108. data/spec/riak/walk_spec_spec.rb +10 -6
  109. data/spec/spec_helper.rb +11 -2
  110. data/spec/support/crdt_search_config.rb +112 -0
  111. data/spec/support/crdt_search_fixtures.rb +42 -0
  112. data/spec/support/search_config.rb +7 -5
  113. data/spec/support/search_corpus_setup.rb +2 -2
  114. data/spec/support/test_client.rb +2 -2
  115. data/spec/support/unified_backend_examples.rb +5 -5
  116. data/spec/support/version_filter.rb +5 -3
  117. data/spec/support/wait_until.rb +9 -3
  118. metadata +36 -13
  119. data/spec/riak/bucket_typed/bucket.rb +0 -43
@@ -0,0 +1,42 @@
1
+ module CrdtSearchFixtures
2
+ def map_result_score
3
+ 43.21
4
+ end
5
+
6
+ def maps_type_name
7
+ 'maps'
8
+ end
9
+
10
+ def maps_bucket_type
11
+ return @maps_bucket_type if defined? @maps_bucket_type
12
+
13
+ @maps_bucket_type = instance_double('Riak::BucketType').tap do |bt|
14
+ allow(bt).to receive(:bucket).
15
+ with(bucket_name).
16
+ and_return(map_bucket)
17
+ allow(bt).to receive(:data_type_class).
18
+ and_return(Riak::Crdt::Map)
19
+ end
20
+ end
21
+
22
+ def map_bucket
23
+ @map_bucket ||= instance_double('Riak::BucketTyped::Bucket')
24
+ end
25
+
26
+ def map_raw
27
+ @map_raw ||= {
28
+ 'score'=>map_result_score,
29
+ '_yz_rb'=>bucket_name,
30
+ '_yz_rt'=>maps_type_name,
31
+ '_yz_rk'=>'map-key'
32
+ }
33
+ end
34
+
35
+ def map_results
36
+ @map_results ||= Riak::Search::ResultDocument.new client, map_raw
37
+ end
38
+ end
39
+
40
+ RSpec.configure do |config|
41
+ config.include CrdtSearchFixtures, crdt_search_fixtures: true
42
+ end
@@ -11,15 +11,17 @@ module SearchConfig
11
11
  @index_name ||= search_bucket.name
12
12
  end
13
13
 
14
+ def index
15
+ return @index if defined? @index
16
+ create_index
17
+ @index = Riak::Search::Index.new test_client, index_name
18
+ end
19
+
14
20
  def create_index
15
21
  return if defined? @index_exists
16
22
 
17
23
  test_client.create_search_index index_name
18
24
 
19
- wait_until do
20
- test_client.get_search_index index_name
21
- end
22
-
23
25
  @index_exists = true
24
26
  end
25
27
 
@@ -28,7 +30,7 @@ module SearchConfig
28
30
 
29
31
  create_index
30
32
 
31
- test_client.set_bucket_props(search_bucket,
33
+ test_client.set_bucket_props(search_bucket,
32
34
  { search_index: index_name },
33
35
  'yokozuna')
34
36
 
@@ -28,9 +28,9 @@ shared_context "search corpus setup" do
28
28
  end
29
29
  end
30
30
  Encoding.default_external = old_encoding
31
-
31
+
32
32
  wait_until do
33
- results = @backend.search(@search_bucket.name,
33
+ results = @backend.search(@search_bucket.name,
34
34
  'contain your entire keyspace',
35
35
  df: 'text')
36
36
  results['docs'].length > 0
@@ -7,7 +7,7 @@ module TestClient
7
7
  candidate_client = Riak::Client.new test_client_configuration
8
8
 
9
9
  live = candidate_client.ping
10
-
10
+
11
11
  return $test_client = candidate_client if live
12
12
  end
13
13
 
@@ -31,7 +31,7 @@ module TestClient
31
31
  $test_client_configuration = config
32
32
  end
33
33
 
34
- def random_bucket(name='test_client')
34
+ def random_bucket(name = 'test_client')
35
35
  bucket_name = [name, Time.now.to_i, random_key].join('-')
36
36
  test_client.bucket bucket_name
37
37
  end
@@ -45,7 +45,7 @@ shared_examples_for "Unified backend API" do
45
45
  expect(@exception).to be_not_found
46
46
  end
47
47
 
48
- [1,2,3,:one,:quorum,:all,:default].each do |q|
48
+ [1, 2, 3, :one, :quorum, :all, :default].each do |q|
49
49
  it "accepts a R value of #{q.inspect} for the request" do
50
50
  robj = @backend.fetch_object(@bucket.name, "fetch", :r => q)
51
51
  expect(robj).to be_kind_of(Riak::RObject)
@@ -82,7 +82,7 @@ shared_examples_for "Unified backend API" do
82
82
  @backend.reload_object(@robject)
83
83
  end
84
84
 
85
- [1,2,3,:one,:quorum,:all,:default].each do |q|
85
+ [1, 2, 3, :one, :quorum, :all, :default].each do |q|
86
86
  it "accepts a valid R value of #{q.inspect} for the request" do
87
87
  @backend.reload_object(@robject, :r => q)
88
88
  end
@@ -117,7 +117,7 @@ shared_examples_for "Unified backend API" do
117
117
  expect(@robject.vclock).to be_present
118
118
  end
119
119
 
120
- [1,2,3,:one,:quorum,:all,:default].each do |q|
120
+ [1, 2, 3, :one, :quorum, :all, :default].each do |q|
121
121
  it "accepts a W value of #{q.inspect} for the request" do
122
122
  @backend.store_object(@robject, :returnbody => false, :w => q)
123
123
  expect(@bucket.exists?(@robject.key)).to be_truthy
@@ -158,7 +158,7 @@ shared_examples_for "Unified backend API" do
158
158
  expect(@obj.bucket.exists?("delete")).to be_falsey
159
159
  end
160
160
 
161
- [1,2,3,:one,:quorum,:all,:default].each do |q|
161
+ [1, 2, 3, :one, :quorum, :all, :default].each do |q|
162
162
  it "accepts an RW value of #{q.inspect} for the request" do
163
163
  @backend.delete_object("test", "delete", :rw => q)
164
164
  end
@@ -273,7 +273,7 @@ shared_examples_for "Unified backend API" do
273
273
  end
274
274
 
275
275
  it "finds keys for a range query" do
276
- expect(@backend.get_index('test', 'index_int', 19..21)).to match_array(["19","20", "21"])
276
+ expect(@backend.get_index('test', 'index_int', 19..21)).to match_array(%w(19 20 21))
277
277
  end
278
278
 
279
279
  it "returns an empty array for a query that does not match any keys" do
@@ -1,10 +1,12 @@
1
1
  require 'rubygems'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.before(:each, :version => lambda {|v| !!v }) do |example|
4
+ config.before(:each, version: ->(v) { v }) do |example|
5
5
  required = Gem::Requirement.create(example.metadata[:version])
6
6
  actual = Gem::Version.new(test_server.version)
7
- skip("SKIP: Tests feature for Riak #{required.to_s}, but testing against #{actual.to_s}",
8
- :unless => required.satisfied_by?(actual))
7
+ skip(
8
+ "SKIP: Tests feature for Riak #{required}, but testing against #{actual}",
9
+ unless: required.satisfied_by?(actual)
10
+ )
9
11
  end
10
12
  end
@@ -1,8 +1,14 @@
1
+ # This module is used for search testing, and other testing activities that may
2
+ # take time to "settle" in Riak.
1
3
  module WaitUntil
2
- def wait_until(attempts=10)
4
+ def wait_until(attempts = 10)
3
5
  (0..attempts).each do |a|
4
- break if yield rescue nil
5
-
6
+ begin
7
+ break if yield
8
+ rescue
9
+ nil
10
+ end
11
+
6
12
  sleep a
7
13
  end
8
14
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riak-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.pre1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Sean Cribbs
8
7
  - Bryce Kerley
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
@@ -73,14 +72,14 @@ dependencies:
73
72
  requirements:
74
73
  - - "~>"
75
74
  - !ruby/object:Gem::Version
76
- version: 0.8.2
75
+ version: 0.10.0
77
76
  type: :development
78
77
  prerelease: false
79
78
  version_requirements: !ruby/object:Gem::Requirement
80
79
  requirements:
81
80
  - - "~>"
82
81
  - !ruby/object:Gem::Version
83
- version: 0.8.2
82
+ version: 0.10.0
84
83
  - !ruby/object:Gem::Dependency
85
84
  name: instrumentable
86
85
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +94,20 @@ dependencies:
95
94
  - - "~>"
96
95
  - !ruby/object:Gem::Version
97
96
  version: 1.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.28.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.28.0
98
111
  - !ruby/object:Gem::Dependency
99
112
  name: i18n
100
113
  requirement: !ruby/object:Gem::Requirement
@@ -115,14 +128,14 @@ dependencies:
115
128
  requirements:
116
129
  - - "~>"
117
130
  - !ruby/object:Gem::Version
118
- version: '1.0'
131
+ version: '1.1'
119
132
  type: :runtime
120
133
  prerelease: false
121
134
  version_requirements: !ruby/object:Gem::Requirement
122
135
  requirements:
123
136
  - - "~>"
124
137
  - !ruby/object:Gem::Version
125
- version: '1.0'
138
+ version: '1.1'
126
139
  - !ruby/object:Gem::Dependency
127
140
  name: multi_json
128
141
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +182,6 @@ description: riak-client is a rich client for Riak, the distributed database by
169
182
  It supports the full HTTP and Protocol Buffers interfaces including storage operations,
170
183
  bucket configuration, link-walking, secondary indexes and map-reduce.
171
184
  email:
172
- - sean@basho.com
173
185
  - bryce@basho.com
174
186
  executables: []
175
187
  extensions: []
@@ -259,6 +271,7 @@ files:
259
271
  - lib/riak/map_reduce/results.rb
260
272
  - lib/riak/map_reduce_error.rb
261
273
  - lib/riak/multiget.rb
274
+ - lib/riak/preflist_item.rb
262
275
  - lib/riak/rcontent.rb
263
276
  - lib/riak/robject.rb
264
277
  - lib/riak/search.rb
@@ -292,9 +305,12 @@ files:
292
305
  - spec/integration/riak/bucket_types_spec.rb
293
306
  - spec/integration/riak/conflict_resolution_spec.rb
294
307
  - spec/integration/riak/counters_spec.rb
308
+ - spec/integration/riak/crdt/configuration_spec.rb
309
+ - spec/integration/riak/crdt_search_spec.rb
295
310
  - spec/integration/riak/crdt_spec.rb
296
311
  - spec/integration/riak/crdt_validation/map_spec.rb
297
312
  - spec/integration/riak/crdt_validation/set_spec.rb
313
+ - spec/integration/riak/preflist_spec.rb
298
314
  - spec/integration/riak/properties_spec.rb
299
315
  - spec/integration/riak/protobuffs/interrupted_request_spec.rb
300
316
  - spec/integration/riak/protobuffs_backends_spec.rb
@@ -313,7 +329,7 @@ files:
313
329
  - spec/riak/bucket_properties_spec.rb
314
330
  - spec/riak/bucket_spec.rb
315
331
  - spec/riak/bucket_type_spec.rb
316
- - spec/riak/bucket_typed/bucket.rb
332
+ - spec/riak/bucket_typed/bucket_spec.rb
317
333
  - spec/riak/client_spec.rb
318
334
  - spec/riak/core_ext/to_param_spec.rb
319
335
  - spec/riak/counter_spec.rb
@@ -360,6 +376,8 @@ files:
360
376
  - spec/support/certs/server.crl
361
377
  - spec/support/certs/server.crt
362
378
  - spec/support/certs/server.key
379
+ - spec/support/crdt_search_config.rb
380
+ - spec/support/crdt_search_fixtures.rb
363
381
  - spec/support/integration_setup.rb
364
382
  - spec/support/search_config.rb
365
383
  - spec/support/search_corpus_setup.rb
@@ -384,12 +402,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
384
402
  version: 1.9.3
385
403
  required_rubygems_version: !ruby/object:Gem::Requirement
386
404
  requirements:
387
- - - ">"
405
+ - - ">="
388
406
  - !ruby/object:Gem::Version
389
- version: 1.3.1
407
+ version: '0'
390
408
  requirements: []
391
409
  rubyforge_project:
392
- rubygems_version: 2.4.5
410
+ rubygems_version: 2.4.6
393
411
  signing_key:
394
412
  specification_version: 4
395
413
  summary: riak-client is a rich client for Riak, the distributed database by Basho.
@@ -410,9 +428,12 @@ test_files:
410
428
  - spec/integration/riak/bucket_types_spec.rb
411
429
  - spec/integration/riak/conflict_resolution_spec.rb
412
430
  - spec/integration/riak/counters_spec.rb
431
+ - spec/integration/riak/crdt/configuration_spec.rb
432
+ - spec/integration/riak/crdt_search_spec.rb
413
433
  - spec/integration/riak/crdt_spec.rb
414
434
  - spec/integration/riak/crdt_validation/map_spec.rb
415
435
  - spec/integration/riak/crdt_validation/set_spec.rb
436
+ - spec/integration/riak/preflist_spec.rb
416
437
  - spec/integration/riak/properties_spec.rb
417
438
  - spec/integration/riak/protobuffs/interrupted_request_spec.rb
418
439
  - spec/integration/riak/protobuffs_backends_spec.rb
@@ -431,7 +452,7 @@ test_files:
431
452
  - spec/riak/bucket_properties_spec.rb
432
453
  - spec/riak/bucket_spec.rb
433
454
  - spec/riak/bucket_type_spec.rb
434
- - spec/riak/bucket_typed/bucket.rb
455
+ - spec/riak/bucket_typed/bucket_spec.rb
435
456
  - spec/riak/client_spec.rb
436
457
  - spec/riak/core_ext/to_param_spec.rb
437
458
  - spec/riak/counter_spec.rb
@@ -478,6 +499,8 @@ test_files:
478
499
  - spec/support/certs/server.crl
479
500
  - spec/support/certs/server.crt
480
501
  - spec/support/certs/server.key
502
+ - spec/support/crdt_search_config.rb
503
+ - spec/support/crdt_search_fixtures.rb
481
504
  - spec/support/integration_setup.rb
482
505
  - spec/support/search_config.rb
483
506
  - spec/support/search_corpus_setup.rb
@@ -1,43 +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.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 'bucket properties' do
24
- it 'returns properties scoped by bucket and type' do
25
- expect(client).to receive(:get_bucket_props).with(subject, { type: subject.type.name }).and_return('allow_mult' => true)
26
-
27
- expect(props = subject.props).to be_a Hash
28
- expect(props['allow_mult']).to be
29
- end
30
-
31
- it 'clears properties scoped by bucket and type' do
32
- expect(client).to receive(:clear_bucket_props).with(subject, { type: subject.type.name })
33
-
34
- expect{ subject.clear_props }.to_not raise_error
35
- end
36
-
37
- it 'sets properties scoped by bucket and type' do
38
- expect(client).to receive(:set_bucket_props).with(subject, { 'allow_mult' => true }, subject.type.name)
39
-
40
- expect{ subject.props = { 'allow_mult' => true } }.to_not raise_error
41
- end
42
- end
43
- end