-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for mongoose_internal_databases:wait_for_mnesia
- Loading branch information
1 parent
7ea781b
commit c6131e5
Showing
2 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
-module(mnesia_db_SUITE). | ||
-compile([export_all, nowarn_export_all]). | ||
|
||
-include_lib("exml/include/exml.hrl"). | ||
-include_lib("eunit/include/eunit.hrl"). | ||
-include("mongoose.hrl"). | ||
-include("jlib.hrl"). | ||
|
||
local() -> | ||
#{node => node()}. | ||
|
||
all() -> | ||
[mnesia_wait_for_tables]. | ||
|
||
init_per_suite(Config) -> | ||
Config. | ||
|
||
end_per_suite(Config) -> | ||
ok. | ||
|
||
init_per_testcase(_, C) -> | ||
mock_mnesia(), | ||
logger_ct_backend:start(local()), | ||
C. | ||
|
||
end_per_testcase(_, _) -> | ||
meck:unload(), | ||
logger_ct_backend:stop(local()). | ||
|
||
mock_mnesia() -> | ||
meck:new(mnesia, []), | ||
meck:expect(mnesia, system_info, fun(local_tables) -> [test_table_fast, test_table_slow] end), | ||
meck:expect(mnesia, table_info, fun(_, _) -> [] end), | ||
meck:expect(mnesia, wait_for_tables, fun(Tables, Interval) -> | ||
case meck:num_calls(mnesia, wait_for_tables, '_') > 5 of | ||
true -> ok; | ||
false -> {timeout, Tables -- [test_table_fast]} | ||
end | ||
end), | ||
ok. | ||
|
||
mnesia_wait_for_tables(_Config) -> | ||
logger_ct_backend:capture(warning, local()), | ||
mongoose_internal_databases:wait_for_mnesia(), | ||
logger_ct_backend:stop_capture(local()), | ||
FilterFun = fun(_, Msg) -> re:run(Msg, "what: mnesia_wait_for_tables_progress") /= nomatch end, | ||
6 = length(logger_ct_backend:recv(FilterFun)). |