Пример #1
0
    def test_get_lfs_zfs(self):
        conf = {"fs": "zfs", "swift_dir": self.testdir, "devices": self.testdir}
        try:
            import nspyzfs

            storage = lfs.get_lfs(conf, self.ring, "test_lfs", FakeLogger())
            self.assertTrue(isinstance(storage, lfs.zfs.LFSZFS))
        except ImportError:
            self.assertRaises(LFSException, lambda: lfs.get_lfs(conf, self.ring, "devices", "test_lfs"))
Пример #2
0
 def test_get_lfs_invalid_fs(self):
     conf = {"fs": "afs", "swift_dir": self.testdir, "devices": self.testdir}
     self.assertRaises(
         SwiftConfigurationError, lambda: lfs.get_lfs(conf, "test_ring.ring.gz", "test_lfs", FakeLogger())
     )
     try:
         lfs.get_lfs(conf, "test_ring.ring.gz", "test_lfs", FakeLogger())
     except SwiftConfigurationError, e:
         self.assertEqual(str(e), "Cannot load LFS. Invalid FS: afs. No module named afs")
Пример #3
0
Файл: lfs.py Проект: Nexenta/lfs
 def __init__(self, app, conf):
     self.app = app
     logger = get_logger(conf, log_route='swift_lfs')
     swift_dir = conf.get('swift_dir', '/etc/swift')
     storage_type = conf.get('storage_type')
     if storage_type not in DATADIRS:
         raise Exception(
             _('Configuration error: Requires "storage_type" be set to: '
               '%s; was set to "%s"' %
               (', '.join(DATADIRS.keys()), storage_type)))
     ring = Ring(swift_dir, ring_name=storage_type)
     self.storage = get_lfs(conf, ring, DATADIRS[storage_type],
                            DEFAULT_PORT[storage_type], logger)
     self.storage.setup_node()
Пример #4
0
 def setUp(self):
     """ Set up for testing swift_lfs.fs.LFS """
     utils.HASH_PATH_SUFFIX = 'endcap'
     self.testdir = os.path.join(mkdtemp(), 'tmp_test_common_lfs')
     self.conf = {'fs': 'xfs', 'swift_dir': self.testdir,
                  'devices': self.testdir}
     mkdirs(os.path.join(self.testdir, 'sda1', 'tmp'))
     pickle.dump(RingData([[0, 1, 0, 1], [1, 0, 1, 0]],
         [{'id': 0, 'zone': 0, 'device': 'sda1', 'ip': '127.0.0.1',
           'port': '6010', 'mirror_copies': 1},
                 {'id': 1, 'zone': 1, 'device': 'sdb1', 'ip': '127.0.0.1',
                  'port': '6020', 'mirror_copies': 1}], 30),
         GzipFile(os.path.join(self.testdir, 'test_ring.ring.gz'), 'wb'))
     self.ring = Ring(os.path.join(self.testdir, 'test_ring.ring.gz'))
     self.storage = lfs.get_lfs(self.conf, self.ring, 'test_lfs',
         FakeLogger())
Пример #5
0
 def test_get_lfs_xfs(self):
     conf = {"fs": "xfs", "swift_dir": self.testdir, "devices": self.testdir}
     storage = lfs.get_lfs(conf, self.ring, "test_lfs", FakeLogger())
     self.assertTrue(isinstance(storage, lfs.xfs.LFSXFS))