Ejemplo n.º 1
0
    def test_create(self):
        '''
        Test if it create a glusterfs volume.
        '''
        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertRaises(SaltInvocationError, glusterfs.create,
                              'newvolume', 'host1:brick')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertRaises(SaltInvocationError, glusterfs.create,
                              'newvolume', 'host1/brick')

        mock = MagicMock(return_value=xml_command_fail)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertRaises(CommandExecutionError, glusterfs.create,
                              'newvolume', 'host1:/brick', True, True, True,
                              'tcp', True)

        mock = MagicMock(return_value=xml_command_success)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(
                glusterfs.create('newvolume', 'host1:/brick', True, True, True,
                                 'tcp', True),
                'Volume newvolume created and started')

        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:/brick'),
                             'Volume newvolume created. Start volume to use')
Ejemplo n.º 2
0
    def test_create(self):
        '''
        Test if it create a glusterfs volume.
        '''
        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:brick'),
                             'Error: Brick paths must start with /')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1/brick'),
                             'Error: Brick syntax is <peer>:<path>')

        mock = MagicMock(return_value='creation success')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:/brick',
                                              True, True, True, 'tcp', True),
                             'Volume newvolume created and started')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:/brick',
                                              True, True, True,
                                              'tcp', True), '')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:/brick'),
                             'Volume newvolume created. Start volume to use')
    def test_create(self):
        '''
        Test if it create a glusterfs volume.
        '''
        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:brick'),
                             'Error: Brick paths must start with /')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1/brick'),
                             'Error: Brick syntax is <peer>:<path>')

        mock = MagicMock(return_value='creation success')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(
                glusterfs.create('newvolume', 'host1:/brick', True, True, True,
                                 'tcp', True),
                'Volume newvolume created and started')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(
                glusterfs.create('newvolume', 'host1:/brick', True, True, True,
                                 'tcp', True), '')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:/brick'),
                             'Volume newvolume created. Start volume to use')
Ejemplo n.º 4
0
    def test_create(self):
        '''
        Test if it create a glusterfs volume.
        '''
        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertRaises(
                SaltInvocationError, glusterfs.create, 'newvolume', 'host1:brick')

        mock = MagicMock(return_value='')
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertRaises(
                SaltInvocationError, glusterfs.create, 'newvolume', 'host1/brick')

        mock = MagicMock(return_value=xml_command_fail)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertRaises(CommandExecutionError, glusterfs.create, 'newvolume', 'host1:/brick',
                              True, True, True, 'tcp', True)

        mock = MagicMock(return_value=xml_command_success)
        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:/brick',
                                              True, True, True, 'tcp', True),
                             'Volume newvolume created and started')

        with patch.dict(glusterfs.__salt__, {'cmd.run': mock}):
            self.assertEqual(glusterfs.create('newvolume', 'host1:/brick'),
                             'Volume newvolume created. Start volume to use')