riak-client 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,225 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::SecondaryIndex do
|
4
|
-
before(:each) do
|
5
|
-
@client = Riak::Client.new
|
6
|
-
@bucket = Riak::Bucket.new @client, 'foo'
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "initialization" do
|
10
|
-
it "accepts a bucket, index name, and scalar" do
|
11
|
-
expect { Riak::SecondaryIndex.new @bucket, 'asdf', 'aaaa' }.not_to raise_error
|
12
|
-
expect { Riak::SecondaryIndex.new @bucket, 'asdf', 12345 }.not_to raise_error
|
13
|
-
end
|
14
|
-
|
15
|
-
it "accepts a bucket, index name, and a range" do
|
16
|
-
expect { Riak::SecondaryIndex.new @bucket, 'asdf', 'aaaa'..'zzzz' }.not_to raise_error
|
17
|
-
expect { Riak::SecondaryIndex.new @bucket, 'asdf', 1..5 }.not_to raise_error
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "operation" do
|
22
|
-
before(:each) do
|
23
|
-
@backend = double 'Backend'
|
24
|
-
allow(@client).to receive(:backend).and_yield(@backend)
|
25
|
-
@args = [@bucket, 'asdf', 'aaaa'..'zzzz', {}]
|
26
|
-
@index = Riak::SecondaryIndex.new *@args
|
27
|
-
|
28
|
-
expect(@backend).to receive(:get_index).with(*@args).and_return(%w{abcd efgh})
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns an array of keys" do
|
32
|
-
@results = @index.keys
|
33
|
-
expect(@results).to be_a Array
|
34
|
-
expect(@results.first).to be_a String
|
35
|
-
end
|
36
|
-
it "returns an array of values" do
|
37
|
-
expect(@backend).to receive(:fetch_object).with(@bucket, 'abcd', {}).and_return('abcd')
|
38
|
-
expect(@backend).to receive(:fetch_object).with(@bucket, 'efgh', {}).and_return('efgh')
|
39
|
-
|
40
|
-
@results = @index.values
|
41
|
-
expect(@results).to be_a Array
|
42
|
-
expect(@results.length).to eq(2)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "streaming" do
|
47
|
-
it "streams keys into a block" do
|
48
|
-
@backend = double 'Backend'
|
49
|
-
allow(@client).to receive(:backend).and_yield(@backend)
|
50
|
-
@args = [@bucket, 'asdf', 'aaaa'..'zzzz', {stream: true}]
|
51
|
-
@index = Riak::SecondaryIndex.new *@args
|
52
|
-
|
53
|
-
expect(@backend).to receive(:get_index).with(*@args).and_yield('abcd').and_yield('efgh')
|
54
|
-
|
55
|
-
@index.keys {|b| :noop }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "pagination" do
|
60
|
-
it "supports max_results" do
|
61
|
-
@max_results = 5
|
62
|
-
|
63
|
-
@expected_collection = Riak::IndexCollection.new_from_json({
|
64
|
-
'keys' => %w{aaaa bbbb cccc dddd eeee},
|
65
|
-
'continuation' => 'examplecontinuation'
|
66
|
-
}.to_json)
|
67
|
-
|
68
|
-
@backend = double 'Backend'
|
69
|
-
allow(@client).to receive(:backend).and_yield(@backend)
|
70
|
-
expect(@backend).
|
71
|
-
to receive(:get_index).
|
72
|
-
with(
|
73
|
-
@bucket,
|
74
|
-
'asdf',
|
75
|
-
('aaaa'..'zzzz'),
|
76
|
-
:max_results => @max_results
|
77
|
-
).
|
78
|
-
and_return(@expected_collection)
|
79
|
-
allow(@backend).to receive(:get_server_version).and_return('1.4.0')
|
80
|
-
|
81
|
-
|
82
|
-
@index = Riak::SecondaryIndex.new(
|
83
|
-
@bucket,
|
84
|
-
'asdf',
|
85
|
-
'aaaa'..'zzzz',
|
86
|
-
:max_results => @max_results
|
87
|
-
)
|
88
|
-
|
89
|
-
@results = @index.keys
|
90
|
-
expect(@results).to be_an Array
|
91
|
-
expect(@results).to eq(@expected_collection)
|
92
|
-
expect(@results.length).to eq(@max_results)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "supports continuations" do
|
96
|
-
@max_results = 5
|
97
|
-
|
98
|
-
@expected_collection = Riak::IndexCollection.new_from_json({
|
99
|
-
'keys' => %w{ffff gggg hhhh}
|
100
|
-
}.to_json)
|
101
|
-
|
102
|
-
@backend = double 'Backend'
|
103
|
-
allow(@client).to receive(:backend).and_yield(@backend)
|
104
|
-
expect(@backend).
|
105
|
-
to receive(:get_index).
|
106
|
-
with(
|
107
|
-
@bucket,
|
108
|
-
'asdf',
|
109
|
-
('aaaa'..'zzzz'),
|
110
|
-
max_results: @max_results,
|
111
|
-
continuation: 'examplecontinuation'
|
112
|
-
).
|
113
|
-
and_return(@expected_collection)
|
114
|
-
allow(@backend).to receive(:get_server_version).and_return('1.4.0')
|
115
|
-
|
116
|
-
|
117
|
-
@index = Riak::SecondaryIndex.new(
|
118
|
-
@bucket,
|
119
|
-
'asdf',
|
120
|
-
'aaaa'..'zzzz',
|
121
|
-
max_results: @max_results,
|
122
|
-
continuation: 'examplecontinuation'
|
123
|
-
)
|
124
|
-
|
125
|
-
@results = @index.keys
|
126
|
-
expect(@results).to be_an Array
|
127
|
-
expect(@results).to eq(@expected_collection)
|
128
|
-
end
|
129
|
-
|
130
|
-
it "supports a next_page method" do
|
131
|
-
@max_results = 5
|
132
|
-
|
133
|
-
@expected_collection = Riak::IndexCollection.new_from_json({
|
134
|
-
'keys' => %w{aaaa bbbb cccc dddd eeee},
|
135
|
-
'continuation' => 'examplecontinuation'
|
136
|
-
}.to_json)
|
137
|
-
|
138
|
-
@backend = double 'Backend'
|
139
|
-
allow(@client).to receive(:backend).and_yield(@backend)
|
140
|
-
expect(@backend).
|
141
|
-
to receive(:get_index).
|
142
|
-
once.
|
143
|
-
with(
|
144
|
-
@bucket,
|
145
|
-
'asdf',
|
146
|
-
('aaaa'..'zzzz'),
|
147
|
-
:max_results => @max_results
|
148
|
-
).
|
149
|
-
and_return(@expected_collection)
|
150
|
-
allow(@backend).to receive(:get_server_version).and_return('1.4.0')
|
151
|
-
|
152
|
-
|
153
|
-
@index = Riak::SecondaryIndex.new(
|
154
|
-
@bucket,
|
155
|
-
'asdf',
|
156
|
-
'aaaa'..'zzzz',
|
157
|
-
:max_results => @max_results
|
158
|
-
)
|
159
|
-
|
160
|
-
@results = @index.keys
|
161
|
-
expect(@results).to eq(@expected_collection)
|
162
|
-
|
163
|
-
@second_collection = Riak::IndexCollection.new_from_json({
|
164
|
-
'keys' => %w{ffff gggg hhhh}
|
165
|
-
}.to_json)
|
166
|
-
expect(@backend).
|
167
|
-
to receive(:get_index).
|
168
|
-
once.
|
169
|
-
with(
|
170
|
-
@bucket,
|
171
|
-
'asdf',
|
172
|
-
('aaaa'..'zzzz'),
|
173
|
-
max_results: @max_results,
|
174
|
-
continuation: 'examplecontinuation'
|
175
|
-
).
|
176
|
-
and_return(@second_collection)
|
177
|
-
|
178
|
-
@second_page = @index.next_page
|
179
|
-
@second_results = @second_page.keys
|
180
|
-
expect(@second_results).to eq(@second_collection)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe "return_terms" do
|
185
|
-
it "optionally gives the index value" do
|
186
|
-
@expected_collection = Riak::IndexCollection.new_from_json({
|
187
|
-
'results' => [
|
188
|
-
{'aaaa' => 'aaaa'},
|
189
|
-
{'bbbb' => 'bbbb'},
|
190
|
-
{'bbbb' => 'bbbb2'}
|
191
|
-
]
|
192
|
-
}.to_json)
|
193
|
-
|
194
|
-
|
195
|
-
@backend = double 'Backend'
|
196
|
-
allow(@client).to receive(:backend).and_yield(@backend)
|
197
|
-
expect(@backend).
|
198
|
-
to receive(:get_index).
|
199
|
-
with(
|
200
|
-
@bucket,
|
201
|
-
'asdf',
|
202
|
-
('aaaa'..'zzzz'),
|
203
|
-
:return_terms => true
|
204
|
-
).
|
205
|
-
and_return(@expected_collection)
|
206
|
-
allow(@backend).to receive(:get_server_version).and_return('1.4.0')
|
207
|
-
|
208
|
-
|
209
|
-
@index = Riak::SecondaryIndex.new(
|
210
|
-
@bucket,
|
211
|
-
'asdf',
|
212
|
-
'aaaa'..'zzzz',
|
213
|
-
:return_terms => true
|
214
|
-
)
|
215
|
-
|
216
|
-
@results = @index.keys
|
217
|
-
expect(@results).to be_an Array
|
218
|
-
expect(@results).to eq(@expected_collection)
|
219
|
-
expect(@results.with_terms).to eq({
|
220
|
-
'aaaa' => %w{aaaa},
|
221
|
-
'bbbb' => %w{bbbb bbbb2}
|
222
|
-
})
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::Serializers do
|
4
|
-
shared_examples_for "a serializer" do |type, deserialized, serialized|
|
5
|
-
context "for #{type}" do
|
6
|
-
it "serializes #{deserialized} to #{serialized}" do
|
7
|
-
expect(described_class.serialize(type, deserialized)).to eq(serialized)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "deserializes #{serialized} to #{deserialized}" do
|
11
|
-
expect(described_class.deserialize(type, serialized)).
|
12
|
-
to eq(deserialized)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "round trips properly" do
|
16
|
-
str = described_class.serialize(type, deserialized)
|
17
|
-
expect(described_class.deserialize(type, str)).to eq(deserialized)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it_behaves_like "a serializer", "text/plain", "a string", "a string"
|
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 })
|
28
|
-
|
29
|
-
described_class::YAML_MIME_TYPES.each do |mime_type|
|
30
|
-
it_behaves_like "a serializer",
|
31
|
-
mime_type,
|
32
|
-
{ "a" => 7 },
|
33
|
-
YAML.dump({ "a" => 7 })
|
34
|
-
end
|
35
|
-
|
36
|
-
%w[ serialize deserialize ].each do |meth|
|
37
|
-
describe ".#{meth}" do
|
38
|
-
it 'raises an IOError when given an unrecognized content type' do
|
39
|
-
expect {
|
40
|
-
described_class.send(meth, "application/unrecognized", "string")
|
41
|
-
}.to raise_error(IOError)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "plain text serializer" do
|
47
|
-
it 'calls #to_s to convert the object to a string' do
|
48
|
-
expect(described_class.serialize('text/plain', :a_string)).
|
49
|
-
to eq('a_string')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "JSON serializer" do
|
54
|
-
it "respects the max nesting option" do
|
55
|
-
# Sadly, this spec will not fail for me when using yajl-ruby
|
56
|
-
# on Ruby 1.9, even when passing the options to #to_json is
|
57
|
-
# not implemented.
|
58
|
-
Riak.json_options = {:max_nesting => 51}
|
59
|
-
h = {}
|
60
|
-
p = h
|
61
|
-
(1..50).each do |i|
|
62
|
-
p['a'] = {}
|
63
|
-
p = p['a']
|
64
|
-
end
|
65
|
-
s = h.to_json(Riak.json_options)
|
66
|
-
expect {
|
67
|
-
described_class.serialize('application/json', h)
|
68
|
-
}.to_not raise_error
|
69
|
-
|
70
|
-
expect {
|
71
|
-
described_class.deserialize('application/json', s)
|
72
|
-
}.to_not raise_error
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "a custom serializer" do
|
77
|
-
let(:custom_serializer) do
|
78
|
-
Object.new.tap do |o|
|
79
|
-
def o.dump(string)
|
80
|
-
"The string is: #{string}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def o.load(string)
|
84
|
-
string.sub(/^The string is: /, '')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'can be registered' do
|
90
|
-
described_class['application/custom-type-1'] = custom_serializer
|
91
|
-
expect(described_class['application/custom-type-1']).
|
92
|
-
to be(custom_serializer)
|
93
|
-
# fail
|
94
|
-
end
|
95
|
-
|
96
|
-
it_behaves_like "a serializer",
|
97
|
-
"application/custom-type-a",
|
98
|
-
"foo",
|
99
|
-
"The string is: foo" do
|
100
|
-
before(:each) do
|
101
|
-
described_class['application/custom-type-a'] = custom_serializer
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
after(:each) do
|
106
|
-
# Make sure to clean up the registered serializer
|
107
|
-
%w{application/custom-type-1 application/custom-type-a}.each do |ctype|
|
108
|
-
described_class.send(:serializers).delete(ctype)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
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}'
|
121
|
-
end
|
data/spec/riak/stamp_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak/stamp'
|
3
|
-
|
4
|
-
describe Riak::Stamp, test_client: true, integration: true do
|
5
|
-
subject { described_class.new test_client }
|
6
|
-
it "generates always increasing integer identifiers" do
|
7
|
-
1000.times do
|
8
|
-
one = subject.next
|
9
|
-
two = subject.next
|
10
|
-
expect([one, two]).to be_all {|i| Integer === i }
|
11
|
-
expect(two).to be > one
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "delays until the next millisecond when the sequence overflows" do
|
16
|
-
old = subject.instance_variable_get(:@timestamp) + 0
|
17
|
-
subject.instance_variable_set(:@sequence, described_class::SEQUENCE_MASK)
|
18
|
-
count = 0
|
19
|
-
# Simulate the time_gen method returning the same thing multiple times
|
20
|
-
allow(subject).to receive(:time_gen) do
|
21
|
-
count += 1
|
22
|
-
if count < 10
|
23
|
-
old
|
24
|
-
else
|
25
|
-
old + 1
|
26
|
-
end
|
27
|
-
end
|
28
|
-
expect((subject.next >> described_class::TIMESTAMP_SHIFT) & described_class::TIMESTAMP_MASK).to eq(old + 1)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "raises an exception when the system clock moves backwards" do
|
32
|
-
old = subject.instance_variable_get(:@timestamp)
|
33
|
-
expect(subject).to receive(:time_gen).and_return(old - 10)
|
34
|
-
expect {
|
35
|
-
subject.next
|
36
|
-
}.to raise_error(Riak::BackwardsClockError)
|
37
|
-
end
|
38
|
-
|
39
|
-
# The client/worker ID should be used for disambiguation, not for
|
40
|
-
# primary ordering. This breaks from the Snowflake model where the
|
41
|
-
# worker ID is in more significant bits.
|
42
|
-
it "uses the client ID as the bottom component of the identifier" do
|
43
|
-
expect(subject.next & described_class::CLIENT_ID_MASK).to eq(subject.client.client_id.hash & described_class::CLIENT_ID_MASK)
|
44
|
-
end
|
45
|
-
|
46
|
-
context "using a non-integer client ID" do
|
47
|
-
subject { described_class.new(Riak::Client.new(:client_id => "ripple")) }
|
48
|
-
let(:hash) { "ripple".hash }
|
49
|
-
|
50
|
-
it "uses the hash of the client ID as the bottom component of the identifier" do
|
51
|
-
expect(subject.next & described_class::CLIENT_ID_MASK).to eq(subject.client.client_id.hash & described_class::CLIENT_ID_MASK)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::TimeSeries::Deletion do
|
4
|
-
subject{ described_class.new client, table_name }
|
5
|
-
let(:table_name){ 'GeoCheckin' }
|
6
|
-
let(:client){ instance_double('Riak::Client') }
|
7
|
-
let(:key){ double 'key' }
|
8
|
-
let(:backend) do
|
9
|
-
instance_double('Riak::Client::BeefcakeProtobuffsBackend').tap do |be|
|
10
|
-
allow(client).to receive(:backend).and_yield be
|
11
|
-
end
|
12
|
-
end
|
13
|
-
let(:operator) do
|
14
|
-
Riak::Client::BeefcakeProtobuffsBackend.configured?
|
15
|
-
instance_double(
|
16
|
-
'Riak::Client::BeefcakeProtobuffsBackend::TimeSeriesDeleteOperator'
|
17
|
-
).tap do |op|
|
18
|
-
allow(backend).to receive(:time_series_delete_operator).
|
19
|
-
and_return(op)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'initializes with client and table name' do
|
24
|
-
expect{ described_class.new client, table_name }.to_not raise_error
|
25
|
-
expect{ described_class.new client }.to raise_error ArgumentError
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'passes keys to delete to a delete operator' do
|
29
|
-
expect{ subject.key = key }.to_not raise_error
|
30
|
-
expect(operator).to receive(:delete).with(table_name, key, Hash.new)
|
31
|
-
expect{ subject.delete! }.to_not raise_error
|
32
|
-
end
|
33
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::TimeSeries::List do
|
4
|
-
subject { described_class.new client, table_name }
|
5
|
-
let(:table_name){ 'GeoCheckin' }
|
6
|
-
let(:client){ instance_double('Riak::Client') }
|
7
|
-
let(:key){ double 'key' }
|
8
|
-
let(:backend) do
|
9
|
-
instance_double('Riak::Client::BeefcakeProtobuffsBackend').tap do |be|
|
10
|
-
allow(client).to receive(:backend).and_yield be
|
11
|
-
allow(client).to receive(:convert_timestamp).and_return(true)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
let(:operator) do
|
15
|
-
Riak::Client::BeefcakeProtobuffsBackend.configured?
|
16
|
-
instance_double(
|
17
|
-
'Riak::Client::BeefcakeProtobuffsBackend::TimeSeriesListOperator'
|
18
|
-
).tap do |op|
|
19
|
-
allow(backend).to receive(:time_series_list_operator).
|
20
|
-
and_return(op)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:list_results) do
|
25
|
-
Riak::TimeSeries::Collection.new.tap do |buf|
|
26
|
-
%w{family series timestamp}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'initializes with client and table name' do
|
31
|
-
expect{ described_class.new client, table_name }.to_not raise_error
|
32
|
-
expect{ described_class.new client }.to raise_error ArgumentError
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'passes a block to the operator' do
|
36
|
-
streamer = proc { double 'block contents' }
|
37
|
-
|
38
|
-
expect(operator).to receive(:list).with(table_name, streamer, timeout: nil)
|
39
|
-
|
40
|
-
subject.issue! &streamer
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'returns a list of results' do
|
44
|
-
expect(operator).to receive(:list).
|
45
|
-
with(table_name, nil, timeout: nil).
|
46
|
-
and_return(list_results)
|
47
|
-
|
48
|
-
expect(subject.issue!).to eq list_results
|
49
|
-
expect(subject.results).to eq list_results
|
50
|
-
end
|
51
|
-
end
|