riak-client 1.4.5 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +0 -1
  4. data/{LICENSE → LICENSE.md} +0 -0
  5. data/README.markdown +211 -66
  6. data/RELEASE_NOTES.md +22 -47
  7. data/Rakefile +45 -0
  8. data/lib/riak.rb +1 -1
  9. data/lib/riak/bucket.rb +2 -2
  10. data/lib/riak/client.rb +22 -195
  11. data/lib/riak/client/beefcake/crdt_loader.rb +127 -0
  12. data/lib/riak/client/beefcake/crdt_operator.rb +222 -0
  13. data/lib/riak/client/beefcake/footer +4 -0
  14. data/lib/riak/client/beefcake/header +6 -0
  15. data/lib/riak/client/beefcake/message_codes.rb +29 -0
  16. data/lib/riak/client/beefcake/message_overlay.rb +61 -0
  17. data/lib/riak/client/beefcake/messages.rb +733 -371
  18. data/lib/riak/client/beefcake/object_methods.rb +1 -1
  19. data/lib/riak/client/beefcake/protocol.rb +105 -0
  20. data/lib/riak/client/beefcake/socket.rb +243 -0
  21. data/lib/riak/client/beefcake_protobuffs_backend.rb +262 -122
  22. data/lib/riak/client/node.rb +4 -75
  23. data/lib/riak/client/protobuffs_backend.rb +6 -14
  24. data/lib/riak/client/search.rb +0 -64
  25. data/lib/riak/client/yokozuna.rb +52 -0
  26. data/lib/riak/counter.rb +1 -1
  27. data/lib/riak/crdt.rb +21 -0
  28. data/lib/riak/crdt/base.rb +97 -0
  29. data/lib/riak/crdt/batch_counter.rb +19 -0
  30. data/lib/riak/crdt/batch_map.rb +41 -0
  31. data/lib/riak/crdt/counter.rb +71 -0
  32. data/lib/riak/crdt/inner_counter.rb +74 -0
  33. data/lib/riak/crdt/inner_flag.rb +42 -0
  34. data/lib/riak/crdt/inner_map.rb +53 -0
  35. data/lib/riak/crdt/inner_register.rb +26 -0
  36. data/lib/riak/crdt/inner_set.rb +95 -0
  37. data/lib/riak/crdt/map.rb +88 -0
  38. data/lib/riak/crdt/operation.rb +19 -0
  39. data/lib/riak/crdt/set.rb +156 -0
  40. data/lib/riak/crdt/typed_collection.rb +131 -0
  41. data/lib/riak/errors/base.rb +9 -0
  42. data/lib/riak/errors/connection_error.rb +44 -0
  43. data/lib/riak/errors/crdt_error.rb +18 -0
  44. data/lib/riak/errors/failed_request.rb +56 -0
  45. data/lib/riak/errors/protobuffs_error.rb +11 -0
  46. data/lib/riak/i18n.rb +2 -0
  47. data/lib/riak/json.rb +1 -1
  48. data/lib/riak/locale/en.yml +26 -1
  49. data/lib/riak/locale/fr.yml +0 -1
  50. data/lib/riak/map_reduce.rb +1 -1
  51. data/lib/riak/map_reduce/results.rb +1 -1
  52. data/lib/riak/multiget.rb +1 -2
  53. data/lib/riak/rcontent.rb +8 -3
  54. data/lib/riak/robject.rb +2 -8
  55. data/lib/riak/secondary_index.rb +4 -4
  56. data/lib/riak/serializers.rb +1 -1
  57. data/lib/riak/util/escape.rb +3 -5
  58. data/lib/riak/version.rb +1 -1
  59. data/lib/riak/walk_spec.rb +7 -3
  60. data/riak-client.gemspec +10 -8
  61. data/spec/fixtures/bitcask.txt +25 -0
  62. data/spec/integration/riak/bucket_types_spec.rb +61 -0
  63. data/spec/integration/riak/counters_spec.rb +17 -32
  64. data/spec/integration/riak/crdt_spec.rb +181 -0
  65. data/spec/integration/riak/crdt_validation/map_spec.rb +63 -0
  66. data/spec/integration/riak/crdt_validation/set_spec.rb +122 -0
  67. data/spec/integration/riak/protobuffs_backends_spec.rb +9 -26
  68. data/spec/integration/riak/security_spec.rb +94 -0
  69. data/spec/integration/riak/threading_spec.rb +24 -67
  70. data/spec/integration/yokozuna/index_spec.rb +61 -0
  71. data/spec/integration/yokozuna/queries_spec.rb +116 -0
  72. data/spec/integration/yokozuna/schema_spec.rb +49 -0
  73. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +222 -0
  74. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +4 -4
  75. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +189 -0
  76. data/spec/riak/beefcake_protobuffs_backend/socket_spec.rb +151 -0
  77. data/spec/riak/beefcake_protobuffs_backend_spec.rb +68 -106
  78. data/spec/riak/bucket_spec.rb +81 -77
  79. data/spec/riak/client_spec.rb +43 -340
  80. data/spec/riak/core_ext/to_param_spec.rb +2 -2
  81. data/spec/riak/counter_spec.rb +20 -20
  82. data/spec/riak/crdt/counter_spec.rb +52 -0
  83. data/spec/riak/crdt/inner_counter_spec.rb +21 -0
  84. data/spec/riak/crdt/inner_flag_spec.rb +39 -0
  85. data/spec/riak/crdt/inner_map_spec.rb +47 -0
  86. data/spec/riak/crdt/inner_register_spec.rb +40 -0
  87. data/spec/riak/crdt/inner_set_spec.rb +33 -0
  88. data/spec/riak/crdt/map_spec.rb +77 -0
  89. data/spec/riak/crdt/set_spec.rb +58 -0
  90. data/spec/riak/crdt/shared_examples.rb +74 -0
  91. data/spec/riak/crdt/typed_collection_spec.rb +231 -0
  92. data/spec/riak/escape_spec.rb +33 -37
  93. data/spec/riak/feature_detection_spec.rb +45 -45
  94. data/spec/riak/index_collection_spec.rb +12 -12
  95. data/spec/riak/link_spec.rb +34 -34
  96. data/spec/riak/list_buckets_spec.rb +7 -7
  97. data/spec/riak/map_reduce/filter_builder_spec.rb +6 -6
  98. data/spec/riak/map_reduce/phase_spec.rb +35 -35
  99. data/spec/riak/map_reduce_spec.rb +89 -87
  100. data/spec/riak/multiget_spec.rb +20 -15
  101. data/spec/riak/node_spec.rb +5 -152
  102. data/spec/riak/robject_spec.rb +95 -108
  103. data/spec/riak/search_spec.rb +17 -139
  104. data/spec/riak/secondary_index_spec.rb +49 -49
  105. data/spec/riak/serializers_spec.rb +9 -9
  106. data/spec/riak/stamp_spec.rb +9 -9
  107. data/spec/riak/walk_spec_spec.rb +46 -46
  108. data/spec/spec_helper.rb +14 -22
  109. data/spec/support/certs/README.md +13 -0
  110. data/spec/support/certs/ca.crt +22 -0
  111. data/spec/support/certs/client.crt +95 -0
  112. data/spec/support/certs/client.key +27 -0
  113. data/spec/support/certs/empty_ca.crt +21 -0
  114. data/spec/support/certs/server.crl +13 -0
  115. data/spec/support/certs/server.crt +95 -0
  116. data/spec/support/certs/server.key +27 -0
  117. data/spec/support/integration_setup.rb +1 -1
  118. data/spec/support/search_corpus_setup.rb +29 -8
  119. data/spec/support/test_client.rb +46 -0
  120. data/spec/support/test_client.yml.example +10 -0
  121. data/spec/support/unified_backend_examples.rb +104 -83
  122. data/spec/support/version_filter.rb +2 -2
  123. data/spec/support/wait_until.rb +14 -0
  124. metadata +134 -132
  125. data/erl_src/riak_kv_test014_backend.beam +0 -0
  126. data/erl_src/riak_kv_test014_backend.erl +0 -189
  127. data/erl_src/riak_kv_test_backend.beam +0 -0
  128. data/erl_src/riak_kv_test_backend.erl +0 -731
  129. data/erl_src/riak_search_test_backend.beam +0 -0
  130. data/erl_src/riak_search_test_backend.erl +0 -175
  131. data/lib/riak/client/excon_backend.rb +0 -172
  132. data/lib/riak/client/http_backend.rb +0 -413
  133. data/lib/riak/client/http_backend/bucket_streamer.rb +0 -15
  134. data/lib/riak/client/http_backend/chunked_json_streamer.rb +0 -42
  135. data/lib/riak/client/http_backend/configuration.rb +0 -227
  136. data/lib/riak/client/http_backend/key_streamer.rb +0 -15
  137. data/lib/riak/client/http_backend/object_methods.rb +0 -114
  138. data/lib/riak/client/http_backend/request_headers.rb +0 -34
  139. data/lib/riak/client/http_backend/transport_methods.rb +0 -201
  140. data/lib/riak/client/instrumentation.rb +0 -25
  141. data/lib/riak/client/net_http_backend.rb +0 -82
  142. data/lib/riak/cluster.rb +0 -151
  143. data/lib/riak/failed_request.rb +0 -81
  144. data/lib/riak/instrumentation.rb +0 -6
  145. data/lib/riak/node.rb +0 -40
  146. data/lib/riak/node/configuration.rb +0 -304
  147. data/lib/riak/node/console.rb +0 -133
  148. data/lib/riak/node/control.rb +0 -207
  149. data/lib/riak/node/defaults.rb +0 -85
  150. data/lib/riak/node/generation.rb +0 -127
  151. data/lib/riak/node/log.rb +0 -34
  152. data/lib/riak/node/version.rb +0 -29
  153. data/lib/riak/search.rb +0 -3
  154. data/lib/riak/test_server.rb +0 -89
  155. data/lib/riak/util/headers.rb +0 -32
  156. data/lib/riak/util/multipart.rb +0 -52
  157. data/lib/riak/util/multipart/stream_parser.rb +0 -62
  158. data/spec/fixtures/munchausen.txt +0 -1033
  159. data/spec/integration/riak/cluster_spec.rb +0 -88
  160. data/spec/integration/riak/http_backends_spec.rb +0 -180
  161. data/spec/integration/riak/node_spec.rb +0 -170
  162. data/spec/integration/riak/test_server_spec.rb +0 -57
  163. data/spec/riak/excon_backend_spec.rb +0 -102
  164. data/spec/riak/headers_spec.rb +0 -21
  165. data/spec/riak/http_backend/configuration_spec.rb +0 -273
  166. data/spec/riak/http_backend/object_methods_spec.rb +0 -243
  167. data/spec/riak/http_backend/transport_methods_spec.rb +0 -97
  168. data/spec/riak/http_backend_spec.rb +0 -367
  169. data/spec/riak/instrumentation_spec.rb +0 -167
  170. data/spec/riak/multipart_spec.rb +0 -23
  171. data/spec/riak/net_http_backend_spec.rb +0 -15
  172. data/spec/riak/stream_parser_spec.rb +0 -53
  173. data/spec/support/drb_mock_server.rb +0 -39
  174. data/spec/support/http_backend_implementation_examples.rb +0 -253
  175. data/spec/support/mock_server.rb +0 -81
  176. data/spec/support/mocks.rb +0 -4
  177. data/spec/support/riak_test.rb +0 -77
  178. data/spec/support/sometimes.rb +0 -46
  179. data/spec/support/test_server.rb +0 -61
  180. data/spec/support/test_server.yml.example +0 -14
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+ require 'riak'
3
+
4
+ describe 'CRDT map validation', integration: true, test_client: true do
5
+ let(:bucket){ random_bucket 'crdt_validation' }
6
+ let(:map){ Riak::Crdt::Map.new bucket, random_key }
7
+
8
+ it 'deletes sets and re-add entries' do
9
+ map.batch do |m|
10
+ m.sets['set'].add 'X'
11
+ m.sets['set'].add 'Y'
12
+ end
13
+
14
+ map.reload
15
+ expect(map.sets['set'].include? 'Y').to be
16
+
17
+ expect do
18
+ map.batch do |m|
19
+ m.sets.delete 'set'
20
+ m.sets['set'].add 'Z'
21
+ end
22
+ end.to_not raise_error
23
+
24
+ map2 = Riak::Crdt::Map.new bucket, map.key
25
+
26
+ expect(map2.sets['set'].members).to eq ::Set.new(['Z'])
27
+ end
28
+
29
+ it 'deletes counters and increments counters' do
30
+ map.counters['counter'].increment 5
31
+
32
+ map.reload
33
+
34
+ expect(map.counters['counter'].value).to eq 5
35
+
36
+ map.batch do |m|
37
+ m.counters['counter'].increment 2
38
+ m.counters.delete 'counter'
39
+ end
40
+
41
+ map2 = Riak::Crdt::Map.new bucket, map.key
42
+
43
+ expect(map2.counters['counter'].value).to eq(7).or eq(2)
44
+ end
45
+
46
+ it 'deletes maps containing sets and re-adds the contained sets' do
47
+ map.batch do |m|
48
+ m.maps['map'].sets['set'].add "X"
49
+ m.maps['map'].sets['set'].add "Y"
50
+ end
51
+
52
+ map.reload
53
+ expect(map.maps['map'].sets['set'].members).to eq ::Set.new(['X', 'Y'])
54
+
55
+ map.batch do |m|
56
+ m.maps.delete 'map'
57
+ m.maps['map'].sets['set'].add "Z"
58
+ end
59
+
60
+ map2 = Riak::Crdt::Map.new bucket, map.key
61
+ expect(map2.maps['map'].sets['set'].members).to eq ::Set.new(['Z'])
62
+ end
63
+ end
@@ -0,0 +1,122 @@
1
+ require 'spec_helper'
2
+ require 'riak'
3
+
4
+ describe 'CRDT set validation', integration: true, test_client: true do
5
+ let(:bucket){ random_bucket 'crdt_validation' }
6
+ let(:set){ Riak::Crdt::Set.new bucket, random_key }
7
+
8
+ it 'removes recently-added set entries during batch mode' do
9
+ expect do
10
+ set.batch do |s|
11
+ s.add 'X'
12
+ s.add 'Y'
13
+ s.add 'Z'
14
+ s.remove 'Y'
15
+ end
16
+ end.to raise_error Riak::CrdtError::SetRemovalWithoutContextError
17
+ end
18
+
19
+ it 'removes non-members with context' do
20
+ set.batch do |s|
21
+ s.add 'X'
22
+ s.add 'Y'
23
+ end
24
+
25
+ set.reload
26
+
27
+ expect{ set.remove 'bogus' }.to_not raise_error
28
+
29
+ set2 = Riak::Crdt::Set.new bucket, set.key
30
+ expect(set2.members).to eq ::Set.new(%w{X Y})
31
+ end
32
+
33
+ it 'adds duplicate members' do
34
+ set.batch do |s|
35
+ s.add 'X'
36
+ s.add 'Y'
37
+ end
38
+
39
+ set.reload
40
+
41
+ expect{ set.add 'X' }.to_not raise_error
42
+
43
+ set2 = Riak::Crdt::Set.new bucket, set.key
44
+ expect(set2.members).to eq ::Set.new(%w{X Y})
45
+ end
46
+
47
+ it 'no-ops adding then removing a duplicate member' do
48
+ set.batch do |s|
49
+ s.add 'X'
50
+ s.add 'Y'
51
+ end
52
+
53
+ set.reload
54
+ expect(set.members).to eq ::Set.new(%w{X Y})
55
+
56
+ expect do
57
+ set.batch do |s|
58
+ s.add 'X'
59
+ s.remove 'X'
60
+ end
61
+ end.to_not raise_error
62
+
63
+ set2 = Riak::Crdt::Set.new bucket, set.key
64
+ expect(set2.members).to eq ::Set.new(%w{X Y})
65
+ end
66
+
67
+ it 'no-ops removing then re-adding a set member' do
68
+ set.batch do |s|
69
+ s.add 'X'
70
+ s.add 'Y'
71
+ end
72
+
73
+ set.reload
74
+ expect(set.members).to eq ::Set.new(%w{X Y})
75
+
76
+ expect do
77
+ set.batch do |s|
78
+ s.remove 'X'
79
+ s.add 'X'
80
+ end
81
+ end.to_not raise_error
82
+
83
+ set2 = Riak::Crdt::Set.new bucket, set.key
84
+ expect(set2.members).to eq ::Set.new(%w{X Y})
85
+ end
86
+
87
+ describe 'parallel operations' do
88
+ it 'removes with up-to-date context' do
89
+ set.batch do |s|
90
+ s.add 'X'
91
+ s.add 'Y'
92
+ end
93
+
94
+ set_parallel = Riak::Crdt::Set.new bucket, set.key
95
+ set_parallel.add 'Z'
96
+
97
+ set.reload
98
+
99
+ expect{ set.remove 'Z' }.to_not raise_error
100
+
101
+ set2 = Riak::Crdt::Set.new bucket, set.key
102
+ expect(set2.members).to eq ::Set.new(%w{X Y})
103
+ end
104
+
105
+ it "doesn't remove with outdated context" do
106
+ set.batch do |s|
107
+ s.add 'X'
108
+ s.add 'Y'
109
+ end
110
+
111
+ set.reload
112
+
113
+ set_parallel = Riak::Crdt::Set.new bucket, set.key
114
+ set_parallel.add 'Z'
115
+
116
+ expect{ set.remove 'Z' }.to_not raise_error
117
+
118
+ set2 = Riak::Crdt::Set.new bucket, set.key
119
+ expect(set2.members).to eq ::Set.new(%w{X Y Z})
120
+ end
121
+ end
122
+ end
@@ -1,10 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Protocol Buffers" do
3
+ describe "Protocol Buffers", test_client: true do
4
4
  before do
