riak-client 1.4.5 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +0 -1
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.markdown +211 -66
- data/RELEASE_NOTES.md +22 -47
- data/Rakefile +45 -0
- data/lib/riak.rb +1 -1
- data/lib/riak/bucket.rb +2 -2
- data/lib/riak/client.rb +22 -195
- data/lib/riak/client/beefcake/crdt_loader.rb +127 -0
- data/lib/riak/client/beefcake/crdt_operator.rb +222 -0
- data/lib/riak/client/beefcake/footer +4 -0
- data/lib/riak/client/beefcake/header +6 -0
- data/lib/riak/client/beefcake/message_codes.rb +29 -0
- data/lib/riak/client/beefcake/message_overlay.rb +61 -0
- data/lib/riak/client/beefcake/messages.rb +733 -371
- data/lib/riak/client/beefcake/object_methods.rb +1 -1
- data/lib/riak/client/beefcake/protocol.rb +105 -0
- data/lib/riak/client/beefcake/socket.rb +243 -0
- data/lib/riak/client/beefcake_protobuffs_backend.rb +262 -122
- data/lib/riak/client/node.rb +4 -75
- data/lib/riak/client/protobuffs_backend.rb +6 -14
- data/lib/riak/client/search.rb +0 -64
- data/lib/riak/client/yokozuna.rb +52 -0
- data/lib/riak/counter.rb +1 -1
- data/lib/riak/crdt.rb +21 -0
- data/lib/riak/crdt/base.rb +97 -0
- data/lib/riak/crdt/batch_counter.rb +19 -0
- data/lib/riak/crdt/batch_map.rb +41 -0
- data/lib/riak/crdt/counter.rb +71 -0
- data/lib/riak/crdt/inner_counter.rb +74 -0
- data/lib/riak/crdt/inner_flag.rb +42 -0
- data/lib/riak/crdt/inner_map.rb +53 -0
- data/lib/riak/crdt/inner_register.rb +26 -0
- data/lib/riak/crdt/inner_set.rb +95 -0
- data/lib/riak/crdt/map.rb +88 -0
- data/lib/riak/crdt/operation.rb +19 -0
- data/lib/riak/crdt/set.rb +156 -0
- data/lib/riak/crdt/typed_collection.rb +131 -0
- data/lib/riak/errors/base.rb +9 -0
- data/lib/riak/errors/connection_error.rb +44 -0
- data/lib/riak/errors/crdt_error.rb +18 -0
- data/lib/riak/errors/failed_request.rb +56 -0
- data/lib/riak/errors/protobuffs_error.rb +11 -0
- data/lib/riak/i18n.rb +2 -0
- data/lib/riak/json.rb +1 -1
- data/lib/riak/locale/en.yml +26 -1
- data/lib/riak/locale/fr.yml +0 -1
- data/lib/riak/map_reduce.rb +1 -1
- data/lib/riak/map_reduce/results.rb +1 -1
- data/lib/riak/multiget.rb +1 -2
- data/lib/riak/rcontent.rb +8 -3
- data/lib/riak/robject.rb +2 -8
- data/lib/riak/secondary_index.rb +4 -4
- data/lib/riak/serializers.rb +1 -1
- data/lib/riak/util/escape.rb +3 -5
- data/lib/riak/version.rb +1 -1
- data/lib/riak/walk_spec.rb +7 -3
- data/riak-client.gemspec +10 -8
- data/spec/fixtures/bitcask.txt +25 -0
- data/spec/integration/riak/bucket_types_spec.rb +61 -0
- data/spec/integration/riak/counters_spec.rb +17 -32
- data/spec/integration/riak/crdt_spec.rb +181 -0
- data/spec/integration/riak/crdt_validation/map_spec.rb +63 -0
- data/spec/integration/riak/crdt_validation/set_spec.rb +122 -0
- data/spec/integration/riak/protobuffs_backends_spec.rb +9 -26
- data/spec/integration/riak/security_spec.rb +94 -0
- data/spec/integration/riak/threading_spec.rb +24 -67
- data/spec/integration/yokozuna/index_spec.rb +61 -0
- data/spec/integration/yokozuna/queries_spec.rb +116 -0
- data/spec/integration/yokozuna/schema_spec.rb +49 -0
- data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +222 -0
- data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +4 -4
- data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +189 -0
- data/spec/riak/beefcake_protobuffs_backend/socket_spec.rb +151 -0
- data/spec/riak/beefcake_protobuffs_backend_spec.rb +68 -106
- data/spec/riak/bucket_spec.rb +81 -77
- data/spec/riak/client_spec.rb +43 -340
- data/spec/riak/core_ext/to_param_spec.rb +2 -2
- data/spec/riak/counter_spec.rb +20 -20
- data/spec/riak/crdt/counter_spec.rb +52 -0
- data/spec/riak/crdt/inner_counter_spec.rb +21 -0
- data/spec/riak/crdt/inner_flag_spec.rb +39 -0
- data/spec/riak/crdt/inner_map_spec.rb +47 -0
- data/spec/riak/crdt/inner_register_spec.rb +40 -0
- data/spec/riak/crdt/inner_set_spec.rb +33 -0
- data/spec/riak/crdt/map_spec.rb +77 -0
- data/spec/riak/crdt/set_spec.rb +58 -0
- data/spec/riak/crdt/shared_examples.rb +74 -0
- data/spec/riak/crdt/typed_collection_spec.rb +231 -0
- data/spec/riak/escape_spec.rb +33 -37
- data/spec/riak/feature_detection_spec.rb +45 -45
- data/spec/riak/index_collection_spec.rb +12 -12
- data/spec/riak/link_spec.rb +34 -34
- data/spec/riak/list_buckets_spec.rb +7 -7
- data/spec/riak/map_reduce/filter_builder_spec.rb +6 -6
- data/spec/riak/map_reduce/phase_spec.rb +35 -35
- data/spec/riak/map_reduce_spec.rb +89 -87
- data/spec/riak/multiget_spec.rb +20 -15
- data/spec/riak/node_spec.rb +5 -152
- data/spec/riak/robject_spec.rb +95 -108
- data/spec/riak/search_spec.rb +17 -139
- data/spec/riak/secondary_index_spec.rb +49 -49
- data/spec/riak/serializers_spec.rb +9 -9
- data/spec/riak/stamp_spec.rb +9 -9
- data/spec/riak/walk_spec_spec.rb +46 -46
- data/spec/spec_helper.rb +14 -22
- data/spec/support/certs/README.md +13 -0
- data/spec/support/certs/ca.crt +22 -0
- data/spec/support/certs/client.crt +95 -0
- data/spec/support/certs/client.key +27 -0
- data/spec/support/certs/empty_ca.crt +21 -0
- data/spec/support/certs/server.crl +13 -0
- data/spec/support/certs/server.crt +95 -0
- data/spec/support/certs/server.key +27 -0
- data/spec/support/integration_setup.rb +1 -1
- data/spec/support/search_corpus_setup.rb +29 -8
- data/spec/support/test_client.rb +46 -0
- data/spec/support/test_client.yml.example +10 -0
- data/spec/support/unified_backend_examples.rb +104 -83
- data/spec/support/version_filter.rb +2 -2
- data/spec/support/wait_until.rb +14 -0
- metadata +134 -132
- data/erl_src/riak_kv_test014_backend.beam +0 -0
- data/erl_src/riak_kv_test014_backend.erl +0 -189
- data/erl_src/riak_kv_test_backend.beam +0 -0
- data/erl_src/riak_kv_test_backend.erl +0 -731
- data/erl_src/riak_search_test_backend.beam +0 -0
- data/erl_src/riak_search_test_backend.erl +0 -175
- data/lib/riak/client/excon_backend.rb +0 -172
- data/lib/riak/client/http_backend.rb +0 -413
- data/lib/riak/client/http_backend/bucket_streamer.rb +0 -15
- data/lib/riak/client/http_backend/chunked_json_streamer.rb +0 -42
- data/lib/riak/client/http_backend/configuration.rb +0 -227
- data/lib/riak/client/http_backend/key_streamer.rb +0 -15
- data/lib/riak/client/http_backend/object_methods.rb +0 -114
- data/lib/riak/client/http_backend/request_headers.rb +0 -34
- data/lib/riak/client/http_backend/transport_methods.rb +0 -201
- data/lib/riak/client/instrumentation.rb +0 -25
- data/lib/riak/client/net_http_backend.rb +0 -82
- data/lib/riak/cluster.rb +0 -151
- data/lib/riak/failed_request.rb +0 -81
- data/lib/riak/instrumentation.rb +0 -6
- data/lib/riak/node.rb +0 -40
- data/lib/riak/node/configuration.rb +0 -304
- data/lib/riak/node/console.rb +0 -133
- data/lib/riak/node/control.rb +0 -207
- data/lib/riak/node/defaults.rb +0 -85
- data/lib/riak/node/generation.rb +0 -127
- data/lib/riak/node/log.rb +0 -34
- data/lib/riak/node/version.rb +0 -29
- data/lib/riak/search.rb +0 -3
- data/lib/riak/test_server.rb +0 -89
- data/lib/riak/util/headers.rb +0 -32
- data/lib/riak/util/multipart.rb +0 -52
- data/lib/riak/util/multipart/stream_parser.rb +0 -62
- data/spec/fixtures/munchausen.txt +0 -1033
- data/spec/integration/riak/cluster_spec.rb +0 -88
- data/spec/integration/riak/http_backends_spec.rb +0 -180
- data/spec/integration/riak/node_spec.rb +0 -170
- data/spec/integration/riak/test_server_spec.rb +0 -57
- data/spec/riak/excon_backend_spec.rb +0 -102
- data/spec/riak/headers_spec.rb +0 -21
- data/spec/riak/http_backend/configuration_spec.rb +0 -273
- data/spec/riak/http_backend/object_methods_spec.rb +0 -243
- data/spec/riak/http_backend/transport_methods_spec.rb +0 -97
- data/spec/riak/http_backend_spec.rb +0 -367
- data/spec/riak/instrumentation_spec.rb +0 -167
- data/spec/riak/multipart_spec.rb +0 -23
- data/spec/riak/net_http_backend_spec.rb +0 -15
- data/spec/riak/stream_parser_spec.rb +0 -53
- data/spec/support/drb_mock_server.rb +0 -39
- data/spec/support/http_backend_implementation_examples.rb +0 -253
- data/spec/support/mock_server.rb +0 -81
- data/spec/support/mocks.rb +0 -4
- data/spec/support/riak_test.rb +0 -77
- data/spec/support/sometimes.rb +0 -46
- data/spec/support/test_server.rb +0 -61
- data/spec/support/test_server.yml.example +0 -14
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak/cluster'
|
3
|
-
|
4
|
-
describe Riak::Cluster, :test_server => false, :slow => true, :nodegen => true do
|
5
|
-
let(:config) { YAML.load_file("spec/support/test_server.yml").symbolize_keys }
|
6
|
-
subject { described_class.new(config) }
|
7
|
-
|
8
|
-
it "should have a list of nodes" do
|
9
|
-
should respond_to(:nodes)
|
10
|
-
subject.nodes.should be_kind_of(Array)
|
11
|
-
subject.nodes.should have(4).items
|
12
|
-
subject.nodes.should be_all {|n| n.kind_of?(Riak::Node) }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should have a configuration" do
|
16
|
-
should respond_to(:configuration)
|
17
|
-
subject.configuration.should be_kind_of(Hash)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should require a :source and :root configuration keys" do
|
21
|
-
expect {
|
22
|
-
described_class.new({})
|
23
|
-
}.to raise_error(ArgumentError)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should not be created initially" do
|
27
|
-
should_not be_exist
|
28
|
-
end
|
29
|
-
|
30
|
-
context "creating the cluster" do
|
31
|
-
before { subject.create }
|
32
|
-
after { subject.destroy }
|
33
|
-
|
34
|
-
it "should generate all nodes inside its root" do
|
35
|
-
subject.root.should be_exist
|
36
|
-
subject.nodes.should be_all {|n| n.exist? }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "destroying the cluster" do
|
41
|
-
before { subject.create; subject.should be_exist; subject.destroy }
|
42
|
-
|
43
|
-
it "should remove all nodes and its root directory" do
|
44
|
-
subject.should_not be_exist
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "dropping data from the cluster" do
|
49
|
-
it "should make all nodes drop their data" do
|
50
|
-
subject.nodes.each {|n| n.should_receive(:drop) }
|
51
|
-
subject.drop
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "starting the cluster", :slow => true do
|
56
|
-
before { subject.create }
|
57
|
-
after { subject.destroy }
|
58
|
-
|
59
|
-
it "should start all nodes in the cluster" do
|
60
|
-
subject.start
|
61
|
-
subject.nodes.should be_all {|n| n.started? }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "stopping the cluster", :slow => true do
|
66
|
-
before { subject.create; subject.start; subject.should be_started }
|
67
|
-
after { subject.destroy }
|
68
|
-
|
69
|
-
it "should stop all nodes in the cluster" do
|
70
|
-
subject.stop
|
71
|
-
subject.nodes.should be_all {|n| n.stopped? }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "joining the cluster together", :slow => true do
|
76
|
-
before { subject.create; subject.start; subject.should be_started }
|
77
|
-
after { subject.destroy }
|
78
|
-
|
79
|
-
it "should join nodes into a cluster" do
|
80
|
-
subject.join
|
81
|
-
node_names = subject.nodes.map {|n| n.name }.sort
|
82
|
-
subject.nodes.should be_all do |n|
|
83
|
-
n.peers.should have(3).items
|
84
|
-
n.peers.sort == (node_names - [n.name])
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,180 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "HTTP" do
|
4
|
-
before do
|
5
|
-
@web_port = test_server.http_port
|
6
|
-
@client = Riak::Client.new(:http_port => @web_port)
|
7
|
-
end
|
8
|
-
|
9
|
-
[:ExconBackend, :NetHTTPBackend].each do |klass|
|
10
|
-
bklass = Riak::Client.const_get(klass)
|
11
|
-
if bklass.configured?
|
12
|
-
describe klass.to_s do
|
13
|
-
before do
|
14
|
-
@backend = bklass.new(@client, @client.node)
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like "Unified backend API"
|
18
|
-
|
19
|
-
describe "searching fulltext indexes (1.1 and earlier)", :version => "< 1.2.0" do
|
20
|
-
include_context "search corpus setup"
|
21
|
-
|
22
|
-
it 'should find indexed documents, returning ids' do
|
23
|
-
results = @backend.search 'search_test', 'fearless elephant rushed', :fl => 'id'
|
24
|
-
results.should have_key 'docs'
|
25
|
-
results.should have_key 'max_score'
|
26
|
-
results.should have_key 'num_found'
|
27
|
-
results['docs'].should include({"id" => "munchausen-605"})
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should find indexed documents, returning documents' do
|
31
|
-
# For now use '*' until #122 is merged into riak_search
|
32
|
-
results = @backend.search 'search_test', 'fearless elephant rushed', :fl => '*'
|
33
|
-
results.should have_key 'docs'
|
34
|
-
results.should have_key 'max_score'
|
35
|
-
results.should have_key 'num_found'
|
36
|
-
results['docs'].should include({"id" => "munchausen-605", "value" => "Fearless I advanced against the elephant, desirous to take alive the haughty Tippoo Sahib; but he drew a pistol from his belt, and discharged it full in my face as I rushed upon him, which did me no further harm than wound my cheek-bone, which disfigures me somewhat under my left eye. I could not withstand the rage and impulse of that moment, and with one blow of my sword separated his head from his body.\n"})
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "clearing bucket properties" do
|
41
|
-
it "should return false when unsupported", :version => "< 1.3.0" do
|
42
|
-
@backend.clear_bucket_props('foo').should be_false
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should reset a previously set property to the default", :version => ">= 1.3.0" do
|
46
|
-
bucket = @client['bucketpropscleartest']
|
47
|
-
original_n = @backend.get_bucket_props(bucket)['n_val']
|
48
|
-
@backend.set_bucket_props(bucket, {'n_val' => 2})
|
49
|
-
@backend.get_bucket_props(bucket)['n_val'].should == 2
|
50
|
-
@backend.clear_bucket_props(bucket)
|
51
|
-
@backend.get_bucket_props(bucket)['n_val'].should == original_n
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "using Luwak", :version => "< 1.1.0" do
|
56
|
-
let(:file) { File.open(__FILE__) }
|
57
|
-
let(:key) { "spec.rb" }
|
58
|
-
let(:string) { file.read }
|
59
|
-
|
60
|
-
def retry_400
|
61
|
-
begin
|
62
|
-
yield
|
63
|
-
rescue Riak::HTTPFailedRequest => e
|
64
|
-
# Riak 1.0.x (and possibly earlier) has a bug in
|
65
|
-
# mochiweb that will sometimes leave dangling 400
|
66
|
-
# responses on the wire between requests when the
|
67
|
-
# connection is left open. This will happen sometimes
|
68
|
-
# immediately after a store_file request.
|
69
|
-
if e.code == 400
|
70
|
-
retry
|
71
|
-
else
|
72
|
-
raise
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should store an IO with a given key" do
|
78
|
-
@backend.store_file(key, 'text/plain', file)
|
79
|
-
stored_file = retry_400 { @backend.get_file(key) }
|
80
|
-
stored_file.content_type.should == 'text/plain'
|
81
|
-
stored_file.size.should == file.size
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should store a String with a given key" do
|
85
|
-
@backend.store_file(key, 'text/plain', string)
|
86
|
-
stored_file = retry_400 { @backend.get_file(key) }
|
87
|
-
stored_file.content_type.should == 'text/plain'
|
88
|
-
stored_file.size.should == string.bytesize
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should store an IO with a server-defined key" do
|
92
|
-
key = @backend.store_file('text/plain', file)
|
93
|
-
stored_file = retry_400 { @backend.get_file(key) }
|
94
|
-
stored_file.content_type.should == 'text/plain'
|
95
|
-
stored_file.size.should == file.size
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should store a String with a server-defined key" do
|
99
|
-
key = @backend.store_file('text/plain', string)
|
100
|
-
stored_file = retry_400 { @backend.get_file(key) }
|
101
|
-
stored_file.content_type.should == 'text/plain'
|
102
|
-
stored_file.size.should == string.bytesize
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe 'key and bucket escaping' do
|
107
|
-
let(:default_bucket){ @client[rand(36**10).to_s(36)] }
|
108
|
-
|
109
|
-
{ 'question mark' => 'question?marks',
|
110
|
-
'hash' => 'hashtag#riak',
|
111
|
-
'slash' => 'slash/fiction',
|
112
|
-
'space' => 'space opera',
|
113
|
-
'plus' => 'plus+one',
|
114
|
-
'caret' => 'caret^top',
|
115
|
-
'square bracket' => 'square[]meal',
|
116
|
-
}.each do |k, v|
|
117
|
-
it "doesn't mangle keys with a #{k} in them" do
|
118
|
-
obj = default_bucket.new v
|
119
|
-
obj.content_type = 'text/plain'
|
120
|
-
obj.data = rand(36**10).to_s(36)
|
121
|
-
obj.store
|
122
|
-
|
123
|
-
o2 = nil
|
124
|
-
expect{ o2 = default_bucket.get v }.to_not raise_error
|
125
|
-
expect(o2.data).to eq obj.data
|
126
|
-
end
|
127
|
-
|
128
|
-
it "doesn't mangle buckets with a #{k} in them" do
|
129
|
-
bucket = @client[v]
|
130
|
-
obj = bucket.new rand(36**10).to_s(36)
|
131
|
-
obj.content_type = 'text/plain'
|
132
|
-
obj.data = rand(36**10).to_s(36)
|
133
|
-
obj.store
|
134
|
-
|
135
|
-
o2 = nil
|
136
|
-
expect{ o2 = bucket.get obj.key }.to_not raise_error
|
137
|
-
expect(o2.data).to eq obj.data
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
class SizelessReader < Array
|
146
|
-
def read(*args)
|
147
|
-
shift
|
148
|
-
end
|
149
|
-
|
150
|
-
undef :size
|
151
|
-
end
|
152
|
-
|
153
|
-
describe 'NetHTTPBackend' do
|
154
|
-
subject { Riak::Client::NetHTTPBackend.new(@client, @client.node) }
|
155
|
-
shared_examples "IO uploads" do |io|
|
156
|
-
it "should upload without error" do
|
157
|
-
lambda do
|
158
|
-
Timeout::timeout(2) do
|
159
|
-
subject.put(
|
160
|
-
204,
|
161
|
-
subject.object_path('nethttp', 'test-io'),
|
162
|
-
io,
|
163
|
-
{'Content-Type' => 'text/plain'}
|
164
|
-
)
|
165
|
-
end
|
166
|
-
end.should_not raise_error
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
context "File" do
|
171
|
-
include_examples "IO uploads", File.open(__FILE__)
|
172
|
-
end
|
173
|
-
context "Sized reader" do
|
174
|
-
include_examples "IO uploads", StringIO.new(%w{foo bar baz}.join)
|
175
|
-
end
|
176
|
-
context "Sizeless reader" do
|
177
|
-
include_examples "IO uploads", SizelessReader.new(%w{foo bar baz})
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
@@ -1,170 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak/node'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
describe Riak::Node, :test_server => false, :slow => true, :nodegen => true do
|
6
|
-
let(:test_server_config){ YAML.load_file("spec/support/test_server.yml") }
|
7
|
-
let(:node){ described_class.new(:root => ".ripplenode", :source => test_server_config['source']) }
|
8
|
-
subject { node }
|
9
|
-
after { node.stop if node.started? }
|
10
|
-
after(:all) { node.destroy }
|
11
|
-
|
12
|
-
context "finding the base_dir and version" do
|
13
|
-
its(:base_dir) { should be_directory }
|
14
|
-
its(:version) { should match /^\d+.\d+.\d+$/ }
|
15
|
-
end
|
16
|
-
|
17
|
-
context "creation" do
|
18
|
-
before { subject.create }
|
19
|
-
after { subject.destroy }
|
20
|
-
|
21
|
-
describe "generating the manifest" do
|
22
|
-
it "should store the configuration manifest in the node directory" do
|
23
|
-
(subject.root + '.node.yml').should be_exist
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "generating app.config" do
|
28
|
-
let(:file) { subject.etc + 'app.config'}
|
29
|
-
let(:contents) { file.read }
|
30
|
-
|
31
|
-
it "should create the app.config file in the node directory" do
|
32
|
-
file.should be_exist
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should generate a correct Erlang configuration" do
|
36
|
-
contents.should =~ /\A\[.*\]\.\Z/m
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should set the ports starting from the given port" do
|
40
|
-
contents.should include('{http, [{"127.0.0.1", 8080}]}')
|
41
|
-
contents.should include('{pb_port, 8081}')
|
42
|
-
contents.should include('{handoff_port, 8082}')
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should set the ring directory to point to the node data directory" do
|
46
|
-
contents.should include("{ring_state_dir, \"#{subject.root + 'data/ring'}\"}")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "generating vm.args" do
|
51
|
-
let(:file){ subject.etc + 'vm.args' }
|
52
|
-
let(:contents) { file.read }
|
53
|
-
|
54
|
-
it "should create the vm.args file in the node directory" do
|
55
|
-
file.should be_exist
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should set a quasi-random node name by default" do
|
59
|
-
contents.should match(/-name riak\d+@127\.0\.0\.1/)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should set a quasi-random cookie by default" do
|
63
|
-
contents.should match(/-setcookie \d+_\d+/)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "generating the environment script" do
|
68
|
-
let(:file) { (subject.version >= '1.4.0') ? subject.env_script : subject.control_script }
|
69
|
-
let(:contents) { file.read }
|
70
|
-
|
71
|
-
it "should create the script in the node directory" do
|
72
|
-
file.should be_exist
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should modify the RUNNER_SCRIPT_DIR to point to the node directory" do
|
76
|
-
contents.should match(/RUNNER_SCRIPT_DIR=#{subject.bin.to_s}/)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should modify the RUNNER_ETC_DIR to point to the node directory" do
|
80
|
-
contents.should match(/RUNNER_ETC_DIR=#{subject.etc.to_s}/)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should modify the RUNNER_USER to point to none" do
|
84
|
-
contents.should match(/RUNNER_USER=$/)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should modify the RUNNER_LOG_DIR to point to the node directory" do
|
88
|
-
contents.should match(/RUNNER_LOG_DIR=#{subject.log.to_s}/)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should modify the RUNNER_BASE_DIR so that it is not relative" do
|
92
|
-
contents.should_not match(/RUNNER_BASE_DIR=\$\{RUNNER_SCRIPT_DIR%\/\*\}/)
|
93
|
-
contents.should match(/RUNNER_BASE_DIR=(.*)/) do |path|
|
94
|
-
path.strip.should == subject.root.to_s
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should modify the PIPE_DIR to point to the node directory" do
|
99
|
-
contents.should match(/PIPE_DIR=#{subject.pipe.to_s}\/?/)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "destroying" do
|
105
|
-
before { subject.create; subject.destroy }
|
106
|
-
|
107
|
-
it "should remove the node directory and all its contents" do
|
108
|
-
subject.root.should_not be_exist
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "dropping data" do
|
113
|
-
before do
|
114
|
-
subject.create
|
115
|
-
subject.start # Make it create some data directories
|
116
|
-
subject.with_console do |console|
|
117
|
-
# Write a ringfile
|
118
|
-
console.command "riak_core_ring_manager:write_ringfile()."
|
119
|
-
end
|
120
|
-
# Don't restart the node after dropping so we can see the handiwork
|
121
|
-
subject.stop
|
122
|
-
subject.drop
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should remove all data from the node" do
|
126
|
-
(subject.root + 'data').children.map {|dir| dir.children }.flatten.should be_empty
|
127
|
-
end
|
128
|
-
|
129
|
-
it "should remove the ring" do
|
130
|
-
(subject.root + 'data/ring').children.should be_empty
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
context "starting" do
|
135
|
-
before { subject.create; subject.start }
|
136
|
-
it { should be_started }
|
137
|
-
after { subject.stop }
|
138
|
-
end
|
139
|
-
|
140
|
-
context "stopping" do
|
141
|
-
before { subject.create; subject.start; subject.stop }
|
142
|
-
it { should be_stopped }
|
143
|
-
end
|
144
|
-
|
145
|
-
context "attaching" do
|
146
|
-
before { subject.create; subject.start }
|
147
|
-
|
148
|
-
it "should attach to the running node" do
|
149
|
-
console = subject.attach
|
150
|
-
console.should be_kind_of(Riak::Node::Console)
|
151
|
-
expect {
|
152
|
-
console.command "ok."
|
153
|
-
console.close
|
154
|
-
}.to_not raise_error
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
context "running" do
|
159
|
-
before { subject.create; subject.start; subject.stop }
|
160
|
-
|
161
|
-
it "should read the console log" do
|
162
|
-
if subject.version >= "1.0.0"
|
163
|
-
subject.read_console_log(:debug, :info, :notice).should_not be_empty
|
164
|
-
subject.read_console_log('debug'..'emergency').should_not be_empty
|
165
|
-
subject.read_console_log(:info).should_not be_empty
|
166
|
-
subject.read_console_log(:foo).should be_empty
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'riak/test_server'
|
3
|
-
|
4
|
-
describe Riak::TestServer, :nodegen => true do
|
5
|
-
subject { test_server }
|
6
|
-
let(:app_config) { (subject.etc + 'app.config').read }
|
7
|
-
|
8
|
-
it "should add the test backends to the code path" do
|
9
|
-
erl_src = File.expand_path("../../../../erl_src", __FILE__)
|
10
|
-
subject.env[:riak_kv][:add_paths].should include(erl_src)
|
11
|
-
app_config.should match(/\{add_paths, \[.*#{erl_src.inspect}.*\]\}/)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should use the KV test backend" do
|
15
|
-
backend = if subject.version < "1.0.0"
|
16
|
-
:riak_kv_test014_backend
|
17
|
-
elsif subject.version < "1.2.0"
|
18
|
-
:riak_kv_test_backend
|
19
|
-
else
|
20
|
-
:riak_kv_memory_backend
|
21
|
-
end
|
22
|
-
subject.kv_backend.should == backend
|
23
|
-
subject.env[:riak_kv][:storage_backend].should == backend
|
24
|
-
app_config.should include("{storage_backend, #{backend}}")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should use the Search test backend" do
|
28
|
-
subject.search_backend.should == :riak_search_test_backend
|
29
|
-
subject.env[:riak_search][:search_backend].should == :riak_search_test_backend
|
30
|
-
app_config.should include("{search_backend, riak_search_test_backend}")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should clear stored data" do
|
34
|
-
# TODO: use $test_server.to_host when client/host split is finished.
|
35
|
-
client = Riak::Client.new(:http_port => subject.http_port)
|
36
|
-
obj = client['test_bucket'].new("test_item")
|
37
|
-
obj.data = {"data" => "testing"}
|
38
|
-
obj.store # rescue nil
|
39
|
-
|
40
|
-
subject.drop
|
41
|
-
expect {
|
42
|
-
client['test_bucket']['test_item']
|
43
|
-
}.to raise_error(Riak::FailedRequest)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should not clobber user-specified paths in riak_kv/add_paths [seancribbs/ripple #256]", :test_server => false do
|
47
|
-
# clean up the existing directory so the config is not overwritten
|
48
|
-
test_server.send(:delete)
|
49
|
-
config = {
|
50
|
-
:root => subject.root,
|
51
|
-
:source => subject.source,
|
52
|
-
:env => {:riak_kv => {:add_paths => ["app/mapreduce/erlang"]}}
|
53
|
-
}
|
54
|
-
ts = described_class.new(config)
|
55
|
-
ts.env[:riak_kv][:add_paths].should include("app/mapreduce/erlang")
|
56
|
-
end
|
57
|
-
end
|