Exemple #1
0
    def test_good_and_lost(self):
        self.mock_time.return_value = 0
        event_stream = [
            dict(msg=dict(operation='poll', agent_id='alpha'),
                 reply=dict(operation='execute',
                            command='RUN',
                            start_at=STEP * 2,
                            expected_duration=STEP),
                 time=1),
            dict(msg=dict(operation='poll', agent_id='beta'),
                 reply=dict(operation='execute',
                            command='RUN',
                            start_at=STEP * 2,
                            expected_duration=STEP),
                 time=2),
            dict(msg=dict(operation='reply', agent_id='beta'),
                 reply=dict(operation='none'),
                 time=20),
            dict(msg=dict(operation='reply', agent_id='heartbeat'),
                 reply=dict(operation='none'),
                 time=STEP * 10),
        ]

        quorum = make_quorum(self._message_queue_gen(event_stream))
        test_case = {
            'alpha': DummyExecutor(),
            'beta': DummyExecutor(),
        }
        result = quorum.execute(test_case)
        self.assertEqual(result.keys(), test_case.keys())
        self.assertEqual('lost', result['alpha']['status'])
        self.assertEqual('ok', result['beta']['status'])
Exemple #2
0
    def test_poll_reply(self):
        self.mock_time.return_value = 0
        event_stream = [
            dict(msg=dict(operation='poll', agent_id='alpha'),
                 reply=dict(operation='execute',
                            command='RUN',
                            start_at=STEP * 2,
                            expected_duration=STEP),
                 time=1),
            dict(msg=dict(operation='reply', agent_id='alpha'),
                 reply=dict(operation='none'),
                 time=20),
        ]

        quorum = make_quorum(self._message_queue_gen(event_stream))
        test_case = {'alpha': DummyExecutor()}
        result = quorum.execute(test_case)
        self.assertEqual(result.keys(), test_case.keys())
Exemple #3
0
    def test_agent_loss_timeout(self):
        """Tests that agent is not marked as lost during loss-timeout."""
        self.mock_time.return_value = 0
        event_stream = [
            dict(msg=dict(operation='poll', agent_id='alpha'),
                 reply=dict(operation='execute',
                            command='RUN',
                            start_at=STEP * 2,
                            expected_duration=STEP),
                 time=1),
            dict(msg=dict(operation='reply', agent_id='heartbeat'),
                 reply=dict(operation='none'),
                 time=LOSS_TIMEOUT),
            dict(msg=dict(operation='reply', agent_id='alpha'),
                 reply=dict(operation='none'),
                 time=LOSS_TIMEOUT),
        ]

        quorum = make_quorum(self._message_queue_gen(event_stream))
        test_case = {'alpha': DummyExecutor()}
        result = quorum.execute(test_case)
        self.assertEqual(result.keys(), test_case.keys())
        self.assertEqual('ok', result['alpha']['status'])