riak-client 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +5 -5
- data/.gitignore +3 -0
- data/Gemfile +17 -17
- data/Guardfile +20 -20
- data/LICENSE.md +16 -16
- data/RELNOTES.md +4 -0
- data/Rakefile +6 -1
- data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -18
- data/lib/riak/client/beefcake/crdt/hyper_log_log_loader.rb +18 -0
- data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -64
- data/lib/riak/client/beefcake/crdt_loader.rb +4 -1
- data/lib/riak/client/beefcake/crdt_operator.rb +13 -0
- data/lib/riak/client/beefcake/footer +4 -4
- data/lib/riak/client/beefcake/header +6 -6
- data/lib/riak/client/beefcake/messages.rb +67 -10
- data/lib/riak/client/decaying.rb +36 -36
- data/lib/riak/client/feature_detection.rb +120 -120
- data/lib/riak/client/instrumentation.rb +19 -19
- data/lib/riak/client/node.rb +49 -49
- data/lib/riak/client/search.rb +27 -27
- data/lib/riak/conflict.rb +13 -13
- data/lib/riak/core_ext.rb +7 -7
- data/lib/riak/core_ext/blank.rb +53 -53
- data/lib/riak/core_ext/extract_options.rb +7 -7
- data/lib/riak/core_ext/json.rb +15 -15
- data/lib/riak/core_ext/slice.rb +18 -18
- data/lib/riak/core_ext/stringify_keys.rb +10 -10
- data/lib/riak/core_ext/symbolize_keys.rb +10 -10
- data/lib/riak/core_ext/to_param.rb +31 -31
- data/lib/riak/crdt.rb +23 -21
- data/lib/riak/crdt/base.rb +1 -1
- data/lib/riak/crdt/hyper_log_log.rb +97 -0
- data/lib/riak/crdt/operation.rb +19 -19
- data/lib/riak/encoding.rb +6 -6
- data/lib/riak/errors/backend_creation.rb +9 -9
- data/lib/riak/errors/connection_error.rb +50 -50
- data/lib/riak/errors/protobuffs_error.rb +11 -11
- data/lib/riak/i18n.rb +7 -7
- data/lib/riak/instrumentation.rb +6 -6
- data/lib/riak/json.rb +52 -52
- data/lib/riak/list_buckets.rb +28 -28
- data/lib/riak/locale/en.yml +1 -0
- data/lib/riak/locale/fr.yml +51 -51
- data/lib/riak/map_reduce/results.rb +49 -49
- data/lib/riak/map_reduce_error.rb +7 -7
- data/lib/riak/multiget.rb +122 -122
- data/lib/riak/robject.rb +17 -1
- data/lib/riak/search/result_document.rb +9 -0
- data/lib/riak/stamp.rb +77 -77
- data/lib/riak/tombstone.rb +13 -0
- data/lib/riak/util/tcp_socket_extensions.rb +58 -58
- data/lib/riak/version.rb +1 -1
- data/spec/failover/failover.rb +59 -59
- data/spec/fixtures/bitcask.txt +25 -25
- data/spec/fixtures/multipart-basic-conflict.txt +15 -15
- data/spec/fixtures/multipart-blank.txt +7 -7
- data/spec/fixtures/multipart-mapreduce.txt +10 -10
- data/spec/fixtures/multipart-with-body.txt +16 -16
- data/spec/fixtures/multipart-with-marked-tombstones.txt +17 -17
- data/spec/fixtures/multipart-with-unmarked-tombstone.txt +16 -16
- data/spec/fixtures/server.cert.crt +15 -15
- data/spec/fixtures/server.cert.key +15 -15
- data/spec/fixtures/test.pem +1 -1
- data/spec/integration/riak/bucket_types_spec.rb +38 -0
- data/spec/integration/riak/crdt/configuration_spec.rb +4 -3
- data/spec/integration/riak/crdt_spec.rb +70 -0
- data/spec/integration/riak/encodings/crdt_spec.rb +29 -3
- data/spec/integration/riak/encodings/yz_spec.rb +2 -1
- data/spec/integration/riak/preflist_spec.rb +15 -3
- data/spec/integration/riak/protobuffs/timeouts_spec.rb +1 -1
- data/spec/integration/riak/security_spec.rb +11 -6
- data/spec/integration/riak/threading_spec.rb +154 -150
- data/spec/integration/yokozuna/index_spec.rb +61 -61
- data/spec/integration/yokozuna/queries_spec.rb +1 -1
- data/spec/integration/yokozuna/schema_spec.rb +49 -49
- data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +22 -0
- data/spec/riak/core_ext/to_param_spec.rb +15 -15
- data/spec/riak/crdt/hyper_log_log_spec.rb +56 -0
- data/spec/riak/crdt/inner_counter_spec.rb +21 -21
- data/spec/riak/crdt/inner_set_spec.rb +33 -33
- data/spec/riak/crdt/set_spec.rb +61 -61
- data/spec/riak/crdt/shared_examples.rb +14 -0
- data/spec/riak/escape_spec.rb +72 -72
- data/spec/riak/feature_detection_spec.rb +77 -77
- data/spec/riak/index_collection_spec.rb +53 -53
- data/spec/riak/instrumentation_spec.rb +124 -124
- data/spec/riak/link_spec.rb +85 -85
- data/spec/riak/list_buckets_spec.rb +41 -41
- data/spec/riak/node_spec.rb +26 -26
- data/spec/riak/robject_spec.rb +45 -0
- data/spec/support/certs/README.md +12 -12
- data/spec/support/certs/ca.crt +21 -21
- data/spec/support/certs/client.crl +13 -13
- data/spec/support/certs/client.crt +94 -94
- data/spec/support/certs/client.csr +18 -18
- data/spec/support/certs/client.key +27 -27
- data/spec/support/certs/empty_ca.crt +21 -21
- data/spec/support/certs/server.crl +13 -13
- data/spec/support/certs/server.crt +94 -94
- data/spec/support/certs/server.key +27 -27
- data/spec/support/crdt_search_fixtures.rb +1 -1
- data/spec/support/integration_setup.rb +10 -10
- data/spec/support/test_client.rb +1 -1
- data/spec/support/test_client.yml.example +10 -10
- metadata +10 -3
@@ -72,3 +72,17 @@ shared_examples_for 'Set CRDT' do
|
|
72
72
|
expect(subject).to respond_to :remove
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
shared_examples_for 'HyperLogLog CRDT' do
|
77
|
+
it 'has a value' do
|
78
|
+
expect(subject).to respond_to :value
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'has a cardinality' do
|
82
|
+
expect(subject).to respond_to :cardinality
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'has an add method' do
|
86
|
+
expect(subject).to respond_to :add
|
87
|
+
end
|
88
|
+
end
|
data/spec/riak/escape_spec.rb
CHANGED
@@ -1,72 +1,72 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Riak::Util::Escape do
|
5
|
-
before :each do
|
6
|
-
@object = Object.new
|
7
|
-
@object.extend(Riak::Util::Escape)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "uses URI by default for escaping" do
|
11
|
-
expect(Riak.escaper).to eq(URI)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when using CGI for escaping" do
|
15
|
-
before { @oldesc, Riak.escaper = Riak.escaper, CGI }
|
16
|
-
after { Riak.escaper = @oldesc }
|
17
|
-
|
18
|
-
it "escapes standard non-safe characters" do
|
19
|
-
expect(@object.escape("some string")).to eq("some%20string")
|
20
|
-
expect(@object.escape("another^one")).to eq("another%5Eone")
|
21
|
-
expect(@object.escape("bracket[one")).to eq("bracket%5Bone")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "escapes slashes" do
|
25
|
-
expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "converts the bucket or key to a string before escaping" do
|
29
|
-
expect(@object.escape(125)).to eq('125')
|
30
|
-
end
|
31
|
-
|
32
|
-
it "unescapes escaped strings" do
|
33
|
-
expect(@object.unescape("some%20string")).to eq("some string")
|
34
|
-
expect(@object.unescape("another%5Eone")).to eq("another^one")
|
35
|
-
expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
|
36
|
-
expect(@object.unescape("some%2Finner%2Fpath")).to eq("some/inner/path")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "when using URI for escaping" do
|
41
|
-
before { @oldesc, Riak.escaper = Riak.escaper, URI }
|
42
|
-
after { Riak.escaper = @oldesc }
|
43
|
-
|
44
|
-
it "escapes standard non-safe characters" do
|
45
|
-
expect(@object.escape("some string")).to eq("some%20string")
|
46
|
-
expect(@object.escape("another^one")).to eq("another%5Eone")
|
47
|
-
expect(@object.escape("--one+two--")).to eq("--one%2Btwo--")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "allows URI-safe characters" do
|
51
|
-
expect(@object.escape("bracket[one")).to eq("bracket[one")
|
52
|
-
expect(@object.escape("sean@basho")).to eq("sean@basho")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "escapes slashes" do
|
56
|
-
expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "converts the bucket or key to a string before escaping" do
|
60
|
-
expect(@object.escape(125)).to eq('125')
|
61
|
-
end
|
62
|
-
|
63
|
-
it "unescapes escaped strings" do
|
64
|
-
expect(@object.unescape("some%20string")).to eq("some string")
|
65
|
-
expect(@object.unescape("another%5Eone")).to eq("another^one")
|
66
|
-
expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
|
67
|
-
expect(@object.unescape("some%2Finner%2Fpath")).to eq("some/inner/path")
|
68
|
-
expect(@object.unescape("--one%2Btwo--")).to eq("--one+two--")
|
69
|
-
expect(@object.unescape("me%40basho.co")).to eq("me@basho.co")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Riak::Util::Escape do
|
5
|
+
before :each do
|
6
|
+
@object = Object.new
|
7
|
+
@object.extend(Riak::Util::Escape)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "uses URI by default for escaping" do
|
11
|
+
expect(Riak.escaper).to eq(URI)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when using CGI for escaping" do
|
15
|
+
before { @oldesc, Riak.escaper = Riak.escaper, CGI }
|
16
|
+
after { Riak.escaper = @oldesc }
|
17
|
+
|
18
|
+
it "escapes standard non-safe characters" do
|
19
|
+
expect(@object.escape("some string")).to eq("some%20string")
|
20
|
+
expect(@object.escape("another^one")).to eq("another%5Eone")
|
21
|
+
expect(@object.escape("bracket[one")).to eq("bracket%5Bone")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "escapes slashes" do
|
25
|
+
expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "converts the bucket or key to a string before escaping" do
|
29
|
+
expect(@object.escape(125)).to eq('125')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "unescapes escaped strings" do
|
33
|
+
expect(@object.unescape("some%20string")).to eq("some string")
|
34
|
+
expect(@object.unescape("another%5Eone")).to eq("another^one")
|
35
|
+
expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
|
36
|
+
expect(@object.unescape("some%2Finner%2Fpath")).to eq("some/inner/path")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when using URI for escaping" do
|
41
|
+
before { @oldesc, Riak.escaper = Riak.escaper, URI }
|
42
|
+
after { Riak.escaper = @oldesc }
|
43
|
+
|
44
|
+
it "escapes standard non-safe characters" do
|
45
|
+
expect(@object.escape("some string")).to eq("some%20string")
|
46
|
+
expect(@object.escape("another^one")).to eq("another%5Eone")
|
47
|
+
expect(@object.escape("--one+two--")).to eq("--one%2Btwo--")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "allows URI-safe characters" do
|
51
|
+
expect(@object.escape("bracket[one")).to eq("bracket[one")
|
52
|
+
expect(@object.escape("sean@basho")).to eq("sean@basho")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "escapes slashes" do
|
56
|
+
expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "converts the bucket or key to a string before escaping" do
|
60
|
+
expect(@object.escape(125)).to eq('125')
|
61
|
+
end
|
62
|
+
|
63
|
+
it "unescapes escaped strings" do
|
64
|
+
expect(@object.unescape("some%20string")).to eq("some string")
|
65
|
+
expect(@object.unescape("another%5Eone")).to eq("another^one")
|
66
|
+
expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
|
67
|
+
expect(@object.unescape("some%2Finner%2Fpath")).to eq("some/inner/path")
|
68
|
+
expect(@object.unescape("--one%2Btwo--")).to eq("--one+two--")
|
69
|
+
expect(@object.unescape("me%40basho.co")).to eq("me@basho.co")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -1,77 +1,77 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak/client/feature_detection'
|
3
|
-
|
4
|
-
describe Riak::Client::FeatureDetection do
|
5
|
-
let(:klass) {
|
6
|
-
Class.new do
|
7
|
-
include Riak::Client::FeatureDetection
|
8
|
-
end
|
9
|
-
}
|
10
|
-
subject { klass.new }
|
11
|
-
|
12
|
-
context "when the get_server_version is unimplemented" do
|
13
|
-
it "raises a NotImplementedError" do
|
14
|
-
expect { subject.server_version }.to raise_error(NotImplementedError)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when the Riak version is 0.14.x" do
|
19
|
-
before { allow(subject).to receive(:get_server_version).and_return("0.14.2") }
|
20
|
-
it { is_expected.not_to be_mapred_phaseless }
|
21
|
-
it { is_expected.not_to be_pb_indexes }
|
22
|
-
it { is_expected.not_to be_pb_search }
|
23
|
-
it { is_expected.not_to be_pb_conditionals }
|
24
|
-
it { is_expected.not_to be_quorum_controls }
|
25
|
-
it { is_expected.not_to be_tombstone_vclocks }
|
26
|
-
it { is_expected.not_to be_pb_head }
|
27
|
-
it { is_expected.not_to be_http_props_clearable }
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when the Riak version is 1.0.x" do
|
31
|
-
before { allow(subject).to receive(:get_server_version).and_return("1.0.3") }
|
32
|
-
it { is_expected.not_to be_mapred_phaseless }
|
33
|
-
it { is_expected.not_to be_pb_indexes }
|
34
|
-
it { is_expected.not_to be_pb_search }
|
35
|
-
it { is_expected.to be_pb_conditionals }
|
36
|
-
it { is_expected.to be_quorum_controls }
|
37
|
-
it { is_expected.to be_tombstone_vclocks }
|
38
|
-
it { is_expected.to be_pb_head }
|
39
|
-
it { is_expected.not_to be_http_props_clearable }
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when the Riak version is 1.1.x" do
|
43
|
-
before { allow(subject).to receive(:get_server_version).and_return("1.1.4") }
|
44
|
-
it { is_expected.to be_mapred_phaseless }
|
45
|
-
it { is_expected.not_to be_pb_indexes }
|
46
|
-
it { is_expected.not_to be_pb_search }
|
47
|
-
it { is_expected.to be_pb_conditionals }
|
48
|
-
it { is_expected.to be_quorum_controls }
|
49
|
-
it { is_expected.to be_tombstone_vclocks }
|
50
|
-
it { is_expected.to be_pb_head }
|
51
|
-
it { is_expected.not_to be_http_props_clearable }
|
52
|
-
end
|
53
|
-
|
54
|
-
context "when the Riak version is 1.2.x" do
|
55
|
-
before { allow(subject).to receive(:get_server_version).and_return("1.2.1") }
|
56
|
-
it { is_expected.to be_mapred_phaseless }
|
57
|
-
it { is_expected.to be_pb_indexes }
|
58
|
-
it { is_expected.to be_pb_search }
|
59
|
-
it { is_expected.to be_pb_conditionals }
|
60
|
-
it { is_expected.to be_quorum_controls }
|
61
|
-
it { is_expected.to be_tombstone_vclocks }
|
62
|
-
it { is_expected.to be_pb_head }
|
63
|
-
it { is_expected.not_to be_http_props_clearable }
|
64
|
-
end
|
65
|
-
|
66
|
-
context "when the Riak version is 1.3.x" do
|
67
|
-
before { allow(subject).to receive(:get_server_version).and_return("1.3.0") }
|
68
|
-
it { is_expected.to be_mapred_phaseless }
|
69
|
-
it { is_expected.to be_pb_indexes }
|
70
|
-
it { is_expected.to be_pb_search }
|
71
|
-
it { is_expected.to be_pb_conditionals }
|
72
|
-
it { is_expected.to be_quorum_controls }
|
73
|
-
it { is_expected.to be_tombstone_vclocks }
|
74
|
-
it { is_expected.to be_pb_head }
|
75
|
-
it { is_expected.to be_http_props_clearable }
|
76
|
-
end
|
77
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'riak/client/feature_detection'
|
3
|
+
|
4
|
+
describe Riak::Client::FeatureDetection do
|
5
|
+
let(:klass) {
|
6
|
+
Class.new do
|
7
|
+
include Riak::Client::FeatureDetection
|
8
|
+
end
|
9
|
+
}
|
10
|
+
subject { klass.new }
|
11
|
+
|
12
|
+
context "when the get_server_version is unimplemented" do
|
13
|
+
it "raises a NotImplementedError" do
|
14
|
+
expect { subject.server_version }.to raise_error(NotImplementedError)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when the Riak version is 0.14.x" do
|
19
|
+
before { allow(subject).to receive(:get_server_version).and_return("0.14.2") }
|
20
|
+
it { is_expected.not_to be_mapred_phaseless }
|
21
|
+
it { is_expected.not_to be_pb_indexes }
|
22
|
+
it { is_expected.not_to be_pb_search }
|
23
|
+
it { is_expected.not_to be_pb_conditionals }
|
24
|
+
it { is_expected.not_to be_quorum_controls }
|
25
|
+
it { is_expected.not_to be_tombstone_vclocks }
|
26
|
+
it { is_expected.not_to be_pb_head }
|
27
|
+
it { is_expected.not_to be_http_props_clearable }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when the Riak version is 1.0.x" do
|
31
|
+
before { allow(subject).to receive(:get_server_version).and_return("1.0.3") }
|
32
|
+
it { is_expected.not_to be_mapred_phaseless }
|
33
|
+
it { is_expected.not_to be_pb_indexes }
|
34
|
+
it { is_expected.not_to be_pb_search }
|
35
|
+
it { is_expected.to be_pb_conditionals }
|
36
|
+
it { is_expected.to be_quorum_controls }
|
37
|
+
it { is_expected.to be_tombstone_vclocks }
|
38
|
+
it { is_expected.to be_pb_head }
|
39
|
+
it { is_expected.not_to be_http_props_clearable }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when the Riak version is 1.1.x" do
|
43
|
+
before { allow(subject).to receive(:get_server_version).and_return("1.1.4") }
|
44
|
+
it { is_expected.to be_mapred_phaseless }
|
45
|
+
it { is_expected.not_to be_pb_indexes }
|
46
|
+
it { is_expected.not_to be_pb_search }
|
47
|
+
it { is_expected.to be_pb_conditionals }
|
48
|
+
it { is_expected.to be_quorum_controls }
|
49
|
+
it { is_expected.to be_tombstone_vclocks }
|
50
|
+
it { is_expected.to be_pb_head }
|
51
|
+
it { is_expected.not_to be_http_props_clearable }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when the Riak version is 1.2.x" do
|
55
|
+
before { allow(subject).to receive(:get_server_version).and_return("1.2.1") }
|
56
|
+
it { is_expected.to be_mapred_phaseless }
|
57
|
+
it { is_expected.to be_pb_indexes }
|
58
|
+
it { is_expected.to be_pb_search }
|
59
|
+
it { is_expected.to be_pb_conditionals }
|
60
|
+
it { is_expected.to be_quorum_controls }
|
61
|
+
it { is_expected.to be_tombstone_vclocks }
|
62
|
+
it { is_expected.to be_pb_head }
|
63
|
+
it { is_expected.not_to be_http_props_clearable }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when the Riak version is 1.3.x" do
|
67
|
+
before { allow(subject).to receive(:get_server_version).and_return("1.3.0") }
|
68
|
+
it { is_expected.to be_mapred_phaseless }
|
69
|
+
it { is_expected.to be_pb_indexes }
|
70
|
+
it { is_expected.to be_pb_search }
|
71
|
+
it { is_expected.to be_pb_conditionals }
|
72
|
+
it { is_expected.to be_quorum_controls }
|
73
|
+
it { is_expected.to be_tombstone_vclocks }
|
74
|
+
it { is_expected.to be_pb_head }
|
75
|
+
it { is_expected.to be_http_props_clearable }
|
76
|
+
end
|
77
|
+
end
|
@@ -1,53 +1,53 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::IndexCollection do
|
4
|
-
describe "json initialization" do
|
5
|
-
it "accepts a list of keys" do
|
6
|
-
@input = {
|
7
|
-
'keys' => %w{first second third}
|
8
|
-
}.to_json
|
9
|
-
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
10
|
-
expect(%w{first second third}).to eq(@coll)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "accepts a list of keys and a continuation" do
|
14
|
-
@input = {
|
15
|
-
'keys' => %w{first second third},
|
16
|
-
'continuation' => 'examplecontinuation'
|
17
|
-
}.to_json
|
18
|
-
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
19
|
-
expect(%w{first second third}).to eq(@coll)
|
20
|
-
expect(@coll.continuation).to eq('examplecontinuation')
|
21
|
-
end
|
22
|
-
|
23
|
-
it "accepts a list of results hashes" do
|
24
|
-
@input = {
|
25
|
-
'results' => [
|
26
|
-
{'first' => 'first'},
|
27
|
-
{'second' => 'second'},
|
28
|
-
{'second' => 'other'}
|
29
|
-
]
|
30
|
-
}.to_json
|
31
|
-
|
32
|
-
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
33
|
-
expect(%w{first second other}).to eq(@coll)
|
34
|
-
expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "accepts a list of results hashes and a continuation" do
|
38
|
-
@input = {
|
39
|
-
'results' => [
|
40
|
-
{'first' => 'first'},
|
41
|
-
{'second' => 'second'},
|
42
|
-
{'second' => 'other'}
|
43
|
-
],
|
44
|
-
'continuation' => 'examplecontinuation'
|
45
|
-
}.to_json
|
46
|
-
|
47
|
-
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
48
|
-
expect(%w{first second other}).to eq(@coll)
|
49
|
-
expect(@coll.continuation).to eq('examplecontinuation')
|
50
|
-
expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Riak::IndexCollection do
|
4
|
+
describe "json initialization" do
|
5
|
+
it "accepts a list of keys" do
|
6
|
+
@input = {
|
7
|
+
'keys' => %w{first second third}
|
8
|
+
}.to_json
|
9
|
+
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
10
|
+
expect(%w{first second third}).to eq(@coll)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "accepts a list of keys and a continuation" do
|
14
|
+
@input = {
|
15
|
+
'keys' => %w{first second third},
|
16
|
+
'continuation' => 'examplecontinuation'
|
17
|
+
}.to_json
|
18
|
+
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
19
|
+
expect(%w{first second third}).to eq(@coll)
|
20
|
+
expect(@coll.continuation).to eq('examplecontinuation')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "accepts a list of results hashes" do
|
24
|
+
@input = {
|
25
|
+
'results' => [
|
26
|
+
{'first' => 'first'},
|
27
|
+
{'second' => 'second'},
|
28
|
+
{'second' => 'other'}
|
29
|
+
]
|
30
|
+
}.to_json
|
31
|
+
|
32
|
+
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
33
|
+
expect(%w{first second other}).to eq(@coll)
|
34
|
+
expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "accepts a list of results hashes and a continuation" do
|
38
|
+
@input = {
|
39
|
+
'results' => [
|
40
|
+
{'first' => 'first'},
|
41
|
+
{'second' => 'second'},
|
42
|
+
{'second' => 'other'}
|
43
|
+
],
|
44
|
+
'continuation' => 'examplecontinuation'
|
45
|
+
}.to_json
|
46
|
+
|
47
|
+
expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
|
48
|
+
expect(%w{first second other}).to eq(@coll)
|
49
|
+
expect(@coll.continuation).to eq('examplecontinuation')
|
50
|
+
expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,124 +1,124 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Riak::Client do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Riak::Client.new
|
7
|
-
@backend = double("Backend")
|
8
|
-
allow(@client).to receive(:backend).and_yield(@backend)
|
9
|
-
allow(@client).to receive(:http).and_yield(@backend)
|
10
|
-
@bucket = Riak::Bucket.new(@client, "foo")
|
11
|
-
|
12
|
-
@events = []
|
13
|
-
@notifier = ActiveSupport::Notifications.notifier
|
14
|
-
@notifier.subscribe { |*args| (@events ||= []) << event(*args) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "instrumentation", instrumentation: true do
|
18
|
-
|
19
|
-
it "should notify on the 'buckets' operation" do
|
20
|
-
expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
|
21
|
-
test_client_event(@client, 'riak.list_buckets') do
|
22
|
-
@client.buckets
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should notify on the 'list_buckets' operation" do
|
27
|
-
expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
|
28
|
-
test_client_event(@client, 'riak.list_buckets') do
|
29
|
-
@client.list_buckets
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should notify on the 'list_keys' operation" do
|
34
|
-
expect(@backend).to receive(:list_keys).and_return(%w{test test2})
|
35
|
-
test_client_event(@client, 'riak.list_keys') do
|
36
|
-
@client.list_keys(@bucket)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should notify on the 'get_bucket_props' operation" do
|
41
|
-
expect(@backend).to receive(:get_bucket_props).and_return({})
|
42
|
-
test_client_event(@client, 'riak.get_bucket_props') do
|
43
|
-
@client.get_bucket_props(@bucket)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should notify on the 'set_bucket_props' operation" do
|
48
|
-
expect(@backend).to receive(:set_bucket_props).and_return({})
|
49
|
-
test_client_event(@client, 'riak.set_bucket_props') do
|
50
|
-
@client.set_bucket_props(@bucket, {})
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should notify on the 'clear_bucket_props' operation" do
|
55
|
-
expect(@backend).to receive(:reset_bucket_props).and_return({})
|
56
|
-
test_client_event(@client, 'riak.clear_bucket_props') do
|
57
|
-
@client.clear_bucket_props(@bucket)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should notify on the 'get_index' operation" do
|
62
|
-
expect(@backend).to receive(:get_index).and_return({})
|
63
|
-
test_client_event(@client, 'riak.get_index') do
|
64
|
-
@client.get_index(@bucket, 'index', 'query', {})
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should notify on the 'get_object' operation" do
|
69
|
-
expect(@backend).to receive(:fetch_object).and_return(nil)
|
70
|
-
test_client_event(@client, 'riak.get_object') do
|
71
|
-
@client.get_object(@bucket, 'bar')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should notify on the 'store_object' operation" do
|
76
|
-
expect(@backend).to receive(:store_object).and_return(nil)
|
77
|
-
test_client_event(@client, 'riak.store_object') do
|
78
|
-
@client.store_object(Object.new)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should notify on the 'reload_object' operation" do
|
83
|
-
expect(@backend).to receive(:reload_object).and_return(nil)
|
84
|
-
test_client_event(@client, 'riak.reload_object') do
|
85
|
-
@client.reload_object(Object.new)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should notify on the 'delete_object' operation" do
|
90
|
-
expect(@backend).to receive(:delete_object).and_return(nil)
|
91
|
-
test_client_event(@client, 'riak.delete_object') do
|
92
|
-
@client.delete_object(@bucket, 'bar')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should notify on the 'mapred' operation" do
|
97
|
-
@mapred = Riak::MapReduce.new(@client).add('test').map("function(){}").map("function(){}")
|
98
|
-
expect(@backend).to receive(:mapred).and_return(nil)
|
99
|
-
test_client_event(@client, 'riak.map_reduce') do
|
100
|
-
@client.mapred(@mapred)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should notify on the 'ping' operation" do
|
105
|
-
expect(@backend).to receive(:ping).and_return(nil)
|
106
|
-
test_client_event(@client, 'riak.ping') do
|
107
|
-
@client.ping
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_client_event(client, event_name, &block)
|
114
|
-
block.call
|
115
|
-
expect(@events.size).to eql(1)
|
116
|
-
event = @events.first
|
117
|
-
expect(event.name).to eql(event_name)
|
118
|
-
expect(event.payload[:client_id]).to eql(client.client_id)
|
119
|
-
end
|
120
|
-
|
121
|
-
# name, start, finish, id, payload
|
122
|
-
def event(*args)
|
123
|
-
ActiveSupport::Notifications::Event.new(*args)
|
124
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Riak::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Riak::Client.new
|
7
|
+
@backend = double("Backend")
|
8
|
+
allow(@client).to receive(:backend).and_yield(@backend)
|
9
|
+
allow(@client).to receive(:http).and_yield(@backend)
|
10
|
+
@bucket = Riak::Bucket.new(@client, "foo")
|
11
|
+
|
12
|
+
@events = []
|
13
|
+
@notifier = ActiveSupport::Notifications.notifier
|
14
|
+
@notifier.subscribe { |*args| (@events ||= []) << event(*args) }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "instrumentation", instrumentation: true do
|
18
|
+
|
19
|
+
it "should notify on the 'buckets' operation" do
|
20
|
+
expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
|
21
|
+
test_client_event(@client, 'riak.list_buckets') do
|
22
|
+
@client.buckets
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should notify on the 'list_buckets' operation" do
|
27
|
+
expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
|
28
|
+
test_client_event(@client, 'riak.list_buckets') do
|
29
|
+
@client.list_buckets
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should notify on the 'list_keys' operation" do
|
34
|
+
expect(@backend).to receive(:list_keys).and_return(%w{test test2})
|
35
|
+
test_client_event(@client, 'riak.list_keys') do
|
36
|
+
@client.list_keys(@bucket)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should notify on the 'get_bucket_props' operation" do
|
41
|
+
expect(@backend).to receive(:get_bucket_props).and_return({})
|
42
|
+
test_client_event(@client, 'riak.get_bucket_props') do
|
43
|
+
@client.get_bucket_props(@bucket)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should notify on the 'set_bucket_props' operation" do
|
48
|
+
expect(@backend).to receive(:set_bucket_props).and_return({})
|
49
|
+
test_client_event(@client, 'riak.set_bucket_props') do
|
50
|
+
@client.set_bucket_props(@bucket, {})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should notify on the 'clear_bucket_props' operation" do
|
55
|
+
expect(@backend).to receive(:reset_bucket_props).and_return({})
|
56
|
+
test_client_event(@client, 'riak.clear_bucket_props') do
|
57
|
+
@client.clear_bucket_props(@bucket)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should notify on the 'get_index' operation" do
|
62
|
+
expect(@backend).to receive(:get_index).and_return({})
|
63
|
+
test_client_event(@client, 'riak.get_index') do
|
64
|
+
@client.get_index(@bucket, 'index', 'query', {})
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should notify on the 'get_object' operation" do
|
69
|
+
expect(@backend).to receive(:fetch_object).and_return(nil)
|
70
|
+
test_client_event(@client, 'riak.get_object') do
|
71
|
+
@client.get_object(@bucket, 'bar')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should notify on the 'store_object' operation" do
|
76
|
+
expect(@backend).to receive(:store_object).and_return(nil)
|
77
|
+
test_client_event(@client, 'riak.store_object') do
|
78
|
+
@client.store_object(Object.new)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should notify on the 'reload_object' operation" do
|
83
|
+
expect(@backend).to receive(:reload_object).and_return(nil)
|
84
|
+
test_client_event(@client, 'riak.reload_object') do
|
85
|
+
@client.reload_object(Object.new)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should notify on the 'delete_object' operation" do
|
90
|
+
expect(@backend).to receive(:delete_object).and_return(nil)
|
91
|
+
test_client_event(@client, 'riak.delete_object') do
|
92
|
+
@client.delete_object(@bucket, 'bar')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should notify on the 'mapred' operation" do
|
97
|
+
@mapred = Riak::MapReduce.new(@client).add('test').map("function(){}").map("function(){}")
|
98
|
+
expect(@backend).to receive(:mapred).and_return(nil)
|
99
|
+
test_client_event(@client, 'riak.map_reduce') do
|
100
|
+
@client.mapred(@mapred)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should notify on the 'ping' operation" do
|
105
|
+
expect(@backend).to receive(:ping).and_return(nil)
|
106
|
+
test_client_event(@client, 'riak.ping') do
|
107
|
+
@client.ping
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_client_event(client, event_name, &block)
|
114
|
+
block.call
|
115
|
+
expect(@events.size).to eql(1)
|
116
|
+
event = @events.first
|
117
|
+
expect(event.name).to eql(event_name)
|
118
|
+
expect(event.payload[:client_id]).to eql(client.client_id)
|
119
|
+
end
|
120
|
+
|
121
|
+
# name, start, finish, id, payload
|
122
|
+
def event(*args)
|
123
|
+
ActiveSupport::Notifications::Event.new(*args)
|
124
|
+
end
|