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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/RELNOTES.md +3 -0
  4. data/lib/riak/bucket.rb +1 -1
  5. data/lib/riak/client.rb +14 -7
  6. data/lib/riak/client/beefcake/messages.rb +13 -0
  7. data/lib/riak/multi.rb +101 -0
  8. data/lib/riak/multiexist.rb +14 -0
  9. data/lib/riak/multiget.rb +7 -107
  10. data/lib/riak/version.rb +1 -1
  11. metadata +12 -234
  12. data/.document +0 -5
  13. data/.gitignore +0 -44
  14. data/.rspec +0 -2
  15. data/Gemfile +0 -17
  16. data/Guardfile +0 -20
  17. data/Rakefile +0 -124
  18. data/riak-client.gemspec +0 -71
  19. data/spec/failover/failover.rb +0 -59
  20. data/spec/fixtures/bitcask.txt +0 -25
  21. data/spec/fixtures/cat.jpg +0 -0
  22. data/spec/fixtures/multipart-basic-conflict.txt +0 -15
  23. data/spec/fixtures/multipart-blank.txt +0 -7
  24. data/spec/fixtures/multipart-mapreduce.txt +0 -10
  25. data/spec/fixtures/multipart-with-body.txt +0 -16
  26. data/spec/fixtures/multipart-with-marked-tombstones.txt +0 -17
  27. data/spec/fixtures/multipart-with-unmarked-tombstone.txt +0 -16
  28. data/spec/fixtures/server.cert.crt +0 -15
  29. data/spec/fixtures/server.cert.key +0 -15
  30. data/spec/fixtures/test.pem +0 -1
  31. data/spec/fixtures/yz_schema_template.xml +0 -18
  32. data/spec/integration/riak/bucket_types_spec.rb +0 -308
  33. data/spec/integration/riak/conflict_resolution_spec.rb +0 -96
  34. data/spec/integration/riak/counters_spec.rb +0 -36
  35. data/spec/integration/riak/crdt/configuration_spec.rb +0 -38
  36. data/spec/integration/riak/crdt_search_spec.rb +0 -176
  37. data/spec/integration/riak/crdt_spec.rb +0 -332
  38. data/spec/integration/riak/crdt_validation/map_spec.rb +0 -63
  39. data/spec/integration/riak/crdt_validation/set_spec.rb +0 -122
  40. data/spec/integration/riak/encodings/crdt_spec.rb +0 -122
  41. data/spec/integration/riak/encodings/kv_spec.rb +0 -87
  42. data/spec/integration/riak/encodings/yz_spec.rb +0 -142
  43. data/spec/integration/riak/preflist_spec.rb +0 -43
  44. data/spec/integration/riak/properties_spec.rb +0 -69
  45. data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +0 -33
  46. data/spec/integration/riak/protobuffs/timeouts_spec.rb +0 -178
  47. data/spec/integration/riak/protobuffs_backends_spec.rb +0 -40
  48. data/spec/integration/riak/search_spec.rb +0 -104
  49. data/spec/integration/riak/secondary_index_spec.rb +0 -72
  50. data/spec/integration/riak/security_spec.rb +0 -105
  51. data/spec/integration/riak/threading_spec.rb +0 -154
  52. data/spec/integration/riak/time_series_spec.rb +0 -212
  53. data/spec/integration/yokozuna/index_spec.rb +0 -61
  54. data/spec/integration/yokozuna/queries_spec.rb +0 -115
  55. data/spec/integration/yokozuna/schema_spec.rb +0 -49
  56. data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +0 -247
  57. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +0 -244
  58. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +0 -53
  59. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +0 -189
  60. data/spec/riak/beefcake_protobuffs_backend/ts_cell_codec_spec.rb +0 -124
  61. data/spec/riak/beefcake_protobuffs_backend_spec.rb +0 -162
  62. data/spec/riak/bucket_properties_spec.rb +0 -135
  63. data/spec/riak/bucket_spec.rb +0 -275
  64. data/spec/riak/bucket_type_spec.rb +0 -50
  65. data/spec/riak/bucket_typed/bucket_spec.rb +0 -78
  66. data/spec/riak/client_spec.rb +0 -304
  67. data/spec/riak/core_ext/to_param_spec.rb +0 -15
  68. data/spec/riak/counter_spec.rb +0 -122
  69. data/spec/riak/crdt/counter_spec.rb +0 -55
  70. data/spec/riak/crdt/hyper_log_log_spec.rb +0 -56
  71. data/spec/riak/crdt/inner_counter_spec.rb +0 -21
  72. data/spec/riak/crdt/inner_flag_spec.rb +0 -39
  73. data/spec/riak/crdt/inner_map_spec.rb +0 -47
  74. data/spec/riak/crdt/inner_register_spec.rb +0 -40
  75. data/spec/riak/crdt/inner_set_spec.rb +0 -33
  76. data/spec/riak/crdt/map_spec.rb +0 -78
  77. data/spec/riak/crdt/set_spec.rb +0 -61
  78. data/spec/riak/crdt/shared_examples.rb +0 -88
  79. data/spec/riak/crdt/typed_collection_spec.rb +0 -225
  80. data/spec/riak/escape_spec.rb +0 -72
  81. data/spec/riak/feature_detection_spec.rb +0 -77
  82. data/spec/riak/index_collection_spec.rb +0 -53
  83. data/spec/riak/instrumentation_spec.rb +0 -124
  84. data/spec/riak/link_spec.rb +0 -85
  85. data/spec/riak/list_buckets_spec.rb +0 -41
  86. data/spec/riak/map_reduce/filter_builder_spec.rb +0 -32
  87. data/spec/riak/map_reduce/phase_spec.rb +0 -142
  88. data/spec/riak/map_reduce_spec.rb +0 -434
  89. data/spec/riak/multiget_spec.rb +0 -81
  90. data/spec/riak/node_spec.rb +0 -26
  91. data/spec/riak/robject_spec.rb +0 -542
  92. data/spec/riak/search/index_spec.rb +0 -72
  93. data/spec/riak/search/query_spec.rb +0 -88
  94. data/spec/riak/search/result_collection_spec.rb +0 -89
  95. data/spec/riak/search/result_document_spec.rb +0 -106
  96. data/spec/riak/search/schema_spec.rb +0 -63
  97. data/spec/riak/search_spec.rb +0 -107
  98. data/spec/riak/secondary_index_spec.rb +0 -225
  99. data/spec/riak/serializers_spec.rb +0 -121
  100. data/spec/riak/stamp_spec.rb +0 -54
  101. data/spec/riak/time_series/deletion_spec.rb +0 -33
  102. data/spec/riak/time_series/listing_spec.rb +0 -51
  103. data/spec/riak/time_series/submission_spec.rb +0 -35
  104. data/spec/riak/util/gzip_spec.rb +0 -49
  105. data/spec/riak/walk_spec_spec.rb +0 -203
  106. data/spec/spec_helper.rb +0 -67
  107. data/spec/support/certs/README.md +0 -13
  108. data/spec/support/certs/ca.crt +0 -21
  109. data/spec/support/certs/client.crl +0 -13
  110. data/spec/support/certs/client.crt +0 -94
  111. data/spec/support/certs/client.csr +0 -18
  112. data/spec/support/certs/client.key +0 -27
  113. data/spec/support/certs/empty_ca.crt +0 -21
  114. data/spec/support/certs/server.crl +0 -13
  115. data/spec/support/certs/server.crt +0 -94
  116. data/spec/support/certs/server.key +0 -27
  117. data/spec/support/crdt_search_config.rb +0 -112
  118. data/spec/support/crdt_search_fixtures.rb +0 -42
  119. data/spec/support/integration_setup.rb +0 -10
  120. data/spec/support/search_config.rb +0 -83
  121. data/spec/support/search_corpus_setup.rb +0 -39
  122. data/spec/support/test_client.rb +0 -52
  123. data/spec/support/test_client.yml.example +0 -10
  124. data/spec/support/unified_backend_examples.rb +0 -402
  125. data/spec/support/version_filter.rb +0 -12
  126. data/spec/support/wait_until.rb +0 -20
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
- require 'riak'
3
-
4
- describe Riak::Counter, test_client: true, integration: true do
5
- before :all do
6
- @bucket = random_bucket 'counter_spec'
7
- @bucket.allow_mult = true
8
-
9
- @counter = Riak::Counter.new @bucket, 'counter_spec'
10
- end
11
-
12
- it 'reads and updates' do
13
- initial = @counter.value
14
-
15
- @counter.increment
16
- @counter.increment
17
-
18
- expect(@counter.value).to eq(initial + 2)
19
-
20
- @counter.decrement 2
21
-
22
- expect(@counter.value).to eq(initial)
23
-
24
- 5.times do
25
- amt = rand(10_000)
26
-
27
- @counter.increment amt
28
- expect(@counter.value).to eq(initial + amt)
29
-
30
- @counter.decrement (amt * 2)
31
- expect(@counter.value).to eq(initial - amt)
32
-
33
- expect(@counter.increment_and_return(amt)).to eq(initial)
34
- end
35
- end
36
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
- require 'riak'
3
-
4
- describe "CRDT configuration", integration: true, test_client: true do
5
- SETS = Riak::Crdt::DEFAULT_BUCKET_TYPES[:set]
6
- let(:bucket) { random_bucket }
7
-
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
@@ -1,176 +0,0 @@
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
@@ -1,332 +0,0 @@
1
- require 'spec_helper'
2
- require 'riak'
3
- require 'riak/errors/failed_request'
4
-
5
- describe "CRDTs", integration: true, test_client: true do
6
- let(:bucket) { random_bucket }
7
-
8
- describe 'Riak-assigned names' do
9
- describe 'an anonymous counter' do
10
- subject { Riak::Crdt::Counter.new bucket, nil }
11
- it 'accepts a Riak-assigned name' do
12
- subject.increment
13
- expect(subject.key).to be
14
- expect(subject.value).to eq 1
15
- end
16
- end
17
-
18
- describe 'an anonymous set' do
19
- subject { Riak::Crdt::Set.new bucket, nil }
20
- it 'accepts a Riak-assigned name' do
21
- subject.add 'sandwich'
22
- expect(subject.key).to be
23
- expect(subject).to include 'sandwich'
24
- end
25
- end
26
-
27
- describe 'an anonymous map' do
28
- subject { Riak::Crdt::Map.new bucket, nil }
29
- it 'accepts a Riak-assigned name' do
30
- subject.registers['coat_pattern'] = 'tabby'
31
- expect(subject.key).to be
32
- expect(subject.registers['coat_pattern']).to eq 'tabby'
33
- end
34
- end
35
- end
36
-
37
- describe 'counters' do
38
- subject { Riak::Crdt::Counter.new bucket, random_key }
39
- it 'allows straightforward counter ops' do
40
- start = subject.value
41
- subject.increment
42
- expect(subject.value).to eq(start + 1)
43
- subject.increment
44
- expect(subject.value).to eq(start + 2)
45
- subject.increment -1
46
- expect(subject.value).to eq(start + 1)
47
- subject.decrement
48
- expect(subject.value).to eq(start)
49
- end
50
-
51
- it 'allows batched counter ops' do
52
- start = subject.value
53
- subject.batch do |s|
54
- s.increment
55
- s.increment 2
56
- s.increment
57
- s.increment
58
- end
59
- expect(subject.value).to eq(start + 5)
60
- end
61
-
62
- it 'asks for and accepts a returned body by default' do
63
- other = Riak::Crdt::Counter.new subject.bucket, subject.key
64
-
65
- start = subject.value
66
-
67
- expect(subject.value).to eq start
68
-
69
- other.increment 10
70
-
71
- subject.increment 1
72
-
73
- expect(subject.dirty?).to_not be
74
- expect(subject.value).to eq(start + 10 + 1)
75
- end
76
-
77
- describe 'equality' do
78
- let(:same){ Riak::Crdt::Counter.new subject.bucket, subject.key }
79
- let(:same_bucket){ Riak::Bucket.new test_client, bucket.name }
80
- let(:similar){ Riak::Crdt::Counter.new same_bucket, subject.key }
81
- it { is_expected.to eq subject }
82
- it { is_expected.to eq same }
83
- it { is_expected.to eq similar }
84
- end
85
- end
86
-
87
- describe 'sets' do
88
-
89
- subject { Riak::Crdt::Set.new bucket, random_key }
90
-
91
- it 'allows straightforward set ops' do
92
- start = subject.members
93
- addition = random_key
94
-
95
- subject.add addition
96
- expect(subject.include? addition).to be
97
- expect(subject.members).to include(addition)
98
-
99
- subject.remove addition
100
- expect(subject.include? addition).to_not be
101
- expect(subject.members).to_not include(addition)
102
- expect(subject.members).to eq(start)
103
- end
104
-
105
- it 'lets Riak silently accept removals after reload' do
106
- addition = random_key
107
- subject.add addition
108
-
109
- other = Riak::Crdt::Set.new subject.bucket, subject.key
110
- expect{ other.remove addition }.to raise_error(Riak::CrdtError::SetRemovalWithoutContextError)
111
- other.reload
112
- expect{ other.remove addition }.to_not raise_error
113
- other.reload
114
- expect{ other.remove 'an element not in the set' }.to_not raise_error
115
- end
116
-
117
- it 'allows batched set ops' do
118
- subject.add 'zero'
119
- subject.reload
120
-
121
- subject.batch do |s|
122
- s.add 'first'
123
- s.remove 'zero'
124
- end
125
-
126
- expect(subject.members.to_a).to eq %w{first}
127
- end
128
-
129
- it 'asks for and accepts a returned body by default' do
130
- other = Riak::Crdt::Set.new subject.bucket, subject.key
131
-
132
- expect(subject.include? 'coffee').to_not be
133
- expect(other.include? 'coffee').to_not be
134
-
135
- other.add 'coffee'
136
- subject.add 'tea'
137
-
138
- expect(subject.dirty?).to_not be
139
-
140
- expect(other.include? 'coffee').to be
141
- expect(subject.include? 'coffee').to be
142
- end
143
- end
144
-
145
- describe 'maps' do
146
- subject { Riak::Crdt::Map.new bucket, random_key }
147
-
148
- it 'allows straightforward map ops' do
149
- subject.registers['first'] = 'hello'
150
- expect(subject.registers['first']).to eq('hello')
151
-
152
- subject.sets['arnold'].add 'commando'
153
- subject.sets['arnold'].add 'terminator'
154
- expect(subject.sets['arnold'].members).to include('commando')
155
- subject.sets['arnold'].remove 'commando'
156
- expect(subject.sets['arnold'].members).to_not include('commando')
157
- expect(subject.sets['arnold'].members).to include('terminator')
158
-
159
- subject.maps['first'].registers['second'] = 'good evening'
160
- subject.maps['first'].maps['third'].counters['fourth'].increment
161
-
162
- expect(subject.maps['first'].registers['second']).to eq('good evening')
163
- expect(subject.maps['first'].maps['third'].counters['fourth'].value).to eq(1)
164
-
165
- subject.counters['hits'].increment
166
- expect(subject.counters['hits'].value).to eq 1
167
-
168
- subject.flags['yes'] = true
169
- expect(subject.flags['yes']).to eq true
170
-
171
- expect do
172
- subject.registers.delete 'first'
173
- subject.sets.delete 'arnold'
174
- subject.maps.delete 'first'
175
- subject.counters.delete 'hits'
176
- subject.flags.delete 'yes'
177
- end.to_not raise_error
178
- end
179
-
180
- it 'allows batched map ops' do
181
- subject.batch do |s|
182
- s.registers['condiment'] = 'ketchup'
183
- s.counters['banana'].increment
184
- end
185
-
186
- expect(subject.registers['condiment']).to eq 'ketchup'
187
- expect(subject.counters['banana'].value).to eq 1
188
- end
189
-
190
- it 'asks for and accepts a returned body by default' do
191
- other = Riak::Crdt::Map.new subject.bucket, subject.key
192
-
193
- expect(subject.sets['bees'].include? 'honey').to_not be
194
- expect(other.sets['bees'].include? 'honey').to_not be
195
-
196
- other.sets['bees'].add 'honey'
197
- subject.counters['stings'].increment
198
-
199
- expect(subject.dirty?).to_not be
200
-
201
- expect(other.sets['bees'].include? 'honey').to be
202
- expect(subject.sets['bees'].include? 'honey').to be
203
- end
204
-
205
- describe 'containing a map' do
206
- it 'bubbles straightforward map ops up' do
207
- street_map = subject.maps['street']
208
-
209
- street_map.registers['bird'] = 'avenue'
210
- street_map.flags['traffic_light'] = false
211
-
212
- expect(subject.maps['street'])
213
- end
214
-
215
- it 'includes inner-map ops in the outer-map batch' do
216
- subject.batch do |m|
217
- m.maps['road'].counters['speedbumps'].increment 4
218
- m.maps['road'].sets['signs'].add 'yield'
219
- end
220
-
221
- expect(subject.maps['road'].counters['speedbumps'].value).to eq 4
222
- expect(subject.maps['road'].sets['signs'].include? 'yield').to be
223
- end
224
-
225
- it 'deletes nested inner-map' do
226
- bag_map = subject.maps['bag']
227
- inner_map = bag_map.maps['123']
228
- inner_map.registers['name'] = 'f1'
229
-
230
- expect(subject.maps['bag'].maps['123'].registers['name']).to eq 'f1'
231
-
232
- expect{ bag_map.maps.delete('123') }.to_not raise_error
233
- expect(bag_map.maps.include? '123').to_not be
234
- expect(bag_map.maps['123'].registers['name']).to_not be
235
- end
236
- end
237
-
238
- describe 'containing a register' do
239
- it 'bubbles straightforward register ops up' do
240
- subject.registers['hkey_local_machine'] = 'registry'
241
-
242
- expect(subject.registers['hkey_local_machine']).to eq 'registry'
243
- end
244
-
245
- it "doesn't error on an unset register" do
246
- expect{ subject.registers['unset'] }.to_not raise_error
247
- expect(subject.registers['other_unset']).to_not be
248
- end
249
- end
250
-
251
- describe 'containing a flag' do
252
- it 'bubbles straightforward flag ops up' do
253
- subject.flags['enable_magic'] = true
254
-
255
- expect(subject.flags['enable_magic']).to be
256
- end
257
-
258
- it "doesn't error on an unset flag" do
259
- expect{ subject.flags['unset'] }.to_not raise_error
260
- expect(subject.flags['other_unset']).to_not be
261
- end
262
- end
263
- end
264
-
265
- describe 'HLLs', hll: true do
266
- before(:each) do
267
- begin
268
- hlls = test_client.bucket_type Riak::Crdt::DEFAULT_BUCKET_TYPES[:hll]
269
- hlls.properties
270
- rescue Riak::ProtobuffsErrorResponse
271
- skip('HyperLogLog bucket-type not found or active.')
272
- end
273
- end
274
-
275
- subject { Riak::Crdt::HyperLogLog.new bucket, random_key }
276
-
277
- it 'allows straightforward HLL ops' do
278
- addition = random_key
279
-
280
- subject.add addition
281
-
282
- expect(subject.value).to be_a(Integer)
283
- expect(subject.value).to eq 1
284
- end
285
-
286
- it 'asks for and accepts a returned body by default' do
287
- other = Riak::Crdt::HyperLogLog.new subject.bucket, subject.key
288
-
289
- other.add 'coffee'
290
-
291
- expect(other.value).to be_a(Integer)
292
- expect(other.value).to eq 1
293
-
294
- expect(subject.value).to eq 1
295
-
296
- subject.add 'tea'
297
-
298
- expect(subject.value).to be_a(Integer)
299
- expect(subject.value).to eq 2
300
-
301
- other.reload
302
- expect(other.value).to eq 2
303
-
304
- other.add 'juice'
305
-
306
- expect(other.value).to be_a(Integer)
307
- expect(other.value).to eq 3
308
-
309
- # repeat input to verify the HLL value doesn't increment
310
- other.add 'juice'
311
-
312
- expect(other.value).to be_a(Integer)
313
- expect(other.value).to eq 3
314
-
315
- expect(subject.dirty?).to_not be
316
- end
317
-
318
- it 'allows batched HLL ops' do
319
- subject.add 'zero'
320
- subject.reload
321
-
322
- subject.batch do |s|
323
- s.add 'first'
324
- s.add 'second'
325
- s.add 'second'
326
- end
327
-
328
- expect(subject.value).to be_a(Integer)
329
- expect(subject.value).to eq 3
330
- end
331
- end
332
- end