Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add 2I support to TestServer backend #35

Merged
merged 8 commits into from Apr 17, 2012
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
@@ -25,18 +25,18 @@
]).
-include_lib("riak_search/include/riak_search.hrl").
-
+-define(T(P), list_to_atom("rs" ++ integer_to_list(P))).
-record(state, {partition, table}).
reset() ->
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
- [ ets:delete_all_objects(list_to_atom("rs" ++ integer_to_list(P))) ||
+ [ catch ets:delete_all_objects(?T(P)) ||
P <- riak_core_ring:my_indices(Ring) ],
riak_search_config:clear(),
ok.
start(Partition, _Config) ->
- Table = ets:new(list_to_atom("rs" ++ integer_to_list(Partition)),
+ Table = ets:new(?T(Partition),
[named_table, public, ordered_set]),
{ok, #state{partition=Partition, table=Table}}.
@@ -167,6 +167,7 @@ def configure_data
def configure_logging
if env[:lager]
env[:lager][:handlers] = {
+ :lager_console_backend => :info,
:lager_file_backend => [
Tuple[(log+"error.log").expand_path.to_s, :error],
Tuple[(log+"console.log").expand_path.to_s, :info]
View
@@ -30,7 +30,6 @@ def self.open(node)
def initialize(pipedir, nodename)
@nodename = nodename
@mutex = Mutex.new
- @winch = Signal.trap("WINCH", &method(:handle_winch))
@prompt = /\(#{Regexp.escape(nodename)}\)\d+>\s*/
pipedir = Pathname(pipedir)
pipedir.children.each do |path|
@@ -108,12 +107,6 @@ def close
end
protected
- # Handles the "window change" signal by faking it.
- def handle_winch
- debug "WINCHED!"
- @w.print "\033_winsize=80,26\033\\"
- Signal.trap("WINCH", &method(:handle_winch))
- end
def debug(msg)
$stderr.puts msg if ENV["DEBUG_RIAK_CONSOLE"]
View
@@ -17,6 +17,9 @@ def initialize(configuration = {})
configuration[:env] ||= {}
configuration[:env][:riak_kv] ||= {}
(configuration[:env][:riak_kv][:add_paths] ||= []) << File.expand_path("../../../erl_src", __FILE__)
+ configuration[:env][:riak_kv][:test] = true
+ configuration[:env][:memory_backend] ||={}
+ configuration[:env][:memory_backend][:test] = true
configuration[:env][:riak_search] ||= {}
configuration[:env][:riak_search][:search_backend] = :riak_search_test_backend
super configuration
@@ -75,8 +78,11 @@ def configure_data
super
if version < "1.0.0"
env[:riak_kv][:storage_backend] = :riak_kv_test014_backend
- else
+ elsif version =~ /^1\.[01]\.\d+$/ # 1.0 and 1.1 series
env[:riak_kv][:storage_backend] = :riak_kv_test_backend
+ else
+ # TODO: change this when 1.2+ is released, if it includes riak_kv#314
+ env[:riak_kv][:storage_backend] = :riak_kv_memory_backend
end
end
end
@@ -241,6 +241,27 @@
end
end
+ # get_index
+ context "querying secondary indexes" do
+ before do
+ 50.times do |i|
+ @client.bucket('test').new(i.to_s).tap do |obj|
+ obj.indexes["index_int"] << i
+ obj.data = [i]
+ @backend.store_object(obj)
+ end
+ end
+ end
+
+ it "should find keys for an equality query" do
+ @backend.get_index('test', 'index_int', 20).should == ["20"]
+ end
+
+ it "should find keys for a range query" do
+ @backend.get_index('test', 'index_int', 19..21).should =~ ["19","20", "21"]
+ end
+ end
+
# mapred
context "performing MapReduce" do
before do