iilyak closed pull request #1798: Suppress compiler warnings
URL: https://github.com/apache/couchdb/pull/1798
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/rebar.config.script b/rebar.config.script
index 5f17c29e0c..85cc20f886 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -27,12 +27,13 @@ SubDirs = [
"src/couch_log",
"src/chttpd",
"src/couch",
+ "src/couch_event",
+ "src/mem3",
"src/couch_index",
"src/couch_mrview",
"src/couch_replicator",
"src/couch_plugins",
"src/couch_pse_tests",
- "src/couch_event",
"src/couch_stats",
"src/couch_peruser",
"src/couch_tests",
@@ -40,7 +41,6 @@ SubDirs = [
"src/fabric",
"src/global_changes",
"src/mango",
- "src/mem3",
"src/rexi",
"src/setup",
"rel"
diff --git a/src/chttpd/src/chttpd_sup.erl b/src/chttpd/src/chttpd_sup.erl
index 369248ea6a..d4bdb118c3 100644
--- a/src/chttpd/src/chttpd_sup.erl
+++ b/src/chttpd/src/chttpd_sup.erl
@@ -88,7 +88,7 @@ lru_opts() ->
append_if_set({Key, Value}, Opts) when Value > 0 ->
[{Key, Value} | Opts];
-append_if_set({Key, 0}, Opts) ->
+append_if_set({_Key, 0}, Opts) ->
Opts;
append_if_set({Key, Value}, Opts) ->
couch_log:error(
diff --git a/src/couch/src/couch.erl b/src/couch/src/couch.erl
index fd5c9e1014..60a8b66265 100644
--- a/src/couch/src/couch.erl
+++ b/src/couch/src/couch.erl
@@ -12,7 +12,11 @@
-module(couch).
--compile(export_all).
+-export([
+ start/0,
+ stop/0,
+ restart/0
+]).
deps() ->
diff --git a/src/couch/src/couch_btree.erl b/src/couch/src/couch_btree.erl
index ea224b1abe..daf846ba89 100644
--- a/src/couch/src/couch_btree.erl
+++ b/src/couch/src/couch_btree.erl
@@ -378,13 +378,12 @@ get_chunk_size() ->
end.
modify_node(Bt, RootPointerInfo, Actions, QueryOutput) ->
- case RootPointerInfo of
+ {NodeType, NodeList} = case RootPointerInfo of
nil ->
- NodeType = kv_node,
- NodeList = [];
+ {kv_node, []};
_Tuple ->
Pointer = element(1, RootPointerInfo),
- {NodeType, NodeList} = get_node(Bt, Pointer)
+ get_node(Bt, Pointer)
end,
NodeTuple = list_to_tuple(NodeList),
diff --git a/src/couch/src/couch_compaction_daemon.erl
b/src/couch/src/couch_compaction_daemon.erl
index fea505e423..115a9a8974 100644
--- a/src/couch/src/couch_compaction_daemon.erl
+++ b/src/couch/src/couch_compaction_daemon.erl
@@ -167,15 +167,15 @@ maybe_compact_db(Parent, DbName, Config) ->
gen_server:call(Parent, {start, DbName}),
{ok, _} = couch_db:start_compact(Db),
TimeLeft = compact_time_left(Config),
- case Config#config.parallel_view_compact of
+ {ViewsCompactPid, ViewsMonRef} = case
Config#config.parallel_view_compact of
true ->
- ViewsCompactPid = spawn_link(fun() ->
+ Pid = spawn_link(fun() ->
maybe_compact_views(DbName, DDocNames, Config)
end),
- ViewsMonRef = erlang:monitor(process, ViewsCompactPid);
+ Ref = erlang:monitor(process, Pid),
+ {Pid, Ref};
false ->
- ViewsCompactPid = nil,
- ViewsMonRef = nil
+ {nil, nil}
end,
case couch_db:wait_for_compaction(Db, TimeLeft) of
ok ->
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index 0ae164d9ba..1f8bc422fd 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -1767,7 +1767,7 @@ is_system_db_name(DbName) when is_binary(DbName) ->
Suffix = filename:basename(Normalized),
case {filename:dirname(Normalized), lists:member(Suffix,
?SYSTEM_DATABASES)} of
{<<".">>, Result} -> Result;
- {Prefix, false} -> false;
+ {_Prefix, false} -> false;
{Prefix, true} ->
ReOpts = [{capture,none}, dollar_endonly],
re:run(Prefix, ?DBNAME_REGEX, ReOpts) == match
diff --git a/src/couch/src/couch_debug.erl b/src/couch/src/couch_debug.erl
index 96c7a505fa..9506a80ceb 100644
--- a/src/couch/src/couch_debug.erl
+++ b/src/couch/src/couch_debug.erl
@@ -551,7 +551,7 @@ should_include_extra_info({InitialPid, _Processes, _Tree})
->
?assert(lists:keymember(reductions, 1, Props)),
?assert(lists:keymember(message_queue_len, 1, Props)),
?assert(lists:keymember(memory, 1, Props));
- Port ->
+ _Port ->
ok
end,
Props
diff --git a/src/couch/src/couch_uuids.erl b/src/couch/src/couch_uuids.erl
index 5c7359b337..b9c03b5022 100644
--- a/src/couch/src/couch_uuids.erl
+++ b/src/couch/src/couch_uuids.erl
@@ -95,7 +95,7 @@ new_prefix() ->
couch_util:to_hex((crypto:strong_rand_bytes(13))).
inc() ->
- crypto:rand_uniform(1, 16#ffe).
+ couch_rand:uniform(16#ffd).
state() ->
AlgoStr = config:get("uuids", "algorithm", "random"),
diff --git a/src/couch/test/couch_changes_tests.erl
b/src/couch/test/couch_changes_tests.erl
index e4ea761676..0c2f5f91f2 100644
--- a/src/couch/test/couch_changes_tests.erl
+++ b/src/couch/test/couch_changes_tests.erl
@@ -122,17 +122,17 @@ filter_by_design() ->
}
}.
-filter_by_custom_function() ->
- {
- "Filter function",
- {
- foreach,
- fun setup/0, fun teardown/1,
- [
- fun should_receive_heartbeats/1
- ]
- }
- }.
+%% filter_by_custom_function() ->
+%% {
+%% "Filter function",
+%% {
+%% foreach,
+%% fun setup/0, fun teardown/1,
+%% [
+%% fun should_receive_heartbeats/1
+%% ]
+%% }
+%% }.
filter_by_filter_function() ->
{
@@ -547,72 +547,72 @@ should_emit_only_design_documents({DbName, Revs}) ->
Rows2)
end).
-should_receive_heartbeats(_) ->
- {timeout, ?TEST_TIMEOUT div 1000,
- ?_test(
- begin
- DbName = ?tempdb(),
- Timeout = 100,
- {ok, Db} = create_db(DbName),
-
- {ok, _} = save_doc(Db, {[
- {<<"_id">>, <<"_design/filtered">>},
- {<<"language">>, <<"javascript">>},
- {<<"filters">>, {[
- {<<"foo">>, <<"function(doc) {
- return ['doc10', 'doc11',
'doc12'].indexOf(doc._id) != -1;}">>
- }]}}
- ]}),
-
- ChangesArgs = #changes_args{
- filter = "filtered/foo",
- feed = "continuous",
- timeout = 10000,
- heartbeat = 1000
- },
- Consumer = spawn_consumer(DbName, ChangesArgs, {json_req, null}),
-
- {ok, _Rev1} = save_doc(Db, {[{<<"_id">>, <<"doc1">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev2} = save_doc(Db, {[{<<"_id">>, <<"doc2">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev3} = save_doc(Db, {[{<<"_id">>, <<"doc3">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev4} = save_doc(Db, {[{<<"_id">>, <<"doc4">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev5} = save_doc(Db, {[{<<"_id">>, <<"doc5">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev6} = save_doc(Db, {[{<<"_id">>, <<"doc6">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev7} = save_doc(Db, {[{<<"_id">>, <<"doc7">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev8} = save_doc(Db, {[{<<"_id">>, <<"doc8">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev9} = save_doc(Db, {[{<<"_id">>, <<"doc9">>}]}),
-
- Heartbeats = get_heartbeats(Consumer),
- ?assert(Heartbeats > 0),
-
- {ok, _Rev10} = save_doc(Db, {[{<<"_id">>, <<"doc10">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev11} = save_doc(Db, {[{<<"_id">>, <<"doc11">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev12} = save_doc(Db, {[{<<"_id">>, <<"doc12">>}]}),
-
- Heartbeats2 = get_heartbeats(Consumer),
- ?assert(Heartbeats2 > Heartbeats),
-
- Rows = get_rows(Consumer),
- ?assertEqual(3, length(Rows)),
-
- {ok, _Rev13} = save_doc(Db, {[{<<"_id">>, <<"doc13">>}]}),
- timer:sleep(Timeout),
- {ok, _Rev14} = save_doc(Db, {[{<<"_id">>, <<"doc14">>}]}),
- timer:sleep(Timeout),
-
- Heartbeats3 = get_heartbeats(Consumer),
- ?assert(Heartbeats3 > Heartbeats2)
- end)}.
+%% should_receive_heartbeats(_) ->
+%% {timeout, ?TEST_TIMEOUT div 1000,
+%% ?_test(
+%% begin
+%% DbName = ?tempdb(),
+%% Timeout = 100,
+%% {ok, Db} = create_db(DbName),
+
+%% {ok, _} = save_doc(Db, {[
+%% {<<"_id">>, <<"_design/filtered">>},
+%% {<<"language">>, <<"javascript">>},
+%% {<<"filters">>, {[
+%% {<<"foo">>, <<"function(doc) {
+%% return ['doc10', 'doc11',
'doc12'].indexOf(doc._id) != -1;}">>
+%% }]}}
+%% ]}),
+
+%% ChangesArgs = #changes_args{
+%% filter = "filtered/foo",
+%% feed = "continuous",
+%% timeout = 10000,
+%% heartbeat = 1000
+%% },
+%% Consumer = spawn_consumer(DbName, ChangesArgs, {json_req,
null}),
+
+%% {ok, _Rev1} = save_doc(Db, {[{<<"_id">>, <<"doc1">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev2} = save_doc(Db, {[{<<"_id">>, <<"doc2">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev3} = save_doc(Db, {[{<<"_id">>, <<"doc3">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev4} = save_doc(Db, {[{<<"_id">>, <<"doc4">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev5} = save_doc(Db, {[{<<"_id">>, <<"doc5">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev6} = save_doc(Db, {[{<<"_id">>, <<"doc6">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev7} = save_doc(Db, {[{<<"_id">>, <<"doc7">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev8} = save_doc(Db, {[{<<"_id">>, <<"doc8">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev9} = save_doc(Db, {[{<<"_id">>, <<"doc9">>}]}),
+
+%% Heartbeats = get_heartbeats(Consumer),
+%% ?assert(Heartbeats > 0),
+
+%% {ok, _Rev10} = save_doc(Db, {[{<<"_id">>, <<"doc10">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev11} = save_doc(Db, {[{<<"_id">>, <<"doc11">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev12} = save_doc(Db, {[{<<"_id">>, <<"doc12">>}]}),
+
+%% Heartbeats2 = get_heartbeats(Consumer),
+%% ?assert(Heartbeats2 > Heartbeats),
+
+%% Rows = get_rows(Consumer),
+%% ?assertEqual(3, length(Rows)),
+
+%% {ok, _Rev13} = save_doc(Db, {[{<<"_id">>, <<"doc13">>}]}),
+%% timer:sleep(Timeout),
+%% {ok, _Rev14} = save_doc(Db, {[{<<"_id">>, <<"doc14">>}]}),
+%% timer:sleep(Timeout),
+
+%% Heartbeats3 = get_heartbeats(Consumer),
+%% ?assert(Heartbeats3 > Heartbeats2)
+%% end)}.
should_filter_by_doc_attribute({DbName, _}) ->
?_test(
@@ -800,17 +800,17 @@ get_rows({Consumer, _}) ->
?assertNotEqual(timeout, Resp),
Resp.
-get_heartbeats({Consumer, _}) ->
- Ref = make_ref(),
- Consumer ! {get_heartbeats, Ref},
- Resp = receive
- {hearthbeats, Ref, HeartBeats} ->
- HeartBeats
- after ?TIMEOUT ->
- timeout
- end,
- ?assertNotEqual(timeout, Resp),
- Resp.
+%% get_heartbeats({Consumer, _}) ->
+%% Ref = make_ref(),
+%% Consumer ! {get_heartbeats, Ref},
+%% Resp = receive
+%% {hearthbeats, Ref, HeartBeats} ->
+%% HeartBeats
+%% after ?TIMEOUT ->
+%% timeout
+%% end,
+%% ?assertNotEqual(timeout, Resp),
+%% Resp.
clear_rows({Consumer, _}) ->
Ref = make_ref(),
diff --git a/src/couch/test/couch_doc_json_tests.erl
b/src/couch/test/couch_doc_json_tests.erl
index bcff0646a5..cc5dc32225 100644
--- a/src/couch/test/couch_doc_json_tests.erl
+++ b/src/couch/test/couch_doc_json_tests.erl
@@ -51,6 +51,8 @@ json_doc_test_() ->
fun setup/0, fun teardown/1,
fun(_) ->
[{"Document from JSON", [
+ from_json_with_dbname_error_cases(),
+ from_json_with_db_name_success_cases(),
from_json_success_cases(),
from_json_error_cases()
]},
diff --git a/src/couch/test/couch_file_tests.erl
b/src/couch/test/couch_file_tests.erl
index a387615dde..34c1a1654d 100644
--- a/src/couch/test/couch_file_tests.erl
+++ b/src/couch/test/couch_file_tests.erl
@@ -418,7 +418,7 @@ nuke_dir_test_() ->
File0 = ?tempfile() ++ ".couch",
RootDir = filename:dirname(File0),
BaseName = filename:basename(File0),
- Seed = crypto:rand_uniform(1000000000, 9999999999),
+ Seed = couch_rand:uniform(8999999999) + 999999999,
DDocDir = io_lib:format("db.~b_design", [Seed]),
ViewDir = filename:join([RootDir, DDocDir]),
file:make_dir(ViewDir),
diff --git a/src/couch/test/couch_flags_tests.erl
b/src/couch/test/couch_flags_tests.erl
index a467265cbd..cda7639bfb 100644
--- a/src/couch/test/couch_flags_tests.erl
+++ b/src/couch/test/couch_flags_tests.erl
@@ -124,14 +124,14 @@ is_enabled() ->
?_assertNot(couch_flags:is_enabled(non_existent,
"shards/blacklist/4"))}
]}].
-match_performance() ->
- [{"match_performance", [
- ?_test(begin
- ?debugTime("1 million of operations took", lists:foreach(fun(_) ->
- couch_flags:is_enabled(bar, "shards/test/exact")
- end, lists:seq(1, 1000000)))
- end)
- ]}].
+%% match_performance() ->
+%% [{"match_performance", [
+%% ?_test(begin
+%% ?debugTime("1 million of operations took", lists:foreach(fun(_)
->
+%% couch_flags:is_enabled(bar, "shards/test/exact")
+%% end, lists:seq(1, 1000000)))
+%% end)
+%% ]}].
test_config() ->
diff --git a/src/couch/test/couch_key_tree_prop_tests.erl
b/src/couch/test/couch_key_tree_prop_tests.erl
index 604a8285a5..f8146926a8 100644
--- a/src/couch/test/couch_key_tree_prop_tests.erl
+++ b/src/couch/test/couch_key_tree_prop_tests.erl
@@ -14,7 +14,6 @@
-include_lib("triq/include/triq.hrl").
-triq(eunit).
--include_lib("eunit/include/eunit.hrl").
-define(SIZE_REDUCTION, 3). % How much to reduce size with tree depth.
-define(MAX_BRANCHES, 4). % Maximum number of branches.
diff --git a/src/couch/test/couch_util_tests.erl
b/src/couch/test/couch_util_tests.erl
index a0e9238724..3e145c4f61 100644
--- a/src/couch/test/couch_util_tests.erl
+++ b/src/couch/test/couch_util_tests.erl
@@ -87,7 +87,7 @@ flush_test() ->
_IntsToAGazillion = lists:seq(1, 200000),
_LotsOfData = lists:map(fun(_) -> <<"foobar">> end,
lists:seq(1, 500000)),
- _BigBin = list_to_binary(_LotsOfData),
+ _ = list_to_binary(_LotsOfData),
%% Allocation 200K tuples puts us above the memory threshold
%% Originally, there should be:
diff --git a/src/couch/test/couchdb_mrview_tests.erl
b/src/couch/test/couchdb_mrview_tests.erl
index 2549528be6..1c96a0ae0d 100644
--- a/src/couch/test/couchdb_mrview_tests.erl
+++ b/src/couch/test/couchdb_mrview_tests.erl
@@ -151,7 +151,7 @@ should_cleanup_index_files(_PortType, {Host, DbName}) ->
".[0-9]*_design/mrview/*"
],
ReqUrl = Host ++ "/" ++ DbName ++ "/_design/foo/_view/view1",
- {ok, Status0, _Headers0, Body0} = test_request:get(ReqUrl, [?AUTH]),
+ {ok, _Status0, _Headers0, _Body0} = test_request:get(ReqUrl, [?AUTH]),
FileList0 = filelib:wildcard(IndexWildCard),
?assertNotEqual([], FileList0),
@@ -169,7 +169,7 @@ should_cleanup_index_files(_PortType, {Host, DbName}) ->
?assertEqual([], lists:usort(FileList1 -- (FileList0 ++ ToDelete))),
CleanupUrl = Host ++ "/" ++ DbName ++ "/_view_cleanup",
- {ok, Status1, _Headers1, Body1} = test_request:post(
+ {ok, _Status1, _Headers1, _Body1} = test_request:post(
CleanupUrl, [], <<>>, [?AUTH]),
test_util:wait(fun() ->
IndexFiles = filelib:wildcard(IndexWildCard),
diff --git a/src/couch/test/couchdb_vhosts_tests.erl
b/src/couch/test/couchdb_vhosts_tests.erl
index 2562a06533..1c41172155 100644
--- a/src/couch/test/couchdb_vhosts_tests.erl
+++ b/src/couch/test/couchdb_vhosts_tests.erl
@@ -270,7 +270,3 @@ should_return_path_for_vhost_with_wildcard_host({Url,
DbName}) ->
{reason, ?iofmt("Request failed: ~p", [Else])}]})
end
end).
-
-ensure_index_file() ->
- Body = <<"<!DOCTYPE html>\n<html>\n<body>\nHello
world\n</body>\n</html>">>,
- file:write_file(filename:join([?TEMPDIR, "index.html"]), Body).
diff --git a/src/couch/test/json_stream_parse_tests.erl
b/src/couch/test/json_stream_parse_tests.erl
index ffcf9185ac..e690d77281 100644
--- a/src/couch/test/json_stream_parse_tests.erl
+++ b/src/couch/test/json_stream_parse_tests.erl
@@ -136,7 +136,7 @@ single_byte_data_fun([H | T]) ->
multiple_bytes_data_fun([]) ->
done;
multiple_bytes_data_fun(L) ->
- N = crypto:rand_uniform(0, 7),
+ N = couch_rand:uniform(7) - 1,
{Part, Rest} = split(L, N),
{list_to_binary(Part), fun() -> multiple_bytes_data_fun(Rest) end}.
diff --git a/src/couch_epi/src/couch_epi.erl b/src/couch_epi/src/couch_epi.erl
index 2ce4592d29..0e5c233abd 100644
--- a/src/couch_epi/src/couch_epi.erl
+++ b/src/couch_epi/src/couch_epi.erl
@@ -58,9 +58,6 @@
-type apply_opts() :: [apply_opt()].
--type data_spec_opt()
- :: {interval, pos_integer()}.
-
-type data_spec()
:: {static_module, module()}
| {callback_module, module()}
diff --git a/src/couch_epi/src/couch_epi_sup.erl
b/src/couch_epi/src/couch_epi_sup.erl
index 509f5a1c21..218db54453 100644
--- a/src/couch_epi/src/couch_epi_sup.erl
+++ b/src/couch_epi/src/couch_epi_sup.erl
@@ -37,6 +37,11 @@
%% Supervisor callbacks
-export([init/1]).
+%% For testing
+-export([
+ plugin_childspecs/3
+]).
+
%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
@@ -132,105 +137,3 @@ merge([], Children) ->
Children;
merge([{Id, _, _, _, _, _} = Spec | Rest], Children) ->
merge(Rest, lists:keystore(Id, 1, Children, Spec)).
-
-
-%% ------------------------------------------------------------------
-%% Tests
-%% ------------------------------------------------------------------
-
--ifdef(TEST).
--include_lib("eunit/include/eunit.hrl").
-
-%% ----
-%% BEGIN couch_epi_plugin behaviour callbacks
-
--compile([export_all]).
-
-app() -> test_app.
-providers() ->
- [
- {my_service, provider1},
- {my_service, provider2}
- ].
-
-services() ->
- [
- {my_service, ?MODULE}
- ].
-
-data_providers() ->
- [
- {{test_app, descriptions}, {static_module, ?MODULE}, [{interval, 100}]}
- ].
-
-data_subscriptions() ->
- [
- {test_app, descriptions}
- ].
-
-processes() ->
- [
- {?MODULE, [?CHILD(extra_process, worker)]},
- {?MODULE, [{to_replace, {new, start_link, [bar]},
- permanent, 5000, worker, [bar]}]}
- ].
-
-notify(_Key, _OldData, _NewData) ->
- ok.
-
-%% END couch_epi_plugin behaviour callbacks
-%% ----
-
-parse_child_id(Id) when is_atom(Id) ->
- Id;
-parse_child_id(Id) ->
- ["couch_epi_codechange_monitor", ServiceName, KindStr] = string:tokens(Id,
"|"),
- Kind = list_to_atom(KindStr),
- case string:tokens(ServiceName, ":") of
- [ServiceId, Key] ->
- {{list_to_atom(ServiceId), list_to_atom(Key)}, Kind};
- [Key] ->
- {list_to_atom(Key), Kind}
- end.
-
-basic_test() ->
- Expected = lists:sort([
- {extra_process, [], [extra_process]},
- {to_replace, [bar], [bar]},
- {{my_service, providers},
- [couch_epi_functions_gen_my_service],
- [couch_epi_codechange_monitor, couch_epi_functions_gen_my_service,
- provider1, provider2]},
- {{my_service, services},
- [couch_epi_functions_gen_my_service],
- [couch_epi_codechange_monitor, couch_epi_functions_gen_my_service,
- couch_epi_sup]},
- {{{test_app, descriptions}, data_subscriptions},
- [couch_epi_data_gen_test_app_descriptions],
- [couch_epi_codechange_monitor,
- couch_epi_data_gen_test_app_descriptions, couch_epi_sup]},
- {{{test_app, descriptions}, data_providers},
- [couch_epi_data_gen_test_app_descriptions],
- [couch_epi_codechange_monitor,
couch_epi_data_gen_test_app_descriptions,
- couch_epi_sup]}
- ]),
-
- ToReplace = {to_replace, {old, start_link, [foo]}, permanent, 5000,
worker, [foo]},
- Children = lists:sort(plugin_childspecs(?MODULE, [?MODULE], [ToReplace])),
- Results = [
- {parse_child_id(Id), Args, lists:sort(Modules)}
- || {Id, {_M, _F, Args}, _, _, _, Modules} <- Children
- ],
-
- Tests = lists:zip(Expected, Results),
- [?assertEqual(Expect, Result) || {Expect, Result} <- Tests],
-
- ExpectedChild = {to_replace, {new, start_link, [bar]},
- permanent, 5000, worker, [bar]},
- ?assertEqual(
- ExpectedChild,
- lists:keyfind(to_replace, 1, Children)),
-
- ok.
-
--endif.
diff --git a/src/couch_epi/test/couch_epi_basic_test.erl
b/src/couch_epi/test/couch_epi_basic_test.erl
new file mode 100644
index 0000000000..587d1564e9
--- /dev/null
+++ b/src/couch_epi/test/couch_epi_basic_test.erl
@@ -0,0 +1,137 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_epi_basic_test).
+
+-export([
+ start_link/0
+]).
+
+-export([
+ app/0,
+ providers/0,
+ services/0,
+ data_providers/0,
+ data_subscriptions/0,
+ processes/0,
+ notify/3
+]).
+
+-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
+
+
+start_link() -> ok.
+
+
+%% BEGIN couch_epi_plugin behaviour callbacks
+
+
+app() -> test_app.
+
+
+providers() ->
+ [
+ {my_service, provider1},
+ {my_service, provider2}
+ ].
+
+
+services() ->
+ [
+ {my_service, ?MODULE}
+ ].
+
+
+data_providers() ->
+ [
+ {{test_app, descriptions}, {static_module, ?MODULE}, [{interval, 100}]}
+ ].
+
+
+data_subscriptions() ->
+ [
+ {test_app, descriptions}
+ ].
+
+
+processes() ->
+ [
+ {?MODULE, [?CHILD(extra_process, worker)]},
+ {?MODULE, [{to_replace, {new, start_link, [bar]},
+ permanent, 5000, worker, [bar]}]}
+ ].
+
+
+notify(_Key, _OldData, _NewData) ->
+ ok.
+
+
+%% END couch_epi_plugin behaviour callbacks
+
+
+parse_child_id(Id) when is_atom(Id) ->
+ Id;
+parse_child_id(Id) ->
+ ["couch_epi_codechange_monitor", ServiceName, KindStr]
+ = string:tokens(Id, "|"),
+ Kind = list_to_atom(KindStr),
+ case string:tokens(ServiceName, ":") of
+ [ServiceId, Key] ->
+ {{list_to_atom(ServiceId), list_to_atom(Key)}, Kind};
+ [Key] ->
+ {list_to_atom(Key), Kind}
+ end.
+
+
+-include_lib("eunit/include/eunit.hrl").
+
+basic_test() ->
+ Expected = lists:sort([
+ {extra_process, [], [extra_process]},
+ {to_replace, [bar], [bar]},
+ {{my_service, providers},
+ [couch_epi_functions_gen_my_service],
+ [couch_epi_codechange_monitor, couch_epi_functions_gen_my_service,
+ provider1, provider2]},
+ {{my_service, services},
+ [couch_epi_functions_gen_my_service],
+ lists:sort([couch_epi_codechange_monitor,
+ couch_epi_functions_gen_my_service, ?MODULE])},
+ {{{test_app, descriptions}, data_subscriptions},
+ [couch_epi_data_gen_test_app_descriptions],
+ lists:sort([couch_epi_codechange_monitor,
+ couch_epi_data_gen_test_app_descriptions, ?MODULE])},
+ {{{test_app, descriptions}, data_providers},
+ [couch_epi_data_gen_test_app_descriptions],
+ lists:sort([couch_epi_codechange_monitor,
+ couch_epi_data_gen_test_app_descriptions, ?MODULE])}
+ ]),
+
+ ToReplace = {to_replace,
+ {old, start_link, [foo]}, permanent, 5000, worker, [foo]},
+ Children = lists:sort(couch_epi_sup:plugin_childspecs(
+ ?MODULE, [?MODULE], [ToReplace])),
+ Results = [
+ {parse_child_id(Id), Args, lists:sort(Modules)}
+ || {Id, {_M, _F, Args}, _, _, _, Modules} <- Children
+ ],
+
+ Tests = lists:zip(Expected, Results),
+ [?assertEqual(Expect, Result) || {Expect, Result} <- Tests],
+
+ ExpectedChild = {to_replace, {new, start_link, [bar]},
+ permanent, 5000, worker, [bar]},
+ ?assertEqual(
+ ExpectedChild,
+ lists:keyfind(to_replace, 1, Children)),
+
+ ok.
diff --git a/src/couch_log/src/couch_log_writer_file.erl
b/src/couch_log/src/couch_log_writer_file.erl
index fb01363fde..1fe35a8abb 100644
--- a/src/couch_log/src/couch_log_writer_file.erl
+++ b/src/couch_log/src/couch_log_writer_file.erl
@@ -37,7 +37,9 @@
-ifdef(TEST).
--compile(export_all).
+-export([
+ maybe_reopen/1
+]).
-endif.
diff --git a/src/couch_log/src/couch_log_writer_syslog.erl
b/src/couch_log/src/couch_log_writer_syslog.erl
index d918bb7830..e3a6fc4b64 100644
--- a/src/couch_log/src/couch_log_writer_syslog.erl
+++ b/src/couch_log/src/couch_log_writer_syslog.erl
@@ -39,7 +39,10 @@
-ifdef(TEST).
--compile(export_all).
+-export([
+ get_facility/1,
+ get_level/1
+]).
-endif.
diff --git a/src/couch_log/test/couch_log_test_util.erl
b/src/couch_log/test/couch_log_test_util.erl
index c7fd34f2d7..00f3981fcc 100644
--- a/src/couch_log/test/couch_log_test_util.erl
+++ b/src/couch_log/test/couch_log_test_util.erl
@@ -11,8 +11,17 @@
% the License.
-module(couch_log_test_util).
--compile(export_all).
+-export([
+ start/0,
+ stop/1,
+ last_log/0,
+ last_log_key/0,
+ wait_for_config/0,
+ with_config_listener/1,
+ with_level/2,
+ with_meck/2
+]).
-include("couch_log.hrl").
diff --git a/src/couch_mrview/src/couch_mrview_test_util.erl
b/src/couch_mrview/src/couch_mrview_test_util.erl
index ac298263d1..a6242cde78 100644
--- a/src/couch_mrview/src/couch_mrview_test_util.erl
+++ b/src/couch_mrview/src/couch_mrview_test_util.erl
@@ -13,6 +13,7 @@
-module(couch_mrview_test_util).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("couch/include/couch_db.hrl").
-include_lib("couch/include/couch_eunit.hrl").
diff --git a/src/couch_mrview/test/couch_mrview_index_changes_tests.erl
b/src/couch_mrview/test/couch_mrview_index_changes_tests.erl
index 2701e0c223..f0be1b9b15 100644
--- a/src/couch_mrview/test/couch_mrview_index_changes_tests.erl
+++ b/src/couch_mrview/test/couch_mrview_index_changes_tests.erl
@@ -186,15 +186,13 @@ test_stream(Db) ->
test_indexer(Db) ->
Result = run_query(Db, [{since, 14}, refresh]),
Expect = {ok, 15, [{{15,14,<<"14">>},14}]},
- ?_assertEqual(Result, Expect),
{ok, Db1} = save_doc(Db, 15),
timer:sleep(1500),
Result1 = run_query(Db1, [{since, 14}], false),
Expect1 = {ok, 16, [{{15,14,<<"14">>},14},
{{16,15,<<"15">>},15}]},
- ?_assertEqual(Result1, Expect1),
- ok.
+ ?_assert(Result == Expect andalso Result1 == Expect1).
save_doc(Db, Id) ->
diff --git a/src/couch_pse_tests/src/cpse_test_attachments.erl
b/src/couch_pse_tests/src/cpse_test_attachments.erl
index 61ada38c46..8c454ecb63 100644
--- a/src/couch_pse_tests/src/cpse_test_attachments.erl
+++ b/src/couch_pse_tests/src/cpse_test_attachments.erl
@@ -12,6 +12,7 @@
-module(cpse_test_attachments).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_compaction.erl
b/src/couch_pse_tests/src/cpse_test_compaction.erl
index d006111013..c8a2c1a7df 100644
--- a/src/couch_pse_tests/src/cpse_test_compaction.erl
+++ b/src/couch_pse_tests/src/cpse_test_compaction.erl
@@ -12,6 +12,7 @@
-module(cpse_test_compaction).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_fold_changes.erl
b/src/couch_pse_tests/src/cpse_test_fold_changes.erl
index 8ee74f0417..436396276d 100644
--- a/src/couch_pse_tests/src/cpse_test_fold_changes.erl
+++ b/src/couch_pse_tests/src/cpse_test_fold_changes.erl
@@ -12,6 +12,7 @@
-module(cpse_test_fold_changes).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
@@ -170,25 +171,11 @@ do_mutation_ordering(Db, Seq, [{DocId, _OldSeq} | Rest],
DocSeqAcc) ->
shuffle(List) ->
- random:seed(os:timestamp()),
- Paired = [{random:uniform(), I} || I <- List],
+ Paired = [{couch_rand:uniform(), I} || I <- List],
Sorted = lists:sort(Paired),
[I || {_, I} <- Sorted].
-remove_random(List) ->
- Pos = random:uniform(length(List)),
- remove_random(Pos, List).
-
-
-remove_random(1, [Item | Rest]) ->
- {Item, Rest};
-
-remove_random(N, [Skip | Rest]) when N > 1 ->
- {Item, Tail} = remove_random(N - 1, Rest),
- {Item, [Skip | Tail]}.
-
-
fold_fun(#full_doc_info{id=Id, update_seq=Seq}, Acc) ->
{ok, [{Id, Seq} | Acc]}.
diff --git a/src/couch_pse_tests/src/cpse_test_fold_docs.erl
b/src/couch_pse_tests/src/cpse_test_fold_docs.erl
index 09fbd26d0b..d43930c4ab 100644
--- a/src/couch_pse_tests/src/cpse_test_fold_docs.erl
+++ b/src/couch_pse_tests/src/cpse_test_fold_docs.erl
@@ -12,6 +12,7 @@
-module(cpse_test_fold_docs).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_fold_purge_infos.erl
b/src/couch_pse_tests/src/cpse_test_fold_purge_infos.erl
index 42bc536d28..4826c5d9cb 100644
--- a/src/couch_pse_tests/src/cpse_test_fold_purge_infos.erl
+++ b/src/couch_pse_tests/src/cpse_test_fold_purge_infos.erl
@@ -12,6 +12,7 @@
-module(cpse_test_fold_purge_infos).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_get_set_props.erl
b/src/couch_pse_tests/src/cpse_test_get_set_props.erl
index 1f8684475e..02f0eb5313 100644
--- a/src/couch_pse_tests/src/cpse_test_get_set_props.erl
+++ b/src/couch_pse_tests/src/cpse_test_get_set_props.erl
@@ -12,6 +12,7 @@
-module(cpse_test_get_set_props).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_open_close_delete.erl
b/src/couch_pse_tests/src/cpse_test_open_close_delete.erl
index c19d0ee4ce..d9b589fd67 100644
--- a/src/couch_pse_tests/src/cpse_test_open_close_delete.erl
+++ b/src/couch_pse_tests/src/cpse_test_open_close_delete.erl
@@ -12,6 +12,7 @@
-module(cpse_test_open_close_delete).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_purge_docs.erl
b/src/couch_pse_tests/src/cpse_test_purge_docs.erl
index 34bd34df6c..1788eecd1a 100644
--- a/src/couch_pse_tests/src/cpse_test_purge_docs.erl
+++ b/src/couch_pse_tests/src/cpse_test_purge_docs.erl
@@ -12,6 +12,7 @@
-module(cpse_test_purge_docs).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_purge_seqs.erl
b/src/couch_pse_tests/src/cpse_test_purge_seqs.erl
index a943fc4879..057d6da336 100644
--- a/src/couch_pse_tests/src/cpse_test_purge_seqs.erl
+++ b/src/couch_pse_tests/src/cpse_test_purge_seqs.erl
@@ -12,6 +12,7 @@
-module(cpse_test_purge_seqs).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_read_write_docs.erl
b/src/couch_pse_tests/src/cpse_test_read_write_docs.erl
index 84bf9f323e..fd830d8123 100644
--- a/src/couch_pse_tests/src/cpse_test_read_write_docs.erl
+++ b/src/couch_pse_tests/src/cpse_test_read_write_docs.erl
@@ -12,6 +12,7 @@
-module(cpse_test_read_write_docs).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_test_ref_counting.erl
b/src/couch_pse_tests/src/cpse_test_ref_counting.erl
index 2a0e4c2022..cb115a7857 100644
--- a/src/couch_pse_tests/src/cpse_test_ref_counting.erl
+++ b/src/couch_pse_tests/src/cpse_test_ref_counting.erl
@@ -12,6 +12,7 @@
-module(cpse_test_ref_counting).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_pse_tests/src/cpse_util.erl
b/src/couch_pse_tests/src/cpse_util.erl
index d3e1259246..7556d234b3 100644
--- a/src/couch_pse_tests/src/cpse_util.erl
+++ b/src/couch_pse_tests/src/cpse_util.erl
@@ -12,6 +12,7 @@
-module(cpse_util).
-compile(export_all).
+-compile(nowarn_export_all).
-include_lib("eunit/include/eunit.hrl").
diff --git a/src/couch_replicator/test/couch_replicator_compact_tests.erl
b/src/couch_replicator/test/couch_replicator_compact_tests.erl
index 89e9295d4d..7cc530c195 100644
--- a/src/couch_replicator/test/couch_replicator_compact_tests.erl
+++ b/src/couch_replicator/test/couch_replicator_compact_tests.erl
@@ -97,7 +97,7 @@ should_run_replication(RepPid, RepId, Source, Target) ->
should_ensure_replication_still_running(RepPid, RepId, Source, Target) ->
?_test(check_active_tasks(RepPid, RepId, Source, Target)).
-check_active_tasks(RepPid, {BaseId, Ext} = RepId, Src, Tgt) ->
+check_active_tasks(RepPid, {BaseId, Ext} = _RepId, Src, Tgt) ->
Source = case Src of
{remote, NameSrc} ->
<<(db_url(NameSrc))/binary, $/>>;
diff --git a/src/couch_replicator/test/couch_replicator_connection_tests.erl
b/src/couch_replicator/test/couch_replicator_connection_tests.erl
index ef3f2b37e6..e75cc5a63a 100644
--- a/src/couch_replicator/test/couch_replicator_connection_tests.erl
+++ b/src/couch_replicator/test/couch_replicator_connection_tests.erl
@@ -73,7 +73,7 @@ connections_not_shared_after_owner_death({Host, Port}) ->
Self = self(),
spawn(fun() ->
Self ! couch_replicator_connection:acquire(URL),
- 1/0
+ error("simulate division by zero without compiler warning")
end),
receive
{ok, Pid} ->
diff --git a/src/couch_tests/test/couch_tests_app_tests.erl
b/src/couch_tests/test/couch_tests_app_tests.erl
index 1acdec7892..6f9c7e419b 100644
--- a/src/couch_tests/test/couch_tests_app_tests.erl
+++ b/src/couch_tests/test/couch_tests_app_tests.erl
@@ -46,7 +46,7 @@ setup2(Arg1, Arg2) ->
Ctx1 = couch_tests:start_applications([public_key], Ctx0),
couch_tests:set_state(Fixture, Ctx1, {Arg1, Arg2})
end,
- fun(Fixture, Ctx) ->
+ fun(_Fixture, Ctx) ->
Ctx
end).
diff --git a/src/ddoc_cache/test/ddoc_cache_tutil.erl
b/src/ddoc_cache/test/ddoc_cache_tutil.erl
index ec5d2db1ed..b34d4b1639 100644
--- a/src/ddoc_cache/test/ddoc_cache_tutil.erl
+++ b/src/ddoc_cache/test/ddoc_cache_tutil.erl
@@ -13,7 +13,16 @@
-module(ddoc_cache_tutil).
--compile(export_all).
+-export([
+ start_couch/0,
+ start_couch/1,
+ stop_couch/1,
+ clear/0,
+ get_rev/2,
+ ddocs/0,
+ purge_modules/0,
+ with/1
+]).
-include_lib("couch/include/couch_db.hrl").
diff --git a/src/fabric/src/fabric_dict.erl b/src/fabric/src/fabric_dict.erl
index ec2e25cfce..a336b47b0a 100644
--- a/src/fabric/src/fabric_dict.erl
+++ b/src/fabric/src/fabric_dict.erl
@@ -12,6 +12,7 @@
-module(fabric_dict).
-compile(export_all).
+-compile(nowarn_export_all).
% Instead of ets, let's use an ordered keylist. We'll need to revisit if we
% have >> 100 shards, so a private interface is a good idea. - APK June 2010
diff --git a/src/mem3/src/mem3.erl b/src/mem3/src/mem3.erl
index de633006a4..f1af0f796c 100644
--- a/src/mem3/src/mem3.erl
+++ b/src/mem3/src/mem3.erl
@@ -196,10 +196,13 @@ choose_shards(DbName, Nodes, Options) ->
Q = mem3_util:q_val(couch_util:get_value(q, Options,
config:get("cluster", "q", "8"))),
%% rotate to a random entry in the nodelist for even distribution
- {A, B} = lists:split(crypto:rand_uniform(1,length(Nodes)+1), Nodes),
- RotatedNodes = B ++ A,
+ RotatedNodes = rotate_rand(Nodes),
mem3_util:create_partition_map(DbName, N, Q, RotatedNodes, Suffix).
+rotate_rand(Nodes) ->
+ {A, B} = lists:split(couch_rand:uniform(length(Nodes)), Nodes),
+ B ++ A.
+
get_placement(Options) ->
case couch_util:get_value(placement, Options) of
undefined ->
@@ -382,4 +385,11 @@ allowed_nodes_test_() ->
]
}]}.
+rotate_rand_degenerate_test() ->
+ ?assertEqual([1], rotate_rand([1])).
+
+rotate_rand_distribution_test() ->
+ Cases = [rotate_rand([1, 2, 3]) || _ <- lists:seq(1, 100)],
+ ?assertEqual(3, length(lists:usort(Cases))).
+
-endif.
diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 340bc0e7b1..a30630167a 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -137,7 +137,6 @@ verify_purge_checkpoint(DbName, Props) ->
Target = binary_to_existing_atom(TargetBin, latin1),
try
- Shards = mem3:shards(DbName),
Nodes = lists:foldl(fun(Shard, Acc) ->
case Shard#shard.range == Range of
true -> [Shard#shard.node | Acc];
diff --git a/src/mem3/src/mem3_sync_event_listener.erl
b/src/mem3/src/mem3_sync_event_listener.erl
index cd671e4d5e..56ffe3d070 100644
--- a/src/mem3/src/mem3_sync_event_listener.erl
+++ b/src/mem3/src/mem3_sync_event_listener.erl
@@ -269,7 +269,7 @@ should_set_sync_frequency(Pid) ->
ok
end).
-should_restart_listener(Pid) ->
+should_restart_listener(_Pid) ->
?_test(begin
meck:reset(config_notifier),
config:set("mem3", "sync_frequency", "error", false),
diff --git a/src/mem3/test/mem3_seeds_test.erl
b/src/mem3/test/mem3_seeds_test.erl
index 19e0079503..ba83b66bef 100644
--- a/src/mem3/test/mem3_seeds_test.erl
+++ b/src/mem3/test/mem3_seeds_test.erl
@@ -12,7 +12,7 @@
-module(mem3_seeds_test).
--include_lib("eunit/include/eunit.hrl").
+-include_lib("couch/include/couch_eunit.hrl").
a_test_() ->
Tests = [
@@ -29,7 +29,7 @@ empty_seedlist_status_ok() ->
?assertEqual({[]}, couch_util:get_value(seeds, Result)),
?assertEqual(ok, couch_util:get_value(status, Result))
after
- application:stop(mem3)
+ cleanup()
end.
seedlist_misconfiguration() ->
@@ -43,7 +43,7 @@ seedlist_misconfiguration() ->
?assertMatch({_}, couch_util:get_value('[email protected]',
Seeds)),
?assertEqual(seeding, couch_util:get_value(status, Result))
after
- application:stop(mem3)
+ cleanup()
end.
check_nodelist() ->
@@ -54,9 +54,14 @@ check_nodelist() ->
?assert(lists:member('[email protected]', Nodes)),
?assert(lists:member('[email protected]', Nodes))
after
- application:stop(mem3)
+ cleanup()
end.
+cleanup() ->
+ application:stop(mem3),
+ Filename = config:get("mem3", "nodes_db", "_nodes") ++ ".couch",
+ file:delete(filename:join([?BUILDDIR(), "tmp", "data", Filename])).
+
setup() ->
test_util:start_couch([rexi]).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services