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
@@ -2,15 +2,15 @@ require 'spec_helper'
|
|
2
2
|
require 'riak/search/query'
|
3
3
|
|
4
4
|
describe Riak::Search::Query do
|
5
|
-
let(:client) do
|
5
|
+
let(:client) do
|
6
6
|
instance_double('Riak::Client').tap do |c|
|
7
7
|
allow(c).to receive(:backend).and_yield(backend)
|
8
8
|
end
|
9
9
|
end
|
10
|
-
let(:index) do
|
10
|
+
let(:index) do
|
11
11
|
instance_double(
|
12
12
|
'Riak::Search::Index',
|
13
|
-
name: index_name,
|
13
|
+
name: index_name,
|
14
14
|
'exists?' => true).tap do |i|
|
15
15
|
allow(i).to receive(:is_a?).with(String).and_return(false)
|
16
16
|
allow(i).to receive(:is_a?).with(Riak::Search::Index).and_return(true)
|
@@ -48,7 +48,7 @@ describe Riak::Search::Query do
|
|
48
48
|
expect{ described_class.new client, index, term }.to_not raise_error
|
49
49
|
end
|
50
50
|
|
51
|
-
it 'creates query objects with a client, index name, and query string' do
|
51
|
+
it 'creates query objects with a client, index name, and query string' do
|
52
52
|
class_double('Riak::Search::Index', new: index).as_stubbed_const
|
53
53
|
allow(index).to receive(:is_a?).with(Riak::Search::Index).and_return(true)
|
54
54
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'riak/search/result_collection'
|
3
3
|
|
4
|
-
describe Riak::Search::ResultCollection do
|
5
|
-
let(:client) do
|
4
|
+
describe Riak::Search::ResultCollection, crdt_search_fixtures: true do
|
5
|
+
let(:client) do
|
6
6
|
instance_double('Riak::Client').tap do |c|
|
7
7
|
allow(c).to receive(:bucket_type).
|
8
8
|
with(bucket_type_name).
|
@@ -44,7 +44,8 @@ describe Riak::Search::ResultCollection do
|
|
44
44
|
{"score"=>"6.73738599999999937529e-02",
|
45
45
|
"_yz_rb"=>"search_test-1419261439-ew70sak2qr",
|
46
46
|
"_yz_rt"=>"yokozuna",
|
47
|
-
"_yz_rk"=>"bitcask-4"}
|
47
|
+
"_yz_rk"=>"bitcask-4"},
|
48
|
+
map_raw
|
48
49
|
]
|
49
50
|
}
|
50
51
|
end
|
@@ -81,7 +82,8 @@ describe Riak::Search::ResultCollection do
|
|
81
82
|
|
82
83
|
it 'fetches individual documents on demand' do
|
83
84
|
fetch_first_expectation
|
84
|
-
|
85
|
+
allow(bucket_type).to receive(:data_type_class).and_return nil
|
86
|
+
|
85
87
|
expect(subject.first).to eq first_result
|
86
88
|
end
|
87
89
|
end
|
@@ -1,26 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'riak/search/result_document'
|
3
3
|
|
4
|
-
describe Riak::Search::ResultDocument do
|
4
|
+
describe Riak::Search::ResultDocument, crdt_search_fixtures: true do
|
5
5
|
let(:key){ 'bitcask-10' }
|
6
6
|
let(:bucket_name){ 'search_test' }
|
7
7
|
let(:bucket_type_name){ 'yokozuna' }
|
8
8
|
let(:score){ 43.21 }
|
9
9
|
let(:other_field){ 'banana' }
|
10
10
|
|
11
|
-
let(:client) do
|
11
|
+
let(:client) do
|
12
12
|
instance_double('Riak::Client').tap do |c|
|
13
13
|
allow(c).to receive(:bucket_type).
|
14
|
-
|
15
|
-
|
14
|
+
with(bucket_type_name).
|
15
|
+
and_return(bucket_type)
|
16
|
+
allow(c).to receive(:bucket_type).
|
17
|
+
with(maps_type_name).
|
18
|
+
and_return(maps_bucket_type)
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
22
|
let(:bucket_type) do
|
20
23
|
instance_double('Riak::BucketType').tap do |bt|
|
21
24
|
allow(bt).to receive(:bucket).
|
22
|
-
|
23
|
-
|
25
|
+
with(bucket_name).
|
26
|
+
and_return(bucket)
|
27
|
+
allow(bt).to receive(:data_type_class).
|
28
|
+
and_return(nil)
|
24
29
|
end
|
25
30
|
end
|
26
31
|
|
@@ -53,11 +58,49 @@ describe Riak::Search::ResultDocument do
|
|
53
58
|
expect(subject.score).to eq score
|
54
59
|
end
|
55
60
|
|
56
|
-
it 'makes other yz fields
|
61
|
+
it 'makes other yz fields available' do
|
57
62
|
expect(subject[:other_field]).to eq other_field
|
58
63
|
end
|
59
64
|
|
60
|
-
|
61
|
-
|
65
|
+
describe 'identifying a key-value object' do
|
66
|
+
it 'fetches the robject it identifies' do
|
67
|
+
expect(subject.robject).to eq robject
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns the data type class the document is' do
|
71
|
+
expect(subject.type_class).to eq Riak::RObject
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'refuses to return a CRDT' do
|
75
|
+
expect{ subject.crdt }.to raise_error Riak::CrdtError::NotACrdt
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'identifying a CRDT map object' do
|
80
|
+
subject { map_results }
|
81
|
+
|
82
|
+
it 'returns the data type class the document is' do
|
83
|
+
expect(subject.type_class).to eq Riak::Crdt::Map
|
84
|
+
end
|
85
|
+
|
86
|
+
let(:fake_map){ instance_double 'Riak::Crdt::Map' }
|
87
|
+
|
88
|
+
it 'fetches the map it identifies' do
|
89
|
+
expect(Riak::Crdt::Map).
|
90
|
+
to receive(:new).
|
91
|
+
with(map_bucket, 'map-key', maps_bucket_type).
|
92
|
+
and_return(fake_map).
|
93
|
+
twice
|
94
|
+
|
95
|
+
expect(subject.map).to eq fake_map
|
96
|
+
expect(subject.crdt).to eq fake_map
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'refuses to fetch a counter or set' do
|
100
|
+
expect{ subject.counter }.
|
101
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
102
|
+
expect{ subject.set }.
|
103
|
+
to raise_error Riak::CrdtError::UnexpectedDataType
|
104
|
+
end
|
62
105
|
end
|
63
106
|
end
|
@@ -15,7 +15,7 @@ describe Riak::Search::Schema do
|
|
15
15
|
resp = instance_double 'Riak::Client::BeefcakeProtobuffsBackend::RpbYokozunaSchema'
|
16
16
|
allow(resp).to receive(:name).and_return(schema_name)
|
17
17
|
allow(resp).to receive(:content).and_return(schema_content)
|
18
|
-
|
18
|
+
|
19
19
|
resp
|
20
20
|
end
|
21
21
|
|
@@ -51,7 +51,7 @@ describe Riak::Search::Schema do
|
|
51
51
|
|
52
52
|
it 'raises an error when creating a schema that already exists' do
|
53
53
|
schema_exists_expectation
|
54
|
-
|
54
|
+
|
55
55
|
expect{ subject.create! schema_content }.to raise_error(Riak::SearchError::SchemaExistsError)
|
56
56
|
end
|
57
57
|
|
@@ -80,8 +80,8 @@ describe Riak::SecondaryIndex do
|
|
80
80
|
|
81
81
|
|
82
82
|
@index = Riak::SecondaryIndex.new(
|
83
|
-
@bucket,
|
84
|
-
'asdf',
|
83
|
+
@bucket,
|
84
|
+
'asdf',
|
85
85
|
'aaaa'..'zzzz',
|
86
86
|
:max_results => @max_results
|
87
87
|
)
|
@@ -115,8 +115,8 @@ describe Riak::SecondaryIndex do
|
|
115
115
|
|
116
116
|
|
117
117
|
@index = Riak::SecondaryIndex.new(
|
118
|
-
@bucket,
|
119
|
-
'asdf',
|
118
|
+
@bucket,
|
119
|
+
'asdf',
|
120
120
|
'aaaa'..'zzzz',
|
121
121
|
max_results: @max_results,
|
122
122
|
continuation: 'examplecontinuation'
|
@@ -151,8 +151,8 @@ describe Riak::SecondaryIndex do
|
|
151
151
|
|
152
152
|
|
153
153
|
@index = Riak::SecondaryIndex.new(
|
154
|
-
@bucket,
|
155
|
-
'asdf',
|
154
|
+
@bucket,
|
155
|
+
'asdf',
|
156
156
|
'aaaa'..'zzzz',
|
157
157
|
:max_results => @max_results
|
158
158
|
)
|
@@ -8,7 +8,8 @@ describe Riak::Serializers do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "deserializes #{serialized} to #{deserialized}" do
|
11
|
-
expect(described_class.deserialize(type, serialized)).
|
11
|
+
expect(described_class.deserialize(type, serialized)).
|
12
|
+
to eq(deserialized)
|
12
13
|
end
|
13
14
|
|
14
15
|
it "round trips properly" do
|
@@ -19,11 +20,17 @@ describe Riak::Serializers do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
it_behaves_like "a serializer", "text/plain", "a string", "a string"
|
22
|
-
it_behaves_like "a serializer", "application/json", { "a" => 7 },
|
23
|
-
it_behaves_like "a serializer",
|
23
|
+
it_behaves_like "a serializer", "application/json", { "a" => 7 }, '{"a":7}'
|
24
|
+
it_behaves_like "a serializer",
|
25
|
+
"application/x-ruby-marshal",
|
26
|
+
{ a: 3 },
|
27
|
+
Marshal.dump({ a: 3 })
|
24
28
|
|
25
29
|
described_class::YAML_MIME_TYPES.each do |mime_type|
|
26
|
-
it_behaves_like "a serializer",
|
30
|
+
it_behaves_like "a serializer",
|
31
|
+
mime_type,
|
32
|
+
{ "a" => 7 },
|
33
|
+
YAML.dump({ "a" => 7 })
|
27
34
|
end
|
28
35
|
|
29
36
|
%w[ serialize deserialize ].each do |meth|
|
@@ -38,7 +45,8 @@ describe Riak::Serializers do
|
|
38
45
|
|
39
46
|
describe "plain text serializer" do
|
40
47
|
it 'calls #to_s to convert the object to a string' do
|
41
|
-
expect(described_class.serialize(
|
48
|
+
expect(described_class.serialize('text/plain', :a_string)).
|
49
|
+
to eq('a_string')
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
@@ -80,11 +88,15 @@ describe Riak::Serializers do
|
|
80
88
|
|
81
89
|
it 'can be registered' do
|
82
90
|
described_class['application/custom-type-1'] = custom_serializer
|
83
|
-
expect(described_class['application/custom-type-1']).
|
91
|
+
expect(described_class['application/custom-type-1']).
|
92
|
+
to be(custom_serializer)
|
84
93
|
# fail
|
85
94
|
end
|
86
95
|
|
87
|
-
it_behaves_like "a serializer",
|
96
|
+
it_behaves_like "a serializer",
|
97
|
+
"application/custom-type-a",
|
98
|
+
"foo",
|
99
|
+
"The string is: foo" do
|
88
100
|
before(:each) do
|
89
101
|
described_class['application/custom-type-a'] = custom_serializer
|
90
102
|
end
|
@@ -98,7 +110,12 @@ describe Riak::Serializers do
|
|
98
110
|
end
|
99
111
|
end
|
100
112
|
|
101
|
-
it_behaves_like "a serializer",
|
102
|
-
|
113
|
+
it_behaves_like "a serializer",
|
114
|
+
"application/json; charset=UTF-8",
|
115
|
+
{ "a" => 7 },
|
116
|
+
'{"a":7}'
|
117
|
+
it_behaves_like "a serializer",
|
118
|
+
"application/json ;charset=UTF-8",
|
119
|
+
{ "a" => 7 },
|
120
|
+
'{"a":7}'
|
103
121
|
end
|
104
|
-
|
data/spec/riak/walk_spec_spec.rb
CHANGED
@@ -65,7 +65,7 @@ describe Riak::WalkSpec do
|
|
65
65
|
it "raises an ArgumentError for invalid arguments" do
|
66
66
|
expect { Riak::WalkSpec.new }.to raise_error(ArgumentError)
|
67
67
|
expect { Riak::WalkSpec.new("foo") }.to raise_error(ArgumentError)
|
68
|
-
expect { Riak::WalkSpec.new("foo","bar") }.to raise_error(ArgumentError)
|
68
|
+
expect { Riak::WalkSpec.new("foo", "bar") }.to raise_error(ArgumentError)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -96,7 +96,7 @@ describe Riak::WalkSpec do
|
|
96
96
|
|
97
97
|
describe "creating from a list of parameters" do
|
98
98
|
it "detects hashes and WalkSpecs interleaved with other parameters" do
|
99
|
-
specs = Riak::WalkSpec.normalize(nil,"next",nil,{:bucket => "foo"},Riak::WalkSpec.new({:tag => "child", :keep => true}))
|
99
|
+
specs = Riak::WalkSpec.normalize(nil, "next", nil, {:bucket => "foo"}, Riak::WalkSpec.new({:tag => "child", :keep => true}))
|
100
100
|
expect(specs.size).to eq(3)
|
101
101
|
expect(specs).to be_all {|s| s.kind_of?(Riak::WalkSpec) }
|
102
102
|
expect(specs.join("/")).to eq("_,next,_/foo,_,_/_,child,1")
|
@@ -171,12 +171,14 @@ describe Riak::WalkSpec do
|
|
171
171
|
end
|
172
172
|
|
173
173
|
it "matches a walk spec with the same bucket" do
|
174
|
-
@other.bucket = "foo"
|
174
|
+
@other.bucket = "foo"
|
175
|
+
@spec.bucket = "foo"
|
175
176
|
expect(@spec).to be === @other
|
176
177
|
end
|
177
178
|
|
178
179
|
it "doesn't match a walk spec with a different bucket" do
|
179
|
-
@other.bucket = "foo"
|
180
|
+
@other.bucket = "foo"
|
181
|
+
@spec.bucket = "bar"
|
180
182
|
expect(@spec).not_to be === @other
|
181
183
|
end
|
182
184
|
|
@@ -186,12 +188,14 @@ describe Riak::WalkSpec do
|
|
186
188
|
end
|
187
189
|
|
188
190
|
it "matches a walk spec with the same tag" do
|
189
|
-
@other.tag = "next"
|
191
|
+
@other.tag = "next"
|
192
|
+
@spec.tag = "next"
|
190
193
|
expect(@spec).to be === @other
|
191
194
|
end
|
192
195
|
|
193
196
|
it "doesn't match a walk spec with a different tag" do
|
194
|
-
@other.tag = "next"
|
197
|
+
@other.tag = "next"
|
198
|
+
@spec.tag = "previous"
|
195
199
|
expect(@spec).not_to be === @other
|
196
200
|
end
|
197
201
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,13 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
|
4
4
|
if ENV['COVERAGE']
|
5
5
|
require 'simplecov'
|
6
|
-
SimpleCov.start
|
6
|
+
SimpleCov.start do
|
7
|
+
if ENV['COVERAGE_SUITE']
|
8
|
+
SimpleCov.command_name ENV['COVERAGE_SUITE']
|
9
|
+
end
|
10
|
+
add_filter 'vendor/'
|
11
|
+
end
|
12
|
+
|
7
13
|
end
|
8
14
|
|
9
15
|
require 'rubygems' # Use the gems path only for the spec suite
|
@@ -20,7 +26,10 @@ Riak.disable_list_keys_warnings = true
|
|
20
26
|
search_corpus_setup
|
21
27
|
unified_backend_examples
|
22
28
|
test_client
|
23
|
-
search_config
|
29
|
+
search_config
|
30
|
+
crdt_search_config
|
31
|
+
crdt_search_fixtures
|
32
|
+
].each do |file|
|
24
33
|
require File.join("support", file)
|
25
34
|
end
|
26
35
|
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module CrdtSearchConfig
|
2
|
+
include SearchConfig
|
3
|
+
|
4
|
+
def counter_bucket
|
5
|
+
@counter_bucket ||= bucket_for :counter
|
6
|
+
end
|
7
|
+
|
8
|
+
def map_bucket
|
9
|
+
@map_bucket ||= bucket_for :map
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_bucket
|
13
|
+
@set_bucket ||= bucket_for :set
|
14
|
+
end
|
15
|
+
|
16
|
+
def first_counter
|
17
|
+
return @first_counter if defined? @first_counter
|
18
|
+
|
19
|
+
@first_counter = Riak::Crdt::Counter.new counter_bucket, nil
|
20
|
+
@first_counter.increment 83475 # BEANS in leet, i guess
|
21
|
+
|
22
|
+
@first_counter.tap do |c|
|
23
|
+
wait_until do
|
24
|
+
index.query('counter:83475').results.length > 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def first_map
|
30
|
+
return @first_map if defined? @first_map
|
31
|
+
|
32
|
+
@first_map = Riak::Crdt::Map.new map_bucket, nil
|
33
|
+
@first_map.registers['arroz'] = 'frijoles'
|
34
|
+
|
35
|
+
@first_map.tap do |m|
|
36
|
+
wait_until do
|
37
|
+
index.query('arroz_register:frijoles').results.length > 0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def first_set
|
43
|
+
return @first_set if defined? @first_set
|
44
|
+
|
45
|
+
@first_set = Riak::Crdt::Set.new set_bucket, nil
|
46
|
+
@first_set.add 'frijoles'
|
47
|
+
|
48
|
+
@first_set.tap do |s|
|
49
|
+
wait_until do
|
50
|
+
index.query('set:frijoles').results.length > 0
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def configure_crdt_buckets
|
56
|
+
return if defined? @crdt_buckets_configured
|
57
|
+
|
58
|
+
create_index
|
59
|
+
|
60
|
+
cp = Riak::BucketProperties.new counter_bucket
|
61
|
+
mp = Riak::BucketProperties.new map_bucket
|
62
|
+
sp = Riak::BucketProperties.new set_bucket
|
63
|
+
|
64
|
+
cp['search_index'] = index_name
|
65
|
+
cp.store
|
66
|
+
mp['search_index'] = index_name
|
67
|
+
mp.store
|
68
|
+
sp['search_index'] = index_name
|
69
|
+
sp.store
|
70
|
+
|
71
|
+
wait_until do
|
72
|
+
cp.reload
|
73
|
+
cp['search_index'] == index_name
|
74
|
+
end
|
75
|
+
wait_until do
|
76
|
+
mp.reload
|
77
|
+
mp['search_index'] == index_name
|
78
|
+
end
|
79
|
+
wait_until do
|
80
|
+
sp.reload
|
81
|
+
sp['search_index'] == index_name
|
82
|
+
end
|
83
|
+
|
84
|
+
@crdt_buckets_configured = true
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def bucket_for(type)
|
90
|
+
@bucket_for ||= Hash.new
|
91
|
+
return @bucket_for[type] if @bucket_for[type]
|
92
|
+
|
93
|
+
test_client.
|
94
|
+
bucket_type(Riak::Crdt::DEFAULT_BUCKET_TYPES[type]).
|
95
|
+
bucket("crdt-search-#{ type }-#{ random_key }").
|
96
|
+
tap do |bucket|
|
97
|
+
@bucket_for[type] = bucket
|
98
|
+
props = Riak::BucketProperties.new bucket
|
99
|
+
props['search_index'] = index.name
|
100
|
+
props.store
|
101
|
+
|
102
|
+
wait_until do
|
103
|
+
props.reload
|
104
|
+
props['search_index'] == index.name
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
RSpec.configure do |config|
|
111
|
+
config.include CrdtSearchConfig, crdt_search_config: true
|
112
|
+
end
|