5
- @pbc_port ||= test_server.pb_port
6
- @http_port ||= test_server.http_port
7
- @client = Riak::Client.new(:http_port => @http_port, :pb_port => @pbc_port, :protocol => "pbc")
5
+ @client = test_client
6
+ @bucket = random_bucket 'protobuf_spec'
8
7
  end
9
8
 
10
9
  [:BeefcakeProtobuffsBackend].each do |klass|
@@ -17,30 +16,14 @@ describe "Protocol Buffers" do
17
16
 
18
17
  it_should_behave_like "Unified backend API"
19
18
 
20
- describe "searching fulltext indexes (1.1 and earlier)", :version => '< 1.2.0' do
19
+ describe "searching yokozuna" do
21
20
  include_context "search corpus setup"
22
21
 
23
- it 'should find document IDs via MapReduce' do
24
- # Note that the trailing options Hash is ignored when
25
- # emulating search with MapReduce
26
- results = @backend.search 'search_test', 'fearless elephant rushed'
27
- results.should have_key 'docs'
28
- results.should have_key 'max_score'
29
- results.should have_key 'num_found'
30
- results['docs'].should include({"id" => "munchausen-605"})
31
- end
32
- end
33
-
34
- if "".respond_to?(:encoding) # Ruby 1.9 and later only
35
- describe "searching fulltext indexes (1.2 and later)", :version => '>= 1.2.0' do
36
- include_context "search corpus setup"
37
-
38
- it 'should return documents with UTF-8 fields (GH #75)' do
39
- utf8 = Encoding.find('UTF-8')
40
- results = @backend.search 'search_test', 'fearless elephant rushed'
41
- results['docs'].each do |d|
42
- d.each {|(k,v)| k.encoding.should == utf8; v.encoding.should == utf8 }
43
- end
22
+ it 'should return documents with UTF-8 fields (GH #75)' do
23
+ utf8 = Encoding.find('UTF-8')
24
+ results = @backend.search @search_bucket.name, 'fearless elephant rushed', df: 'text'
25
+ results['docs'].each do |d|
26
+ d.each {|(k,v)| expect(k.encoding).to eq(utf8); expect(v.encoding).to eq(utf8) }
44
27
  end
