Ejemplo n.º 1
0
def test_stress_line_of_levels():
    print("Testing Long Line of Actors")
    sys = ActorSystem("test")
    path = "test"
    actors = []
    for i in range(1, 100):
        actor = BaseActor()
        actor.start()
        sys.add_actor(actor, path)
        actors.append(actor)
        path += "/{}".format(actor.get_name())
    print("Closing Actors")
    sys.close()
    assert (len([x for x in actors
                 if x.get_state() is ActorState.TERMINATED]) == len(actors))
Ejemplo n.º 2
0
    async def test():
        print("Creating Actors")
        for i in range(1, 50000):
            a = BaseActor()
            a.start()
            sys.add_actor(a, "test")
            level_one.append(a)

        for i in range(1, 100000):
            # choose random
            a = BaseActor()
            a.start()
            parent = random.choice(level_one)
            path = "test/{}".format(parent.get_name().strip())
            sys.add_actor(a, path)
            level_two.append(parent)
Ejemplo n.º 3
0
def test_balancing_router_actor_addition():
    print("Starting Actor Addition Test")
    sys = ActorSystem("test")
    rr = BalancingRouter("test_router")
    rr.start()
    print(rr.get_name())
    a = BaseActor()
    a.start()
    rr.add_actor(a)
    sys.add_actor(rr, "test")
    rr.remove_actor(a)
    assert (rr.get_num_actors() is 0), "Actor Still in Router"
    sys.close()
    asyncio.get_event_loop().run_until_complete(a.stop())
    assert (rr.get_state() is ActorState.TERMINATED), "Router Not Closed"
    assert (a.get_state() is ActorState.TERMINATED), "Actor is Not Closed"
    print("Actor Addition Test Complete")
Ejemplo n.º 4
0
def test_branch_removal():
    """
    Add a basic branch and remove it.
    """
    print("Testing Branch Creation")
    a = BaseActor()
    a.start()
    b = BaseActor()
    b.start()
    c = BaseActor()
    c.start()
    d = BaseActor()
    d.start()

    sys = ActorSystem("test")
    sys.add_actor(a, "test")
    sys.add_actor(b, "test/{}".format(a.get_name()))
    sys.add_actor(d, "test/{}/{}".format(a.get_name(), b.get_name()))
    sys.add_actor(c, "test")

    sys.close(do_print=False)
    assert (a.get_state() is ActorState.TERMINATED), "Actor was not Terminated"
    assert (b.get_state() is ActorState.TERMINATED), "Actor was not Terminated"
    assert (c.get_state() is ActorState.TERMINATED), "Actor was not Terminated"
    assert (d.get_state() is ActorState.TERMINATED), "Actor was not Terminated"
    print("Finished Testing Branch Creation")
Ejemplo n.º 5
0
def test_round_robin_actor_addition():
    print("Starting Actor Addition Test")
    sys = ActorSystem("tests")
    rr = RoundRobinRouter("test_router")
    rr.start()
    rr.set_actor_system(sys, "tests")

    a = BaseActor("testa")
    a.start()
    rr.add_actor(a)

    b = BaseActor("testb")
    b.start()
    rr.add_actor(b)
    msg = "Actors Missing. Length {}".format(rr.get_num_actors())
    assert(rr.get_num_actors() == 2), msg
    rr.remove_actor(a)
    assert(rr.get_num_actors() == 1), "Number of Actors Should be 1"
    asyncio.get_event_loop().run_until_complete(a.stop())
    sys.close()
    assert(a.get_state() == ActorState.TERMINATED), "Actor a Not Terminated"
    assert(b.get_state() == ActorState.TERMINATED), " Actor b Not Terminated"
    assert(rr.get_state() == ActorState.TERMINATED), "Router Not Terminated"
    print("Actor Addition Test Complete")