Esempio n. 1
0
    def test_zfs_assert_supported_raises_exc_on_missing_module(
        self,
        m_arch,
        m_release,
        m_supfs,
        m_kmod,
        m_popen,
    ):
        """zfs_assert_supported raises RuntimeError modprobe zfs error"""

        m_arch.return_value = 'amd64'
        m_release.return_value = {'codename': 'bionic'}
        m_supfs.return_value = ['ext4']
        m_kmod.return_value = False
        process_mock = mock.Mock()
        attrs = {
            'returncode':
            1,
            'communicate.return_value':
            ('output', 'modprobe: FATAL: Module zfs not found ...'),
        }
        process_mock.configure_mock(**attrs)
        m_popen.return_value = process_mock
        with self.assertRaises(RuntimeError):
            zfs.zfs_assert_supported()
Esempio n. 2
0
 def test_zfs_assert_supported_raises_exc_on_bad_releases(self, mock_util):
     """zfs_assert_supported raises RuntimeError on unspported releases"""
     mock_util.get_platform_arch.return_value = 'amd64'
     mock_util.subp.return_value = ("", "")
     for release in zfs.ZFS_UNSUPPORTED_RELEASES:
         mock_util.lsb_release.return_value = {'codename': release}
         with self.assertRaises(RuntimeError):
             zfs.zfs_assert_supported()
Esempio n. 3
0
 def test_zfs_assert_supported_raises_exception_on_bad_arch(self,
                                                            mock_util):
     """zfs_assert_supported raises RuntimeError on unspported arches"""
     mock_util.lsb_release.return_value = {'codename': 'bionic'}
     mock_util.subp.return_value = ("", "")
     for arch in zfs.ZFS_UNSUPPORTED_ARCHES:
         mock_util.get_platform_arch.return_value = arch
         with self.assertRaises(RuntimeError):
             zfs.zfs_assert_supported()
Esempio n. 4
0
 def test_missing_module(self, mock_supfs, mock_kmod):
     missing = 'modprobe: FATAL: Module zfs not found.\n     '
     self.mock_subp.side_effect = ProcessExecutionError(stdout='',
                                                        stderr=missing,
                                                        exit_code='1')
     mock_supfs.return_value = ['ext4']
     mock_kmod.return_value = False
     with self.assertRaises(RuntimeError):
         zfs.zfs_assert_supported()
Esempio n. 5
0
    def test_zfs_assert_supported_raises_exc_on_missing_binaries(
            self, mock_util, m_arch, m_release, m_supfs):
        """zfs_assert_supported raises RuntimeError if no zpool or zfs tools"""
        mock_util.get_platform_arch.return_value = 'amd64'
        mock_util.lsb_release.return_value = {'codename': 'bionic'}
        mock_util.subp.return_value = ("", "")
        m_supfs.return_value = ['zfs']
        mock_util.which.return_value = None

        with self.assertRaises(RuntimeError):
            zfs.zfs_assert_supported()
Esempio n. 6
0
 def test_unsupported_releases(self):
     for rel in ['precise', 'trusty']:
         self.mock_release.return_value = {'codename': rel}
         with self.assertRaises(RuntimeError):
             zfs.zfs_assert_supported()
Esempio n. 7
0
 def test_unsupported_arch(self):
     self.mock_arch.return_value = 'i386'
     with self.assertRaises(RuntimeError):
         zfs.zfs_assert_supported()