45
28
  end
46
29
  end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+ require 'riak'
3
+ require 'riak/errors/connection_error'
4
+ require 'r509/cert/validator/errors'
5
+
6
+ describe 'Secure Protobuffs', test_client: true, integration: true do
7
+ let(:config){ test_client_configuration.dup }
8
+ describe 'without security enabled on Riak', no_security: true do
9
+ it 'connects normally without authentication configured' do
10
+ expect(test_client.security?).to_not be
11
+
12
+ expect{test_client.ping}.to_not raise_error
13
+ end
14
+
15
+ it 'refuses to connect with authentication configured' do
16
+ with_auth_config = config.dup
17
+ with_auth_config[:authentication] = { user: 'user', password: 'password' }
18
+
19
+ secure_client = Riak::Client.new with_auth_config
20
+
21
+ expect{ secure_client.ping }.to raise_error(Riak::TlsError)
22
+ end
23
+ end
24
+
25
+ describe 'with security enabled on Riak', yes_security: true do
26
+ it 'connects normally with authentication configured' do
27
+ secure_client = Riak::Client.new config
28
+
29
+ expect(secure_client.security?).to be
30
+
31
+ expect{secure_client.ping}.to_not raise_error
32
+ end
33
+
34
+ it 'refuses to connect without authentication configured' do
35
+ no_auth_config = config.dup
36
+ no_auth_config.delete :authentication
37
+
38
+ plaintext_client = Riak::Client.new no_auth_config
39
+
40
+ expect{ plaintext_client.ping }.
41
+ to(raise_error(Riak::ProtobuffsFailedRequest,
42
+ /security is enabled/i))
43
+ end
44
+
45
+ it "refuses to connect if the server cert isn't recognized" do
46
+ broken_auth_config = config.dup
47
+ broken_auth_config[:authentication] = broken_auth_config[:authentication].dup
48
+ # this CA has never ever been used to sign a key
49
+ broken_auth_config[:authentication][:ca_file] =
50
+ File.join('support', 'certs', 'empty_ca.crt')
51
+
52
+ bugged_crypto_client = Riak::Client.new broken_auth_config
53
+
54
+ expect{ bugged_crypto_client.ping }.
55
+ to(raise_error(OpenSSL::SSL::SSLError,
56
+ /certificate verify failed/i))
57
+ end
58
+
59
+ it "refuses to connect if the server cert is revoked" do
60
+ revoked_auth_config = config.dup
61
+ revoked_auth_config[:authentication] = revoked_auth_config[:authentication].dup
62
+
63
+ revoked_auth_config[:authentication][:crl_file] =
64
+ File.expand_path(File.join(__dir__, '..', '..', 'support', 'certs', 'server.crl'))
65
+ revoked_auth_config[:authentication][:crl] = true
66
+
67
+ revoked_auth_client = Riak::Client.new revoked_auth_config
68
+
69
+ expect{ revoked_auth_client.ping }.
70
+ to(raise_error(Riak::TlsError,
71
+ /revoked/i))
72
+ end
73
+ end
74
+
75
+ describe 'with client certificate security enabled on Riak', yes_security: true do
76
+ it 'connects normally with authentication configured' do
77
+ client_cert_config = config.dup
78
+ client_cert_config[:authentication] =
79
+ client_cert_config[:authentication].dup
80
+
81
+ client_cert_config[:authentication][:client_ca] = client_cert_config[:authentication]['ca_file']
82
+
83
+ client_cert_config[:authentication][:cert] = 'spec/support/certs/client.crt'
84
+ client_cert_config[:authentication][:key] = 'spec/support/certs/client.key'
85
+
86
+ client_cert_config[:authentication][:user] = 'certuser'
87
+ client_cert_config[:authentication][:password] = ''
88
+
89
+ cert_client = Riak::Client.new client_cert_config
90
+
91
+ expect{ cert_client.ping }.to_not raise_error
92
+ end
93
+ end
94
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Multithreaded client", :test_server => true do
3
+ describe "Multithreaded client", :test_client => true do
4
4
  class Synchronizer
