<commit_before>%% @copyright 2012-2015 Zuse Institute Berlin

%   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.

%% @author <NAME> <<EMAIL>>
%% @author <NAME> <<EMAIL>>
%% @author <NAME> <<EMAIL>>
%% @doc    Unit tests varifying type constraints via random testing.
%% @end
%% @version $Id$
-module(type_check_SUITE).
-author('<EMAIL>').
-vsn('$Id$').

-compile(export_all).

-include("scalaris.hrl").
-include("unittest.hrl").
-include("client_types.hrl").

all()   -> [
            tester_type_check_api,
            tester_type_check_config,
%%            tester_type_check_dht_node,
            tester_type_check_math,
            tester_type_check_node,
            tester_type_check_paxos,
            tester_type_check_rrepair,
            tester_type_check_tx,
            tester_type_check_rdht_tx,
            tester_type_check_histogram,
            tester_type_check_util,
            tester_type_check_gossip,
            tester_type_check_mr
           ].
suite() -> [ {timetrap, {seconds, 480}} ].

init_per_suite(Config) ->
    Config.

end_per_suite(_Config) ->
    ok.

init_per_testcase(_TestCase, Config) ->
    {priv_dir, PrivDir} = lists:keyfind(priv_dir, 1, Config),
    unittest_helper:make_ring(4, [{config, [{log_path, PrivDir}]}]),
    [{stop_ring, true} | Config].

end_per_testcase(_TestCase, _Config) ->
    ok.

tester_type_check_api(_Config) ->
    Count = 500,
    config:write(no_print_ring_data, true),
    %% [{modulename, [excludelist = {fun, arity}]}]
    tester:register_type_checker({typedef, rdht_tx, encoded_value, []}, rdht_tx, is_encoded_value),
    tester:register_value_creator({typedef, rdht_tx, encoded_value, []}, rdht_tx, encode_value, 1),
    Modules =
        [ {api_dht, [], []},
          {api_dht_raw,
           [ {unreliable_lookup,2}, %% creates arb. messages
             {unreliable_get_key,3} %% creates arb. IP-adresses
           ],
           [ {range_read,1}, %% bug in range_read?
             {range_read_loop,5}, %% receives msgs
             {delete_and_cleanup_timer,2} %% cannot create reference()
           ]},
          {api_monitor, [], []},
          {api_rdht, [], [ {delete_collect_results, 3} ]}, %% receives
          {api_tx,
           [ {get_system_snapshot, 0} %% receives msgs
           ], []},
          {api_mr,
           [ {start_job, 1} %% sends msgs
           ],
           [ {wait_for_results, 3}]} %%receives messages
        ],
    _ = [ tester:type_check_module(Mod, Excl, ExclPriv, Count)
          || {Mod, Excl, ExclPriv} <- Modules ],
    tester:unregister_type_checker({typedef, rdht_tx, encoded_value, []}),
    tester:unregister_value_creator({typedef, rdht_tx, encoded_value, []}),
    true.

tester_type_check_config(_Config) ->
    Count = 500,
    %% [{modulename, [excludelist = {fun, arity}]}]
    Modules =
        [ {config,<commit_msg>type_check_SUITE: temporarily disable split_ring<commit_after>%% @copyright 2012-2015 Zuse Institute Berlin

%   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.

%% @author <NAME> <<EMAIL>>
%% @author <NAME> <<EMAIL>>
%% @author <NAME> <<EMAIL>>
%% @doc    Unit tests varifying type constraints via random testing.
%% @end
%% @version $Id$
-module(type_check_SUITE).
-author('<EMAIL>').
-vsn('$Id$').

-compile(export_all).

-include("scalaris.hrl").
-include("unittest.hrl").
-include("client_types.hrl").

all()   -> [
            tester_type_check_api,
            tester_type_check_config,
%%            tester_type_check_dht_node,
            tester_type_check_math,
            tester_type_check_node,
            tester_type_check_paxos,
            tester_type_check_rrepair,
            tester_type_check_tx,
            tester_type_check_rdht_tx,
            tester_type_check_histogram,
            tester_type_check_util,
            tester_type_check_gossip,
            tester_type_check_mr
           ].
suite() -> [ {timetrap, {seconds, 480}} ].

init_per_suite(Config) ->
    Config.

end_per_suite(_Config) ->
    ok.

init_per_testcase(_TestCase, Config) ->
    {priv_dir, PrivDir} = lists:keyfind(priv_dir, 1, Config),
    unittest_helper:make_ring(4, [{config, [{log_path, PrivDir}]}]),
    [{stop_ring, true} | Config].

end_per_testcase(_TestCase, _Config) ->
    ok.

tester_type_check_api(_Config) ->
    Count = 500,
    config:write(no_print_ring_data, true),
    %% [{modulename, [excludelist = {fun, arity}]}]
    tester:register_type_checker({typedef, rdht_tx, encoded_value, []}, rdht_tx, is_encoded_value),
    tester:register_value_creator({typedef, rdht_tx, encoded_value, []}, rdht_tx, encode_value, 1),
    Modules =
        [ {api_dht, [], []},
          {api_dht_raw,
           [ {unreliable_lookup,2}, %% creates arb. messages
             {unreliable_get_key,3}, %% creates arb. IP-adresses
             {split_ring, 1} %% needs feeder to limit the input size
           ],
           [ {range_read,1}, %% bug in range_read?
             {range_read_loop,5}, %% receives msgs
             {delete_and_cleanup_timer,2} %% cannot create reference()
           ]},
          {api_monitor, [], []},
          {api_rdht, [], [ {delete_collect_results, 3} ]}, %% receives
          {api_tx,
           [ {get_system_snapshot, 0} %% receives msgs
           ], []},
          {api_mr,
           [ {start_job, 1} %% sends msgs
           ],
           [ {wait_for_results, 3}]} %%receives messages
        ],
    _ = [ tester:type_check_module(Mod, Excl, ExclPriv, Count)
          || {Mod, Excl, ExclPriv} <- Modules ],
    tester:unregister_type_checker({typedef, rdht_tx, encoded_value, []}),
    tester:unregister_value_creator({typedef, rdht_tx, encoded_value, []}),
    true.

tester_type_check_config(_Config) ->
    Count = 500,
    %% [{modulename, [excludelist = {fun, arity}]}]
    Modules =
        [ {config,
{'fraction_non_alphanumeric': 0.12967032967032968, 'fraction_numerical': 0.009816849816849818, 'mean_word_length': 2.8850313033579966, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5771214', 'n_tokens_mistral': 2342, 'n_tokens_neox': 2224, 'n_words': 485}