docstr: Test eviction happens when we exceed a nonzero (10MB) cache size.
docstr_tok: ["Test","eviction","happens","when","we","exceed","a","nonzero","(","10MB",")","cache","size","."]
code: def test_hit_cache_size_limit(
      self,
      start_cluster,
      URI_cache_10_MB,
      disable_temporary_uri_pinning,
  ):
      """Test eviction happens when we exceed a nonzero (10MB) cache size."""
      NUM_NODES = 3
      cluster, address = start_cluster
      for i in range(NUM_NODES - 1):  # Head node already added.
          cluster.add_node(
              num_cpus=1,
              runtime_env_dir_name=f"node_{i}_runtime_resources",
          )
          print(
              f'Added node with runtime_env_dir_name "node_{i}_runtime_resources".'
          )
  
      print(f"Added all {NUM_NODES} nodes.")
  
      with tempfile.TemporaryDirectory() as tmp_dir, chdir(tmp_dir):
          print("Entered tempfile context manager.")
  
          with open("test_file_1", "wb") as f:
              f.write(os.urandom(8 * 1024 * 1024))  # 8 MiB
          print('Wrote random bytes to "test_file_1" file.')
  
          ray.init(address, runtime_env={"working_dir": tmp_dir})
          print(f'Initialized Ray at "{address}" with working_dir.')
  
          @ray.remote
          def f():
              pass
  
          ray.get(f.remote())
          print('Created and received response from task "f".')
  
          ray.shutdown()
          print("Ray has been shut down.")
  
          with open("test_file_2", "wb") as f:
              f.write(os.urandom(4 * 1024 * 1024))
          print('Wrote random bytes to "test_file_2".')
  
          os.remove("test_file_1")
          print('Removed "test_file_1".')
  
          ray.init(address, runtime_env={"working_dir": tmp_dir})
          print(
              f'Reinitialized Ray at address "{address}" with working_dir.'
          )
  
          # Without the cache size limit, we would expect the local dir to be
          # 12 MB.  Since we do have a size limit, the first package must be
          # GC'ed, leaving us with 4 MB.
  
          for idx, node in enumerate(cluster.list_all_nodes()):
              local_dir = os.path.join(
                  node.get_runtime_env_dir_path(), "working_dir_files"
              )
              print("Created local_dir path.")
  
              def local_dir_size_near_4mb():
                  return (
                      3
                      < get_directory_size_bytes(local_dir)
                      / (1024**2)
                      < 5
                  )
  
              wait_for_condition(local_dir_size_near_4mb)
  
              print(f"get_directory_size_bytes assertion {idx} passed.")
  
imports: import os
  import sys
  import tempfile
  import time
  from pathlib import Path
  from unittest import mock
  import pytest
  from pytest_lazyfixture import lazy_fixture
  import ray
  import ray.experimental.internal_kv
  from ray._private.ray_constants import RAY_RUNTIME_ENV_URI_PIN_EXPIRATION_S_ENV_VAR
  from ray._private.utils import get_directory_size_bytes
  from ray._private.test_utils import chdir, check_local_files_gced, wait_for_condition, find_free_port
label_desc: Use image node_id 4 for calling the TestGC obj's underlying member method code with example usage: obj.test_hit_cache_size_limit(start_cluster, URI_cache_10_MB, disable_temporary_uri_pinning) and returns: unknown