anchor.diff:  -define(STRESS_ENV_VARIABLE, "stress").
   -define(STRESS_NO_CLEARING_ENV_VARIABLE, "stress_no_clearing").
   -define(STRESS_TIME_ENV_VARIABLE, "stress_time").
  --define(STRESS_DEFAULT_TIME, timer:hours(3) div 1000).
  --define(STRESS_ERRORS_TO_STOP, 100).
  +-define(STRESS_DEFAULT_TIME, timer:hours(10) div 1000).
  +-define(STRESS_ERRORS_TO_STOP, 20).
   -define(STRESS_ETS_NAME, stress_ets).
   -define(STRESS_TIMEOUT_EXTENSION_SECONDS, 600). % extension of ct timeout to let running tests end
   
  
positive.code:                        TestTime = timer:now_diff(Now, StartTime) div 1000000,
                         TimeLeft = TimeLimit - TestTime,
  
                         ErrorsHistoryOK = lists:foldl(fun(FR, Acc) ->
                             case Acc of
                                 error ->
                                     error;
                                 _ ->
                                     check_error(Rep, FR)
                             end
                         end, ok, FailedReps),
  
                         case (TimeLeft > 0) and (ErrorsHistoryOK =:= ok) of
                             true ->
                                 ct:print("SUITE: ~p~nCASE: ~p~nCONFIG: ~p~nREPEAT: ~p, TEST TIME ~p sek, TIME LEFT ~p sek",
                                     [SuiteName, CaseName, ConfigName, Rep, TestTime, TimeLeft]),
  
negative.code: %% Check if stress test should be stopped because of error.
  %% @end
  %%--------------------------------------------------------------------
  -spec check_error(Rep :: integer(), FailedReps :: map()) -> integer() | permanent_error.
  check_error(Rep, FailedReps) ->
      check_error(Rep - 1, Rep, FailedReps).
  
  %%--------------------------------------------------------------------
  %% @private
  %% @doc
  %% Check if stress test should be stopped because of error.
  %% @end
  %%--------------------------------------------------------------------
  -spec check_error(Rep :: integer(), Start :: integer(), FailedReps :: map()) -> integer() | permanent_error.
  check_error(Check, Start, _FailedReps) when Start - ?STRESS_ERRORS_TO_STOP > Check ->
      permanent_error;
  check_error(0, Start, _FailedReps) ->
      Start - 1;
  check_error(Check, Start, FailedReps) ->
      case maps:is_key(integer_to_binary(Check), FailedReps) of
          false ->
              Start - Check - 1;
          _ ->
              check_error(Check - 1, Start, FailedReps)
      end.
  