Permalink
Browse files

insert1.js runs without assertions

  • Loading branch information...
1 parent 2efd2d2 commit 5c75b8fc16292be8311efda926e6b6c2c3ea6242 @pavlobaron committed Apr 30, 2012
Showing with 22 additions and 10 deletions.
  1. +5 −1 src/riak_mongo_message.erl
  2. +1 −1 src/riak_mongo_protocol.erl
  3. +14 −6 src/riak_mongo_riak.erl
  4. +1 −1 src/riak_mongo_worker.erl
  5. +1 −1 test/test.sh
@@ -33,6 +33,7 @@
-define(CMD, <<"$cmd">>).
-define(ADM, <<"admin">>).
-define(DROP, <<"drop">>).
+-define(COLLSTATS, <<"collstats">>).
%%
%% loop over messages
@@ -136,11 +137,14 @@ db_command(_DataBase, <<"getlasterror">>, _Collection, _Options, State) ->
end;
db_command(DataBase, ?DROP, Collection, _Options, State) ->
- NewState = riak_mongo_riak:delete(#mongo_delete{singleremove=false, selector={},
+ NewState = riak_mongo_riak:delete(#mongo_delete{singleremove=false, selector={struct, []},
dbcoll=riak_mongo_protocol:join_dbcoll({DataBase, Collection})},
State),
{ok, [{ok,true}], NewState};
+db_command(DataBase, ?COLLSTATS, Collection, _Options, State) ->
+ riak_mongo_riak:stats(riak_mongo_protocol:join_dbcoll({DataBase, Collection}), State);
+
db_command(DataBase, Command, Collection, _Options, State) ->
error_logger:info_msg("unhandled command: ~p, ~p:~p~n", [Command, DataBase, Collection]),
{ok, [{err, <<"unknown command: db=", DataBase, ", cmd=", Command/binary>>}, {ok, false}], State}.
@@ -148,7 +148,7 @@ split_dbcoll(Bin) ->
{DB, Coll}.
join_dbcoll({Db, Col}) ->
- <<Db/binary, ":", Col/binary>>.
+ <<Db/binary, ".", Col/binary>>.
encode_packet(#mongo_reply{
request_id=RequestId,
View
@@ -31,11 +31,19 @@
-compile([{parse_transform, lager_transform}]).
--export([insert/2, find/2, getmore/2, delete/2, update/2]).
+-export([insert/2, find/2, getmore/2, delete/2, update/2, stats/2]).
-define(DEFAULT_TIMEOUT, 60000).
-define(DEFAULT_FIND_SIZE, 101).
+%% however we map this, first step is to hardcode some values
+%% used by JS tests and see how they can be dynamized
+stats(Bucket, State) ->
+ Doc = [{ns, {utf8, binary_to_list(Bucket)}},
+ {paddingFactor, 1},
+ {ok, 1}],
+ {ok, Doc, State}.
+
insert(#mongo_insert{dbcoll=Bucket, documents=Docs, continueonerror=ContinueOnError}, State) ->
{ok, C} = riak:local_client(),
@@ -171,7 +179,6 @@ delete(#mongo_delete{dbcoll=Bucket, selector=Selector, singleremove=SingleRemove
end;
false when not SingleRemove ->
-
Project = fun(RiakObject, _) ->
{ok, C} = riak:local_client(),
case C:delete(Bucket, riak_object:key(RiakObject)) of
@@ -181,12 +188,10 @@ delete(#mongo_delete{dbcoll=Bucket, selector=Selector, singleremove=SingleRemove
end,
CompiledQuery = riak_mongo_query:compile(Selector),
-
{ok, Errors}
= riak_kv_mrc_pipe:mapred(Bucket,
[{map, {qfun, fun map_query/3}, {CompiledQuery, Project}, true}]),
-
State#worker_state{ lastError=Errors };
false when SingleRemove ->
@@ -323,7 +328,7 @@ cursor_get_results(CursorPID, BatchSize) ->
{done, Ref, StartingFrom, Documents} ->
erlang:demonitor(Ref, [flush]),
{done, StartingFrom, Documents};
- {'DOWN', Ref, _, _, Reason} ->
+ {'DOWN', Ref, _, _, _Reason} ->
{done, 0, []}
end.
@@ -440,7 +445,10 @@ bson_to_riak_key({uuid, BIN}) ->
bson_to_riak_key({md5, BIN}) ->
iolist_to_binary("MD5:" ++ hexencode(BIN));
bson_to_riak_key(BIN) when is_binary(BIN) ->
- BIN.
+ BIN;
+bson_to_riak_key(null) ->
+ iolist_to_binary("UUID:" ++
+ hexencode(list_to_binary(riak_core_util:unique_id_62()))).
hexencode(<<>>) -> [];
hexencode(<<CH, Rest/binary>>) ->
@@ -50,7 +50,7 @@ handle_info({tcp, Sock, Data}, State) ->
State3 = State2#worker_state{rest=Rest},
{noreply, State3};
-handle_info({tcp_closed, _Sock}, _) -> {reply, ok};
+handle_info({tcp_closed, _Sock}, State) -> {noreply, State};
handle_info(?CONTROL_MSG, State) ->
error_logger:info_msg("Having control: ~p~n", [State#worker_state.sock]),
View
@@ -3,7 +3,7 @@
if test -z $1
then
JS=""
- DB="riak"
+ DB="test"
else
cd mongo
git update

0 comments on commit 5c75b8f

Please sign in to comment.