Revision 11aa3ca5 test/py/ganeti.masterd.iallocator_unittest.py
b/test/py/ganeti.masterd.iallocator_unittest.py | ||
---|---|---|
22 | 22 |
"""Script for testing ganeti.masterd.iallocator""" |
23 | 23 |
|
24 | 24 |
import unittest |
25 |
import mock |
|
26 | 25 |
|
27 | 26 |
from ganeti import compat |
28 | 27 |
from ganeti import constants |
29 | 28 |
from ganeti import errors |
30 | 29 |
from ganeti import objects |
31 | 30 |
from ganeti import ht |
32 |
from ganeti import rpc |
|
33 | 31 |
from ganeti.masterd import iallocator |
34 | 32 |
|
35 | 33 |
import testutils |
... | ... | |
200 | 198 |
"storage_size": 44}] |
201 | 199 |
self.node_info = ("123", self.space_info, ({},)) |
202 | 200 |
|
203 |
def testComputeStorageDataLvm(self): |
|
204 |
has_lvm = True |
|
205 |
node_name = "mynode" |
|
206 |
remote_info = rpc.MakeLegacyNodeInfo(self.node_info, |
|
207 |
require_vg_info=has_lvm) |
|
208 |
(total_disk, free_disk, total_spindles, free_spindles) = \ |
|
209 |
iallocator.IAllocator._ComputeStorageData(remote_info, node_name, has_lvm) |
|
210 |
self.assertEqual(self.free_storage_lvm, free_disk) |
|
211 |
self.assertEqual(self.total_storage_lvm, total_disk) |
|
212 |
|
|
213 |
def testComputeStorageDataDefault(self): |
|
201 |
def testComputeStorageDataFromNodeInfoDefault(self): |
|
214 | 202 |
has_lvm = False |
215 | 203 |
node_name = "mynode" |
216 |
remote_info = rpc.MakeLegacyNodeInfo(self.node_info, |
|
217 |
require_vg_info=has_lvm) |
|
218 | 204 |
(total_disk, free_disk, total_spindles, free_spindles) = \ |
219 |
iallocator.IAllocator._ComputeStorageData(remote_info, node_name, has_lvm) |
|
205 |
iallocator.IAllocator._ComputeStorageDataFromNodeInfo( |
|
206 |
self.node_info, node_name, has_lvm) |
|
220 | 207 |
# FIXME: right now, iallocator ignores anything else than LVM, adjust |
221 | 208 |
# this test once that arbitrary storage is supported |
222 | 209 |
self.assertEqual(0, free_disk) |
223 | 210 |
self.assertEqual(0, total_disk) |
224 | 211 |
|
212 |
def testComputeStorageDataFromNodeInfoLvm(self): |
|
213 |
has_lvm = True |
|
214 |
node_name = "mynode" |
|
215 |
(total_disk, free_disk, total_spindles, free_spindles) = \ |
|
216 |
iallocator.IAllocator._ComputeStorageDataFromNodeInfo( |
|
217 |
self.node_info, node_name, has_lvm) |
|
218 |
self.assertEqual(self.free_storage_lvm, free_disk) |
|
219 |
self.assertEqual(self.total_storage_lvm, total_disk) |
|
220 |
|
|
225 | 221 |
|
226 | 222 |
if __name__ == "__main__": |
227 | 223 |
testutils.GanetiTestProgram() |
Also available in: Unified diff