<commit_before>%%% ---------------------------------------------------------------------------
%%% @author <NAME> <<EMAIL>>
%%% @copyright 2016 Space-Time Insight <<EMAIL>>
%%%
%%% @doc
%%% @end
%%% ---------------------------------------------------------------------------
-module(grain_streams_SUITE).

-compile(export_all).

-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").

-include("test_utils.hrl").

all() ->
    [simple_subscribe].

init_per_suite(Config) ->
    application:ensure_all_started(pgsql),
    application:load(erleans),
    application:set_env(erleans, default_lease_time, 60000),
    {ok, _} = application:ensure_all_started(erleans),
    Config.

end_per_suite(_Config) ->
    application:stop(erleans),
    application:stop(pgsql),
    ok.

init_per_testcase(_, Config) ->
    Config.

end_per_testcase(_, _Config) ->
    ok.

simple_subscribe(_Config) ->
    Grain1 = erleans:get_grain(stream_test_grain, <<"simple-subscribe-grain1">>),
    ?UNTIL(stream_test_grain:records_read(Grain1) >= 3),
    ok.<commit_msg>add regression test to verify streams sup is undefined<commit_after>%%% ---------------------------------------------------------------------------
%%% @author <NAME> <<EMAIL>>
%%% @copyright 2016 Space-Time Insight <<EMAIL>>
%%%
%%% @doc
%%% @end
%%% ---------------------------------------------------------------------------
-module(grain_streams_SUITE).

-compile(export_all).

-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").

-include("test_utils.hrl").

all() ->
    [simple_subscribe, no_stream_config_check].

init_per_suite(Config) ->
    Config.

end_per_suite(_Config) ->
    ok.

init_per_testcase(no_stream_config_check, Config) ->
    application:ensure_all_started(pgsql),
    application:load(erleans),
    application:unset_env(erleans, stream_providers),
    application:set_env(erleans, default_lease_time, 60000),
    {ok, _} = application:ensure_all_started(erleans),
    Config;
init_per_testcase(_, Config) ->
    application:ensure_all_started(pgsql),
    application:load(erleans),
    application:set_env(erleans, default_lease_time, 60000),
    {ok, _} = application:ensure_all_started(erleans),
    Config.

end_per_testcase(_, _Config) ->
    application:stop(erleans),
    application:stop(pgsql),
    ok.

simple_subscribe(_Config) ->
    Grain1 = erleans:get_grain(stream_test_grain, <<"simple-subscribe-grain1">>),
    ?UNTIL(stream_test_grain:records_read(Grain1) >= 3),
    ok.

%% regression test for stream supervisor not starting if not configured: #27
no_stream_config_check(_Config) ->
    ?assertEqual(undefined, whereis(erleans_streams_sup)).
{'fraction_non_alphanumeric': 0.24740356083086054, 'fraction_numerical': 0.012240356083086053, 'mean_word_length': 2.914368650217707, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1527490', 'n_tokens_mistral': 900, 'n_tokens_neox': 869, 'n_words': 122}