Ejemplo n.º 1
0
    def test_joined_command_error(self):
        '''
        Test to check joined when command execution error is raised
        '''

        ret = {'name': 'master',
               'changes': {},
               'result': False,
               'comment': 'cluster command error'}

        mock_status = MagicMock(return_value=1)
        mock_join = MagicMock(
            side_effect=exceptions.CommandExecutionError('cluster command error'))
        with patch.dict(crmshmod.__salt__, {'crm.status': mock_status,
                                            'crm.cluster_join': mock_join}):
            assert crmshmod.cluster_joined(
                name='master',
                watchdog='/dev/watchdog',
                interface='eth0',
                quiet=False) == ret
            mock_status.assert_called_once_with()
            mock_join.assert_called_once_with(
                host='master',
                watchdog='/dev/watchdog',
                interface='eth0',
                quiet=False)
Ejemplo n.º 2
0
    def test_joined_error(self):
        '''
        Test to check joined when joining fails
        '''

        ret = {'name': 'master',
               'changes': {'name': 'master'},
               'result': False,
               'comment': 'Error joining to the cluster'}

        mock_status = MagicMock(return_value=1)
        mock_join = MagicMock(return_value=1)
        with patch.dict(crmshmod.__salt__, {'crm.status': mock_status,
                                            'crm.cluster_join': mock_join}):
            assert crmshmod.cluster_joined(
                name='master',
                watchdog='/dev/watchdog',
                interface='eth0',
                quiet=False) == ret
            mock_status.assert_called_once_with()
            mock_join.assert_called_once_with(
                host='master',
                watchdog='/dev/watchdog',
                interface='eth0',
                quiet=False)
Ejemplo n.º 3
0
    def test_joined_joined(self):
        '''
        Test to check joined when node is already joined to cluster
        '''

        ret = {'name': 'master',
               'changes': {},
               'result': True,
               'comment': 'Node is already joined to a cluster'}

        mock_status = MagicMock(return_value=0)
        with patch.dict(crmshmod.__salt__, {'crm.status': mock_status}):
            assert crmshmod.cluster_joined('master') == ret
            mock_status.assert_called_once_with()
Ejemplo n.º 4
0
    def test_joined_test(self):
        '''
        Test to check joined in test mode
        '''

        ret = {'name': 'master',
               'changes': {'name': 'master'},
               'result': None,
               'comment': 'Node would be joined to {}'.format('master')}

        mock_status = MagicMock(return_value=1)
        with patch.dict(crmshmod.__salt__, {'crm.status': mock_status}):
            with patch.dict(crmshmod.__opts__, {'test': True}):
                assert crmshmod.cluster_joined('master') == ret
            mock_status.assert_called_once_with()