Exemplo n.º 1
0
 def test_02_PartitionTable_creation(self):
     num_partitions = 5
     num_replicas = 3
     pt = PartitionTable(num_partitions, num_replicas)
     self.assertEqual(pt.np, num_partitions)
     self.assertEqual(pt.nr, num_replicas)
     self.assertEqual(pt.num_filled_rows, 0)
     partition_list = pt.partition_list
     self.assertEqual(len(partition_list), num_partitions)
     for x in xrange(num_partitions):
         part = partition_list[x]
         self.assertTrue(isinstance(part, list))
         self.assertEqual(len(part), 0)
     self.assertEqual(len(pt.count_dict), 0)
     # no nodes or cells for now
     self.assertFalse(pt.getNodeSet())
     for x in xrange(num_partitions):
         self.assertEqual(len(pt.getCellList(x)), 0)
         self.assertEqual(len(pt.getCellList(x, True)), 0)
         self.assertEqual(len(pt.getRow(x)), 0)
     self.assertFalse(pt.operational())
     self.assertFalse(pt.filled())
     self.assertRaises(RuntimeError, pt.make, [])
     self.assertFalse(pt.operational())
     self.assertFalse(pt.filled())
Exemplo n.º 2
0
 def test_02_PartitionTable_creation(self):
     num_partitions = 5
     num_replicas = 3
     pt = PartitionTable(num_partitions, num_replicas)
     self.assertEqual(pt.np, num_partitions)
     self.assertEqual(pt.nr, num_replicas)
     self.assertEqual(pt.num_filled_rows, 0)
     partition_list = pt.partition_list
     self.assertEqual(len(partition_list), num_partitions)
     for x in xrange(num_partitions):
         part = partition_list[x]
         self.assertTrue(isinstance(part, list))
         self.assertEqual(len(part), 0)
     self.assertEqual(len(pt.count_dict), 0)
     # no nodes or cells for now
     self.assertFalse(pt.getNodeSet())
     for x in xrange(num_partitions):
         self.assertEqual(len(pt.getCellList(x)), 0)
         self.assertEqual(len(pt.getCellList(x, True)), 0)
         self.assertEqual(len(pt.getRow(x)), 0)
     self.assertFalse(pt.operational())
     self.assertFalse(pt.filled())
     self.assertRaises(AssertionError, pt.make, [])
     self.assertFalse(pt.operational())
     self.assertFalse(pt.filled())
Exemplo n.º 3
0
 def test_16_make(self):
     num_partitions = 5
     num_replicas = 1
     pt = PartitionTable(num_partitions, num_replicas)
     # add nodes
     uuid1 = self.getStorageUUID()
     server1 = ("127.0.0.1", 19001)
     sn1 = StorageNode(Mock(), server1, uuid1, NodeStates.RUNNING)
     # add not running node
     uuid2 = self.getStorageUUID()
     server2 = ("127.0.0.2", 19001)
     sn2 = StorageNode(Mock(), server2, uuid2)
     sn2.setState(NodeStates.TEMPORARILY_DOWN)
     # add node without uuid
     server3 = ("127.0.0.3", 19001)
     sn3 = StorageNode(Mock(), server3, None, NodeStates.RUNNING)
     # add clear node
     uuid4 = self.getStorageUUID()
     server4 = ("127.0.0.4", 19001)
     sn4 = StorageNode(Mock(), server4, uuid4, NodeStates.RUNNING)
     uuid5 = self.getStorageUUID()
     server5 = ("127.0.0.5", 1900)
     sn5 = StorageNode(Mock(), server5, uuid5, NodeStates.RUNNING)
     # make the table
     pt.make([sn1, sn2, sn3, sn4, sn5])
     # check it's ok, only running nodes and node with uuid
     # must be present
     for x in xrange(num_partitions):
         cells = pt.getCellList(x)
         self.assertEqual(len(cells), 2)
         nodes = [x.getNode() for x in cells]
         for node in nodes:
             self.assertTrue(node in (sn1, sn4, sn5))
             self.assertTrue(node not in (sn2, sn3))
     self.assertTrue(pt.filled())
     self.assertTrue(pt.operational())
     # create a pt with less nodes
     pt.clear()
     self.assertFalse(pt.filled())
     self.assertFalse(pt.operational())
     pt.make([sn1])
     # check it's ok
     for x in xrange(num_partitions):
         cells = pt.getCellList(x)
         self.assertEqual(len(cells), 1)
         nodes = [x.getNode() for x in cells]
         for node in nodes:
             self.assertEqual(node, sn1)
     self.assertTrue(pt.filled())
     self.assertTrue(pt.operational())
