Example #1
0
    def test_basic(self, mock_random, mock_spawn_n, mock_spawn_after):
        daemon = mock.Mock(reload='reload', config=config.Config())

        control.reload(daemon)

        self.assertFalse(mock_random.called)
        self.assertFalse(mock_spawn_after.called)
        mock_spawn_n.assert_called_once_with('reload')
Example #2
0
    def test_forced_spread(self, mock_random, mock_spawn_n, mock_spawn_after):
        daemon = mock.Mock(reload='reload', config=config.Config())

        control.reload(daemon, 'spread', '20.4')

        mock_random.assert_called_once_with()
        mock_spawn_after.assert_called_once_with(10.2, 'reload')
        self.assertFalse(mock_spawn_n.called)
Example #3
0
    def test_forced_spread(self, mock_random, mock_spawn_n, mock_spawn_after):
        daemon = mock.Mock(reload='reload', config=config.Config())

        control.reload(daemon, 'spread', '20.4')

        mock_random.assert_called_once_with()
        mock_spawn_after.assert_called_once_with(10.2, 'reload')
        self.assertFalse(mock_spawn_n.called)
Example #4
0
    def test_basic(self, mock_random, mock_spawn_n, mock_spawn_after):
        daemon = mock.Mock(reload='reload', config=config.Config())

        control.reload(daemon)

        self.assertFalse(mock_random.called)
        self.assertFalse(mock_spawn_after.called)
        mock_spawn_n.assert_called_once_with('reload')
Example #5
0
    def test_bad_spread_fallback(self, mock_random, mock_spawn_n,
                                 mock_spawn_after):
        daemon = mock.Mock(reload='reload', config=config.Config(conf_dict={
            'control.reload_spread': '40.8',
        }))

        control.reload(daemon, 'spread', '20.4.3')

        mock_random.assert_called_once_with()
        mock_spawn_after.assert_called_once_with(20.4, 'reload')
        self.assertFalse(mock_spawn_n.called)
Example #6
0
    def test_configured_spread_override(self, mock_random, mock_spawn_n,
                                        mock_spawn_after):
        daemon = mock.Mock(reload='reload', config=config.Config(conf_dict={
            'control.reload_spread': '20.4',
        }))

        control.reload(daemon, 'immediate')

        self.assertFalse(mock_random.called)
        self.assertFalse(mock_spawn_after.called)
        mock_spawn_n.assert_called_once_with('reload')
Example #7
0
    def test_configured_spread(self, mock_random, mock_spawn_n,
                               mock_spawn_after):
        daemon = mock.Mock(reload='reload', config=config.Config(conf_dict={
            'control.reload_spread': '20.4',
        }))

        control.reload(daemon)

        mock_random.assert_called_once_with()
        mock_spawn_after.assert_called_once_with(10.2, 'reload')
        self.assertFalse(mock_spawn_n.called)
Example #8
0
    def test_bad_spread_fallback(self, mock_random, mock_spawn_n,
                                 mock_spawn_after):
        daemon = mock.Mock(
            reload='reload',
            config=config.Config(conf_dict={
                'control.reload_spread': '40.8',
            }))

        control.reload(daemon, 'spread', '20.4.3')

        mock_random.assert_called_once_with()
        mock_spawn_after.assert_called_once_with(20.4, 'reload')
        self.assertFalse(mock_spawn_n.called)
Example #9
0
    def test_configured_spread_override(self, mock_random, mock_spawn_n,
                                        mock_spawn_after):
        daemon = mock.Mock(
            reload='reload',
            config=config.Config(conf_dict={
                'control.reload_spread': '20.4',
            }))

        control.reload(daemon, 'immediate')

        self.assertFalse(mock_random.called)
        self.assertFalse(mock_spawn_after.called)
        mock_spawn_n.assert_called_once_with('reload')
Example #10
0
    def test_configured_spread(self, mock_random, mock_spawn_n,
                               mock_spawn_after):
        daemon = mock.Mock(
            reload='reload',
            config=config.Config(conf_dict={
                'control.reload_spread': '20.4',
            }))

        control.reload(daemon)

        mock_random.assert_called_once_with()
        mock_spawn_after.assert_called_once_with(10.2, 'reload')
        self.assertFalse(mock_spawn_n.called)