5
5
  def initialize(n)
6
6
  @mutex = Mutex.new
@@ -55,31 +55,24 @@ describe "Multithreaded client", :test_server => true do
55
55
  end
56
56
 
57
57
  [
58
- {:protocol => 'pbc', :protobuffs_backend => :Beefcake},
59
- {:protocol => 'http', :http_backend => :NetHTTP},
60
- {:protocol => 'http', :http_backend => :Excon}
58
+ {:protobuffs_backend => :Beefcake}
61
59
  ].each do |opts|
62
60
  describe opts.inspect do
63
61
  before do
64
- @pb_port ||= test_server.pb_port
65
- @http_port ||= test_server.http_port
66
- @client = Riak::Client.new({
67
- :pb_port => @pb_port,
68
- :http_port => @http_port
69
- }.merge(opts))
62
+ @bucket = random_bucket 'threading'
70
63
  end
71
64
 
72
65
  it 'should get in parallel' do
73
66
  data = "the gun is good"
74
- ro = @client['test'].new('test')
67
+ ro = @bucket.new('test')
75
68
  ro.content_type = "application/json"
76
69
  ro.data = [data]
77
70
  ro.store
78
71
 
79
72
  threads 10, :synchronize => true do
80
- x = @client['test']['test']
81
- x.content_type.should == "application/json"
82
- x.data.should == [data]
73
+ x = @bucket['test']
74
+ expect(x.content_type).to eq("application/json")
75
+ expect(x.data).to eq([data])
83
76
  end
