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
data/spec/riak/counter_spec.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::Counter do
|
4
|
-
describe "initialization" do
|
5
|
-
before :each do
|
6
|
-
@bucket = Riak::Bucket.allocate
|
7
|
-
@key = 'key'
|
8
|
-
allow(@bucket).to receive(:allow_mult).and_return(true)
|
9
|
-
allow(@bucket).to receive(:client).and_return(double('client'))
|
10
|
-
allow(@bucket).to receive('is_a?').and_return(true)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "sets the bucket and key" do
|
14
|
-
ctr = Riak::Counter.new @bucket, @key
|
15
|
-
expect(ctr.bucket).to eq(@bucket)
|
16
|
-
expect(ctr.key).to eq(@key)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "requires allow_mult" do
|
20
|
-
@bad_bucket = Riak::Bucket.allocate
|
21
|
-
allow(@bad_bucket).to receive(:allow_mult).and_return(false)
|
22
|
-
allow(@bad_bucket).to receive(:client).and_return(double('client'))
|
23
|
-
|
24
|
-
expect{ctr = Riak::Counter.new @bad_bucket, @key}.to raise_error(ArgumentError)
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "incrementing and decrementing" do
|
30
|
-
before :each do
|
31
|
-
@backend = double 'backend'
|
32
|
-
|
33
|
-
@client = double 'client'
|
34
|
-
allow(@client).to receive(:backend).and_yield @backend
|
35
|
-
|
36
|
-
@bucket = Riak::Bucket.allocate
|
37
|
-
allow(@bucket).to receive(:allow_mult).and_return(true)
|
38
|
-
allow(@bucket).to receive(:client).and_return(@client)
|
39
|
-
|
40
|
-
@key = 'key'
|
41
|
-
|
42
|
-
@ctr = Riak::Counter.new @bucket, @key
|
43
|
-
|
44
|
-
@increment_expectation = proc{|n| expect(@backend).to receive(:post_counter).with(@bucket, @key, n, {})}
|
45
|
-
end
|
46
|
-
|
47
|
-
it "increments by 1 by default" do
|
48
|
-
@increment_expectation[1]
|
49
|
-
@ctr.increment
|
50
|
-
end
|
51
|
-
|
52
|
-
it "increments by positive numbers" do
|
53
|
-
@increment_expectation[15]
|
54
|
-
@ctr.increment 15
|
55
|
-
end
|
56
|
-
|
57
|
-
it "increments by negative numbers" do
|
58
|
-
@increment_expectation[-12]
|
59
|
-
@ctr.increment -12
|
60
|
-
end
|
61
|
-
|
62
|
-
it "decrements by 1 by default" do
|
63
|
-
@increment_expectation[-1]
|
64
|
-
@ctr.decrement
|
65
|
-
end
|
66
|
-
|
67
|
-
it "decrements by positive numbers" do
|
68
|
-
@increment_expectation[-30]
|
69
|
-
@ctr.decrement 30
|
70
|
-
end
|
71
|
-
|
72
|
-
it "decrements by negative numbers" do
|
73
|
-
@increment_expectation[41]
|
74
|
-
@ctr.decrement -41
|
75
|
-
end
|
76
|
-
|
77
|
-
it "forbids incrementing by non-integers" do
|
78
|
-
[1.1, nil, :'1', '1', 2.0/2, [1]].each do |candidate|
|
79
|
-
expect do
|
80
|
-
@ctr.increment candidate
|
81
|
-
raise candidate.to_s
|
82
|
-
end.to raise_error(ArgumentError)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "failure modes" do
|
88
|
-
before :each do
|
89
|
-
@nodes = 10.times.map do |n|
|
90
|
-
{pb_port: "100#{n}7"}
|
91
|
-
end
|
92
|
-
|
93
|
-
@fake_pool = double 'pool'
|
94
|
-
@backend = double 'backend'
|
95
|
-
|
96
|
-
@client = Riak::Client.new nodes: @nodes
|
97
|
-
@client.instance_variable_set :@protobuffs_pool, @fake_pool
|
98
|
-
|
99
|
-
allow(@fake_pool).to receive(:take).and_yield(@backend)
|
100
|
-
|
101
|
-
@bucket = Riak::Bucket.allocate
|
102
|
-
allow(@bucket).to receive(:allow_mult).and_return(true)
|
103
|
-
allow(@bucket).to receive(:client).and_return(@client)
|
104
|
-
|
105
|
-
@key = 'key'
|
106
|
-
|
107
|
-
@expect_post = expect(@backend).to receive(:post_counter).with(@bucket, @key, 1, {})
|
108
|
-
|
109
|
-
@ctr = Riak::Counter.new @bucket, @key
|
110
|
-
end
|
111
|
-
|
112
|
-
it "doesn't retry on timeout" do
|
113
|
-
@expect_post.once.and_raise('timeout')
|
114
|
-
expect(proc { @ctr.increment }).to raise_error
|
115
|
-
end
|
116
|
-
|
117
|
-
it "doesn't retry on quorum failure" do
|
118
|
-
@expect_post.once.and_raise('quorum not satisfied')
|
119
|
-
expect(proc { @ctr.increment }).to raise_error
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative 'shared_examples'
|
3
|
-
|
4
|
-
describe Riak::Crdt::Counter do
|
5
|
-
let(:bucket) do
|
6
|
-
double('bucket').tap do |b|
|
7
|
-
allow(b).to receive(:name).and_return('bucket')
|
8
|
-
allow(b).to receive(:is_a?).with(Riak::Bucket).and_return(true)
|
9
|
-
allow(b).to receive(:is_a?).with(Riak::BucketTyped::Bucket).and_return(false)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
it 'initializes with bucket, key, and optional bucket-type' do
|
13
|
-
expect{ described_class.new bucket, 'key' }.to_not raise_error
|
14
|
-
expect{ described_class.new bucket, 'key', 'type' }.to_not raise_error
|
15
|
-
end
|
16
|
-
|
17
|
-
subject{ described_class.new bucket, 'key' }
|
18
|
-
|
19
|
-
describe 'with a client' do
|
20
|
-
let(:response){ double 'response', key: nil }
|
21
|
-
let(:operator){ double 'operator' }
|
22
|
-
let(:loader){ double 'loader', get_loader_for_value: nil }
|
23
|
-
let(:backend){ double 'backend' }
|
24
|
-
let(:client){ double 'client' }
|
25
|
-
|
26
|
-
before(:each) do
|
27
|
-
allow(bucket).to receive(:client).and_return(client)
|
28
|
-
allow(client).to receive(:backend).and_yield(backend)
|
29
|
-
allow(backend).to receive(:crdt_operator).and_return(operator)
|
30
|
-
allow(backend).to receive(:crdt_loader).and_return(loader)
|
31
|
-
end
|
32
|
-
|
33
|
-
include_examples 'Counter CRDT'
|
34
|
-
|
35
|
-
it 'batches properly' do
|
36
|
-
expect(operator).
|
37
|
-
to receive(:operate) { |bucket, key, type, operations|
|
38
|
-
expect(bucket).to eq bucket
|
39
|
-
expect(key).to eq 'key'
|
40
|
-
expect(type).to eq subject.bucket_type
|
41
|
-
|
42
|
-
expect(operations).to be_a Riak::Crdt::Operation::Update
|
43
|
-
expect(operations.value).to eq 5
|
44
|
-
}.
|
45
|
-
and_return(response)
|
46
|
-
|
47
|
-
subject.batch do |s|
|
48
|
-
s.increment 4 # 4
|
49
|
-
s.decrement 2 # 2
|
50
|
-
s.increment 4 # 6
|
51
|
-
s.decrement # 5
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative 'shared_examples'
|
3
|
-
|
4
|
-
describe Riak::Crdt::HyperLogLog, hll: true do
|
5
|
-
let(:bucket) do
|
6
|
-
double('bucket').tap do |b|
|
7
|
-
allow(b).to receive(:name).and_return('bucket')
|
8
|
-
allow(b).to receive(:is_a?).with(Riak::Bucket).and_return(true)
|
9
|
-
allow(b).to receive(:is_a?).with(Riak::BucketTyped::Bucket).and_return(false)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'initializes with bucket, key, and bucket-type' do
|
14
|
-
expect{described_class.new bucket, 'key', 'bucket type'}.
|
15
|
-
to_not raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
subject{ described_class.new bucket, 'key' }
|
19
|
-
|
20
|
-
describe 'with a client' do
|
21
|
-
let(:response){ double 'response', key: nil }
|
22
|
-
let(:operator){ double 'operator' }
|
23
|
-
let(:loader){ double 'loader', get_loader_for_value: nil }
|
24
|
-
let(:backend){ double 'backend' }
|
25
|
-
let(:client){ double 'client' }
|
26
|
-
|
27
|
-
before(:each) do
|
28
|
-
allow(bucket).to receive(:client).and_return(client)
|
29
|
-
allow(client).to receive(:backend).and_yield(backend)
|
30
|
-
allow(backend).to receive(:crdt_operator).and_return(operator)
|
31
|
-
allow(backend).to receive(:crdt_loader).and_return(loader)
|
32
|
-
end
|
33
|
-
|
34
|
-
include_examples 'HyperLogLog CRDT'
|
35
|
-
|
36
|
-
it 'batches properly' do
|
37
|
-
expect(operator).
|
38
|
-
to receive(:operate) { |bucket, key, type, operations|
|
39
|
-
expect(bucket).to eq bucket
|
40
|
-
expect(key).to eq 'key'
|
41
|
-
expect(type).to eq subject.bucket_type
|
42
|
-
|
43
|
-
expect(operations).to be_a Riak::Crdt::Operation::Update
|
44
|
-
expect(operations.value).to eq({add: %w{alpha bravo}})
|
45
|
-
}.
|
46
|
-
and_return(response)
|
47
|
-
|
48
|
-
subject.instance_variable_set :@context, 'placeholder'
|
49
|
-
|
50
|
-
subject.batch do |s|
|
51
|
-
s.add 'alpha'
|
52
|
-
s.add 'bravo'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative 'shared_examples'
|
3
|
-
|
4
|
-
describe Riak::Crdt::InnerCounter do
|
5
|
-
let(:parent){ double 'parent' }
|
6
|
-
let(:counter_name){ 'counter name' }
|
7
|
-
subject do
|
8
|
-
described_class.new(parent, 0).tap do |c|
|
9
|
-
c.name = counter_name
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
include_examples 'Counter CRDT'
|
14
|
-
|
15
|
-
it 'sends increments to the parent' do
|
16
|
-
expect(parent).to receive(:increment).
|
17
|
-
with(counter_name, 1)
|
18
|
-
|
19
|
-
subject.increment
|
20
|
-
end
|
21
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::Crdt::InnerFlag do
|
4
|
-
let(:parent){ double 'parent' }
|
5
|
-
describe 'a truthy flag' do
|
6
|
-
subject { described_class.new parent, true }
|
7
|
-
|
8
|
-
it 'feels truthy' do
|
9
|
-
expect(subject).to be
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'a falsey flag' do
|
14
|
-
subject { described_class.new parent, false }
|
15
|
-
|
16
|
-
it 'feels falsey' do
|
17
|
-
expect(subject).to_not be
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'updating' do
|
22
|
-
let(:new_value){ false }
|
23
|
-
|
24
|
-
it 'asks the class for an update operation' do
|
25
|
-
operation = described_class.update(new_value)
|
26
|
-
|
27
|
-
expect(operation.value).to eq new_value
|
28
|
-
expect(operation.type).to eq :flag
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'deleting' do
|
33
|
-
it 'asks the class for a delete operation' do
|
34
|
-
operation = described_class.delete
|
35
|
-
|
36
|
-
expect(operation.type).to eq :flag
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative 'shared_examples'
|
3
|
-
|
4
|
-
describe Riak::Crdt::InnerMap do
|
5
|
-
let(:parent){ double 'parent' }
|
6
|
-
subject{ described_class.new parent, {} }
|
7
|
-
|
8
|
-
include_examples 'Map CRDT'
|
9
|
-
|
10
|
-
let(:populated_contents) do
|
11
|
-
{
|
12
|
-
counters: {alpha: 0},
|
13
|
-
flags: {bravo: true},
|
14
|
-
maps: {},
|
15
|
-
registers: {delta: 'the expendables' },
|
16
|
-
sets: {echo: %w{stallone statham li lundgren}}
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'is initializable with a nested hash of maps' do
|
21
|
-
expect{described_class.new parent, populated_contents}.
|
22
|
-
to_not raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'deleting the inner map' do
|
26
|
-
it 'asks the class for a delete operation' do
|
27
|
-
operation = described_class.delete
|
28
|
-
|
29
|
-
expect(operation.type).to eq :map
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'receiving an operation' do
|
34
|
-
let(:inner_operation){ double 'inner operation' }
|
35
|
-
it 'wraps the operation in an update operation and pass it to the parent' do
|
36
|
-
subject.name = 'name'
|
37
|
-
|
38
|
-
expect(parent).to receive(:operate) do |name, op|
|
39
|
-
expect(name).to eq 'name'
|
40
|
-
expect(op.type).to eq :map
|
41
|
-
expect(op.value).to eq inner_operation
|
42
|
-
end
|
43
|
-
|
44
|
-
subject.operate inner_operation
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::Crdt::InnerRegister do
|
4
|
-
let(:parent){ double 'parent' }
|
5
|
-
subject { described_class.new parent, "espressos" }
|
6
|
-
|
7
|
-
it 'feels like a string' do
|
8
|
-
expect(subject).to match 'espressos'
|
9
|
-
expect{ subject.gsub('s', 'x') }.to_not raise_error
|
10
|
-
expect(subject.gsub('s', 'x')).to eq 'exprexxox'
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'immutability' do
|
14
|
-
it 'is frozen' do
|
15
|
-
expect(subject.frozen?).to be
|
16
|
-
end
|
17
|
-
it "isn't be gsub!-able" do
|
18
|
-
# "gsub!-able" is awful, open to suggestions
|
19
|
-
expect{ subject.gsub!('s', 'x') }.to raise_error
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'updating' do
|
24
|
-
let(:new_value){ 'new value' }
|
25
|
-
it "asks the class for an update operation" do
|
26
|
-
operation = described_class.update(new_value)
|
27
|
-
|
28
|
-
expect(operation.value).to eq new_value
|
29
|
-
expect(operation.type).to eq :register
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'deleting' do
|
34
|
-
it 'asks the class for a delete operation' do
|
35
|
-
operation = described_class.delete
|
36
|
-
|
37
|
-
expect(operation.type).to eq :register
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative 'shared_examples'
|
3
|
-
|
4
|
-
describe Riak::Crdt::InnerSet do
|
5
|
-
let(:parent){ double 'parent' }
|
6
|
-
let(:set_name){ 'set name' }
|
7
|
-
subject do
|
8
|
-
described_class.new(parent, []).tap do |s|
|
9
|
-
s.name = set_name
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
include_examples 'Set CRDT'
|
14
|
-
|
15
|
-
it 'sends additions to the parent' do
|
16
|
-
expect(parent).to receive(:operate) do |name, op|
|
17
|
-
expect(name).to eq set_name
|
18
|
-
expect(op.type).to eq :set
|
19
|
-
expect(op.value).to eq add: 'el'
|
20
|
-
end
|
21
|
-
|
22
|
-
subject.add 'el'
|
23
|
-
|
24
|
-
expect(parent).to receive(:operate) do |name, op|
|
25
|
-
expect(name).to eq set_name
|
26
|
-
expect(op.type).to eq :set
|
27
|
-
expect(op.value).to eq remove: 'el2'
|
28
|
-
end
|
29
|
-
allow(parent).to receive(:context?).and_return(true)
|
30
|
-
|
31
|
-
subject.remove 'el2'
|
32
|
-
end
|
33
|
-
end
|
data/spec/riak/crdt/map_spec.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative 'shared_examples'
|
3
|
-
|
4
|
-
describe Riak::Crdt::Map do
|
5
|
-
let(:bucket) do
|
6
|
-
double('bucket').tap do |b|
|
7
|
-
allow(b).to receive(:name).and_return('bucket')
|
8
|
-
allow(b).to receive(:is_a?).with(Riak::Bucket).and_return(true)
|
9
|
-
allow(b).to receive(:is_a?).with(Riak::BucketTyped::Bucket).and_return(false)
|
10
|
-
allow(b).to receive(:client).and_return(client)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
let(:operator){ double 'operator' }
|
14
|
-
let(:loader){ double 'loader' }
|
15
|
-
let(:backend){ double 'backend' }
|
16
|
-
let(:client){ double 'client' }
|
17
|
-
let(:key){ 'map' }
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
allow(client).to receive(:backend).and_yield(backend)
|
21
|
-
allow(backend).to receive(:crdt_operator).and_return(operator)
|
22
|
-
allow(backend).to receive(:crdt_loader).and_return(loader)
|
23
|
-
allow(loader).to receive(:load).and_return({})
|
24
|
-
allow(loader).to receive(:context).and_return('context')
|
25
|
-
end
|
26
|
-
|
27
|
-
subject{ described_class.new bucket, key }
|
28
|
-
|
29
|
-
include_examples 'Map CRDT'
|
30
|
-
|
31
|
-
describe 'batch mode' do
|
32
|
-
it 'queues up operations' do
|
33
|
-
expect(operator).
|
34
|
-
to receive(:operate) do |bucket, key_arg, type, operations|
|
35
|
-
|
36
|
-
expect(bucket).to eq bucket
|
37
|
-
expect(key_arg).to eq key
|
38
|
-
expect(type).to eq subject.bucket_type
|
39
|
-
|
40
|
-
expect(operations.length).to eq 2
|
41
|
-
|
42
|
-
expect(operations.first).to be_a Riak::Crdt::Operation::Update
|
43
|
-
|
44
|
-
expect(operations.first.value).to be_a Riak::Crdt::Operation::Update
|
45
|
-
end
|
46
|
-
|
47
|
-
subject.batch do |s|
|
48
|
-
s.registers['hello'] = 'hello'
|
49
|
-
s.maps['goodbye'].flags['okay'] = true
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe 'immediate mode' do
|
55
|
-
it 'submits member operations immediately' do
|
56
|
-
expect(operator).
|
57
|
-
to receive(:operate) do |bucket, key_arg, type, operations|
|
58
|
-
|
59
|
-
expect(bucket).to eq bucket
|
60
|
-
expect(key_arg).to eq key
|
61
|
-
expect(type).to eq subject.bucket_type
|
62
|
-
|
63
|
-
expect(operations.length).to eq 1
|
64
|
-
|
65
|
-
expect(operations.first).to be_a Riak::Crdt::Operation::Update
|
66
|
-
|
67
|
-
inner_op = operations.first.value
|
68
|
-
|
69
|
-
expect(inner_op).to be_a Riak::Crdt::Operation::Update
|
70
|
-
expect(inner_op.name).to eq 'hasta'
|
71
|
-
expect(inner_op.type).to eq :register
|
72
|
-
expect(inner_op.value).to eq 'la vista'
|
73
|
-
end
|
74
|
-
|
75
|
-
subject.registers['hasta'] = 'la vista' # baby
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|