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,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Secondary indexes', test_client: true, integration: true do
|
4
|
-
let(:bucket){ random_bucket '2i-integration' }
|
5
|
-
before do
|
6
|
-
50.times do |i|
|
7
|
-
bucket.new(i.to_s).tap do |obj|
|
8
|
-
obj.indexes["index_int"] << i
|
9
|
-
obj.indexes["index_bin"] << i.to_s
|
10
|
-
obj.data = [i]
|
11
|
-
obj.store
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "finds keys for an equality query" do
|
17
|
-
expect(bucket.get_index('index_int', 20)).to eq(["20"])
|
18
|
-
end
|
19
|
-
|
20
|
-
it "finds keys for a range query" do
|
21
|
-
expect(bucket.get_index('index_int', 19..21)).to match_array(%w(19 20 21))
|
22
|
-
end
|
23
|
-
|
24
|
-
it "returns an empty array for a query that does not match any keys" do
|
25
|
-
expect(bucket.get_index('index_int', 10000)).to eq([])
|
26
|
-
end
|
27
|
-
|
28
|
-
it "returns terms" do
|
29
|
-
results = nil
|
30
|
-
expect do
|
31
|
-
results = bucket.get_index('index_int',
|
32
|
-
19..21,
|
33
|
-
return_terms: true)
|
34
|
-
end.to_not raise_error
|
35
|
-
|
36
|
-
expect(results).to be_a Array
|
37
|
-
expect(results.with_terms).to be_a Hash
|
38
|
-
end
|
39
|
-
|
40
|
-
it "returns terms matching a term_regex" do
|
41
|
-
results = nil
|
42
|
-
expect do
|
43
|
-
results = bucket.get_index('index_bin',
|
44
|
-
'19'..'21',
|
45
|
-
return_terms: true,
|
46
|
-
term_regex: '20')
|
47
|
-
end.to_not raise_error
|
48
|
-
|
49
|
-
terms = results.with_terms
|
50
|
-
|
51
|
-
expect(terms['20']).to be
|
52
|
-
expect(terms['19']).to be_empty
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "with symbolized index names" do
|
56
|
-
it "stores and queries indexes correctly" do
|
57
|
-
obj = bucket.new random_key
|
58
|
-
obj.indexes[:coat_pattern_bin] << "tuxedo"
|
59
|
-
obj.data = "tuxedo"
|
60
|
-
|
61
|
-
expect{ obj.store }.to_not raise_error
|
62
|
-
|
63
|
-
results = nil
|
64
|
-
expect do
|
65
|
-
results = bucket.get_index(:coat_pattern_bin,
|
66
|
-
'tuxedo')
|
67
|
-
end.to_not raise_error
|
68
|
-
|
69
|
-
expect(results.first).to eq obj.key
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak'
|
3
|
-
require 'riak/errors/connection_error'
|
4
|
-
require '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
|
-
if RUBY_PLATFORM == 'java'
|
55
|
-
expect{ bugged_crypto_client.ping }.
|
56
|
-
to(raise_error(OpenSSL::SSL::SSLError))
|
57
|
-
else
|
58
|
-
expect{ bugged_crypto_client.ping }.
|
59
|
-
to(raise_error(OpenSSL::SSL::SSLError,
|
60
|
-
/certificate verify failed/i))
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
it "refuses to connect if the server cert is revoked" do
|
65
|
-
revoked_auth_config = config.dup
|
66
|
-
revoked_auth_config[:authentication] = revoked_auth_config[:authentication].dup
|
67
|
-
|
68
|
-
revoked_auth_config[:authentication][:crl_file] =
|
69
|
-
File.expand_path(File.join('..',
|
70
|
-
'..',
|
71
|
-
'..',
|
72
|
-
'support',
|
73
|
-
'certs',
|
74
|
-
'server.crl'),
|
75
|
-
__FILE__)
|
76
|
-
revoked_auth_config[:authentication][:crl] = true
|
77
|
-
|
78
|
-
revoked_auth_client = Riak::Client.new revoked_auth_config
|
79
|
-
|
80
|
-
expect{ revoked_auth_client.ping }.
|
81
|
-
to(raise_error(Riak::TlsError,
|
82
|
-
/revoked/i))
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe 'with client certificate security enabled on Riak', yes_security: true do
|
87
|
-
it 'connects normally with authentication configured' do
|
88
|
-
client_cert_config = config.dup
|
89
|
-
client_cert_config[:authentication] =
|
90
|
-
client_cert_config[:authentication].dup
|
91
|
-
|
92
|
-
client_cert_config[:authentication][:client_ca] = client_cert_config[:authentication]['ca_file']
|
93
|
-
|
94
|
-
client_cert_config[:authentication][:cert] = 'tools/test-ca/certs/riakuser-client-cert.pem'
|
95
|
-
client_cert_config[:authentication][:key] = 'tools/test-ca/private/riakuser-client-cert-key.pem'
|
96
|
-
|
97
|
-
client_cert_config[:authentication][:user] = 'riakuser'
|
98
|
-
client_cert_config[:authentication][:password] = ''
|
99
|
-
|
100
|
-
cert_client = Riak::Client.new client_cert_config
|
101
|
-
|
102
|
-
expect{ cert_client.ping }.to_not raise_error
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,154 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Multithreaded client", :test_client => true do
|
4
|
-
if ENV['TRAVIS'] == 'true' && RUBY_PLATFORM == 'java'
|
5
|
-
skip 'multithreaded client tests time out on Travis CI'
|
6
|
-
break
|
7
|
-
end
|
8
|
-
class Synchronizer
|
9
|
-
def initialize(n)
|
10
|
-
@mutex = Mutex.new
|
11
|
-
@n = n
|
12
|
-
@waiting = Set.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def sync
|
16
|
-
stop = false
|
17
|
-
@mutex.synchronize do
|
18
|
-
@waiting << Thread.current
|
19
|
-
|
20
|
-
if @waiting.size >= @n
|
21
|
-
# All threads are waiting.
|
22
|
-
@waiting.each do |t|
|
23
|
-
t.run
|
24
|
-
end
|
25
|
-
else
|
26
|
-
stop = true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
if stop
|
31
|
-
Thread.stop
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def threads(n, opts = {})
|
37
|
-
if opts[:synchronize]
|
38
|
-
s1 = Synchronizer.new n
|
39
|
-
s2 = Synchronizer.new n
|
40
|
-
end
|
41
|
-
|
42
|
-
threads = (0...n).map do |i|
|
43
|
-
Thread.new do
|
44
|
-
if opts[:synchronize]
|
45
|
-
s1.sync
|
46
|
-
end
|
47
|
-
|
48
|
-
yield i
|
49
|
-
|
50
|
-
if opts[:synchronize]
|
51
|
-
s2.sync
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
threads.each do |t|
|
57
|
-
t.join
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
[
|
62
|
-
{:protobuffs_backend => :Beefcake}
|
63
|
-
].each do |opts|
|
64
|
-
describe opts.inspect do
|
65
|
-
before do
|
66
|
-
@bucket = random_bucket 'threading'
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'gets in parallel' do
|
70
|
-
data = "the gun is good"
|
71
|
-
ro = @bucket.new('test')
|
72
|
-
ro.content_type = "application/json"
|
73
|
-
ro.data = [data]
|
74
|
-
ro.store
|
75
|
-
|
76
|
-
threads 10, :synchronize => true do
|
77
|
-
x = @bucket['test']
|
78
|
-
expect(x.content_type).to eq("application/json")
|
79
|
-
expect(x.data).to eq([data])
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'puts in parallel' do
|
84
|
-
data = "the tabernacle is indestructible and everlasting"
|
85
|
-
|
86
|
-
n = 10
|
87
|
-
threads n, :synchronize => true do |i|
|
88
|
-
x = @bucket.new("test-#{i}")
|
89
|
-
x.content_type = "application/json"
|
90
|
-
x.data = ["#{data}-#{i}"]
|
91
|
-
x.store
|
92
|
-
end
|
93
|
-
|
94
|
-
(0...n).each do |i|
|
95
|
-
read = @bucket["test-#{i}"]
|
96
|
-
expect(read.content_type).to eq("application/json")
|
97
|
-
expect(read.data).to eq(["#{data}-#{i}"])
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# This is a 1.0+ spec because putting with the same client ID
|
102
|
-
# will not create siblings on 0.14 in the same way. This will
|
103
|
-
# also likely fail for nodes with vnode_vclocks = false.
|
104
|
-
it 'puts conflicts in parallel' do
|
105
|
-
@bucket.allow_mult = true
|
106
|
-
expect(@bucket.allow_mult).to eq(true)
|
107
|
-
|
108
|
-
init = @bucket.new('test')
|
109
|
-
init.content_type = "application/json"
|
110
|
-
init.data = ''
|
111
|
-
init.store
|
112
|
-
|
113
|
-
# Create conflicting writes
|
114
|
-
n = 10
|
115
|
-
s = Synchronizer.new n
|
116
|
-
threads n, :synchronize => true do |i|
|
117
|
-
x = @bucket["test"]
|
118
|
-
s.sync
|
119
|
-
x.data = [i]
|
120
|
-
x.store
|
121
|
-
end
|
122
|
-
|
123
|
-
read = @bucket["test"]
|
124
|
-
expect(read.conflict?).to eq(true)
|
125
|
-
expect(read.siblings.map do |sibling|
|
126
|
-
sibling.data.first
|
127
|
-
end.to_set).to eq((0...n).to_set)
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'lists-keys and gets in parallel', :slow => true do
|
131
|
-
count = 100
|
132
|
-
threads = 2
|
133
|
-
|
134
|
-
# Create items
|
135
|
-
count.times do |i|
|
136
|
-
o = @bucket.new("#{i}")
|
137
|
-
o.content_type = 'application/json'
|
138
|
-
o.data = [i]
|
139
|
-
o.store
|
140
|
-
end
|
141
|
-
|
142
|
-
threads(threads) do
|
143
|
-
set = Set.new
|
144
|
-
@bucket.keys do |stream|
|
145
|
-
stream.each do |key|
|
146
|
-
set.merge @bucket[key].data
|
147
|
-
end
|
148
|
-
end
|
149
|
-
expect(set).to eq((0...count).to_set)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
@@ -1,212 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak'
|
3
|
-
|
4
|
-
describe 'Time Series',
|
5
|
-
test_client: true, integration: true, time_series: true do
|
6
|
-
let(:table_name){ 'GeoCheckin' }
|
7
|
-
|
8
|
-
let(:now_ts) { Time.now.to_i }
|
9
|
-
let(:now){ Time.at(now_ts) }
|
10
|
-
let(:five_minutes_ago){ now - 300 }
|
11
|
-
let(:now_range_str) do
|
12
|
-
past = (now.to_i - 100) * 1000
|
13
|
-
future = (now.to_i + 100) * 1000
|
14
|
-
"time > #{ past } AND time < #{ future }"
|
15
|
-
end
|
16
|
-
let(:never_range_str) do
|
17
|
-
range_start = '1'
|
18
|
-
range_end = '2'
|
19
|
-
"time > #{range_start} AND time < #{range_end}"
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:family){ 'geohash-' + random_key }
|
23
|
-
let(:series){ 'user-' + random_key }
|
24
|
-
|
25
|
-
let(:key){ [family, series, now] }
|
26
|
-
let(:key_ts){ [family, series, now_ts * 1000] }
|
27
|
-
let(:key2){ [family, series, five_minutes_ago] }
|
28
|
-
let(:datum){ [*key, 'cloudy', 27.1] }
|
29
|
-
let(:datum_null){ [*key2, 'cloudy', nil] }
|
30
|
-
|
31
|
-
let(:family_series_str) do
|
32
|
-
"geohash = '#{family}' AND user = '#{series}'"
|
33
|
-
end
|
34
|
-
|
35
|
-
let(:query) do
|
36
|
-
<<-SQL
|
37
|
-
SELECT * FROM #{table_name}
|
38
|
-
WHERE
|
39
|
-
#{family_series_str} AND
|
40
|
-
#{now_range_str}
|
41
|
-
SQL
|
42
|
-
end
|
43
|
-
|
44
|
-
let(:no_data_query) do
|
45
|
-
<<-SQL
|
46
|
-
SELECT * FROM #{table_name}
|
47
|
-
WHERE
|
48
|
-
#{family_series_str} AND
|
49
|
-
#{never_range_str}
|
50
|
-
SQL
|
51
|
-
end
|
52
|
-
|
53
|
-
let(:describe_table) do
|
54
|
-
"DESCRIBE #{table_name}"
|
55
|
-
end
|
56
|
-
|
57
|
-
let(:create_table) do
|
58
|
-
<<-SQL
|
59
|
-
CREATE TABLE timeseries-#{random_key} (
|
60
|
-
geohash varchar not null,
|
61
|
-
user varchar not null,
|
62
|
-
time timestamp not null,
|
63
|
-
weather varchar not null,
|
64
|
-
temperature double,
|
65
|
-
PRIMARY KEY(
|
66
|
-
(geohash, user, quantum(time, 15, m)),
|
67
|
-
geohash, user, time
|
68
|
-
)
|
69
|
-
)
|
70
|
-
SQL
|
71
|
-
end
|
72
|
-
|
73
|
-
let(:stored_datum_expectation) do
|
74
|
-
submission = Riak::TimeSeries::Submission.new test_client, table_name
|
75
|
-
submission.measurements = [datum]
|
76
|
-
expect{ submission.write! }.to_not raise_error
|
77
|
-
end
|
78
|
-
|
79
|
-
let(:stored_datum_null_expectation) do
|
80
|
-
submission = Riak::TimeSeries::Submission.new test_client, table_name
|
81
|
-
submission.measurements = [datum_null]
|
82
|
-
expect{ submission.write! }.to_not raise_error
|
83
|
-
end
|
84
|
-
|
85
|
-
describe 'create table via query' do
|
86
|
-
subject{ Riak::TimeSeries::Query.new test_client, create_table }
|
87
|
-
|
88
|
-
it 'creates a new table without error' do
|
89
|
-
expect{ subject.issue! }.to_not raise_error
|
90
|
-
expect(subject.results).to be
|
91
|
-
expect(subject.results).to be_empty
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe 'describe table via query' do
|
96
|
-
subject{ Riak::TimeSeries::Query.new test_client, describe_table }
|
97
|
-
|
98
|
-
it 'describes a table without error' do
|
99
|
-
expect{ subject.issue! }.to_not raise_error
|
100
|
-
expect(subject.results).to be
|
101
|
-
expect(subject.results).to_not be_empty
|
102
|
-
expect(subject.results.columns).to_not be_empty
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe 'query interface' do
|
107
|
-
subject{ Riak::TimeSeries::Query.new test_client, query }
|
108
|
-
let(:subject_without_data) do
|
109
|
-
Riak::TimeSeries::Query.new test_client, no_data_query
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'queries data without error' do
|
113
|
-
stored_datum_expectation
|
114
|
-
|
115
|
-
expect{ subject.issue! }.to_not raise_error
|
116
|
-
expect(subject.results).to be
|
117
|
-
expect(subject.results).to_not be_empty
|
118
|
-
expect(subject.results.columns).to_not be_empty
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'returns an empty collection when not finding data' do
|
122
|
-
expect{ subject_without_data.issue! }.to_not raise_error
|
123
|
-
expect(subject.results).to_not be
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe 'single-key get interface' do
|
128
|
-
subject{ Riak::TimeSeries::Read.new test_client, table_name }
|
129
|
-
it 'retrieves data without error' do
|
130
|
-
stored_datum_expectation
|
131
|
-
|
132
|
-
subject.key = key
|
133
|
-
result = nil
|
134
|
-
expect{ result = subject.read! }.to_not raise_error
|
135
|
-
expect(result).to be
|
136
|
-
expect(result).to_not be_empty
|
137
|
-
expect(result.first).to_not be_empty
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'retrieves data with a null value without error' do
|
141
|
-
stored_datum_null_expectation
|
142
|
-
|
143
|
-
subject.key = key2
|
144
|
-
result = nil
|
145
|
-
expect{ result = subject.read! }.to_not raise_error
|
146
|
-
expect(result).to be
|
147
|
-
expect(result).to_not be_empty
|
148
|
-
|
149
|
-
row = result.first
|
150
|
-
expect(row).to_not be_empty
|
151
|
-
expect(row[4]).to_not be
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'attempts retrieval of non-existent data without error' do
|
155
|
-
subject.key = [ 'foo', 'bar', now ]
|
156
|
-
result = nil
|
157
|
-
expect{ result = subject.read! }.to_not raise_error
|
158
|
-
expect(result).to_not be
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe 'single-key delete interface' do
|
163
|
-
subject{ Riak::TimeSeries::Deletion.new test_client, table_name }
|
164
|
-
let(:test_read){ Riak::TimeSeries::Read.new test_client, table_name }
|
165
|
-
|
166
|
-
it 'deletes data without error' do
|
167
|
-
stored_datum_expectation
|
168
|
-
|
169
|
-
test_read.key = key
|
170
|
-
expect(test_read.read!).to_not be_empty
|
171
|
-
|
172
|
-
subject.key = key
|
173
|
-
expect{ subject.delete! }.to_not raise_error
|
174
|
-
|
175
|
-
expect(test_read.read!).to_not be
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe 'submission interface' do
|
180
|
-
it 'writes data without error' do
|
181
|
-
stored_datum_expectation
|
182
|
-
end
|
183
|
-
it 'writes data with a null value without error' do
|
184
|
-
stored_datum_null_expectation
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
describe 'list interface' do
|
189
|
-
it 'passes listed keys to a block' do
|
190
|
-
stored_datum_expectation
|
191
|
-
found_expectation = double 'expectation'
|
192
|
-
expect(found_expectation).to receive(:found!).once
|
193
|
-
|
194
|
-
lister = Riak::TimeSeries::List.new test_client, table_name
|
195
|
-
|
196
|
-
lister.issue! do |row|
|
197
|
-
found_expectation.found! if row.to_a == key_ts
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
it 'returns a list of keys without a block' do
|
202
|
-
stored_datum_expectation
|
203
|
-
found_expectation = double 'expectation'
|
204
|
-
|
205
|
-
lister = Riak::TimeSeries::List.new test_client, table_name
|
206
|
-
|
207
|
-
results = lister.issue!
|
208
|
-
|
209
|
-
expect(results).to include key_ts
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|