84
77
  end
85
78
 
@@ -88,27 +81,27 @@ describe "Multithreaded client", :test_server => true do
88
81
 
89
82
  n = 10
90
83
  threads n, :synchronize => true do |i|
91
- x = @client['test'].new("test-#{i}")
84
+ x = @bucket.new("test-#{i}")
92
85
  x.content_type = "application/json"
93
86
  x.data = ["#{data}-#{i}"]
94
87
  x.store
95
88
  end
96
89
 
97
90
  (0...n).each do |i|
98
- read = @client['test']["test-#{i}"]
99
- read.content_type.should == "application/json"
100
- read.data.should == ["#{data}-#{i}"]
91
+ read = @bucket["test-#{i}"]
92
+ expect(read.content_type).to eq("application/json")
93
+ expect(read.data).to eq(["#{data}-#{i}"])
101
94
  end
102
95
  end
103
96
 
104
97
  # This is a 1.0+ spec because putting with the same client ID
105
98
  # will not create siblings on 0.14 in the same way. This will
106
99
  # also likely fail for nodes with vnode_vclocks = false.
107
- it 'should put conflicts in parallel', :version => ">= 1.0.0" do
108
- @client['test'].allow_mult = true
109
- @client['test'].allow_mult.should == true
100
+ it 'should put conflicts in parallel' do
101
+ @bucket.allow_mult = true
102
+ expect(@bucket.allow_mult).to eq(true)
110
103
 
