コード例 #1
0
ファイル: server.py プロジェクト: crisbud/swiftonfile
 def get_object_ring(self):
     if hasattr(self, 'object_ring'):
         if not self.object_ring:
             self.object_ring = Ring(self.swift_dir, ring_name='object')
     else:
         self.object_ring = Ring(self.swift_dir, ring_name='object')
     return self.object_ring
コード例 #2
0
ファイル: test_ring.py プロジェクト: sunyongjie/glusterfs
class TestRing(unittest.TestCase):
    """ Tests for common.utils """

    def setUp(self):
        swift.common.utils.HASH_PATH_SUFFIX = 'endcap'
        swiftdir = os.path.join(os.getcwd(), "common", "data")
        self.ring = Ring(swiftdir, ring_name='object')

    def test_first_device(self):
        part, node = self.ring.get_nodes('test')
        assert node[0]['device'] == 'test'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'test'
        for node in self.ring.get_more_nodes(0):
            assert node['device'] == 'volume_not_in_ring'

    def test_invalid_device(self):
        part, node = self.ring.get_nodes('test2')
        assert node[0]['device'] == 'volume_not_in_ring'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'volume_not_in_ring'

    def test_second_device(self):
        part, node = self.ring.get_nodes('iops')
        assert node[0]['device'] == 'iops'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'iops'
        for node in self.ring.get_more_nodes(0):
            assert node['device'] == 'volume_not_in_ring'

    def test_second_device_with_reseller_prefix(self):
        part, node = self.ring.get_nodes('AUTH_iops')
        assert node[0]['device'] == 'iops'
コード例 #3
0
 def test_ring_file_enoent(self):
     swiftdir = os.path.join(os.getcwd(), "common", "data")
     try:
         self.ring = Ring(swiftdir, ring_name='obj')
     except OSError as ose:
         if ose.errno == errno.ENOENT:
             pass
         else:
             self.fail('ENOENT expected, %s received.' %ose.errno)
     else:
         self.fail('OSError expected.')
コード例 #4
0
ファイル: test_ring.py プロジェクト: ajarr/gluster-swift
 def setUp(self):
     swift.common.utils.HASH_PATH_SUFFIX = 'endcap'
     swiftdir = os.path.join(os.getcwd(), "common", "data")
     self.ring = Ring(swiftdir, ring_name='object')
コード例 #5
0
ファイル: test_ring.py プロジェクト: ajarr/gluster-swift
class TestRing(unittest.TestCase):
    """ Tests for common.utils """

    def setUp(self):
        swift.common.utils.HASH_PATH_SUFFIX = 'endcap'
        swiftdir = os.path.join(os.getcwd(), "common", "data")
        self.ring = Ring(swiftdir, ring_name='object')

    def test_first_device(self):
        part, node = self.ring.get_nodes('test')
        assert node[0]['device'] == 'test'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'test'
        for node in self.ring.get_more_nodes(0):
            assert node['device'] == 'volume_not_in_ring'

    def test_invalid_device(self):
        part, node = self.ring.get_nodes('test2')
        assert node[0]['device'] == 'volume_not_in_ring'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'volume_not_in_ring'

    def test_second_device(self):
        part, node = self.ring.get_nodes('iops')
        assert node[0]['device'] == 'iops'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'iops'
        for node in self.ring.get_more_nodes(0):
            assert node['device'] == 'volume_not_in_ring'

    def test_second_device_with_reseller_prefix(self):
        part, node = self.ring.get_nodes('AUTH_iops')
        assert node[0]['device'] == 'iops'

    def test_partition_id_for_multiple_accounts(self):
        test_part, test_node = self.ring.get_nodes('test')
        iops_part, iops_node = self.ring.get_nodes('iops')
        self.assertNotEqual(test_part, iops_part)
        self.assertEqual(test_node, self.ring.get_part_nodes(test_part))
        self.assertEqual(iops_node, self.ring.get_part_nodes(iops_part))
        self.assertNotEqual(test_node, self.ring.get_part_nodes(iops_part))
        self.assertNotEqual(iops_node, self.ring.get_part_nodes(test_part))

    def test_invalid_partition(self):
        nodes = self.ring.get_part_nodes(0)
        self.assertEqual(nodes[0]['device'], 'volume_not_in_ring')
コード例 #6
0
ファイル: server.py プロジェクト: zyt19941113/gluster-swift
 def get_object_ring(self):
     return Ring(self.swift_dir, ring_name='object')
コード例 #7
0
 def setUp(self):
     swift.common.utils.HASH_PATH_SUFFIX = 'endcap'
     swiftdir = os.path.join(os.getcwd(), "common", "data")
     self.ring = Ring(swiftdir, ring_name='object')
コード例 #8
0
class TestRing(unittest.TestCase):
    """ Tests for common.ring """

    def setUp(self):
        swift.common.utils.HASH_PATH_SUFFIX = 'endcap'
        swiftdir = os.path.join(os.getcwd(), "common", "data")
        self.ring = Ring(swiftdir, ring_name='object')

    def test_first_device(self):
        part, node = self.ring.get_nodes('test')
        assert node[0]['device'] == 'test'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'test'
        for node in self.ring.get_more_nodes(0):
            assert node['device'] == 'volume_not_in_ring'

    def test_invalid_device(self):
        part, node = self.ring.get_nodes('test2')
        assert node[0]['device'] == 'volume_not_in_ring'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'volume_not_in_ring'

    def test_second_device(self):
        part, node = self.ring.get_nodes('iops')
        assert node[0]['device'] == 'iops'
        node = self.ring.get_part_nodes(0)
        assert node[0]['device'] == 'iops'
        for node in self.ring.get_more_nodes(0):
            assert node['device'] == 'volume_not_in_ring'

    def test_second_device_part(self):
        part = self.ring.get_part('iops')
        assert part == 0

    def test_second_device_with_reseller_prefix(self):
        part, node = self.ring.get_nodes('AUTH_iops')
        assert node[0]['device'] == 'iops'

    def test_partition_id_for_multiple_accounts(self):
        test_part, test_node = self.ring.get_nodes('test')
        iops_part, iops_node = self.ring.get_nodes('iops')
        self.assertNotEqual(test_part, iops_part)
        self.assertEqual(test_node, self.ring.get_part_nodes(test_part))
        self.assertEqual(iops_node, self.ring.get_part_nodes(iops_part))
        self.assertNotEqual(test_node, self.ring.get_part_nodes(iops_part))
        self.assertNotEqual(iops_node, self.ring.get_part_nodes(test_part))

    def test_invalid_partition(self):
        nodes = self.ring.get_part_nodes(0)
        self.assertEqual(nodes[0]['device'], 'volume_not_in_ring')

    def test_ring_file_enoent(self):
        swiftdir = os.path.join(os.getcwd(), "common", "data")
        try:
            self.ring = Ring(swiftdir, ring_name='obj')
        except OSError as ose:
            if ose.errno == errno.ENOENT:
                pass
            else:
                self.fail('ENOENT expected, %s received.' %ose.errno)
        else:
            self.fail('OSError expected.')