Esempio n. 1
0
 def verify():
     # By default, node id should be configured to the head node.
     for log in get_log(
         node_id=head_node["node_id"], filename="raylet.out", tail=10
     ):
         # + 1 since the last line is just empty.
         assert len(log.split("\n")) == 11
     return True
Esempio n. 2
0
 def verify():
     # By default, node id should be configured to the head node.
     for log in get_log(actor_id=actor_id, tail=10):
         # + 1 since the last line is just empty.
         assert len(log.split("\n")) == 11
     return True
Esempio n. 3
0
def test_log_get(ray_start_cluster):
    cluster = ray_start_cluster
    cluster.add_node(num_cpus=0)
    ray.init(address=cluster.address)
    head_node = list_nodes()[0]
    cluster.add_node(num_cpus=1)

    @ray.remote(num_cpus=1)
    class Actor:
        def print(self, i):
            for _ in range(i):
                print("1")

        def getpid(self):
            import os

            return os.getpid()

    """
    Test filename match
    """

    def verify():
        # By default, node id should be configured to the head node.
        for log in get_log(
            node_id=head_node["node_id"], filename="raylet.out", tail=10
        ):
            # + 1 since the last line is just empty.
            assert len(log.split("\n")) == 11
        return True

    wait_for_condition(verify)

    """
    Test worker pid / IP match
    """
    a = Actor.remote()
    pid = ray.get(a.getpid.remote())
    ray.get(a.print.remote(20))

    def verify():
        # By default, node id should be configured to the head node.
        for log in get_log(node_ip=head_node["node_ip"], pid=pid, tail=10):
            # + 1 since the last line is just empty.
            assert len(log.split("\n")) == 11
        return True

    wait_for_condition(verify)

    """
    Test actor logs.
    """
    actor_id = a._actor_id.hex()

    def verify():
        # By default, node id should be configured to the head node.
        for log in get_log(actor_id=actor_id, tail=10):
            # + 1 since the last line is just empty.
            assert len(log.split("\n")) == 11
        return True

    wait_for_condition(verify)

    with pytest.raises(NotImplementedError):
        for _ in get_log(task_id=123, tail=10):
            pass