riak-client 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/RELNOTES.md +3 -0
- data/lib/riak/bucket.rb +1 -1
- data/lib/riak/client.rb +14 -7
- data/lib/riak/client/beefcake/messages.rb +13 -0
- data/lib/riak/multi.rb +101 -0
- data/lib/riak/multiexist.rb +14 -0
- data/lib/riak/multiget.rb +7 -107
- data/lib/riak/version.rb +1 -1
- metadata +12 -234
- data/.document +0 -5
- data/.gitignore +0 -44
- data/.rspec +0 -2
- data/Gemfile +0 -17
- data/Guardfile +0 -20
- data/Rakefile +0 -124
- data/riak-client.gemspec +0 -71
- data/spec/failover/failover.rb +0 -59
- data/spec/fixtures/bitcask.txt +0 -25
- data/spec/fixtures/cat.jpg +0 -0
- data/spec/fixtures/multipart-basic-conflict.txt +0 -15
- data/spec/fixtures/multipart-blank.txt +0 -7
- data/spec/fixtures/multipart-mapreduce.txt +0 -10
- data/spec/fixtures/multipart-with-body.txt +0 -16
- data/spec/fixtures/multipart-with-marked-tombstones.txt +0 -17
- data/spec/fixtures/multipart-with-unmarked-tombstone.txt +0 -16
- data/spec/fixtures/server.cert.crt +0 -15
- data/spec/fixtures/server.cert.key +0 -15
- data/spec/fixtures/test.pem +0 -1
- data/spec/fixtures/yz_schema_template.xml +0 -18
- data/spec/integration/riak/bucket_types_spec.rb +0 -308
- data/spec/integration/riak/conflict_resolution_spec.rb +0 -96
- data/spec/integration/riak/counters_spec.rb +0 -36
- data/spec/integration/riak/crdt/configuration_spec.rb +0 -38
- data/spec/integration/riak/crdt_search_spec.rb +0 -176
- data/spec/integration/riak/crdt_spec.rb +0 -332
- data/spec/integration/riak/crdt_validation/map_spec.rb +0 -63
- data/spec/integration/riak/crdt_validation/set_spec.rb +0 -122
- data/spec/integration/riak/encodings/crdt_spec.rb +0 -122
- data/spec/integration/riak/encodings/kv_spec.rb +0 -87
- data/spec/integration/riak/encodings/yz_spec.rb +0 -142
- data/spec/integration/riak/preflist_spec.rb +0 -43
- data/spec/integration/riak/properties_spec.rb +0 -69
- data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +0 -33
- data/spec/integration/riak/protobuffs/timeouts_spec.rb +0 -178
- data/spec/integration/riak/protobuffs_backends_spec.rb +0 -40
- data/spec/integration/riak/search_spec.rb +0 -104
- data/spec/integration/riak/secondary_index_spec.rb +0 -72
- data/spec/integration/riak/security_spec.rb +0 -105
- data/spec/integration/riak/threading_spec.rb +0 -154
- data/spec/integration/riak/time_series_spec.rb +0 -212
- data/spec/integration/yokozuna/index_spec.rb +0 -61
- data/spec/integration/yokozuna/queries_spec.rb +0 -115
- data/spec/integration/yokozuna/schema_spec.rb +0 -49
- data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +0 -247
- data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +0 -244
- data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +0 -53
- data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +0 -189
- data/spec/riak/beefcake_protobuffs_backend/ts_cell_codec_spec.rb +0 -124
- data/spec/riak/beefcake_protobuffs_backend_spec.rb +0 -162
- data/spec/riak/bucket_properties_spec.rb +0 -135
- data/spec/riak/bucket_spec.rb +0 -275
- data/spec/riak/bucket_type_spec.rb +0 -50
- data/spec/riak/bucket_typed/bucket_spec.rb +0 -78
- data/spec/riak/client_spec.rb +0 -304
- data/spec/riak/core_ext/to_param_spec.rb +0 -15
- data/spec/riak/counter_spec.rb +0 -122
- data/spec/riak/crdt/counter_spec.rb +0 -55
- data/spec/riak/crdt/hyper_log_log_spec.rb +0 -56
- data/spec/riak/crdt/inner_counter_spec.rb +0 -21
- data/spec/riak/crdt/inner_flag_spec.rb +0 -39
- data/spec/riak/crdt/inner_map_spec.rb +0 -47
- data/spec/riak/crdt/inner_register_spec.rb +0 -40
- data/spec/riak/crdt/inner_set_spec.rb +0 -33
- data/spec/riak/crdt/map_spec.rb +0 -78
- data/spec/riak/crdt/set_spec.rb +0 -61
- data/spec/riak/crdt/shared_examples.rb +0 -88
- data/spec/riak/crdt/typed_collection_spec.rb +0 -225
- data/spec/riak/escape_spec.rb +0 -72
- data/spec/riak/feature_detection_spec.rb +0 -77
- data/spec/riak/index_collection_spec.rb +0 -53
- data/spec/riak/instrumentation_spec.rb +0 -124
- data/spec/riak/link_spec.rb +0 -85
- data/spec/riak/list_buckets_spec.rb +0 -41
- data/spec/riak/map_reduce/filter_builder_spec.rb +0 -32
- data/spec/riak/map_reduce/phase_spec.rb +0 -142
- data/spec/riak/map_reduce_spec.rb +0 -434
- data/spec/riak/multiget_spec.rb +0 -81
- data/spec/riak/node_spec.rb +0 -26
- data/spec/riak/robject_spec.rb +0 -542
- data/spec/riak/search/index_spec.rb +0 -72
- data/spec/riak/search/query_spec.rb +0 -88
- data/spec/riak/search/result_collection_spec.rb +0 -89
- data/spec/riak/search/result_document_spec.rb +0 -106
- data/spec/riak/search/schema_spec.rb +0 -63
- data/spec/riak/search_spec.rb +0 -107
- data/spec/riak/secondary_index_spec.rb +0 -225
- data/spec/riak/serializers_spec.rb +0 -121
- data/spec/riak/stamp_spec.rb +0 -54
- data/spec/riak/time_series/deletion_spec.rb +0 -33
- data/spec/riak/time_series/listing_spec.rb +0 -51
- data/spec/riak/time_series/submission_spec.rb +0 -35
- data/spec/riak/util/gzip_spec.rb +0 -49
- data/spec/riak/walk_spec_spec.rb +0 -203
- data/spec/spec_helper.rb +0 -67
- data/spec/support/certs/README.md +0 -13
- data/spec/support/certs/ca.crt +0 -21
- data/spec/support/certs/client.crl +0 -13
- data/spec/support/certs/client.crt +0 -94
- data/spec/support/certs/client.csr +0 -18
- data/spec/support/certs/client.key +0 -27
- data/spec/support/certs/empty_ca.crt +0 -21
- data/spec/support/certs/server.crl +0 -13
- data/spec/support/certs/server.crt +0 -94
- data/spec/support/certs/server.key +0 -27
- data/spec/support/crdt_search_config.rb +0 -112
- data/spec/support/crdt_search_fixtures.rb +0 -42
- data/spec/support/integration_setup.rb +0 -10
- data/spec/support/search_config.rb +0 -83
- data/spec/support/search_corpus_setup.rb +0 -39
- data/spec/support/test_client.rb +0 -52
- data/spec/support/test_client.yml.example +0 -10
- data/spec/support/unified_backend_examples.rb +0 -402
- data/spec/support/version_filter.rb +0 -12
- data/spec/support/wait_until.rb +0 -20
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
--CvfrSTCWwIiwezy0Zt1B2zwKgS7
|
3
|
-
Content-Type: multipart/mixed; boundary=E9n2ZOKHIazIoPHzXj9XsWYWJjJ
|
4
|
-
|
5
|
-
--E9n2ZOKHIazIoPHzXj9XsWYWJjJ
|
6
|
-
X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fvpN53+WwZTIlMfKcNVJ6ARfFgA=
|
7
|
-
Location: /buckets/links/keys/target
|
8
|
-
Content-Type: application/octet-stream
|
9
|
-
Link: </buckets/links>; rel="up"
|
10
|
-
Etag: 50FOyLo7juvEVUO33MRJwP
|
11
|
-
Last-Modified: Tue, 18 Oct 2011 18:35:01 GMT
|
12
|
-
|
13
|
-
|
14
|
-
--E9n2ZOKHIazIoPHzXj9XsWYWJjJ--
|
15
|
-
|
16
|
-
--CvfrSTCWwIiwezy0Zt1B2zwKgS7--
|
@@ -1,15 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIICPzCCAagCCQDfZhEdJjSgTDANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJV
|
3
|
-
UzELMAkGA1UECBMCTkMxEjAQBgNVBAcTCUNoYXJsb3R0ZTEOMAwGA1UEChMFQmFz
|
4
|
-
aG8xEDAOBgNVBAsTB1N1cHBvcnQxEjAQBgNVBAMTCTEyNy4wLjAuMTAeFw0xMTAz
|
5
|
-
MjYxNjMzMzNaFw0zODA4MTAxNjMzMzNaMGQxCzAJBgNVBAYTAlVTMQswCQYDVQQI
|
6
|
-
EwJOQzESMBAGA1UEBxMJQ2hhcmxvdHRlMQ4wDAYDVQQKEwVCYXNobzEQMA4GA1UE
|
7
|
-
CxMHU3VwcG9ydDESMBAGA1UEAxMJMTI3LjAuMC4xMIGfMA0GCSqGSIb3DQEBAQUA
|
8
|
-
A4GNADCBiQKBgQCtfHMCsR86HQEAsO52/WvtFWCEigXll0rxYjXvdqeszEPEMFIy
|
9
|
-
Qlg3GlRxH51YrBzp46ReF9Qv5sf0Nh6SR7HGzlWmMEVfPeuAKcz1fzVcjD+IXWHK
|
10
|
-
qklAQjpxz+18dvaGxQ7ZJMPsBlq1v64siTLXI0yhjxXOuQPJWrWsvuuXkQIDAQAB
|
11
|
-
MA0GCSqGSIb3DQEBBQUAA4GBAIqt1A5Ah7s2oUoYQ8YCKC83fKbXbbNCiLFLwIzy
|
12
|
-
TGYXd8j7JTfeY8ettbtitlYgP+ouf23LzonuMo47GRuMgVKRWm4l+ZVMP5Qbkx9t
|
13
|
-
uspx+6lHUWnMT9aRdP9/2I7dscyfuhtzs0UxddADLzL9Cif4Y06E1NhR/KK+zo46
|
14
|
-
Nep8
|
15
|
-
-----END CERTIFICATE-----
|
@@ -1,15 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
MIICXQIBAAKBgQCtfHMCsR86HQEAsO52/WvtFWCEigXll0rxYjXvdqeszEPEMFIy
|
3
|
-
Qlg3GlRxH51YrBzp46ReF9Qv5sf0Nh6SR7HGzlWmMEVfPeuAKcz1fzVcjD+IXWHK
|
4
|
-
qklAQjpxz+18dvaGxQ7ZJMPsBlq1v64siTLXI0yhjxXOuQPJWrWsvuuXkQIDAQAB
|
5
|
-
AoGBAJIguzdPPgBTId8VKSes+lVupie9oo3qy8NaeBfGGCIixAnisbmHzIpNcUb/
|
6
|
-
3CcuggQ4LODcrWvTtiTr2QBZx1FL7E4POBJl/N7zJMaQd+pGjmrJGfv5haSSQN+H
|
7
|
-
r74Ix3HCd0RPdSgt5pmlT4KfsqkfRmqsPd6Nw54zbyLFMlTpAkEA4ar3ZJi2+Y+u
|
8
|
-
FH3AycXuPdDtVW0tKFtxfvKlS48gshB6gmkd06Ugss5eZkdbSY0voAp88Tr2shOJ
|
9
|
-
+pXc++Zl6wJBAMTN9K9k728cVCf41pR6mDVxIaaqjJeY4DWppGQFSqw/fmYz/Quu
|
10
|
-
PlTvk6pGRYiGN6y9CZFNoL2I/SWcd4ukrXMCQCyfYOHsbKn2Zka5Awki8VQZ3wQ4
|
11
|
-
XWiQhGXE1ziUqbNsHL1yyaoTCd8xfWseCwgFOficek49CZD22h7JyXOqAFcCQCn2
|
12
|
-
mFPFu9//NFqJjod+VHIgu0IkX3H7oOMQVwMUtcVgjH0SXMRe1N+bbesCrNTdeYWV
|
13
|
-
kTKwULPZP9EDOeJGrM0CQQCsX+8VZ15yKTy6ADINrOt26PNpD4ib4552TE6T/1wG
|
14
|
-
LKdjn5l0qB5K7ILc22z3LCenNBa0Uxbg5/RSdoX57aHA
|
15
|
-
-----END RSA PRIVATE KEY-----
|
data/spec/fixtures/test.pem
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
i-am-a-pem
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
-
<schema name="SCHEMA_NAME" version="1.5">
|
3
|
-
<fields>
|
4
|
-
<field name="_yz_id" type="_yz_str" indexed="true" stored="true" multiValued="false" required="true" />
|
5
|
-
<field name="_yz_ed" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
6
|
-
<field name="_yz_pn" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
7
|
-
<field name="_yz_fpn" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
8
|
-
<field name="_yz_vtag" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
9
|
-
<field name="_yz_rk" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
10
|
-
<field name="_yz_rb" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
11
|
-
<field name="_yz_rt" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
12
|
-
<field name="_yz_err" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
|
13
|
-
</fields>
|
14
|
-
<uniqueKey>_yz_id</uniqueKey>
|
15
|
-
<types>
|
16
|
-
<fieldType name="_yz_str" class="solr.StrField" sortMissingLast="true" />
|
17
|
-
</types>
|
18
|
-
</schema>
|
@@ -1,308 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak'
|
3
|
-
|
4
|
-
describe 'Bucket Types', test_client: true, integration: true do
|
5
|
-
|
6
|
-
describe 'nested bucket types API' do
|
7
|
-
let(:bucket_type){ test_client.bucket_type 'yokozuna' }
|
8
|
-
|
9
|
-
it 'exposes bucket type properties' do
|
10
|
-
expect(props = bucket_type.properties).to be_a Hash
|
11
|
-
expect(props[:allow_mult]).to be
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'performing key-value operations' do
|
15
|
-
let(:bucket){ bucket_type.bucket(random_key) }
|
16
|
-
let(:untyped_bucket){ test_client.bucket bucket.name }
|
17
|
-
|
18
|
-
let(:object) do
|
19
|
-
object = bucket.new random_key
|
20
|
-
object.data = 'hello'
|
21
|
-
object.content_type = 'text/plain'
|
22
|
-
object.store
|
23
|
-
object
|
24
|
-
end
|
25
|
-
|
26
|
-
let(:untyped_object) do
|
27
|
-
untyped_object = untyped_bucket.new object.key
|
28
|
-
untyped_object.data = 'oooops'
|
29
|
-
untyped_object.content_type = 'text/plain'
|
30
|
-
untyped_object.store
|
31
|
-
untyped_object
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'initializes with a bucket type' do
|
35
|
-
o = bucket.new 'lawnmower'
|
36
|
-
o.data = 'reel'
|
37
|
-
o.content_type = 'text/plain'
|
38
|
-
o.store
|
39
|
-
|
40
|
-
expect(bucket.get('lawnmower').data).to eq o.data
|
41
|
-
expect(bucket.exists?('lawnmower')).to be
|
42
|
-
end
|
43
|
-
|
44
|
-
describe 'loading and modifying a RObject' do
|
45
|
-
it "doesn't modify objects in other buckets" do
|
46
|
-
expect(o = bucket.get(object.key)).to be
|
47
|
-
o.data = 'updated'
|
48
|
-
o.store
|
49
|
-
o.reload
|
50
|
-
|
51
|
-
expect(o.data).to eq 'updated'
|
52
|
-
|
53
|
-
expect{ untyped_bucket.get(object.key)}.to raise_error(/not found/)
|
54
|
-
|
55
|
-
expect(o3 = bucket.get(object.key)).to be
|
56
|
-
expect(o3.data).to eq o.data
|
57
|
-
end
|
58
|
-
|
59
|
-
it "doesn't delete objects in other buckets'" do
|
60
|
-
expect{ untyped_object.reload }.to_not raise_error
|
61
|
-
|
62
|
-
expect(o = bucket.get(object.key)).to be
|
63
|
-
o.delete
|
64
|
-
|
65
|
-
expect{ untyped_object.reload }.to_not raise_error
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'only retrieves with a bucket type' do
|
70
|
-
expect(bucket.get(object.key).data).to eq object.data
|
71
|
-
expect{ untyped_bucket.get object.key }.to raise_error /not_found/
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'reloads with a bucket type' do
|
75
|
-
expect{ object.reload }.to_not raise_error
|
76
|
-
expect(object.data).to eq 'hello'
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'lists keys only for the type' do
|
80
|
-
expect(untyped_bucket).to be # ensure existence
|
81
|
-
expect(object).to be
|
82
|
-
|
83
|
-
expect(untyped_bucket.keys).to be_empty
|
84
|
-
expect(bucket.keys).to include object.key
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'keeps the bucket type attached to value objects' do
|
88
|
-
expect(bucket.get(object.key).bucket).to eq bucket
|
89
|
-
expect(bucket.get(object.key).bucket.type).to eq bucket_type
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'deletion' do
|
93
|
-
it 'self-deletes with a bucket type' do
|
94
|
-
expect(untyped_object).to be # ensure existence
|
95
|
-
|
96
|
-
expect(object.delete).to be
|
97
|
-
expect{ object.reload }.to raise_error /not_found/
|
98
|
-
expect(untyped_object).to be
|
99
|
-
expect{ untyped_object.reload }.to_not raise_error
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'deletes from the typed bucket' do
|
103
|
-
expect(untyped_object).to be # ensure existence
|
104
|
-
|
105
|
-
expect(bucket.delete object.key).to be
|
106
|
-
expect{ object.reload }.to raise_error /not_found/
|
107
|
-
expect{ untyped_object.reload }.to_not raise_error
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'multigets keys' do
|
112
|
-
results = bucket.get_many [object.key]
|
113
|
-
expect(results[object.key]).to be
|
114
|
-
expect(results[object.key].data).to eq object.data
|
115
|
-
end
|
116
|
-
|
117
|
-
describe 'secondary indexes' do
|
118
|
-
it 'finds the correct object with a SecondaryIndex instance' do
|
119
|
-
expect(untyped_object).to be
|
120
|
-
q = Riak::SecondaryIndex.new bucket, '$key', object.key
|
121
|
-
|
122
|
-
expect(q.keys).to include object.key
|
123
|
-
candidate = q.values.first
|
124
|
-
expect(candidate.data).to eq object.data
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe 'map-reduce' do
|
129
|
-
let(:mapred) do
|
130
|
-
Riak::MapReduce.new(test_client) do |mr|
|
131
|
-
mr.map 'function(obj){return [obj.values[0].data];}', keep: true
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'map-reduces correctly with a typed bucket' do
|
136
|
-
expect(object).to be
|
137
|
-
expect(untyped_object).to be
|
138
|
-
|
139
|
-
mapred.add bucket
|
140
|
-
result = mapred.run
|
141
|
-
|
142
|
-
expect(result).to include object.data
|
143
|
-
expect(result).to_not include untyped_object.data
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'map-reduces correctly with a robject in a typed bucket' do
|
147
|
-
expect(object).to be
|
148
|
-
expect(untyped_object).to be
|
149
|
-
|
150
|
-
mapred.add object
|
151
|
-
result = mapred.run
|
152
|
-
|
153
|
-
expect(result).to include object.data
|
154
|
-
expect(result).to_not include untyped_object.data
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe 'manipulating bucket properties' do
|
160
|
-
let(:bucket_type){ test_client.bucket_type 'yokozuna' }
|
161
|
-
let(:bucket){ bucket_type.bucket random_key }
|
162
|
-
let(:untyped_bucket){ test_client.bucket bucket.name }
|
163
|
-
|
164
|
-
it 'allows reading and writing bucket properties' do
|
165
|
-
expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['notfound_ok']).to be
|
166
|
-
expect(test_client.get_bucket_props(untyped_bucket)['notfound_ok']).to be
|
167
|
-
|
168
|
-
# test setting
|
169
|
-
expect{ bucket.props = {'notfound_ok' => false} }.to_not raise_error
|
170
|
-
|
171
|
-
# make sure setting doesn't leak to untyped bucket
|
172
|
-
expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['notfound_ok']).to_not be
|
173
|
-
expect(test_client.get_bucket_props(untyped_bucket)['notfound_ok']).to be
|
174
|
-
|
175
|
-
# add canary setting on untyped bucket
|
176
|
-
expect{ untyped_bucket.props = { 'n_val' => 1} }.to_not raise_error
|
177
|
-
|
178
|
-
# make sure canary setting doesn't leak to typed bucket
|
179
|
-
expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['n_val']).to_not eq 1
|
180
|
-
expect(test_client.get_bucket_props(untyped_bucket)['n_val']).to eq 1
|
181
|
-
|
182
|
-
# test clearing
|
183
|
-
expect{ bucket.clear_props }.to_not raise_error
|
184
|
-
|
185
|
-
# make sure clearing doesn't leak to canary setting on untyped bucket
|
186
|
-
expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['notfound_ok']).to be
|
187
|
-
expect(test_client.get_bucket_props(untyped_bucket)['n_val']).to eq 1
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe 'performing CRDT operations' do
|
192
|
-
let(:bucket_type){ test_client.bucket_type 'other_counters' }
|
193
|
-
let(:bucket){ bucket_type.bucket random_key }
|
194
|
-
let(:counter){ Riak::Crdt::Counter.new bucket, random_key }
|
195
|
-
|
196
|
-
let(:untyped_bucket){ test_client.bucket bucket.name }
|
197
|
-
let(:untyped_counter){ Riak::Crdt::Counter.new untyped_bucket, random_key }
|
198
|
-
|
199
|
-
it 'overrides default bucket types for CRDTs' do
|
200
|
-
expect(untyped_counter.value).to eq 0
|
201
|
-
expect(untyped_counter.bucket_type).to eq Riak::Crdt::DEFAULT_BUCKET_TYPES[:counter]
|
202
|
-
|
203
|
-
untyped_counter.increment
|
204
|
-
counter.reload
|
205
|
-
|
206
|
-
expect(counter.value).to eq 0
|
207
|
-
expect(counter.bucket_type).to eq 'other_counters'
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe 'option-based bucket types API' do
|
213
|
-
let(:bucket){ random_bucket 'bucket_type_spec' }
|
214
|
-
|
215
|
-
describe 'performing key-value operations' do
|
216
|
-
# for the sake of having a non-default one, not search
|
217
|
-
let(:bucket_type){ 'yokozuna' }
|
218
|
-
let(:object) do
|
219
|
-
object = bucket.new random_key
|
220
|
-
object.data = 'hello'
|
221
|
-
object.content_type = 'text/plain'
|
222
|
-
object.store type: bucket_type
|
223
|
-
object
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'only retrieves with a bucket type' do
|
227
|
-
expect{ bucket.get object.key, type: bucket_type }.to_not raise_error
|
228
|
-
expect{ bucket.get object.key }.to raise_error /not_found/
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'deletes from the bucket only with a bucket type' do
|
232
|
-
expect(bucket.delete object.key).to eq true
|
233
|
-
expect{ bucket.get object.key, type: bucket_type }.to_not raise_error
|
234
|
-
|
235
|
-
expect{ bucket.delete object.key, type: bucket_type }.to_not raise_error
|
236
|
-
expect{ bucket.get object.key, type: bucket_type }.to raise_error /not_found/
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'self-deletes only with a bucket type' do
|
240
|
-
expect(object.delete).to be
|
241
|
-
expect{ object.reload type: bucket_type }.to_not raise_error
|
242
|
-
|
243
|
-
expect(object.delete type: bucket_type).to be
|
244
|
-
expect{ object.reload type: bucket_type }.to raise_error /not_found/
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
describe 'performing CRDT set operations' do
|
249
|
-
let(:bucket_type){ Riak::Crdt::DEFAULT_BUCKET_TYPES[:set] }
|
250
|
-
let(:set) do
|
251
|
-
set = Riak::Crdt::Set.new bucket, random_key
|
252
|
-
set.add random_key
|
253
|
-
set
|
254
|
-
end
|
255
|
-
|
256
|
-
it 'retrieves the set blob via key-value using a bucket type' do
|
257
|
-
expect{ bucket.get set.key }.to raise_error /not_found/
|
258
|
-
expect(bucket.get set.key, type: bucket_type).to be
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'deletes the set blob through the bucket type' do
|
262
|
-
expect(bucket.delete set.key).to be
|
263
|
-
expect{ bucket.get set.key, type: bucket_type }.to_not raise_error
|
264
|
-
|
265
|
-
expect(bucket.delete set.key, type: bucket_type).to be
|
266
|
-
expect{ bucket.get set.key, type: bucket_type }.to raise_error /not_found/
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
describe 'performing CRDT HLL operations', hll: true do
|
271
|
-
before(:each) do
|
272
|
-
begin
|
273
|
-
hlls = test_client.bucket_type Riak::Crdt::DEFAULT_BUCKET_TYPES[:hll]
|
274
|
-
hlls.properties
|
275
|
-
rescue Riak::ProtobuffsErrorResponse
|
276
|
-
skip('HyperLogLog bucket-type not found or active.')
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
let(:bucket_type){ Riak::Crdt::DEFAULT_BUCKET_TYPES[:hll] }
|
281
|
-
let(:hll) do
|
282
|
-
hyper_log_log = Riak::Crdt::HyperLogLog.new bucket, random_key, bucket_type
|
283
|
-
hyper_log_log.add random_key
|
284
|
-
hyper_log_log
|
285
|
-
end
|
286
|
-
let(:empty_hll) do
|
287
|
-
Riak::Crdt::HyperLogLog.new bucket, random_key, bucket_type
|
288
|
-
end
|
289
|
-
|
290
|
-
it 'defaults to 0 for a new key' do
|
291
|
-
expect(empty_hll.cardinality).to eq 0
|
292
|
-
end
|
293
|
-
|
294
|
-
it 'retrieves the HLL blob via key-value using a bucket type' do
|
295
|
-
expect{ bucket.get hll.key }.to raise_error /not_found/
|
296
|
-
expect(bucket.get hll.key, type: bucket_type).to be
|
297
|
-
end
|
298
|
-
|
299
|
-
it 'deletes the HLL blob through the bucket type' do
|
300
|
-
expect(bucket.delete hll.key).to be
|
301
|
-
expect{ bucket.get hll.key, type: bucket_type }.to_not raise_error
|
302
|
-
|
303
|
-
expect(bucket.delete hll.key, type: bucket_type).to be
|
304
|
-
expect{ bucket.get hll.key, type: bucket_type }.to raise_error /not_found/
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak'
|
3
|
-
|
4
|
-
describe 'Conflict resolution', integration: true, test_client: true do
|
5
|
-
let(:bucket) do
|
6
|
-
bucket = random_bucket
|
7
|
-
bucket.allow_mult = true
|
8
|
-
|
9
|
-
bucket
|
10
|
-
end
|
11
|
-
|
12
|
-
subject do
|
13
|
-
robj = bucket.new
|
14
|
-
robj.content_type = 'application/json'
|
15
|
-
robj.data = 100
|
16
|
-
robj.store
|
17
|
-
|
18
|
-
robj
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:ten_conflicted_robjects) do
|
22
|
-
10.times.map do |n|
|
23
|
-
t = bucket.new subject.key
|
24
|
-
t.data = rand 50
|
25
|
-
t.store
|
26
|
-
|
27
|
-
t
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
before(:each) do
|
32
|
-
ten_conflicted_robjects
|
33
|
-
subject.reload
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'on_conflict hooks' do
|
37
|
-
after(:each) do
|
38
|
-
Riak::RObject.on_conflict_hooks.delete_if{ |i| true }
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'resolve ten-sided conflicts' do
|
42
|
-
expect(subject).to be_conflict
|
43
|
-
|
44
|
-
# resolver
|
45
|
-
Riak::RObject.on_conflict do |obj|
|
46
|
-
next nil unless obj.siblings.first.data.is_a? Numeric
|
47
|
-
new_sibling = obj.siblings.inject do |memo, sib|
|
48
|
-
memo.data = [memo.data, sib.data].max
|
49
|
-
|
50
|
-
memo
|
51
|
-
end
|
52
|
-
|
53
|
-
obj.siblings = [new_sibling.dup]
|
54
|
-
|
55
|
-
obj
|
56
|
-
end
|
57
|
-
|
58
|
-
subject.attempt_conflict_resolution
|
59
|
-
subject.reload
|
60
|
-
|
61
|
-
expect(subject).to_not be_conflict
|
62
|
-
expect(subject.data).to eq 100
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
it "doesn't resolve impossible conflicts" do
|
67
|
-
expect(subject).to be_conflict
|
68
|
-
|
69
|
-
Riak::RObject.on_conflict do |obj|
|
70
|
-
nil
|
71
|
-
end
|
72
|
-
|
73
|
-
subject.reload
|
74
|
-
|
75
|
-
expect(subject).to be_conflict
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'clobbering siblings without a hook' do
|
80
|
-
it 'resolves ten-sided conflicts' do
|
81
|
-
expect(subject).to be_conflict
|
82
|
-
expect(subject.siblings.length).to eq 11
|
83
|
-
max_sibling = subject.siblings.inject do |memo, sib|
|
84
|
-
next memo if memo.data > sib.data
|
85
|
-
next sib
|
86
|
-
end
|
87
|
-
|
88
|
-
subject.siblings = [max_sibling]
|
89
|
-
subject.store
|
90
|
-
|
91
|
-
subject.reload
|
92
|
-
expect(subject).to_not be_conflict
|
93
|
-
expect(subject.data).to eq 100
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|