Exemplo n.º 4
0
 def test_16_make(self):
     num_partitions = 5
     num_replicas = 1
     pt = PartitionTable(num_partitions, num_replicas)
     # add nodes
     uuid1 = self.getStorageUUID()
     server1 = ("127.0.0.1", 19001)
     sn1 = StorageNode(Mock(), server1, uuid1, NodeStates.RUNNING)
     # add not running node
     uuid2 = self.getStorageUUID()
     server2 = ("127.0.0.2", 19001)
     sn2 = StorageNode(Mock(), server2, uuid2)
     sn2.setState(NodeStates.TEMPORARILY_DOWN)
     # add node without uuid
     server3 = ("127.0.0.3", 19001)
     sn3 = StorageNode(Mock(), server3, None, NodeStates.RUNNING)
     # add clear node
     uuid4 = self.getStorageUUID()
     server4 = ("127.0.0.4", 19001)
     sn4 = StorageNode(Mock(), server4, uuid4, NodeStates.RUNNING)
     uuid5 = self.getStorageUUID()
     server5 = ("127.0.0.5", 1900)
     sn5 = StorageNode(Mock(), server5, uuid5, NodeStates.RUNNING)
     # make the table
     pt.make([sn1, sn2, sn3, sn4, sn5])
     # check it's ok, only running nodes and node with uuid
     # must be present
     for x in xrange(num_partitions):
         cells = pt.getCellList(x)
         self.assertEqual(len(cells), 2)
         nodes = [x.getNode() for x in cells]
         for node in nodes:
             self.assertTrue(node in (sn1, sn4, sn5))
             self.assertTrue(node not in (sn2, sn3))
     self.assertTrue(pt.filled())
     self.assertTrue(pt.operational())
     # create a pt with less nodes
     pt.clear()
     self.assertFalse(pt.filled())
     self.assertFalse(pt.operational())
     pt.make([sn1])
     # check it's ok
     for x in xrange(num_partitions):
         cells = pt.getCellList(x)
         self.assertEqual(len(cells), 1)
         nodes = [x.getNode() for x in cells]
         for node in nodes:
             self.assertEqual(node, sn1)
     self.assertTrue(pt.filled())
     self.assertTrue(pt.operational())
Exemplo n.º 5
0
 def test_16_make(self):
     node_list = [self.createStorage(
             ("127.0.0.1", 19000 + i), self.getStorageUUID(),
             NodeStates.RUNNING)
         for i in xrange(4)]
     for np, nr, expected in (
             (3, 0, 'U..|.U.|..U'),
             (5, 1, 'UU..|..UU|UU..|..UU|UU..'),
             (9, 2, 'UUU.|UU.U|U.UU|.UUU|UUU.|UU.U|U.UU|.UUU|UUU.'),
             ):
         pt = PartitionTable(np, nr)
         pt.make(node_list)
         self.assertPartitionTable(pt, expected)
         self.assertTrue(pt.filled())
         self.assertTrue(pt.operational())
         # create a pt with less nodes
         pt.clear()
         self.assertFalse(pt.filled())
         self.assertFalse(pt.operational())
         pt.make(node_list[:1])
         self.assertPartitionTable(pt, '|'.join('U' * np))
         self.assertTrue(pt.filled())
         self.assertTrue(pt.operational())