def test_cluster_init_crm(self, crm_init): ''' Test cluster_init with crm option ''' with patch.dict(crmshmod.__salt__, {'crm.use_crm': True}): crm_init.return_value = 0 value = crmshmod.cluster_init('hacluster', 'dog', 'eth1', sbd=True, sbd_dev='dev1') assert value == 0 crm_init.assert_called_once_with('hacluster', 'dog', 'eth1', None, None, True, ['dev1'], False, None, None) crm_init.reset_mock() with patch.dict(crmshmod.__salt__, {'crm.use_crm': True}): crm_init.return_value = 0 value = crmshmod.cluster_init('hacluster', 'dog', 'eth1', sbd=False, sbd_dev=['disk1', 'disk2']) assert value == 0 crm_init.assert_called_once_with('hacluster', 'dog', 'eth1', None, None, False, ['disk1', 'disk2'], False, None, None)
def test_cluster_init_crm(self, crm_init): ''' Test cluster_init with crm option ''' with patch.dict(crmshmod.__salt__, {'crmsh.version': True}): crm_init.return_value = 0 value = crmshmod.cluster_init('hacluster', 'dog', 'eth1') assert value == 0 crm_init.assert_called_once_with('hacluster', 'dog', 'eth1', None, None, None, None, None)
def test_cluster_init_ha(self, ha_cluster_init, logger): ''' Test cluster_init with ha_cluster_init option ''' with patch.dict(crmshmod.__salt__, {'crmsh.version': False}): ha_cluster_init.return_value = 0 value = crmshmod.cluster_init('hacluster', 'dog', 'eth1') assert value == 0 logger.assert_called_once_with( 'The parameter name is not considered!') ha_cluster_init.assert_called_once_with('dog', 'eth1', None, None, None, None, None)
def test_cluster_init_basic(self): ''' Test cluster_init method ''' mock_cmd_run = MagicMock(return_value=True) with patch.dict(crmshmod.__salt__, {'cmd.retcode': mock_cmd_run}): result = crmshmod.cluster_init('hacluster') assert result mock_cmd_run.assert_called_once_with( '{crm_command} cluster init -y -n {name}'.format( crm_command=crmshmod.CRM_COMMAND, name='hacluster'))
def test_cluster_init_complete(self): ''' Test cluster_init method ''' mock_cmd_run = MagicMock(return_value=True) with patch.dict(crmshmod.__salt__, {'cmd.retcode': mock_cmd_run}): result = crmshmod.cluster_init('hacluster', 'dog', 'eth1', True, '192.168.1.50', True, 'sbd_dev', True) assert result mock_cmd_run.assert_called_once_with( '{} cluster init -y -n {} -w {} -i {} -u -A {} --enable-sbd -s {} -q' .format(crmshmod.CRM_COMMAND, 'hacluster', 'dog', 'eth1', '192.168.1.50', 'sbd_dev'))
def test_cluster_init_ha(self, ha_cluster_init, logger): ''' Test cluster_init with ha_cluster_init option ''' with patch.dict(crmshmod.__salt__, {'crm.use_crm': False}): ha_cluster_init.return_value = 0 value = crmshmod.cluster_init('hacluster', 'dog', 'eth1', sbd_dev='dev1', no_overwrite_sshkey=True) assert value == 0 logger.assert_has_calls([ mock.call('The parameter name is not considered!'), mock.call('--no_overwrite_sshkey option not available') ]) ha_cluster_init.assert_called_once_with('dog', 'eth1', None, None, None, ['dev1'], None, None)