syn_create_mnesia_SUITE.erl 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. -module(syn_create_mnesia_SUITE).
  2. %% callbacks
  3. -export([all/0]).
  4. -export([init_per_suite/1, end_per_suite/1]).
  5. -export([groups/0, init_per_group/2, end_per_group/2]).
  6. %% tests
  7. -export([
  8. single_node_when_mnesia_is_ram/1,
  9. single_node_when_mnesia_is_opt_disc_no_schema_exists/1,
  10. single_node_when_mnesia_is_opt_disc_schema_exists/1,
  11. single_node_when_mnesia_is_disc/1
  12. ]).
  13. -export([
  14. two_nodes_when_mnesia_is_ram/1
  15. ]).
  16. %% include
  17. -include_lib("common_test/include/ct.hrl").
  18. %% ===================================================================
  19. %% Callbacks
  20. %% ===================================================================
  21. %% -------------------------------------------------------------------
  22. %% Function: all() -> GroupsAndTestCases | {skip,Reason}
  23. %% GroupsAndTestCases = [{group,GroupName} | TestCase]
  24. %% GroupName = atom()
  25. %% TestCase = atom()
  26. %% Reason = term()
  27. %% -------------------------------------------------------------------
  28. all() ->
  29. [
  30. {group, mnesia_creation_single_node}
  31. ].
  32. %% -------------------------------------------------------------------
  33. %% Function: groups() -> [Group]
  34. %% Group = {GroupName,Properties,GroupsAndTestCases}
  35. %% GroupName = atom()
  36. %% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
  37. %% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
  38. %% TestCase = atom()
  39. %% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}
  40. %% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
  41. %% repeat_until_any_ok | repeat_until_any_fail
  42. %% N = integer() | forever
  43. %% -------------------------------------------------------------------
  44. groups() ->
  45. [
  46. {mnesia_creation_single_node, [shuffle], [
  47. single_node_when_mnesia_is_ram,
  48. single_node_when_mnesia_is_opt_disc_no_schema_exists,
  49. single_node_when_mnesia_is_opt_disc_schema_exists,
  50. single_node_when_mnesia_is_disc
  51. ]}
  52. ].
  53. %% -------------------------------------------------------------------
  54. %% Function: init_per_suite(Config0) ->
  55. %% Config1 | {skip,Reason} |
  56. %% {skip_and_save,Reason,Config1}
  57. %% Config0 = Config1 = [tuple()]
  58. %% Reason = term()
  59. %% -------------------------------------------------------------------
  60. init_per_suite(Config) ->
  61. %% config
  62. [
  63. {slave_node_bare_name, syn_slave}
  64. | Config
  65. ].
  66. %% -------------------------------------------------------------------
  67. %% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
  68. %% Config0 = Config1 = [tuple()]
  69. %% -------------------------------------------------------------------
  70. end_per_suite(_Config) -> ok.
  71. %% -------------------------------------------------------------------
  72. %% Function: init_per_group(GroupName, Config0) ->
  73. %% Config1 | {skip,Reason} |
  74. %% {skip_and_save,Reason,Config1}
  75. %% GroupName = atom()
  76. %% Config0 = Config1 = [tuple()]
  77. %% Reason = term()
  78. %% -------------------------------------------------------------------
  79. init_per_group(_GroupName, Config) -> Config.
  80. %% -------------------------------------------------------------------
  81. %% Function: end_per_group(GroupName, Config0) ->
  82. %% void() | {save_config,Config1}
  83. %% GroupName = atom()
  84. %% Config0 = Config1 = [tuple()]
  85. %% -------------------------------------------------------------------
  86. end_per_group(_GroupName, _Config) ->
  87. clean_after_test().
  88. %% ===================================================================
  89. %% Tests
  90. %% ===================================================================
  91. single_node_when_mnesia_is_ram(_Config) ->
  92. %% set schema location
  93. application:set_env(mnesia, schema_location, ram),
  94. %% start
  95. ok = syn:start(),
  96. %% check table exists
  97. true = lists:member(syn_processes_table, mnesia:system_info(tables)).
  98. single_node_when_mnesia_is_opt_disc_no_schema_exists(_Config) ->
  99. %% set schema location
  100. application:set_env(mnesia, schema_location, opt_disc),
  101. %% start
  102. ok = syn:start(),
  103. %% check table exists
  104. true = lists:member(syn_processes_table, mnesia:system_info(tables)).
  105. single_node_when_mnesia_is_opt_disc_schema_exists(_Config) ->
  106. %% set schema location
  107. application:set_env(mnesia, schema_location, opt_disc),
  108. %% create schema
  109. mnesia:create_schema([node()]),
  110. %% start
  111. ok = syn:start(),
  112. %% check table exists
  113. true = lists:member(syn_processes_table, mnesia:system_info(tables)).
  114. single_node_when_mnesia_is_disc(_Config) ->
  115. %% set schema location
  116. application:set_env(mnesia, schema_location, disc),
  117. %% create schema
  118. mnesia:create_schema([node()]),
  119. %% start
  120. ok = syn:start(),
  121. %% check table exists
  122. true = lists:member(syn_processes_table, mnesia:system_info(tables)).
  123. %% ===================================================================
  124. %% Internal
  125. %% ===================================================================
  126. clean_after_test() ->
  127. %% stop mnesia
  128. mnesia:stop(),
  129. %% delete schema
  130. mnesia:delete_schema([node()]),
  131. %% stop syn
  132. syn:stop().