anchor.diff:      registering_upload_for_non_empty_file_should_fail_test/1,
       registering_upload_for_not_owned_file_should_fail_test/1,
       not_registered_upload_should_fail_test/1,
  -    upload_test/1
  -%%    stale_upload_file_should_be_deleted_test/1,
  -%%
  -%%    % sequential tests
  +    upload_test/1,
  +
  +    % sequential tests
  +    stale_upload_file_should_be_deleted_test/1
   %%    upload_with_time_warps_test/1
   ]).
   
  
positive.code:                 {ok, [], Req}
          end
      ),
      ok = test_utils:mock_expect(Workers, cowboy_req, read_part_body,
          fun
              (#{left := 1, size := Size} = Req, _) ->
                  {ok, <<<<$a>> || _ <- lists:seq(1, Size)>>, Req#{done => true}};
  
negative.code:     assert_file_uploaded(krakow, user1, FileGuid, 250).
  
  
  stale_upload_file_should_be_deleted_test(_Config) ->
      [#object{guid = FileGuid}] = onenv_file_test_utils:create_and_sync_file_tree(
          user1, space_krk, #file_spec{}
      ),
  
      ?assertMatch({ok, _}, initialize_gui_upload(krakow, user1, FileGuid)),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      [StallProcess | StallProcesses] = spawn_stall_processes(krakow, user1, FileGuid),
  
      % upload should not be removed as long as there is at least one uploading process alive
      time_test_utils:simulate_seconds_passing(1000),
      force_stale_uploads_removal(krakow),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      lists:foreach(fun stop_stall_process/1, StallProcesses),
      time_test_utils:simulate_seconds_passing(1000),
      force_stale_uploads_removal(krakow),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      % and will be removed if no such process exists for longer than 1 minute
      stop_stall_process(StallProcess),
      time_test_utils:simulate_seconds_passing(59),
      force_stale_uploads_removal(krakow),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      time_test_utils:simulate_seconds_passing(2),
      force_stale_uploads_removal(krakow),
      ?assertMatch(false, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      Node = oct_background:get_random_provider_node(krakow),
      UserSessId = oct_background:get_user_session_id(user1, krakow),
  
      ?assertMatch(
          {error, ?ENOENT},
          onenv_file_test_utils:get_object_attributes(Node, UserSessId, FileGuid),
          ?ATTEMPTS
      ).
  
  
  %%upload_with_time_warps_test(_Config) ->
  %%    UserId = oct_background:get_user_id(user1),
  %%    UserSessId = oct_background:get_user_session_id(user1, krakow),
  %%    [Node] = oct_background:get_provider_nodes(krakow),
  %%
  %%    CurrTime = time_test_utils:get_frozen_time_seconds(),
  %%    {ok, FileGuid} = lfm_proxy:create(Node, UserSessId, ?FILE_PATH),
  %%
  %%    FileKey = ?FILE_REF(FileGuid),
  %%    ?assertMatch({ok, #file_attr{mtime = CurrTime}}, lfm_proxy:stat(Node, UserSessId, FileKey)),
  %%
  %%    ?assertMatch({ok, _}, initialize_gui_upload(UserId, UserSessId, FileGuid, Node)),
  %%    ?assertMatch(true, authorize_chunk_upload(UserId, FileGuid, Node)),
  %%
  %%    % upload should not be canceled if time warps backward (whether write occurred or not)
  %%    PastTime = time_test_utils:simulate_seconds_passing(-1000),
  %%
  %%    ?assertMatch({ok, #file_attr{mtime = CurrTime}}, lfm_proxy:stat(Node, UserSessId, FileKey)),
  %%    force_stale_uploads_removal(krakow),
  %%    ?assertMatch(true, authorize_chunk_upload(UserId, FileGuid, Node)),
  %%
  %%    do_multipart(Node, ?USER(UserId, UserSessId), FileGuid, 5, 10, 1),
  %%    ?assertMatch({ok, #file_attr{mtime = PastTime}}, lfm_proxy:stat(Node, UserSessId, FileKey), ?ATTEMPTS),
  %%    force_stale_uploads_removal(krakow),
  %%    ?assertMatch(true, authorize_chunk_upload(UserId, FileGuid, Node)),
  %%
  %%    % in case of forward time warp if next chunk was written to file (this updates file mtime)
  %%    % it should be left. Otherwise it will be deleted as stale upload.
  %%    FutureTime = time_test_utils:simulate_seconds_passing(3000),
  %%
  %%    do_multipart(Node, ?USER(UserId, UserSessId), FileGuid, 5, 10, 1),
  %%    ?assertMatch({ok, #file_attr{mtime = FutureTime}}, lfm_proxy:stat(Node, UserSessId, FileKey), ?ATTEMPTS),
  %%    force_stale_uploads_removal(krakow),
  %%    ?assertMatch(true, authorize_chunk_upload(UserId, FileGuid, Node)),
  %%
  %%    time_test_utils:simulate_seconds_passing(2000),
  %%
  %%    ?assertMatch({ok, #file_attr{mtime = FutureTime}}, lfm_proxy:stat(Node, UserSessId, FileKey)),
  %%    force_stale_uploads_removal(krakow),
  %%    ?assertMatch(false, authorize_chunk_upload(UserId, FileGuid, Node)),
  %%    ?assertMatch({error, ?ENOENT}, lfm_proxy:stat(Node, UserSessId, FileKey), ?ATTEMPTS).
  
  
  %%%===================================================================
  