111
- init = @client['test'].new('test')
104
+ init = @bucket.new('test')
112
105
  init.content_type = "application/json"
113
106
  init.data = ''
114
107
  init.store
@@ -117,17 +110,17 @@ describe "Multithreaded client", :test_server => true do
117
110
  n = 10
118
111
  s = Synchronizer.new n
119
112
  threads n, :synchronize => true do |i|
120
- x = @client['test']["test"]
113
+ x = @bucket["test"]
121
114
  s.sync
122
115
  x.data = [i]
123
116
  x.store
124
117
  end
125
118
 
126
- read = @client['test']["test"]
127
- read.conflict?.should == true
128
- read.siblings.map do |sibling|
119
+ read = @bucket["test"]
120
+ expect(read.conflict?).to eq(true)
121
+ expect(read.siblings.map do |sibling|
129
122
  sibling.data.first
130
- end.to_set.should == (0...n).to_set
123
+ end.to_set).to eq((0...n).to_set)
131
124
  end
132
125
 
133
126
  it 'should list-keys and get in parallel', :slow => true do
@@ -136,7 +129,7 @@ describe "Multithreaded client", :test_server => true do
136
129
 
137
130
  # Create items
138
131
  count.times do |i|
139
- o = @client['test'].new("#{i}")
132
+ o = @bucket.new("#{i}")
140
133
  o.content_type = 'application/json'
