Beispiel #1
0
def test_usage_lib_cluster_metadata_generation(monkeypatch, shutdown_only):
    with monkeypatch.context() as m:
        m.setenv("RAY_USAGE_STATS_ENABLED", "1")
        ray.init(num_cpus=0)
        """
        Test metadata stored is equivalent to `_generate_cluster_metadata`.
        """
        meta = ray_usage_lib._generate_cluster_metadata()
        cluster_metadata = ray_usage_lib.get_cluster_metadata(
            ray.experimental.internal_kv.internal_kv_get_gcs_client(),
            num_retries=20)
        # Remove fields that are dynamically changed.
        assert meta.pop("session_id")
        assert meta.pop("session_start_timestamp_ms")
        assert cluster_metadata.pop("session_id")
        assert cluster_metadata.pop("session_start_timestamp_ms")
        assert meta == cluster_metadata
        """
        Make sure put & get works properly.
        """
        cluster_metadata = ray_usage_lib.put_cluster_metadata(
            ray.experimental.internal_kv.internal_kv_get_gcs_client(),
            num_retries=20)
        assert cluster_metadata == ray_usage_lib.get_cluster_metadata(
            ray.experimental.internal_kv.internal_kv_get_gcs_client(),
            num_retries=20)
Beispiel #2
0
def test_usage_lib_cluster_metadata_generation(
    monkeypatch, ray_start_cluster, reset_lib_usage
):
    with monkeypatch.context() as m:
        m.setenv("RAY_USAGE_STATS_ENABLED", "1")
        m.setenv("RAY_USAGE_STATS_REPORT_URL", "http://127.0.0.1:8000")
        cluster = ray_start_cluster
        cluster.add_node(num_cpus=0)
        ray.init(address=cluster.address)
        """
        Test metadata stored is equivalent to `_generate_cluster_metadata`.
        """
        meta = ray_usage_lib._generate_cluster_metadata()
        cluster_metadata = ray_usage_lib.get_cluster_metadata(
            ray.experimental.internal_kv.internal_kv_get_gcs_client(), num_retries=20
        )
        # Remove fields that are dynamically changed.
        assert meta.pop("session_id")
        assert meta.pop("session_start_timestamp_ms")
        assert cluster_metadata.pop("session_id")
        assert cluster_metadata.pop("session_start_timestamp_ms")
        assert meta == cluster_metadata

        """
        Make sure put & get works properly.
        """
        cluster_metadata = ray_usage_lib.put_cluster_metadata(
            ray.experimental.internal_kv.internal_kv_get_gcs_client(), num_retries=20
        )
        assert cluster_metadata == ray_usage_lib.get_cluster_metadata(
            ray.experimental.internal_kv.internal_kv_get_gcs_client(), num_retries=20
        )
Beispiel #3
0
def test_usage_lib_cluster_metadata_generation(shutdown_only):
    ray.init(num_cpus=0)
    """
    Test metadata stored is equivalent to `_generate_cluster_metadata`.
    """
    meta = ray_usage_lib._generate_cluster_metadata()
    cluster_metadata = ray_usage_lib.get_cluster_metadata(
        ray.experimental.internal_kv.internal_kv_get_gcs_client(),
        num_retries=20)
    # Session id is random.
    meta.pop("session_id")
    cluster_metadata.pop("session_id")
    assert meta == cluster_metadata
    """
    Make sure put & get works properly.
    """
    cluster_metadata = ray_usage_lib.put_cluster_metadata(
        ray.experimental.internal_kv.internal_kv_get_gcs_client(),
        num_retries=20)
    assert cluster_metadata == ray_usage_lib.get_cluster_metadata(
        ray.experimental.internal_kv.internal_kv_get_gcs_client(),
        num_retries=20)