Beispiel #1
0
    def test_get_filesystem_volume_stats(self):

        path = 'aPath'
        block_size = 4096
        total_block = 2582828
        free_block = 767118
        total = total_block * block_size
        free = free_block * block_size
        used = total - free
        out = " ".join(str(x) for x in (path, 'fb518d79428291bb', 255, 'ef53',
                                        block_size, '4096', total_block,
                                        free_block, 636216, 655360, 583768))
        err = None
        return_exp = out, err
        dbaas.utils.execute_with_timeout = Mock(return_value=return_exp)

        self.interrogator = Interrogator()
        result = self.interrogator.get_filesystem_volume_stats(path)

        self.assertTrue(dbaas.utils.execute_with_timeout.called)
        self.assertTrue('stat' in
                        dbaas.utils.execute_with_timeout.call_args[0])
        self.assertTrue(path in dbaas.utils.execute_with_timeout.call_args[0])

        self.assertEqual(result['block_size'], block_size)
        self.assertEqual(result['total_blocks'], total_block)
        self.assertEqual(result['free_blocks'], free_block)
        self.assertEqual(result['total'], total)
        self.assertEqual(result['free'], free)
        self.assertEqual(result['used'], used)
Beispiel #2
0
    def test_get_filesystem_volume_stats_error(self):

        path = 'aPath'
        block_size = 4096
        total_block = 2582828
        free_block = 767118

        out = " ".join(str(x) for x in (path, 'fb518d79428291bb', 255, 'ef53',
                                        block_size, '4096', total_block,
                                        free_block, 636216, 655360, 583768))
        err = "Error found"
        return_exp = out, err
        dbaas.utils.execute_with_timeout = Mock(return_value=return_exp)
        dbaas.LOG.err = Mock()

        self.interrogator = Interrogator()
        self.assertRaises(RuntimeError,
                          self.interrogator.get_filesystem_volume_stats, path)
Beispiel #3
0
class InterrogatorTest(testtools.TestCase):

    def setUp(self):
        super(InterrogatorTest, self).setUp()
        self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
        self.orig_LOG_err = dbaas.LOG

    def tearDown(self):
        super(InterrogatorTest, self).tearDown()
        dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
        dbaas.LOG = self.orig_LOG_err

    def test_get_filesystem_volume_stats(self):

        path = 'aPath'
        block_size = 4096
        total_block = 2582828
        free_block = 767118
        total = total_block * block_size
        free = free_block * block_size
        used = total - free
        out = " ".join(str(x) for x in (path, 'fb518d79428291bb', 255, 'ef53',
                                        block_size, '4096', total_block,
                                        free_block, 636216, 655360, 583768))
        err = None
        return_exp = out, err
        dbaas.utils.execute_with_timeout = Mock(return_value=return_exp)

        self.interrogator = Interrogator()
        result = self.interrogator.get_filesystem_volume_stats(path)

        self.assertTrue(dbaas.utils.execute_with_timeout.called)
        self.assertTrue('stat' in
                        dbaas.utils.execute_with_timeout.call_args[0])
        self.assertTrue(path in dbaas.utils.execute_with_timeout.call_args[0])

        self.assertEqual(result['block_size'], block_size)
        self.assertEqual(result['total_blocks'], total_block)
        self.assertEqual(result['free_blocks'], free_block)
        self.assertEqual(result['total'], total)
        self.assertEqual(result['free'], free)
        self.assertEqual(result['used'], used)

    def test_get_filesystem_volume_stats_error(self):

        path = 'aPath'
        block_size = 4096
        total_block = 2582828
        free_block = 767118

        out = " ".join(str(x) for x in (path, 'fb518d79428291bb', 255, 'ef53',
                                        block_size, '4096', total_block,
                                        free_block, 636216, 655360, 583768))
        err = "Error found"
        return_exp = out, err
        dbaas.utils.execute_with_timeout = Mock(return_value=return_exp)
        dbaas.LOG.err = Mock()

        self.interrogator = Interrogator()
        self.assertRaises(RuntimeError,
                          self.interrogator.get_filesystem_volume_stats, path)