141
134
  o.data = [i]
142
135
  o.store
@@ -144,48 +137,12 @@ describe "Multithreaded client", :test_server => true do
144
137
 
145
138
  threads(threads) do
146
139
  set = Set.new
147
- @client['test'].keys do |stream|
140
+ @bucket.keys do |stream|
148
141
  stream.each do |key|
149
- set.merge @client['test'][key].data
142
+ set.merge @bucket[key].data
150
143
  end
151
144
  end
152
- set.should == (0...count).to_set
153
- end
154
- end
155
-
156
- sometimes 'should mapreduce in parallel' do
157
- if ("1.0.0"..."1.1.0").include?(test_server.version)
158
- # On a fresh node, this module might not have been loaded yet
159
- # and the mapred test exposes a race condition in riak_pipe_v
160
- # when verifying function validity. This race condition is
161
- # fixed in 1.1.
162
- test_server.with_console do |console|
163
- console.command 'code:load(riak_kv_pipe_get), ok.'
164
- console.command 'code:load(riak_kv_mrc_map), ok.'
165
- end
166
- end
167
-
168
- count = 10
169
- threads = 10
170
-
171
- # Create items
172
- count.times do |i|
173
- o = @client['test'].new("#{i}")
174
- o.content_type = 'application/json'
175
- o.data = i
176
- o.store
177
- end
178
-
179
- # Ze mapreduce
180
- threads(threads) do
181
- # Mapreduce
182
- (0...count).inject(Riak::MapReduce.new(@client)) do |mr, i|
183
- mr.add('test', i.to_s)
184
- end.map(%{function(v) {
185
- return [v.key];
186
- }}, :keep => true).run.map do |s|
187
- s.to_i
188
- end.to_set.should == (0...count).to_set
145
+ expect(set).to eq((0...count).to_set)
189
146
  end
190
147
  end
191
148
  end