Esempio n. 1
0
def test_raylet_tempfiles():
    ray.init(redirect_worker_output=False)
    top_levels = set(os.listdir(tempfile_services.get_temp_root()))
    assert top_levels == {"ray_ui.ipynb", "sockets", "logs"}
    log_files = set(os.listdir(tempfile_services.get_logs_dir_path()))
    assert log_files == {
        "log_monitor.out", "log_monitor.err", "plasma_store.out",
        "plasma_store.err", "webui.out", "webui.err", "monitor.out",
        "monitor.err", "raylet_monitor.out", "raylet_monitor.err",
        "redis-shard_0.out", "redis-shard_0.err", "redis.out", "redis.err",
        "raylet.out", "raylet.err"
    }  # with raylet logs
    socket_files = set(os.listdir(tempfile_services.get_sockets_dir_path()))
    assert socket_files == {"plasma_store", "raylet"}
    ray.shutdown()

    ray.init(redirect_worker_output=True, num_cpus=0)
    top_levels = set(os.listdir(tempfile_services.get_temp_root()))
    assert top_levels == {"ray_ui.ipynb", "sockets", "logs"}
    log_files = set(os.listdir(tempfile_services.get_logs_dir_path()))
    assert log_files == {
        "log_monitor.out", "log_monitor.err", "plasma_store.out",
        "plasma_store.err", "webui.out", "webui.err", "monitor.out",
        "monitor.err", "raylet_monitor.out", "raylet_monitor.err",
        "redis-shard_0.out", "redis-shard_0.err", "redis.out", "redis.err",
        "raylet.out", "raylet.err"
    }  # with raylet logs
    socket_files = set(os.listdir(tempfile_services.get_sockets_dir_path()))
    assert socket_files == {"plasma_store", "raylet"}
    ray.shutdown()

    ray.init(redirect_worker_output=True, num_cpus=2)
    top_levels = set(os.listdir(tempfile_services.get_temp_root()))
    assert top_levels == {"ray_ui.ipynb", "sockets", "logs"}
    time.sleep(3)  # wait workers to start
    log_files = set(os.listdir(tempfile_services.get_logs_dir_path()))
    assert log_files.issuperset({
        "log_monitor.out", "log_monitor.err", "plasma_store.out",
        "plasma_store.err", "webui.out", "webui.err", "monitor.out",
        "monitor.err", "raylet_monitor.out", "raylet_monitor.err",
        "redis-shard_0.out", "redis-shard_0.err", "redis.out", "redis.err",
        "raylet.out", "raylet.err"
    })  # with raylet logs

    # Check numbers of worker log file.
    assert sum(1 for filename in log_files
               if filename.startswith("worker")) == 4

    socket_files = set(os.listdir(tempfile_services.get_sockets_dir_path()))
    assert socket_files == {"plasma_store", "raylet"}
    ray.shutdown()
Esempio n. 2
0
def test_raylet_tempfiles():
    ray.init(redirect_worker_output=False)
    top_levels = set(os.listdir(tempfile_services.get_temp_root()))
    assert top_levels == {"ray_ui.ipynb", "sockets", "logs"}
    log_files = set(os.listdir(tempfile_services.get_logs_dir_path()))
    assert log_files == {
        "log_monitor.out", "log_monitor.err", "plasma_store.out",
        "plasma_store.err", "webui.out", "webui.err", "monitor.out",
        "monitor.err", "redis-shard_0.out", "redis-shard_0.err", "redis.out",
        "redis.err"
    }  # without raylet logs
    socket_files = set(os.listdir(tempfile_services.get_sockets_dir_path()))
    assert socket_files == {"plasma_store", "raylet"}
    ray.shutdown()

    ray.init(redirect_worker_output=True, num_cpus=0)
    top_levels = set(os.listdir(tempfile_services.get_temp_root()))
    assert top_levels == {"ray_ui.ipynb", "sockets", "logs"}
    log_files = set(os.listdir(tempfile_services.get_logs_dir_path()))
    assert log_files == {
        "log_monitor.out", "log_monitor.err", "plasma_store.out",
        "plasma_store.err", "webui.out", "webui.err", "monitor.out",
        "monitor.err", "redis-shard_0.out", "redis-shard_0.err", "redis.out",
        "redis.err", "raylet.out", "raylet.err"
    }  # with raylet logs
    socket_files = set(os.listdir(tempfile_services.get_sockets_dir_path()))
    assert socket_files == {"plasma_store", "raylet"}
    ray.shutdown()

    ray.init(redirect_worker_output=True, num_cpus=2)
    top_levels = set(os.listdir(tempfile_services.get_temp_root()))
    assert top_levels == {"ray_ui.ipynb", "sockets", "logs"}
    time.sleep(3)  # wait workers to start
    log_files = set(os.listdir(tempfile_services.get_logs_dir_path()))
    assert log_files.issuperset({
        "log_monitor.out", "log_monitor.err", "plasma_store.out",
        "plasma_store.err", "webui.out", "webui.err", "monitor.out",
        "monitor.err", "redis-shard_0.out", "redis-shard_0.err", "redis.out",
        "redis.err", "raylet.out", "raylet.err"
    })  # with raylet logs

    # Check numbers of worker log file.
    assert sum(
        1 for filename in log_files if filename.startswith("worker")) == 4

    socket_files = set(os.listdir(tempfile_services.get_sockets_dir_path()))
    assert socket_files == {"plasma_store", "raylet"}
    ray.shutdown()