1 |
|
-module(mongoose_internal_databases). |
2 |
|
-export([init/0]). |
3 |
|
|
4 |
|
init() -> |
5 |
104 |
case mongoose_config:lookup_opt([internal_databases, mnesia]) of |
6 |
|
{ok, _} -> |
7 |
104 |
init_mnesia(), |
8 |
104 |
mongoose_node_num_mnesia:init(); |
9 |
|
{error, _} -> |
10 |
|
%% Ensure mnesia is stopped when applying the test presets from the big tests. |
11 |
|
%% So, we accidentually do not test with mnesia enabled, when starting the |
12 |
|
%% test cases from the clean test build. |
13 |
:-( |
mnesia:stop(), |
14 |
:-( |
ok |
15 |
|
end. |
16 |
|
|
17 |
|
init_mnesia() -> |
18 |
|
%% Mnesia should not be running at this point, unless it is started by tests. |
19 |
|
%% Ensure Mnesia is stopped |
20 |
104 |
mnesia:stop(), |
21 |
104 |
case mnesia:system_info(extra_db_nodes) of |
22 |
|
[] -> |
23 |
104 |
mnesia:create_schema([node()]); |
24 |
|
_ -> |
25 |
:-( |
ok |
26 |
|
end, |
27 |
104 |
application:start(mnesia, permanent), |
28 |
104 |
mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity). |