コード例 #1
0
def test_puller_kill_with_dispatcher(initialized_puller_with_dispatcher):
    """
   Create an initialized Puller and call its kill method

   Test if:
    - Actor is terminated
    - Disconnect from Dispatchers
   """
    initialized_puller_with_dispatcher.send_kill()
    initialized_puller_with_dispatcher.join(500)
    assert not is_actor_alive(initialized_puller_with_dispatcher)
    for _, disp in initialized_puller_with_dispatcher.state.report_filter.filters:
        disp.join(200)
        assert not is_actor_alive(disp)
コード例 #2
0
def test_crash_dispatcher(database, main_process):
    if main_process.is_alive():
        os.kill(main_process.pid, signal.SIGTERM)
        main_process.join(5)
        assert not is_actor_alive(main_process)

    assert True
コード例 #3
0
def test_puller_init_already_init(initialized_puller):
    """
    Create a PullerActor and send a StartMessage to an already initialized Actor
    """
    initialized_puller.send_control(StartMessage())
    assert is_actor_alive(initialized_puller)
    assert isinstance(initialized_puller.receive_control(), ErrorMessage)
コード例 #4
0
def test_puller_create_empty_filter(generate_mongodb_data, supervisor, puller):
    """
    Create a PullerActor with an empty filter
    """
    supervisor.launch_actor(puller)
    assert not is_actor_alive(puller)
    assert isinstance(puller.receive_control(), ErrorMessage)
コード例 #5
0
def test_pusher_kill_after_init(generate_mongodb_data,
                                initialized_pusher_plus_supervisor):
    """
    Create a PusherActor and kill him with a PoisonPillMessage
    """
    initialized_pusher_plus_supervisor[1].kill_actors()
    assert not is_actor_alive(initialized_pusher_plus_supervisor[0])
コード例 #6
0
def test_pusher_kill_without_init(started_pusher):
    """
    Create a PusherActor and kill him with a PoisonPillMessage before initialization
    """
    started_pusher.connect_data()
    started_pusher.send_kill(by_data=True)
    assert not is_actor_alive(started_pusher, 5)
コード例 #7
0
def test_puller_kill_without_init(started_puller):
    """
    Create a PullerActor and kill him with a PoisonPillMessage before initialization
    """
    started_puller.connect_control()
    started_puller.send_kill()
    assert not is_actor_alive(started_puller)
コード例 #8
0
    def test_puller_kill_init(self, initialized_puller):
        """
        Create an initialized Puller and call its kill method

        Test if:
         - Actor is terminated
        """
        initialized_puller.send_kill()
        assert not is_actor_alive(initialized_puller)
コード例 #9
0
def test_pusher_kill_without_init(started_pusher):
    """
    Create a PusherActor and kill him with a PoisonPillMessage before initialization
    """
    started_pusher.connect_control()
    # wait for the main process to connect the pusher before sending the message
    time.sleep(0.5)
    started_pusher.hard_kill()
    assert not is_actor_alive(started_pusher, 5)
コード例 #10
0
def test_mongodb_bad_config(puller, supervisor):
    """
    Send a start message to a PullerActor with a DB with a bad configuration

    After sending the message test :
      - if the actor send an ErrorMessage to the test process
      - if the actor is dead
    """
    with pytest.raises(ActorInitError):
        supervisor.launch_actor(puller)
    assert not is_actor_alive(puller)
コード例 #11
0
    def test_start_msg_db_ok_stream(self, log_socket, initialized_puller):
        """
        Send a start message to a PullerActor with stream mode on

        After sending the message test :
          - if the actor is alive
          - if the following method has been called:
            - connect from database
            - connect_data from dispatcher
        """
        assert is_log_ok(log_socket, ['connect', 'connect_data'])
        assert is_actor_alive(initialized_puller)
コード例 #12
0
def test_puller_kill_without_init(started_puller):
    """
    Create a PullerActor and kill him with a PoisonPillMessage before initialization
    """
    started_puller.connect_control()
    # There is one more important thing to know about PUB-SUB sockets: you do not
    # know precisely when a subscriber starts to get messages. Even if you start
    # a subscriber, wait a while, and then start the publisher, the subscriber will
    # always miss the first messages that the publisher sends. This is because as
    # the subscriber connects to the publisher (something that takes a small but
    # non-zero time), the publisher may already be sending messages out.
    time.sleep(0.1)
    started_puller.hard_kill()
    assert not is_actor_alive(started_puller)
コード例 #13
0
def test_pusher_save_power_report(generate_mongodb_data, initialized_pusher):
    """
    Create a PusherActor, send him a PowerReport, kill him and check it from database
    """
    # Connect data and send a PowerReport
    initialized_pusher.connect_data()
    saved_report = gen_power_report()
    initialized_pusher.send_data(saved_report)

    # Kill it
    initialized_pusher.send_kill(by_data=True)
    assert not is_actor_alive(initialized_pusher, 5)

    # Open a database for read the saved report
    mongodb = initialized_pusher.state.database
    mongodb.connect()
    mongodb_iter = mongodb.iter(PowerModel(), False)
    new_report = next(mongodb_iter)

    assert saved_report == new_report
コード例 #14
0
def test_puller_init_ok(initialized_puller_with_dispatcher):
    """
    Create a PullerActor and send a StartMessage
    """
    assert is_actor_alive(initialized_puller_with_dispatcher)
コード例 #15
0
def test_puller_create_ok(started_puller):
    """
    Create a PullerActor with a good configuration
    """
    assert is_actor_alive(started_puller)
コード例 #16
0
def test_pusher_init_ok(initialized_pusher):
    """
    Create a PusherActor and send a StartMessage
    """
    assert is_actor_alive(initialized_pusher)