コード例 #1
0
ファイル: cmdlib_unittest.py プロジェクト: GangbiaoLiu/ganeti
 def testEven(self):
   for i in [1, 2, 7, 512, 1000, 1023]:
     lu = _FakeLU()
     result = instance_storage._DiskSizeInBytesToMebibytes(lu,
                                                           i * 1024 * 1024)
     self.assertEqual(result, i)
     self.assertFalse(lu.warning_log)
コード例 #2
0
 def testEven(self):
   for i in [1, 2, 7, 512, 1000, 1023]:
     lu = _FakeLU()
     result = instance_storage._DiskSizeInBytesToMebibytes(lu,
                                                           i * 1024 * 1024)
     self.assertEqual(result, i)
     self.assertFalse(lu.warning_log)
コード例 #3
0
ファイル: cmdlib_unittest.py プロジェクト: GangbiaoLiu/ganeti
 def testLessThanOneMebibyte(self):
   for i in [1, 2, 7, 512, 1000, 1023]:
     lu = _FakeLU()
     result = instance_storage._DiskSizeInBytesToMebibytes(lu, i)
     self.assertEqual(result, 1)
     self.assertEqual(len(lu.warning_log), 1)
     self.assertEqual(len(lu.warning_log[0]), 2)
     (_, (warnsize, )) = lu.warning_log[0]
     self.assertEqual(warnsize, (1024 * 1024) - i)
コード例 #4
0
 def testLessThanOneMebibyte(self):
   for i in [1, 2, 7, 512, 1000, 1023]:
     lu = _FakeLU()
     result = instance_storage._DiskSizeInBytesToMebibytes(lu, i)
     self.assertEqual(result, 1)
     self.assertEqual(len(lu.warning_log), 1)
     self.assertEqual(len(lu.warning_log[0]), 2)
     (_, (warnsize, )) = lu.warning_log[0]
     self.assertEqual(warnsize, (1024 * 1024) - i)
コード例 #5
0
ファイル: cmdlib_unittest.py プロジェクト: GangbiaoLiu/ganeti
 def testLargeNumber(self):
   for i in [1, 2, 7, 512, 1000, 1023, 2724, 12420]:
     for j in [1, 2, 486, 326, 986, 1023]:
       lu = _FakeLU()
       size = (1024 * 1024 * i) + j
       result = instance_storage._DiskSizeInBytesToMebibytes(lu, size)
       self.assertEqual(result, i + 1, msg="Amount was not rounded up")
       self.assertEqual(len(lu.warning_log), 1)
       self.assertEqual(len(lu.warning_log[0]), 2)
       (_, (warnsize, )) = lu.warning_log[0]
       self.assertEqual(warnsize, (1024 * 1024) - j)
コード例 #6
0
 def testLargeNumber(self):
   for i in [1, 2, 7, 512, 1000, 1023, 2724, 12420]:
     for j in [1, 2, 486, 326, 986, 1023]:
       lu = _FakeLU()
       size = (1024 * 1024 * i) + j
       result = instance_storage._DiskSizeInBytesToMebibytes(lu, size)
       self.assertEqual(result, i + 1, msg="Amount was not rounded up")
       self.assertEqual(len(lu.warning_log), 1)
       self.assertEqual(len(lu.warning_log[0]), 2)
       (_, (warnsize, )) = lu.warning_log[0]
       self.assertEqual(warnsize, (1024 * 1024) - j)