Exemple #1
0
 def test_start_no_replies(self):
     c = Mock()
     c.app.connection = _amqp_connection()
     mingle = Mingle(c)
     I = c.app.control.inspect.return_value = Mock()
     I.hello.return_value = {}
     mingle.start(c)
Exemple #2
0
 def test_start_no_replies(self):
     c = Mock()
     c.app.connection = _amqp_connection()
     mingle = Mingle(c)
     I = c.app.control.inspect.return_value = Mock()
     I.hello.return_value = {}
     mingle.start(c)
Exemple #3
0
    def test_start(self):
        try:
            c = Mock()
            c.app.connection_for_read = _amqp_connection()
            mingle = Mingle(c)
            self.assertTrue(mingle.enabled)

            Aig = LimitedSet()
            Big = LimitedSet()
            Aig.add("Aig-1")
            Aig.add("Aig-2")
            Big.add("Big-1")

            I = c.app.control.inspect.return_value = Mock()
            I.hello.return_value = {
                "*****@*****.**": {"clock": 312, "revoked": Aig._data},
                "*****@*****.**": {"clock": 29, "revoked": Big._data},
                "*****@*****.**": {"error": "unknown method"},
            }

            mingle.start(c)
            I.hello.assert_called_with(c.hostname, worker_state.revoked._data)
            c.app.clock.adjust.assert_has_calls([call(312), call(29)], any_order=True)
            self.assertIn("Aig-1", worker_state.revoked)
            self.assertIn("Aig-2", worker_state.revoked)
            self.assertIn("Big-1", worker_state.revoked)
        finally:
            worker_state.revoked.clear()
Exemple #4
0
    def test_start(self):
        try:
            c = Mock()
            c.app.connection = _amqp_connection()
            mingle = Mingle(c)
            self.assertTrue(mingle.enabled)

            Aig = LimitedSet()
            Big = LimitedSet()
            Aig.add('Aig-1')
            Aig.add('Aig-2')
            Big.add('Big-1')

            I = c.app.control.inspect.return_value = Mock()
            I.hello.return_value = {
                '*****@*****.**': {
                    'clock': 312,
                    'revoked': Aig._data,
                },
                '*****@*****.**': {
                    'clock': 29,
                    'revoked': Big._data,
                },
                '*****@*****.**': {
                    'error': 'unknown method',
                },
            }

            mingle.start(c)
            I.hello.assert_called_with(c.hostname, worker_state.revoked._data)
            c.app.clock.adjust.assert_has_calls([
                call(312),
                call(29),
            ],
                                                any_order=True)
            self.assertIn('Aig-1', worker_state.revoked)
            self.assertIn('Aig-2', worker_state.revoked)
            self.assertIn('Big-1', worker_state.revoked)
        finally:
            worker_state.revoked.clear()
Exemple #5
0
    def test_start(self):
        try:
            c = Mock()
            c.app.connection = _amqp_connection()
            mingle = Mingle(c)
            self.assertTrue(mingle.enabled)

            Aig = LimitedSet()
            Big = LimitedSet()
            Aig.add('Aig-1')
            Aig.add('Aig-2')
            Big.add('Big-1')

            I = c.app.control.inspect.return_value = Mock()
            I.hello.return_value = {
                '*****@*****.**': {
                    'clock': 312,
                    'revoked': Aig._data,
                },
                '*****@*****.**': {
                    'clock': 29,
                    'revoked': Big._data,
                },
                '*****@*****.**': {
                    'error': 'unknown method',
                },
            }

            mingle.start(c)
            I.hello.assert_called_with(c.hostname, worker_state.revoked._data)
            c.app.clock.adjust.assert_has_calls([
                call(312), call(29),
            ], any_order=True)
            self.assertIn('Aig-1', worker_state.revoked)
            self.assertIn('Aig-2', worker_state.revoked)
            self.assertIn('Big-1', worker_state.revoked)
        finally:
            worker_state.revoked.clear()