riak-client 0.9.8 → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +32 -0
- data/Gemfile +17 -11
- data/Guardfile +14 -0
- data/Rakefile +18 -44
- data/erl_src/riak_kv_test_backend.beam +0 -0
- data/erl_src/riak_kv_test_backend.erl +461 -128
- data/erl_src/riak_search_test_backend.beam +0 -0
- data/erl_src/riak_search_test_backend.erl +175 -0
- data/lib/active_support/cache/riak_store.rb +0 -13
- data/lib/riak.rb +11 -16
- data/lib/riak/bucket.rb +59 -41
- data/lib/riak/cache_store.rb +1 -14
- data/lib/riak/client.rb +145 -73
- data/lib/riak/client/beefcake/messages.rb +36 -31
- data/lib/riak/client/beefcake/object_methods.rb +27 -19
- data/lib/riak/client/beefcake_protobuffs_backend.rb +27 -33
- data/lib/riak/client/excon_backend.rb +0 -13
- data/lib/riak/client/http_backend.rb +95 -60
- data/lib/riak/client/http_backend/configuration.rb +144 -19
- data/lib/riak/client/http_backend/key_streamer.rb +1 -14
- data/lib/riak/client/http_backend/object_methods.rb +16 -16
- data/lib/riak/client/http_backend/request_headers.rb +0 -13
- data/lib/riak/client/http_backend/transport_methods.rb +26 -56
- data/lib/riak/client/net_http_backend.rb +11 -13
- data/lib/riak/client/protobuffs_backend.rb +21 -19
- data/lib/riak/client/pump.rb +1 -15
- data/lib/riak/client/search.rb +85 -0
- data/lib/riak/cluster.rb +151 -0
- data/lib/riak/core_ext.rb +1 -0
- data/lib/riak/core_ext/deep_dup.rb +13 -0
- data/lib/riak/core_ext/json.rb +15 -0
- data/lib/riak/core_ext/stringify_keys.rb +1 -1
- data/lib/riak/core_ext/symbolize_keys.rb +1 -1
- data/lib/riak/encoding.rb +6 -0
- data/lib/riak/failed_request.rb +2 -15
- data/lib/riak/i18n.rb +0 -13
- data/lib/riak/json.rb +19 -8
- data/lib/riak/link.rb +18 -20
- data/lib/riak/locale/en.yml +13 -16
- data/lib/riak/map_reduce.rb +40 -20
- data/lib/riak/map_reduce/filter_builder.rb +14 -18
- data/lib/riak/map_reduce/phase.rb +0 -13
- data/lib/riak/map_reduce_error.rb +0 -13
- data/lib/riak/node.rb +38 -0
- data/lib/riak/node/configuration.rb +286 -0
- data/lib/riak/node/console.rb +139 -0
- data/lib/riak/node/control.rb +207 -0
- data/lib/riak/node/defaults.rb +70 -0
- data/lib/riak/node/generation.rb +99 -0
- data/lib/riak/node/log.rb +34 -0
- data/lib/riak/node/version.rb +37 -0
- data/lib/riak/robject.rb +45 -41
- data/lib/riak/search.rb +2 -161
- data/lib/riak/serializers.rb +74 -0
- data/lib/riak/stamp.rb +77 -0
- data/lib/riak/test_server.rb +56 -220
- data/lib/riak/util/escape.rb +58 -17
- data/lib/riak/util/headers.rb +2 -15
- data/lib/riak/util/multipart.rb +0 -13
- data/lib/riak/util/multipart/stream_parser.rb +0 -13
- data/lib/riak/util/tcp_socket_extensions.rb +1 -14
- data/lib/riak/util/translation.rb +0 -13
- data/lib/riak/version.rb +3 -0
- data/lib/riak/walk_spec.rb +0 -13
- data/riak-client.gemspec +27 -47
- data/spec/fixtures/multipart-with-marked-tombstones.txt +17 -0
- data/spec/fixtures/multipart-with-unmarked-tombstone.txt +16 -0
- data/spec/integration/riak/cache_store_spec.rb +2 -40
- data/spec/integration/riak/cluster_spec.rb +88 -0
- data/spec/integration/riak/http_backends_spec.rb +6 -30
- data/spec/integration/riak/node_spec.rb +184 -0
- data/spec/integration/riak/protobuffs_backends_spec.rb +2 -26
- data/spec/integration/riak/test_server_spec.rb +31 -167
- data/spec/riak/beefcake_protobuffs_backend_spec.rb +5 -4
- data/spec/riak/bucket_spec.rb +26 -36
- data/spec/riak/client_spec.rb +44 -38
- data/spec/riak/escape_spec.rb +56 -30
- data/spec/riak/excon_backend_spec.rb +4 -17
- data/spec/riak/headers_spec.rb +1 -14
- data/spec/riak/http_backend/configuration_spec.rb +211 -34
- data/spec/riak/http_backend/object_methods_spec.rb +52 -18
- data/spec/riak/http_backend/transport_methods_spec.rb +5 -38
- data/spec/riak/http_backend_spec.rb +84 -78
- data/spec/riak/link_spec.rb +19 -18
- data/spec/riak/map_reduce/filter_builder_spec.rb +1 -14
- data/spec/riak/map_reduce/phase_spec.rb +1 -14
- data/spec/riak/map_reduce_spec.rb +141 -43
- data/spec/riak/multipart_spec.rb +1 -14
- data/spec/riak/net_http_backend_spec.rb +2 -15
- data/spec/riak/robject_spec.rb +129 -97
- data/spec/riak/search_spec.rb +45 -62
- data/spec/riak/serializers_spec.rb +93 -0
- data/spec/riak/stamp_spec.rb +54 -0
- data/spec/riak/stream_parser_spec.rb +3 -16
- data/spec/riak/walk_spec_spec.rb +1 -14
- data/spec/spec_helper.rb +22 -27
- data/spec/support/http_backend_implementation_examples.rb +49 -79
- data/spec/support/integration_setup.rb +10 -0
- data/spec/support/mock_server.rb +0 -14
- data/spec/support/mocks.rb +0 -13
- data/spec/support/test_server.rb +30 -0
- data/spec/support/test_server.yml.example +14 -2
- data/spec/support/unified_backend_examples.rb +36 -27
- metadata +100 -31
- data/lib/riak/client/curb_backend.rb +0 -89
- data/spec/riak/curb_backend_spec.rb +0 -76
data/lib/riak/util/headers.rb
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
1
|
require 'net/http'
|
15
2
|
|
16
3
|
# Splits headers into < 8KB chunks
|
@@ -44,7 +31,7 @@ module Riak
|
|
44
31
|
def initialize
|
45
32
|
initialize_http_header({})
|
46
33
|
end
|
47
|
-
|
34
|
+
|
48
35
|
# Parse a single header line into its key and value
|
49
36
|
# @param [String] chunk a single header line
|
50
37
|
def self.parse(chunk)
|
@@ -54,7 +41,7 @@ module Riak
|
|
54
41
|
m = /\A([^:]+):\s*/.match(line)
|
55
42
|
[m[1], m.post_match] rescue [nil, nil]
|
56
43
|
end
|
57
|
-
|
44
|
+
|
58
45
|
# Parses a header line and adds it to the header collection
|
59
46
|
# @param [String] chunk a single header line
|
60
47
|
def parse(chunk)
|
data/lib/riak/util/multipart.rb
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
1
|
require 'riak/util/headers'
|
15
2
|
|
16
3
|
module Riak
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License
|
14
1
|
require 'riak/util/translation'
|
15
2
|
require 'riak/util/multipart'
|
16
3
|
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
1
|
require 'time'
|
15
2
|
require 'timeout'
|
16
3
|
require 'socket'
|
@@ -18,7 +5,7 @@ require 'socket'
|
|
18
5
|
# Borrowed from Webrat and Selenium client, watches for TCP port
|
19
6
|
# liveness of the spawned server.
|
20
7
|
# @private
|
21
|
-
class TCPSocket
|
8
|
+
class TCPSocket
|
22
9
|
def self.wait_for_service(options)
|
23
10
|
verbose_wait until listening_service?(options)
|
24
11
|
end
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
1
|
require 'riak/i18n'
|
15
2
|
|
16
3
|
module Riak
|
data/lib/riak/version.rb
ADDED
data/lib/riak/walk_spec.rb
CHANGED
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
1
|
require 'riak/util/translation'
|
15
2
|
require 'riak/util/escape'
|
16
3
|
require 'riak/link'
|
data/riak-client.gemspec
CHANGED
@@ -1,51 +1,31 @@
|
|
1
|
-
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'riak/version'
|
2
3
|
|
3
|
-
Gem::Specification.new do |
|
4
|
-
|
5
|
-
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
# Meta
|
6
|
+
gem.name = "riak-client"
|
7
|
+
gem.version = Riak::VERSION
|
8
|
+
gem.summary = %Q{riak-client is a rich client for Riak, the distributed database by Basho.}
|
9
|
+
gem.description = %Q{riak-client is a rich client for Riak, the distributed database by Basho. It supports the full HTTP and Protocol Buffers interfaces including storage operations, bucket configuration, link-walking, secondary indexes and map-reduce.}
|
10
|
+
gem.email = ["sean@basho.com"]
|
11
|
+
gem.homepage = "http://seancribbs.github.com/ripple"
|
12
|
+
gem.authors = ["Sean Cribbs"]
|
6
13
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
s.test_files = [%q{spec/integration/riak/cache_store_spec.rb}, %q{spec/integration/riak/http_backends_spec.rb}, %q{spec/integration/riak/protobuffs_backends_spec.rb}, %q{spec/integration/riak/test_server_spec.rb}, %q{spec/riak/beefcake_protobuffs_backend_spec.rb}, %q{spec/riak/bucket_spec.rb}, %q{spec/riak/client_spec.rb}, %q{spec/riak/core_ext/to_param_spec.rb}, %q{spec/riak/curb_backend_spec.rb}, %q{spec/riak/escape_spec.rb}, %q{spec/riak/excon_backend_spec.rb}, %q{spec/riak/headers_spec.rb}, %q{spec/riak/http_backend/configuration_spec.rb}, %q{spec/riak/http_backend/object_methods_spec.rb}, %q{spec/riak/http_backend/transport_methods_spec.rb}, %q{spec/riak/http_backend_spec.rb}, %q{spec/riak/link_spec.rb}, %q{spec/riak/map_reduce/filter_builder_spec.rb}, %q{spec/riak/map_reduce/phase_spec.rb}, %q{spec/riak/map_reduce_spec.rb}, %q{spec/riak/multipart_spec.rb}, %q{spec/riak/net_http_backend_spec.rb}, %q{spec/riak/robject_spec.rb}, %q{spec/riak/search_spec.rb}, %q{spec/riak/stream_parser_spec.rb}, %q{spec/riak/walk_spec_spec.rb}]
|
14
|
+
# Deps
|
15
|
+
gem.add_development_dependency "rspec", "~>2.6.0"
|
16
|
+
gem.add_development_dependency "fakeweb", ">=1.2"
|
17
|
+
gem.add_development_dependency "rack", ">=1.0"
|
18
|
+
gem.add_development_dependency "excon", "~>0.6.1"
|
19
|
+
gem.add_development_dependency 'rake', '~> 0.8.7'
|
20
|
+
gem.add_runtime_dependency "i18n", ">=0.4.0"
|
21
|
+
gem.add_runtime_dependency "builder", ">= 2.1.2"
|
22
|
+
gem.add_runtime_dependency "beefcake", "~>0.3.7"
|
23
|
+
gem.add_runtime_dependency "multi_json", "~>1.0.0"
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
s.add_development_dependency(%q<rack>, [">= 1.0"])
|
26
|
-
s.add_development_dependency(%q<curb>, [">= 0.6"])
|
27
|
-
s.add_development_dependency(%q<excon>, ["~> 0.5.7"])
|
28
|
-
s.add_runtime_dependency(%q<i18n>, [">= 0.4.0"])
|
29
|
-
s.add_runtime_dependency(%q<builder>, ["~> 2.1.2"])
|
30
|
-
s.add_runtime_dependency(%q<beefcake>, ["= 0.3.2"])
|
31
|
-
else
|
32
|
-
s.add_dependency(%q<rspec>, ["~> 2.4.0"])
|
33
|
-
s.add_dependency(%q<fakeweb>, [">= 1.2"])
|
34
|
-
s.add_dependency(%q<rack>, [">= 1.0"])
|
35
|
-
s.add_dependency(%q<curb>, [">= 0.6"])
|
36
|
-
s.add_dependency(%q<excon>, ["~> 0.5.7"])
|
37
|
-
s.add_dependency(%q<i18n>, [">= 0.4.0"])
|
38
|
-
s.add_dependency(%q<builder>, ["~> 2.1.2"])
|
39
|
-
s.add_dependency(%q<beefcake>, ["= 0.3.2"])
|
40
|
-
end
|
41
|
-
else
|
42
|
-
s.add_dependency(%q<rspec>, ["~> 2.4.0"])
|
43
|
-
s.add_dependency(%q<fakeweb>, [">= 1.2"])
|
44
|
-
s.add_dependency(%q<rack>, [">= 1.0"])
|
45
|
-
s.add_dependency(%q<curb>, [">= 0.6"])
|
46
|
-
s.add_dependency(%q<excon>, ["~> 0.5.7"])
|
47
|
-
s.add_dependency(%q<i18n>, [">= 0.4.0"])
|
48
|
-
s.add_dependency(%q<builder>, ["~> 2.1.2"])
|
49
|
-
s.add_dependency(%q<beefcake>, ["= 0.3.2"])
|
50
|
-
end
|
25
|
+
# Files
|
26
|
+
ignores = File.read(".gitignore").split(/\r?\n/).reject{ |f| f =~ /^(#.+|\s*)$/ }.map {|f| Dir[f] }.flatten
|
27
|
+
gem.files = (Dir['**/*','.gitignore'] - ignores).reject {|f| !File.file?(f) }
|
28
|
+
gem.test_files = (Dir['spec/**/*','.gitignore'] - ignores).reject {|f| !File.file?(f) }
|
29
|
+
# gem.executables = Dir['bin/*'].map { |f| File.basename(f) }
|
30
|
+
gem.require_paths = ['lib']
|
51
31
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
--ADqgQtdmA5iQgyR5UGzX6V3HZtI
|
3
|
+
Content-Type: multipart/mixed; boundary=Ljz1mP3hZzqPu6DH1Y4L8k7hfxy
|
4
|
+
|
5
|
+
--Ljz1mP3hZzqPu6DH1Y4L8k7hfxy
|
6
|
+
X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fvrNPcuWwZTIlMfKIOotdIIvCwA=
|
7
|
+
Location: /buckets/links/keys/target
|
8
|
+
Content-Type: application/octet-stream
|
9
|
+
Link: </buckets/links>; rel="up"
|
10
|
+
Etag: 5bUNdzHJhZDdCr7KlWxXq
|
11
|
+
Last-Modified: Tue, 18 Oct 2011 19:10:13 GMT
|
12
|
+
X-Riak-Deleted: true
|
13
|
+
|
14
|
+
|
15
|
+
--Ljz1mP3hZzqPu6DH1Y4L8k7hfxy--
|
16
|
+
|
17
|
+
--ADqgQtdmA5iQgyR5UGzX6V3HZtI--
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
--CvfrSTCWwIiwezy0Zt1B2zwKgS7
|
3
|
+
Content-Type: multipart/mixed; boundary=E9n2ZOKHIazIoPHzXj9XsWYWJjJ
|
4
|
+
|
5
|
+
--E9n2ZOKHIazIoPHzXj9XsWYWJjJ
|
6
|
+
X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fvpN53+WwZTIlMfKcNVJ6ARfFgA=
|
7
|
+
Location: /buckets/links/keys/target
|
8
|
+
Content-Type: application/octet-stream
|
9
|
+
Link: </buckets/links>; rel="up"
|
10
|
+
Etag: 50FOyLo7juvEVUO33MRJwP
|
11
|
+
Last-Modified: Tue, 18 Oct 2011 18:35:01 GMT
|
12
|
+
|
13
|
+
|
14
|
+
--E9n2ZOKHIazIoPHzXj9XsWYWJjJ--
|
15
|
+
|
16
|
+
--CvfrSTCWwIiwezy0Zt1B2zwKgS7--
|
@@ -1,51 +1,13 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require File.expand_path("../../spec_helper", File.dirname(__FILE__))
|
1
|
+
require 'spec_helper'
|
15
2
|
require 'riak/cache_store'
|
16
3
|
|
17
4
|
describe Riak::CacheStore do
|
18
|
-
before :all do
|
19
|
-
if $test_server
|
20
|
-
@web_port = 9000
|
21
|
-
$test_server.start
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
5
|
before do
|
26
|
-
@web_port
|
6
|
+
@web_port = $test_server.http_port
|
27
7
|
@cache = ActiveSupport::Cache.lookup_store(:riak_store, :http_port => @web_port)
|
28
|
-
@cleanup = true
|
29
|
-
end
|
30
|
-
|
31
|
-
after do
|
32
|
-
if @cleanup
|
33
|
-
if $test_server
|
34
|
-
$test_server.recycle
|
35
|
-
Thread.current[:curl_easy_handle] = nil
|
36
|
-
else
|
37
|
-
@cache.bucket.keys(:force => true).each do |k|
|
38
|
-
@cache.bucket.delete(k, :rw => 1) unless k.blank?
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
8
|
end
|
43
9
|
|
44
10
|
describe "Riak integration" do
|
45
|
-
before do
|
46
|
-
@cleanup = false
|
47
|
-
end
|
48
|
-
|
49
11
|
it "should have a client" do
|
50
12
|
@cache.should respond_to(:client)
|
51
13
|
@cache.client.should be_kind_of(Riak::Client)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'riak/cluster'
|
3
|
+
|
4
|
+
describe Riak::Cluster, :test_server => false, :slow => 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,36 +1,12 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require File.expand_path("../../spec_helper", File.dirname(__FILE__))
|
1
|
+
require 'spec_helper'
|
15
2
|
|
16
3
|
describe "HTTP" do
|
17
|
-
before :all do
|
18
|
-
if $test_server
|
19
|
-
@web_port = 9000
|
20
|
-
$test_server.start
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
4
|
before do
|
25
|
-
@web_port
|
5
|
+
@web_port = $test_server.http_port
|
26
6
|
@client = Riak::Client.new(:http_port => @web_port)
|
27
7
|
end
|
28
8
|
|
29
|
-
|
30
|
-
$test_server.recycle if $test_server.started?
|
31
|
-
end
|
32
|
-
|
33
|
-
[:CurbBackend, :ExconBackend, :NetHTTPBackend].each do |klass|
|
9
|
+
[:ExconBackend, :NetHTTPBackend].each do |klass|
|
34
10
|
bklass = Riak::Client.const_get(klass)
|
35
11
|
if bklass.configured?
|
36
12
|
describe klass.to_s do
|
@@ -63,9 +39,9 @@ describe "HTTP" do
|
|
63
39
|
let(:sized) { Reader.new(["foo", "bar", "baz"]) }
|
64
40
|
let(:sizeless) { SizelessReader.new(["foo", "bar", "baz"]) }
|
65
41
|
it "should set the content-length or transfer-encoding properly on IO uploads" do
|
66
|
-
lambda { subject.put(204,
|
67
|
-
lambda { subject.put(204,
|
68
|
-
lambda { subject.put(204,
|
42
|
+
lambda { subject.put(204, subject.object_path('nethttp', 'test-file'), file, {"Content-Type" => "text/plain"}) }.should_not raise_error
|
43
|
+
lambda { subject.put(204, subject.object_path('nethttp', 'test-sized'), sized, {"Content-Type" => "text/plain"}) }.should_not raise_error
|
44
|
+
lambda { subject.put(204, subject.object_path('nethttp', 'test-sizeless'), sizeless, {"Content-Type" => "text/plain"}) }.should_not raise_error
|
69
45
|
end
|
70
46
|
end
|
71
47
|
end
|