riak-client 2.2.0.pre1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +0 -2
- data/README.markdown +11 -7
- data/RELEASE_NOTES.md +29 -2
- data/Rakefile +5 -3
- data/lib/riak/bucket.rb +55 -23
- data/lib/riak/bucket_properties.rb +8 -1
- data/lib/riak/bucket_type.rb +29 -0
- data/lib/riak/bucket_typed/bucket.rb +15 -7
- data/lib/riak/client.rb +24 -8
- data/lib/riak/client/beefcake/bucket_properties_operator.rb +8 -8
- data/lib/riak/client/beefcake/crdt/set_loader.rb +1 -1
- data/lib/riak/client/beefcake/crdt_loader.rb +1 -1
- data/lib/riak/client/beefcake/crdt_operator.rb +9 -9
- data/lib/riak/client/beefcake/message_codes.rb +4 -0
- data/lib/riak/client/beefcake/message_overlay.rb +4 -0
- data/lib/riak/client/beefcake/messages.rb +35 -5
- data/lib/riak/client/beefcake/object_methods.rb +21 -13
- data/lib/riak/client/beefcake/protocol.rb +7 -7
- data/lib/riak/client/beefcake/socket.rb +2 -2
- data/lib/riak/client/beefcake_protobuffs_backend.rb +58 -33
- data/lib/riak/client/protobuffs_backend.rb +5 -5
- data/lib/riak/client/yokozuna.rb +3 -3
- data/lib/riak/core_ext/deep_dup.rb +1 -1
- data/lib/riak/counter.rb +10 -10
- data/lib/riak/crdt/base.rb +39 -21
- data/lib/riak/crdt/batch_counter.rb +5 -5
- data/lib/riak/crdt/batch_map.rb +2 -2
- data/lib/riak/crdt/counter.rb +7 -7
- data/lib/riak/crdt/inner_counter.rb +4 -4
- data/lib/riak/crdt/inner_flag.rb +3 -3
- data/lib/riak/crdt/inner_map.rb +1 -1
- data/lib/riak/crdt/inner_register.rb +1 -1
- data/lib/riak/crdt/inner_set.rb +5 -5
- data/lib/riak/crdt/map.rb +9 -9
- data/lib/riak/crdt/set.rb +10 -10
- data/lib/riak/crdt/typed_collection.rb +39 -36
- data/lib/riak/errors/base.rb +1 -1
- data/lib/riak/errors/crdt_error.rb +20 -0
- data/lib/riak/errors/search_error.rb +6 -0
- data/lib/riak/index_collection.rb +1 -1
- data/lib/riak/link.rb +5 -3
- data/lib/riak/locale/en.yml +5 -1
- data/lib/riak/map_reduce.rb +7 -7
- data/lib/riak/map_reduce/filter_builder.rb +2 -2
- data/lib/riak/map_reduce/phase.rb +2 -2
- data/lib/riak/preflist_item.rb +7 -0
- data/lib/riak/rcontent.rb +8 -8
- data/lib/riak/robject.rb +27 -14
- data/lib/riak/search.rb +1 -0
- data/lib/riak/search/index.rb +17 -3
- data/lib/riak/search/query.rb +14 -6
- data/lib/riak/search/result_collection.rb +56 -3
- data/lib/riak/search/result_document.rb +71 -1
- data/lib/riak/search/schema.rb +6 -6
- data/lib/riak/secondary_index.rb +20 -12
- data/lib/riak/serializers.rb +0 -1
- data/lib/riak/util/escape.rb +2 -2
- data/lib/riak/util/translation.rb +1 -2
- data/lib/riak/version.rb +1 -1
- data/lib/riak/walk_spec.rb +67 -32
- data/riak-client.gemspec +5 -4
- data/spec/integration/riak/bucket_types_spec.rb +35 -5
- data/spec/integration/riak/conflict_resolution_spec.rb +1 -1
- data/spec/integration/riak/counters_spec.rb +1 -1
- data/spec/integration/riak/crdt/configuration_spec.rb +37 -0
- data/spec/integration/riak/crdt_search_spec.rb +176 -0
- data/spec/integration/riak/crdt_spec.rb +9 -33
- data/spec/integration/riak/crdt_validation/map_spec.rb +4 -4
- data/spec/integration/riak/crdt_validation/set_spec.rb +13 -13
- data/spec/integration/riak/preflist_spec.rb +31 -0
- data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +2 -2
- data/spec/integration/riak/protobuffs_backends_spec.rb +9 -2
- data/spec/integration/riak/search_spec.rb +3 -3
- data/spec/integration/riak/secondary_index_spec.rb +3 -3
- data/spec/integration/riak/security_spec.rb +7 -7
- data/spec/integration/yokozuna/queries_spec.rb +1 -1
- data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +9 -9
- data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +9 -9
- data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +5 -5
- data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
- data/spec/riak/bucket_properties_spec.rb +27 -6
- data/spec/riak/bucket_spec.rb +5 -5
- data/spec/riak/bucket_type_spec.rb +21 -5
- data/spec/riak/bucket_typed/bucket_spec.rb +62 -0
- data/spec/riak/client_spec.rb +36 -18
- data/spec/riak/counter_spec.rb +4 -4
- data/spec/riak/crdt/counter_spec.rb +2 -2
- data/spec/riak/crdt/inner_flag_spec.rb +2 -2
- data/spec/riak/crdt/inner_map_spec.rb +4 -4
- data/spec/riak/crdt/inner_register_spec.rb +1 -1
- data/spec/riak/crdt/map_spec.rb +4 -4
- data/spec/riak/crdt/shared_examples.rb +5 -5
- data/spec/riak/crdt/typed_collection_spec.rb +21 -21
- data/spec/riak/map_reduce/filter_builder_spec.rb +2 -2
- data/spec/riak/map_reduce/phase_spec.rb +4 -4
- data/spec/riak/map_reduce_spec.rb +60 -42
- data/spec/riak/multiget_spec.rb +2 -2
- data/spec/riak/robject_spec.rb +55 -14
- data/spec/riak/search/index_spec.rb +12 -2
- data/spec/riak/search/query_spec.rb +4 -4
- data/spec/riak/search/result_collection_spec.rb +6 -4
- data/spec/riak/search/result_document_spec.rb +52 -9
- data/spec/riak/search/schema_spec.rb +2 -2
- data/spec/riak/secondary_index_spec.rb +6 -6
- data/spec/riak/serializers_spec.rb +27 -10
- data/spec/riak/walk_spec_spec.rb +10 -6
- data/spec/spec_helper.rb +11 -2
- data/spec/support/crdt_search_config.rb +112 -0
- data/spec/support/crdt_search_fixtures.rb +42 -0
- data/spec/support/search_config.rb +7 -5
- data/spec/support/search_corpus_setup.rb +2 -2
- data/spec/support/test_client.rb +2 -2
- data/spec/support/unified_backend_examples.rb +5 -5
- data/spec/support/version_filter.rb +5 -3
- data/spec/support/wait_until.rb +9 -3
- metadata +36 -13
- data/spec/riak/bucket_typed/bucket.rb +0 -43
data/riak-client.gemspec
CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.version = Riak::VERSION
|
8
8
|
gem.summary = %Q{riak-client is a rich client for Riak, the distributed database by Basho.}
|
9
9
|
gem.description = %Q{riak-client is a rich client for Riak, the distributed database by Basho. It supports the full HTTP and Protocol Buffers interfaces including storage operations, bucket configuration, link-walking, secondary indexes and map-reduce.}
|
10
|
-
gem.email = [
|
10
|
+
gem.email = ['bryce@basho.com']
|
11
11
|
gem.homepage = "http://github.com/basho/riak-ruby-client"
|
12
|
-
gem.authors = [
|
12
|
+
gem.authors = ['Bryce Kerley']
|
13
13
|
gem.license = 'Apache 2.0'
|
14
14
|
|
15
15
|
gem.required_ruby_version = '>= 1.9.3'
|
@@ -19,11 +19,12 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency 'rake', '~> 10.1.1'
|
20
20
|
gem.add_development_dependency 'yard', '~> 0.8.7'
|
21
21
|
gem.add_development_dependency 'kramdown', '~> 1.4'
|
22
|
-
gem.add_development_dependency 'simplecov', '~> 0.
|
22
|
+
gem.add_development_dependency 'simplecov', '~> 0.10.0'
|
23
23
|
gem.add_development_dependency "instrumentable", "~> 1.1.0"
|
24
|
+
gem.add_development_dependency "rubocop", "~> 0.28.0"
|
24
25
|
|
25
26
|
gem.add_runtime_dependency "i18n", ">=0.4.0"
|
26
|
-
gem.add_runtime_dependency "beefcake", "~> 1.
|
27
|
+
gem.add_runtime_dependency "beefcake", "~> 1.1"
|
27
28
|
gem.add_runtime_dependency "multi_json", "~>1.0"
|
28
29
|
gem.add_runtime_dependency "innertube", "~>1.0.2"
|
29
30
|
gem.add_runtime_dependency 'cert_validator', '~> 0.0.1'
|
@@ -41,6 +41,31 @@ describe 'Bucket Types', test_client: true, integration: true do
|
|
41
41
|
expect(bucket.exists?('lawnmower')).to be
|
42
42
|
end
|
43
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
|
+
|
44
69
|
it 'only retrieves with a bucket type' do
|
45
70
|
expect(bucket.get(object.key).data).to eq object.data
|
46
71
|
expect{ untyped_bucket.get object.key }.to raise_error /not_found/
|
@@ -59,10 +84,15 @@ describe 'Bucket Types', test_client: true, integration: true do
|
|
59
84
|
expect(bucket.keys).to include object.key
|
60
85
|
end
|
61
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
|
+
|
62
92
|
describe 'deletion' do
|
63
93
|
it 'self-deletes with a bucket type' do
|
64
94
|
expect(untyped_object).to be # ensure existence
|
65
|
-
|
95
|
+
|
66
96
|
expect(object.delete).to be
|
67
97
|
expect{ object.reload }.to raise_error /not_found/
|
68
98
|
expect(untyped_object).to be
|
@@ -116,7 +146,7 @@ describe 'Bucket Types', test_client: true, integration: true do
|
|
116
146
|
it 'map-reduces correctly with a robject in a typed bucket' do
|
117
147
|
expect(object).to be
|
118
148
|
expect(untyped_object).to be
|
119
|
-
|
149
|
+
|
120
150
|
mapred.add object
|
121
151
|
result = mapred.run
|
122
152
|
|
@@ -130,11 +160,11 @@ describe 'Bucket Types', test_client: true, integration: true do
|
|
130
160
|
let(:bucket_type){ test_client.bucket_type 'yokozuna' }
|
131
161
|
let(:bucket){ bucket_type.bucket random_key }
|
132
162
|
let(:untyped_bucket){ test_client.bucket bucket.name }
|
133
|
-
|
163
|
+
|
134
164
|
it 'allows reading and writing bucket properties' do
|
135
165
|
expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['last_write_wins']).to_not be
|
136
166
|
expect(test_client.get_bucket_props(untyped_bucket)['last_write_wins']).to_not be
|
137
|
-
|
167
|
+
|
138
168
|
# test setting
|
139
169
|
expect{ bucket.props = {'last_write_wins' => true} }.to_not raise_error
|
140
170
|
|
@@ -152,7 +182,7 @@ describe 'Bucket Types', test_client: true, integration: true do
|
|
152
182
|
# test clearing
|
153
183
|
expect{ bucket.clear_props }.to_not raise_error
|
154
184
|
|
155
|
-
# make sure clearing doesn't leak to canary setting on untyped bucket
|
185
|
+
# make sure clearing doesn't leak to canary setting on untyped bucket
|
156
186
|
expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['last_write_wins']).to_not be
|
157
187
|
expect(test_client.get_bucket_props(untyped_bucket)['n_val']).to eq 1
|
158
188
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'riak'
|
3
|
+
|
4
|
+
describe "CRDT configuration", integration: true, test_client: true do
|
5
|
+
let(:bucket) { random_bucket }
|
6
|
+
|
7
|
+
it "allows default bucket-types to be configured for each data type" do
|
8
|
+
expect(Riak::Crdt::Set.new(bucket, 'set').bucket_type).to eq 'sets'
|
9
|
+
|
10
|
+
Riak::Crdt::DEFAULT_BUCKET_TYPES[:set] = 'new_set_default'
|
11
|
+
expect(Riak::Crdt::Set.new(bucket, 'set').bucket_type).to eq 'new_set_default'
|
12
|
+
|
13
|
+
Riak::Crdt::DEFAULT_BUCKET_TYPES[:set] = 'sets'
|
14
|
+
expect(Riak::Crdt::Set.new(bucket, 'set').bucket_type).to eq 'sets'
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'overriding bucket-types' do
|
18
|
+
let(:name){ 'other_counters' }
|
19
|
+
let(:type){ test_client.bucket_type name }
|
20
|
+
let(:typed_bucket){ type.bucket bucket.name }
|
21
|
+
|
22
|
+
it "overrides with a string" do
|
23
|
+
ctr = Riak::Crdt::Counter.new(bucket, 'ctr', name)
|
24
|
+
expect(ctr.bucket_type).to eq name
|
25
|
+
end
|
26
|
+
|
27
|
+
it "overrides with a typed bucket" do
|
28
|
+
ctr = Riak::Crdt::Counter.new(typed_bucket, 'ctr')
|
29
|
+
expect(ctr.bucket_type).to eq name
|
30
|
+
end
|
31
|
+
|
32
|
+
it "overrides with a bucket type object" do
|
33
|
+
ctr = Riak::Crdt::Counter.new(bucket, 'ctr', type)
|
34
|
+
expect(ctr.bucket_type).to eq name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'riak/search'
|
3
|
+
|
4
|
+
describe 'CRDT Search API', crdt_search_config: true do
|
5
|
+
describe 'querying maps' do
|
6
|
+
let(:query) { index.query 'arroz_register:frijoles' }
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
expect(first_map).to be
|
10
|
+
end
|
11
|
+
|
12
|
+
subject{ query.results }
|
13
|
+
|
14
|
+
it 'finds maps' do
|
15
|
+
expect(subject.length).to be > 0
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'provides access to maps through the #map accessor' do
|
19
|
+
expect(subject.maps.first).to eq first_map
|
20
|
+
expect(subject.docs.first.map).to eq first_map
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'provides access to maps through the #crdt accessor' do
|
24
|
+
expect(subject.crdts.first).to eq first_map
|
25
|
+
expect(subject.docs.first.crdt).to eq first_map
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'provides access to maps through the #object accessor' do
|
29
|
+
expect(subject.first).to eq first_map
|
30
|
+
expect(subject.docs.first.object).to eq first_map
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'raises errors on the set, counter, and robject accessors' do
|
34
|
+
expect{ subject.docs.first.robject }.
|
35
|
+
to raise_error Riak::SearchError::UnexpectedResultError
|
36
|
+
expect{ subject.docs.first.counter }.
|
37
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
38
|
+
expect{ subject.docs.first.set }.
|
39
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'querying sets' do
|
44
|
+
let(:query) { index.query 'set:frijoles' }
|
45
|
+
|
46
|
+
before(:all) do
|
47
|
+
expect(first_set).to be
|
48
|
+
end
|
49
|
+
|
50
|
+
subject{ query.results }
|
51
|
+
|
52
|
+
it 'finds sets' do
|
53
|
+
expect(subject.length).to be > 0
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'provides access to sets through the #set accessor' do
|
57
|
+
expect(subject.sets.first).to eq first_set
|
58
|
+
expect(subject.docs.first.set).to eq first_set
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'provides access to sets through the #object accessor' do
|
62
|
+
expect(subject.first).to eq first_set
|
63
|
+
expect(subject.docs.first.object).to eq first_set
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'raises errors on the counter, map, and robject accessors' do
|
67
|
+
expect{ subject.docs.first.robject }.
|
68
|
+
to raise_error Riak::SearchError::UnexpectedResultError
|
69
|
+
expect{ subject.docs.first.counter }.
|
70
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
71
|
+
expect{ subject.docs.first.map }.
|
72
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'querying counters' do
|
77
|
+
let(:query) { index.query 'counter:83475' }
|
78
|
+
|
79
|
+
before(:all) do
|
80
|
+
expect(first_counter).to be
|
81
|
+
end
|
82
|
+
|
83
|
+
subject{ query.results }
|
84
|
+
|
85
|
+
it 'finds counters' do
|
86
|
+
expect(subject.length).to be > 0
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'provides access to counters through the #counter accessor' do
|
90
|
+
expect(subject.counters.first).to eq first_counter
|
91
|
+
expect(subject.docs.first.counter).to eq first_counter
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'provides access to counters through the #object accessor' do
|
95
|
+
expect(subject.first).to eq first_counter
|
96
|
+
expect(subject.docs.first.object).to eq first_counter
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'raises errors on the counter, map, and robject accessors' do
|
100
|
+
expect{ subject.docs.first.robject }.
|
101
|
+
to raise_error Riak::SearchError::UnexpectedResultError
|
102
|
+
expect{ subject.docs.first.set }.
|
103
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
104
|
+
expect{ subject.docs.first.map }.
|
105
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'querying multiple kinds of CRDT' do
|
110
|
+
let(:query) do
|
111
|
+
index.query 'arroz_register:frijoles OR set:frijoles OR counter:83475'
|
112
|
+
end
|
113
|
+
subject{ query.results }
|
114
|
+
|
115
|
+
before(:all) do
|
116
|
+
expect(first_counter).to be
|
117
|
+
expect(first_map).to be
|
118
|
+
expect(first_set).to be
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'finds CRDTs' do
|
122
|
+
expect(subject.length).to be >= 3
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'provides access through appropriate accessors' do
|
126
|
+
expect(subject.counters.first).to eq first_counter
|
127
|
+
expect(subject.maps.first).to eq first_map
|
128
|
+
expect(subject.sets.first).to eq first_set
|
129
|
+
expect(subject.crdts).to include first_counter
|
130
|
+
expect(subject.crdts).to include first_map
|
131
|
+
expect(subject.crdts).to include first_set
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'allows looping through each object' do
|
135
|
+
# I worry that this may be order-dependent and occasionally fail
|
136
|
+
expect{ |b| subject.crdts.each &b }.
|
137
|
+
to yield_successive_args(first_counter, first_map, first_set)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'allows looping through each kind of object' do
|
141
|
+
expect{ |b| subject.counters.each &b }.to yield_with_args(first_counter)
|
142
|
+
expect{ |b| subject.maps.each &b }.to yield_with_args(first_map)
|
143
|
+
expect{ |b| subject.sets.each &b }.to yield_with_args(first_set)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe 'querying both CRDTs and RObjects' do
|
148
|
+
let(:query) do
|
149
|
+
index.query 'arroz_register:frijoles OR set:frijoles OR counter:83475 OR "bitcask"'
|
150
|
+
end
|
151
|
+
subject{ query.results }
|
152
|
+
|
153
|
+
before(:all) do
|
154
|
+
load_corpus
|
155
|
+
expect(first_counter).to be
|
156
|
+
expect(first_map).to be
|
157
|
+
expect(first_set).to be
|
158
|
+
end
|
159
|
+
|
160
|
+
let(:first_robject){ subject.robjects.first }
|
161
|
+
|
162
|
+
it 'finds CRDTs and RObjects' do
|
163
|
+
expect(subject.objects).to include first_counter
|
164
|
+
expect(subject.objects).to include first_map
|
165
|
+
expect(subject.objects).to include first_set
|
166
|
+
expect(subject.objects).to include first_robject
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'provides access through appropriate accessors' do
|
170
|
+
expect(subject.crdts).to_not include first_robject
|
171
|
+
expect(subject.robjects).to_not include first_counter
|
172
|
+
expect(subject.robjects).to_not include first_map
|
173
|
+
expect(subject.robjects).to_not include first_set
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -4,39 +4,6 @@ require 'riak'
|
|
4
4
|
describe "CRDTs", integration: true, test_client: true do
|
5
5
|
let(:bucket) { random_bucket }
|
6
6
|
|
7
|
-
describe 'configuration' do
|
8
|
-
it "allows default bucket-types to be configured for each data type" do
|
9
|
-
expect(Riak::Crdt::Set.new(bucket, 'set').bucket_type).to eq 'sets'
|
10
|
-
|
11
|
-
Riak::Crdt::DEFAULT_BUCKET_TYPES[:set] = 'new_set_default'
|
12
|
-
expect(Riak::Crdt::Set.new(bucket, 'set').bucket_type).to eq 'new_set_default'
|
13
|
-
|
14
|
-
Riak::Crdt::DEFAULT_BUCKET_TYPES[:set] = 'sets'
|
15
|
-
expect(Riak::Crdt::Set.new(bucket, 'set').bucket_type).to eq 'sets'
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'overriding bucket-types' do
|
19
|
-
let(:name){ 'other_counters' }
|
20
|
-
let(:type){ test_client.bucket_type name }
|
21
|
-
let(:typed_bucket){ type.bucket bucket.name }
|
22
|
-
|
23
|
-
it "overrides with a string" do
|
24
|
-
ctr = Riak::Crdt::Counter.new(bucket, 'ctr', name)
|
25
|
-
expect(ctr.bucket_type).to eq name
|
26
|
-
end
|
27
|
-
|
28
|
-
it "overrides with a typed bucket" do
|
29
|
-
ctr = Riak::Crdt::Counter.new(typed_bucket, 'ctr')
|
30
|
-
expect(ctr.bucket_type).to eq name
|
31
|
-
end
|
32
|
-
|
33
|
-
it "overrides with a bucket type object" do
|
34
|
-
ctr = Riak::Crdt::Counter.new(bucket, 'ctr', type)
|
35
|
-
expect(ctr.bucket_type).to eq name
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
7
|
describe 'Riak-assigned names' do
|
41
8
|
describe 'an anonymous counter' do
|
42
9
|
subject { Riak::Crdt::Counter.new bucket, nil }
|
@@ -105,6 +72,15 @@ describe "CRDTs", integration: true, test_client: true do
|
|
105
72
|
expect(subject.dirty?).to_not be
|
106
73
|
expect(subject.value).to eq(start + 10 + 1)
|
107
74
|
end
|
75
|
+
|
76
|
+
describe 'equality' do
|
77
|
+
let(:same){ Riak::Crdt::Counter.new subject.bucket, subject.key }
|
78
|
+
let(:same_bucket){ Riak::Bucket.new test_client, bucket.name }
|
79
|
+
let(:similar){ Riak::Crdt::Counter.new same_bucket, subject.key }
|
80
|
+
it { is_expected.to eq subject }
|
81
|
+
it { is_expected.to eq same }
|
82
|
+
it { is_expected.to eq similar }
|
83
|
+
end
|
108
84
|
end
|
109
85
|
describe 'sets' do
|
110
86
|
|
@@ -22,7 +22,7 @@ describe 'CRDT map validation', integration: true, test_client: true do
|
|
22
22
|
end.to_not raise_error
|
23
23
|
|
24
24
|
map2 = Riak::Crdt::Map.new bucket, map.key
|
25
|
-
|
25
|
+
|
26
26
|
expect(map2.sets['set'].members).to eq ::Set.new(['Z'])
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ describe 'CRDT map validation', integration: true, test_client: true do
|
|
30
30
|
map.counters['counter'].increment 5
|
31
31
|
|
32
32
|
map.reload
|
33
|
-
|
33
|
+
|
34
34
|
expect(map.counters['counter'].value).to eq 5
|
35
35
|
|
36
36
|
map.batch do |m|
|
@@ -50,13 +50,13 @@ describe 'CRDT map validation', integration: true, test_client: true do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
map.reload
|
53
|
-
expect(map.maps['map'].sets['set'].members).to eq ::Set.new(
|
53
|
+
expect(map.maps['map'].sets['set'].members).to eq ::Set.new(%w(X Y))
|
54
54
|
|
55
55
|
map.batch do |m|
|
56
56
|
m.maps.delete 'map'
|
57
57
|
m.maps['map'].sets['set'].add "Z"
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
map2 = Riak::Crdt::Map.new bucket, map.key
|
61
61
|
expect(map2.maps['map'].sets['set'].members).to eq ::Set.new(['Z'])
|
62
62
|
end
|
@@ -4,7 +4,7 @@ require 'riak'
|
|
4
4
|
describe 'CRDT set validation', integration: true, test_client: true do
|
5
5
|
let(:bucket){ random_bucket 'crdt_validation' }
|
6
6
|
let(:set){ Riak::Crdt::Set.new bucket, random_key }
|
7
|
-
|
7
|
+
|
8
8
|
it 'removes recently-added set entries during batch mode' do
|
9
9
|
expect do
|
10
10
|
set.batch do |s|
|
@@ -15,17 +15,17 @@ describe 'CRDT set validation', integration: true, test_client: true do
|
|
15
15
|
end
|
16
16
|
end.to raise_error Riak::CrdtError::SetRemovalWithoutContextError
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it 'removes non-members with context' do
|
20
20
|
set.batch do |s|
|
21
21
|
s.add 'X'
|
22
22
|
s.add 'Y'
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
set.reload
|
26
|
-
|
26
|
+
|
27
27
|
expect{ set.remove 'bogus' }.to_not raise_error
|
28
|
-
|
28
|
+
|
29
29
|
set2 = Riak::Crdt::Set.new bucket, set.key
|
30
30
|
expect(set2.members).to eq ::Set.new(%w{X Y})
|
31
31
|
end
|
@@ -35,9 +35,9 @@ describe 'CRDT set validation', integration: true, test_client: true do
|
|
35
35
|
s.add 'X'
|
36
36
|
s.add 'Y'
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
set.reload
|
40
|
-
|
40
|
+
|
41
41
|
expect{ set.add 'X' }.to_not raise_error
|
42
42
|
|
43
43
|
set2 = Riak::Crdt::Set.new bucket, set.key
|
@@ -90,14 +90,14 @@ describe 'CRDT set validation', integration: true, test_client: true do
|
|
90
90
|
s.add 'X'
|
91
91
|
s.add 'Y'
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
set_parallel = Riak::Crdt::Set.new bucket, set.key
|
95
95
|
set_parallel.add 'Z'
|
96
|
-
|
96
|
+
|
97
97
|
set.reload
|
98
|
-
|
98
|
+
|
99
99
|
expect{ set.remove 'Z' }.to_not raise_error
|
100
|
-
|
100
|
+
|
101
101
|
set2 = Riak::Crdt::Set.new bucket, set.key
|
102
102
|
expect(set2.members).to eq ::Set.new(%w{X Y})
|
103
103
|
end
|
@@ -107,9 +107,9 @@ describe 'CRDT set validation', integration: true, test_client: true do
|
|
107
107
|
s.add 'X'
|
108
108
|
s.add 'Y'
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
set.reload
|
112
|
-
|
112
|
+
|
113
113
|
set_parallel = Riak::Crdt::Set.new bucket, set.key
|
114
114
|
set_parallel.add 'Z'
|
115
115
|
|