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
data/spec/support/mock_server.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Based on code from Rob Styles and Chris Tierney found at:
|
3
|
-
# http://dynamicorange.com/2009/02/18/ruby-mock-web-server/
|
4
|
-
require 'rack'
|
5
|
-
require 'openssl'
|
6
|
-
require 'webrick/https'
|
7
|
-
require 'rack/handler/webrick'
|
8
|
-
|
9
|
-
class MockServer
|
10
|
-
attr_accessor :port
|
11
|
-
attr_accessor :satisfied
|
12
|
-
|
13
|
-
def initialize(pause = 1)
|
14
|
-
self.port = 4000 + rand(61535)
|
15
|
-
@block = nil
|
16
|
-
@parent_thread = Thread.current
|
17
|
-
options = {:AccessLog => [], :Logger => NullLogger.new, :Host => '127.0.0.1'}
|
18
|
-
@thread = Thread.new do
|
19
|
-
Rack::Handler::WEBrick.run(self, options.merge(:Port => port))
|
20
|
-
end
|
21
|
-
@ssl_thread = Thread.new do
|
22
|
-
Rack::Handler::WEBrick.run(self, options.merge(:Port => port+1,
|
23
|
-
:SSLEnable => true,
|
24
|
-
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
|
25
|
-
:SSLCertificate => read_cert,
|
26
|
-
:SSLPrivateKey => read_pkey,
|
27
|
-
:SSLCertName => [ [ "CN",'127.0.0.1' ] ]))
|
28
|
-
end
|
29
|
-
sleep pause # give the server time to fire up… YUK!
|
30
|
-
end
|
31
|
-
|
32
|
-
def stop
|
33
|
-
Thread.kill(@thread)
|
34
|
-
Thread.kill(@ssl_thread)
|
35
|
-
end
|
36
|
-
|
37
|
-
def expect(status, headers, method, path, query, body)
|
38
|
-
attach do |env|
|
39
|
-
@satisfied = (env["REQUEST_METHOD"] == method &&
|
40
|
-
env["PATH_INFO"] == path &&
|
41
|
-
env["QUERY_STRING"] == query)
|
42
|
-
[status, headers, Array(body)]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def attach(&block)
|
47
|
-
@block = block
|
48
|
-
end
|
49
|
-
|
50
|
-
def detach()
|
51
|
-
@block = nil
|
52
|
-
end
|
53
|
-
|
54
|
-
def call(env)
|
55
|
-
begin
|
56
|
-
raise "Specify a handler for the request using attach(block), the block should return a valid rack response and can test expectations" unless @block
|
57
|
-
@block.call(env)
|
58
|
-
rescue Exception => e
|
59
|
-
@satisfied = false
|
60
|
-
# @parent_thread.raise e
|
61
|
-
body = "Bad test code\n#{e.inspect}\n#{e.backtrace}"
|
62
|
-
[ 500, { 'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [ body ]]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def read_pkey
|
67
|
-
OpenSSL::PKey::RSA.new(File.read(File.expand_path(File.dirname(__FILE__) + '/../fixtures/server.cert.key')), 'ripple')
|
68
|
-
end
|
69
|
-
|
70
|
-
def read_cert
|
71
|
-
OpenSSL::X509::Certificate.new(File.read((File.expand_path(File.dirname(__FILE__) + '/../fixtures/server.cert.crt'))))
|
72
|
-
end
|
73
|
-
|
74
|
-
class NullLogger
|
75
|
-
def fatal(msg) end
|
76
|
-
def error(msg) end
|
77
|
-
def warn(msg) end
|
78
|
-
def info(msg) end
|
79
|
-
def debug(msg) end
|
80
|
-
end
|
81
|
-
end
|
data/spec/support/mocks.rb
DELETED
data/spec/support/riak_test.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'riak/test_server'
|
2
|
-
|
3
|
-
# This class is used for running the integration suite against
|
4
|
-
# existing Riak nodes that have been preconfigured for test mode, e.g.
|
5
|
-
# as part of the riak_test integration suite. This is only supported
|
6
|
-
# on Riak versions > 1.2, with the KV backend set to memory with the
|
7
|
-
# 'test' flag, and the Search backend set to the backend bundled with
|
8
|
-
# the client (called riak_search_test_backend).
|
9
|
-
class PrebuiltTestServer
|
10
|
-
def self.valid?
|
11
|
-
%W{RIAK_ROOT_DIR RIAK_NODE_NAME HTTP_PORT PB_PORT RIAK_VERSION}.all? {|e| ENV[e] }
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_reader :http_port, :pb_port, :version, :root, :name
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@root = Pathname(ENV['RIAK_ROOT_DIR'])
|
18
|
-
@name = ENV['RIAK_NODE_NAME'].dup
|
19
|
-
@version = ENV['RIAK_VERSION'].dup[/\d+\.\d+\.\d+/, 0]
|
20
|
-
@http_port = ENV['HTTP_PORT'].to_i
|
21
|
-
@pb_port = ENV['PB_PORT'].to_i
|
22
|
-
end
|
23
|
-
|
24
|
-
def pipe
|
25
|
-
# Have to remove leading slash on root
|
26
|
-
@pipe ||= Pathname("/tmp") + @root.to_s[1..-1]
|
27
|
-
end
|
28
|
-
|
29
|
-
def exist?; true; end
|
30
|
-
def stop; end
|
31
|
-
def start; end
|
32
|
-
def started?; true; end
|
33
|
-
|
34
|
-
def drop
|
35
|
-
begin
|
36
|
-
maybe_attach
|
37
|
-
@console.command "riak_kv_memory_backend:reset()."
|
38
|
-
@console.command "riak_search_test_backend:reset()."
|
39
|
-
rescue IOError
|
40
|
-
retry
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def attach
|
45
|
-
Riak::Node::Console.open self
|
46
|
-
end
|
47
|
-
|
48
|
-
protected
|
49
|
-
# Tries to reattach the console if it's closed
|
50
|
-
def maybe_attach
|
51
|
-
unless open?
|
52
|
-
@console.close if @console && !@console.frozen?
|
53
|
-
@console = attach
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def open?
|
58
|
-
@console && @console.open?
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
module PrebuiltTestServerSupport
|
63
|
-
def test_server
|
64
|
-
unless $test_server
|
65
|
-
if PrebuiltTestServer.valid?
|
66
|
-
$test_server = PrebuiltTestServer.new
|
67
|
-
else
|
68
|
-
super
|
69
|
-
end
|
70
|
-
end
|
71
|
-
$test_server
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
RSpec.configure do |config|
|
76
|
-
config.include PrebuiltTestServerSupport, :integration => true
|
77
|
-
end
|
data/spec/support/sometimes.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# Emulates the QuickCheck ?SOMETIMES macro.
|
2
|
-
|
3
|
-
module Sometimes
|
4
|
-
def run_with_retries(example_to_run, retries)
|
5
|
-
self.example.metadata[:retries] ||= retries
|
6
|
-
retries.times do |t|
|
7
|
-
self.example.metadata[:retried] = t + 1
|
8
|
-
self.example.instance_variable_set(:@exception, nil)
|
9
|
-
example_to_run.run
|
10
|
-
break unless self.example.exception
|
11
|
-
end
|
12
|
-
if e = self.example.exception
|
13
|
-
new_exception = e.exception(e.message + "[Retried #{retries} times]")
|
14
|
-
new_exception.set_backtrace e.backtrace
|
15
|
-
self.example.instance_variable_set(:@exception, new_exception)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
RSpec.configure do |config|
|
21
|
-
config.include Sometimes
|
22
|
-
config.alias_example_to :sometimes, :sometimes => true
|
23
|
-
config.add_setting :sometimes_retry_count, :default => 3
|
24
|
-
|
25
|
-
config.around(:each, :sometimes => true) do |example|
|
26
|
-
retries = example.metadata[:retries] || RSpec.configuration.sometimes_retry_count
|
27
|
-
run_with_retries(example, retries)
|
28
|
-
end
|
29
|
-
|
30
|
-
config.after(:suite) do
|
31
|
-
formatter = RSpec.configuration.formatters.first
|
32
|
-
color = lambda {|tint, msg| formatter.send(tint, msg) }
|
33
|
-
retried_examples = RSpec.world.example_groups.map do |g|
|
34
|
-
g.descendants.map do |d|
|
35
|
-
d.filtered_examples.select {|e| e.metadata[:sometimes] && e.metadata[:retried] > 1 }
|
36
|
-
end
|
37
|
-
end.flatten
|
38
|
-
formatter.message color[retried_examples.empty? ? :success_color : :pending_color, "\n\nRetried examples: #{retried_examples.count}"]
|
39
|
-
unless retried_examples.empty?
|
40
|
-
retried_examples.each do |e|
|
41
|
-
formatter.message " #{e.full_description}"
|
42
|
-
formatter.message(color[:pending_color, " [#{e.metadata[:retried]}/#{e.metadata[:retries]}] "] + RSpec::Core::Metadata::relative_path(e.location))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
data/spec/support/test_server.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'riak/test_server'
|
2
|
-
|
3
|
-
module TestServerSupport
|
4
|
-
def test_server
|
5
|
-
unless $test_server
|
6
|
-
begin
|
7
|
-
require 'yaml'
|
8
|
-
config = YAML.load_file(File.expand_path("../test_server.yml", __FILE__))
|
9
|
-
$test_server = Riak::TestServer.create(:root => config['root'],
|
10
|
-
:source => config['source'],
|
11
|
-
:min_port => config['min_port'] || 15000)
|
12
|
-
rescue SocketError => e
|
13
|
-
warn "Couldn't connect to Riak TestServer! #{$test_server.inspect}"
|
14
|
-
warn "Skipping remaining integration tests."
|
15
|
-
warn_crash_log
|
16
|
-
$test_server_fatal = e
|
17
|
-
rescue => e
|
18
|
-
warn "Can't run integration specs without the test server. Please create/verify spec/support/test_server.yml."
|
19
|
-
warn "Skipping remaining integration tests."
|
20
|
-
warn e.inspect
|
21
|
-
warn_crash_log
|
22
|
-
$test_server_fatal = e
|
23
|
-
end
|
24
|
-
end
|
25
|
-
$test_server
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_server_fatal
|
29
|
-
$test_server_fatal
|
30
|
-
end
|
31
|
-
|
32
|
-
def warn_crash_log
|
33
|
-
if $test_server && crash_log = $test_server.log + 'crash.log'
|
34
|
-
warn crash_log.read if crash_log.exist?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
RSpec.configure do |config|
|
40
|
-
config.include TestServerSupport, :integration => true
|
41
|
-
|
42
|
-
config.before(:each, :integration => true) do
|
43
|
-
fail "Test server not working: #{test_server_fatal}" if test_server_fatal
|
44
|
-
if example.metadata[:test_server] == false
|
45
|
-
test_server.stop
|
46
|
-
else
|
47
|
-
test_server.create unless test_server.exist?
|
48
|
-
test_server.start
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
config.after(:each, :integration => true) do
|
53
|
-
if test_server && !test_server_fatal && test_server.started? && example.metadata[:test_server] != false
|
54
|
-
test_server.drop
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
config.after(:suite) do
|
59
|
-
$test_server.stop if $test_server
|
60
|
-
end
|
61
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# This is where the test server node will be generated. Something on
|
2
|
-
# /tmp is usually ok.
|
3
|
-
root: /tmp/riak-client-test-server
|
4
|
-
|
5
|
-
# This is where Riak is installed on your system, that is, the path to
|
6
|
-
# the 'riak' and 'riak-admin' scripts. I use a self-built node, but
|
7
|
-
# here's where it will generally be on various platforms:
|
8
|
-
#
|
9
|
-
# Linux: /usr/sbin
|
10
|
-
# Solaris/OpenSolaris: /opt/riak/bin
|
11
|
-
# Mac OS/X (Homebrew): /usr/local/bin
|
12
|
-
# Source/Self built: /path/to/your/install/rel/riak/bin
|
13
|
-
#
|
14
|
-
source: /Users/sean/Development/riak/rel/riak/bin
|