Esempio n. 1
0
 def test_monitor_not_started(self):
     """
     Test _monitor action when zerodb is not started
     """
     zdb = Zerodb('zdb', data=self.valid_data)
     zdb.state.set('actions', 'install', 'ok')
     with pytest.raises(StateCheckError, message='_monitor should not start zerodb is the start action has not been called'):
         zdb._monitor()
     with pytest.raises(StateCheckError, message='_monitor should not start zerodb is the start action has not been called'):
         zdb.state.check('status', 'running', 'ok')
Esempio n. 2
0
    def test_monitor_started(self):
        """
        Test _monitor action when zerodb should be started and it can be started
        """
        node = MagicMock()
        node.state.check.return_value = True

        zdb = Zerodb('zdb', data=self.valid_data)
        zdb.api.services.get = MagicMock(return_value=node)

        zdb._zerodb_sal.is_running = MagicMock(side_effect=[(False,), (True,)])
        zdb.state.set('actions', 'install', 'ok')
        zdb.state.set('actions', 'start', 'ok')
        zdb._monitor()
        zdb.state.check('status', 'running', 'ok')