summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-01-06 12:57:37 -0800
committerJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-01-24 16:54:23 +0000
commita4223f1d89ea7033cbae35790a0411ec439cdb6d (patch)
treebf3768b78a9ab8633b525b17579bc8326bbcab63 /nova/tests
parent91bc67d81a9711fbf5a0f0c46bbf1d87232391f8 (diff)
KVM and XEN Disk Management Parity
Implements blueprint disk-configuration-parity This change splits local_gb into root_gb and ephemeral_gb. libvirt interpreted local_gb as what ephemeral_gb is now, whereas XenAPI interpreted local_gb as what root_gb is now. Change-Id: I496600991bac1e990326d4ded1607fee08209d68
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/ec2/test_admin.py2
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py8
-rw-r--r--nova/tests/api/openstack/compute/test_consoles.py2
-rw-r--r--nova/tests/api/openstack/compute/test_flavors.py6
-rw-r--r--nova/tests/api/openstack/compute/test_server_actions.py2
-rw-r--r--nova/tests/api/openstack/fakes.py3
-rw-r--r--nova/tests/db/fakes.py17
-rw-r--r--nova/tests/fake_network.py2
-rw-r--r--nova/tests/scheduler/fakes.py18
-rw-r--r--nova/tests/scheduler/test_distributed_scheduler.py12
-rw-r--r--nova/tests/scheduler/test_host_filters.py15
-rw-r--r--nova/tests/scheduler/test_scheduler.py24
-rw-r--r--nova/tests/test_compute.py23
-rw-r--r--nova/tests/test_compute_utils.py2
-rw-r--r--nova/tests/test_instance_types.py46
-rw-r--r--nova/tests/test_instance_types_extra_specs.py3
-rw-r--r--nova/tests/test_libvirt.py6
-rw-r--r--nova/tests/test_quota.py10
-rw-r--r--nova/tests/test_xenapi.py103
-rw-r--r--nova/tests/utils.py4
-rw-r--r--nova/tests/vmwareapi/db_fakes.py12
-rw-r--r--nova/tests/xenapi/stubs.py10
22 files changed, 231 insertions, 99 deletions
diff --git a/nova/tests/api/ec2/test_admin.py b/nova/tests/api/ec2/test_admin.py
index 0277e8278..2b4e463ee 100644
--- a/nova/tests/api/ec2/test_admin.py
+++ b/nova/tests/api/ec2/test_admin.py
@@ -123,7 +123,7 @@ class AdminTestCase(test.TestCase):
inst = {'name': 'this_inst',
'memory_mb': 1024,
'vcpus': 2,
- 'local_gb': 500,
+ 'root_gb': 500,
'flavorid': 1}
expected_inst_dict = {'name': 'this_inst',
diff --git a/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py b/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py
index 3ff12bf3a..b41773824 100644
--- a/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py
+++ b/nova/tests/api/openstack/compute/contrib/test_simple_tenant_usage.py
@@ -34,7 +34,8 @@ FLAGS = flags.FLAGS
SERVERS = 5
TENANTS = 2
HOURS = 24
-LOCAL_GB = 10
+ROOT_GB = 10
+EPHEMERAL_GB = 20
MEMORY_MB = 1024
VCPUS = 2
STOP = datetime.datetime.utcnow()
@@ -44,7 +45,8 @@ START = STOP - datetime.timedelta(hours=HOURS)
def fake_instance_type_get(self, context, instance_type_id):
return {'id': 1,
'vcpus': VCPUS,
- 'local_gb': LOCAL_GB,
+ 'root_gb': ROOT_GB,
+ 'ephemeral_gb': EPHEMERAL_GB,
'memory_mb': MEMORY_MB,
'name':
'fakeflavor'}
@@ -107,7 +109,7 @@ class SimpleTenantUsageTest(test.TestCase):
self.assertEqual(int(usages[i]['total_hours']),
SERVERS * HOURS)
self.assertEqual(int(usages[i]['total_local_gb_usage']),
- SERVERS * LOCAL_GB * HOURS)
+ SERVERS * (ROOT_GB + EPHEMERAL_GB) * HOURS)
self.assertEqual(int(usages[i]['total_memory_mb_usage']),
SERVERS * MEMORY_MB * HOURS)
self.assertEqual(int(usages[i]['total_vcpus_usage']),
diff --git a/nova/tests/api/openstack/compute/test_consoles.py b/nova/tests/api/openstack/compute/test_consoles.py
index 00239d99c..ac0499e84 100644
--- a/nova/tests/api/openstack/compute/test_consoles.py
+++ b/nova/tests/api/openstack/compute/test_consoles.py
@@ -101,7 +101,7 @@ def stub_instance(id, user_id='fake', project_id='fake', host=None,
"task_state": task_state,
"memory_mb": 0,
"vcpus": 0,
- "local_gb": 0,
+ "root_gb": 0,
"hostname": "",
"host": host,
"instance_type": {},
diff --git a/nova/tests/api/openstack/compute/test_flavors.py b/nova/tests/api/openstack/compute/test_flavors.py
index 672f5b8eb..8ad5eea0c 100644
--- a/nova/tests/api/openstack/compute/test_flavors.py
+++ b/nova/tests/api/openstack/compute/test_flavors.py
@@ -38,13 +38,13 @@ FAKE_FLAVORS = {
"flavorid": '1',
"name": 'flavor 1',
"memory_mb": '256',
- "local_gb": '10'
+ "root_gb": '10'
},
'flavor 2': {
"flavorid": '2',
"name": 'flavor 2',
"memory_mb": '512',
- "local_gb": '20'
+ "root_gb": '20'
},
}
@@ -63,7 +63,7 @@ def fake_instance_type_get_all(inactive=False, filters=None):
for (flavor_name, flavor) in FAKE_FLAVORS.items():
if reject_min('memory_mb', 'min_memory_mb'):
continue
- elif reject_min('local_gb', 'min_local_gb'):
+ elif reject_min('root_gb', 'min_root_gb'):
continue
output[flavor_name] = flavor
diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py
index 08612adb1..6c38c3fad 100644
--- a/nova/tests/api/openstack/compute/test_server_actions.py
+++ b/nova/tests/api/openstack/compute/test_server_actions.py
@@ -100,7 +100,7 @@ def stub_instance(id, metadata=None, image_ref="10", flavor_id="1",
"task_state": task_state,
"memory_mb": 0,
"vcpus": 0,
- "local_gb": 0,
+ "root_gb": 0,
"hostname": "",
"host": "fake_host",
"instance_type": dict(inst_type),
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index 103f3678c..b5966b460 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -514,7 +514,8 @@ def stub_instance(id, user_id='fake', project_id='fake', host=None,
"power_state": power_state,
"memory_mb": 0,
"vcpus": 0,
- "local_gb": 0,
+ "root_gb": 0,
+ "ephemeral_gb": 0,
"hostname": "",
"host": host,
"instance_type": dict(inst_type),
diff --git a/nova/tests/db/fakes.py b/nova/tests/db/fakes.py
index f24f020a6..9f89aaba8 100644
--- a/nova/tests/db/fakes.py
+++ b/nova/tests/db/fakes.py
@@ -349,29 +349,33 @@ def stub_out_db_instance_api(stubs, injected=True):
'm1.tiny': dict(id=2,
memory_mb=512,
vcpus=1,
- local_gb=0,
+ root_gb=0,
+ ephemeral_gb=10,
flavorid=1,
rxtx_cap=1,
swap=0),
'm1.small': dict(id=5,
memory_mb=2048,
vcpus=1,
- local_gb=20,
+ root_gb=20,
+ ephemeral_gb=0,
flavorid=2,
rxtx_cap=2,
- swap=0),
+ swap=1024),
'm1.medium':
dict(id=1,
memory_mb=4096,
vcpus=2,
- local_gb=40,
+ root_gb=40,
+ ephemeral_gb=40,
flavorid=3,
rxtx_cap=3,
swap=0),
'm1.large': dict(id=3,
memory_mb=8192,
vcpus=4,
- local_gb=80,
+ root_gb=80,
+ ephemeral_gb=80,
flavorid=4,
rxtx_cap=4,
swap=0),
@@ -379,7 +383,8 @@ def stub_out_db_instance_api(stubs, injected=True):
dict(id=4,
memory_mb=16384,
vcpus=8,
- local_gb=160,
+ root_gb=160,
+ ephemeral_gb=160,
flavorid=5,
rxtx_cap=5,
swap=0)}
diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py
index 29bb793ce..2c950c143 100644
--- a/nova/tests/fake_network.py
+++ b/nova/tests/fake_network.py
@@ -155,7 +155,7 @@ flavor = {'id': 0,
'name': 'fake_flavor',
'memory_mb': 2048,
'vcpus': 2,
- 'local_gb': 10,
+ 'root_gb': 10,
'flavor_id': 0,
'swap': 0,
'rxtx_factor': 3}
diff --git a/nova/tests/scheduler/fakes.py b/nova/tests/scheduler/fakes.py
index 94287bac3..d2de4ba40 100644
--- a/nova/tests/scheduler/fakes.py
+++ b/nova/tests/scheduler/fakes.py
@@ -40,14 +40,20 @@ COMPUTE_NODES = [
]
INSTANCES = [
- dict(local_gb=512, memory_mb=512, vcpus=1, host='host1'),
- dict(local_gb=512, memory_mb=512, vcpus=1, host='host2'),
- dict(local_gb=512, memory_mb=512, vcpus=1, host='host2'),
- dict(local_gb=1024, memory_mb=1024, vcpus=1, host='host3'),
+ dict(root_gb=512, ephemeral_gb=0, memory_mb=512, vcpus=1,
+ host='host1'),
+ dict(root_gb=512, ephemeral_gb=0, memory_mb=512, vcpus=1,
+ host='host2'),
+ dict(root_gb=512, ephemeral_gb=0, memory_mb=512, vcpus=1,
+ host='host2'),
+ dict(root_gb=1024, ephemeral_gb=0, memory_mb=1024, vcpus=1,
+ host='host3'),
# Broken host
- dict(local_gb=1024, memory_mb=1024, vcpus=1, host=None),
+ dict(root_gb=1024, ephemeral_gb=0, memory_mb=1024, vcpus=1,
+ host=None),
# No matching host
- dict(local_gb=1024, memory_mb=1024, vcpus=1, host='host5'),
+ dict(root_gb=1024, ephemeral_gb=0, memory_mb=1024, vcpus=1,
+ host='host5'),
]
diff --git a/nova/tests/scheduler/test_distributed_scheduler.py b/nova/tests/scheduler/test_distributed_scheduler.py
index 8e586ac8b..426da044f 100644
--- a/nova/tests/scheduler/test_distributed_scheduler.py
+++ b/nova/tests/scheduler/test_distributed_scheduler.py
@@ -104,7 +104,8 @@ class DistributedSchedulerTestCase(test.TestCase):
self.stubs.Set(db, 'zone_get_all', fake_zone_get_all)
fake_context = context.RequestContext('user', 'project')
- request_spec = {'instance_type': {'memory_mb': 1, 'local_gb': 1},
+ request_spec = {'instance_type': {'memory_mb': 1, 'root_gb': 1,
+ 'ephemeral_gb': 0},
'instance_properties': {'project_id': 1}}
self.assertRaises(exception.NoValidHost, sched.schedule_run_instance,
fake_context, request_spec)
@@ -219,7 +220,8 @@ class DistributedSchedulerTestCase(test.TestCase):
self.stubs.Set(sched, '_call_zone_method', fake_call_zone_method)
request_spec = {'num_instances': 10,
- 'instance_type': {'memory_mb': 512, 'local_gb': 512},
+ 'instance_type': {'memory_mb': 512, 'root_gb': 512,
+ 'ephemeral_gb': 0},
'instance_properties': {'project_id': 1}}
self.mox.ReplayAll()
weighted_hosts = sched._schedule(fake_context, 'compute',
@@ -260,10 +262,12 @@ class DistributedSchedulerTestCase(test.TestCase):
self.stubs.Set(sched, '_call_zone_method', fake_call_zone_method)
request_spec = {'num_instances': 10,
- 'instance_type': {'memory_mb': 512, 'local_gb': 512},
+ 'instance_type': {'memory_mb': 512, 'root_gb': 512,
+ 'ephemeral_gb': 256},
'instance_properties': {'project_id': 1,
'memory_mb': 512,
- 'local_gb': 512,
+ 'root_gb': 512,
+ 'ephemeral_gb': 0,
'vcpus': 1}}
filter_properties = {'local_zone_only': True}
self.mox.ReplayAll()
diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py
index 5e3ff2601..d03d224d1 100644
--- a/nova/tests/scheduler/test_host_filters.py
+++ b/nova/tests/scheduler/test_host_filters.py
@@ -267,7 +267,8 @@ class HostFiltersTestCase(test.TestCase):
def test_json_filter_passes(self):
filt_cls = filters.JsonFilter()
filter_properties = {'instance_type': {'memory_mb': 1024,
- 'local_gb': 200},
+ 'root_gb': 200,
+ 'ephemeral_gb': 0},
'query': self.json_query}
capabilities = {'enabled': True}
host = fakes.FakeHostState('host1', 'compute',
@@ -279,7 +280,8 @@ class HostFiltersTestCase(test.TestCase):
def test_json_filter_passes_with_no_query(self):
filt_cls = filters.JsonFilter()
filter_properties = {'instance_type': {'memory_mb': 1024,
- 'local_gb': 200}}
+ 'root_gb': 200,
+ 'ephemeral_gb': 0}}
capabilities = {'enabled': True}
host = fakes.FakeHostState('host1', 'compute',
{'free_ram_mb': 0,
@@ -290,7 +292,8 @@ class HostFiltersTestCase(test.TestCase):
def test_json_filter_fails_on_memory(self):
filt_cls = filters.JsonFilter()
filter_properties = {'instance_type': {'memory_mb': 1024,
- 'local_gb': 200},
+ 'root_gb': 200,
+ 'ephemeral_gb': 0},
'query': self.json_query}
capabilities = {'enabled': True}
host = fakes.FakeHostState('host1', 'compute',
@@ -302,7 +305,8 @@ class HostFiltersTestCase(test.TestCase):
def test_json_filter_fails_on_disk(self):
filt_cls = filters.JsonFilter()
filter_properties = {'instance_type': {'memory_mb': 1024,
- 'local_gb': 200},
+ 'root_gb': 200,
+ 'ephemeral_gb': 0},
'query': self.json_query}
capabilities = {'enabled': True}
host = fakes.FakeHostState('host1', 'compute',
@@ -318,7 +322,8 @@ class HostFiltersTestCase(test.TestCase):
['>=', '$free_disk_mb', 200 * 1024],
'$capabilities.enabled'])
filter_properties = {'instance_type': {'memory_mb': 1024,
- 'local_gb': 200},
+ 'root_gb': 200,
+ 'ephemeral_gb': 0},
'query': json_query}
capabilities = {'enabled': False}
host = fakes.FakeHostState('host1', 'compute',
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py
index 73b538768..26e1aaaba 100644
--- a/nova/tests/scheduler/test_scheduler.py
+++ b/nova/tests/scheduler/test_scheduler.py
@@ -167,15 +167,18 @@ class SchedulerManagerTestCase(test.TestCase):
instances = [{'project_id': 'project1',
'vcpus': 1,
'memory_mb': 128,
- 'local_gb': 128},
+ 'root_gb': 128,
+ 'ephemeral_gb': 0},
{'project_id': 'project1',
'vcpus': 2,
'memory_mb': 256,
- 'local_gb': 384},
+ 'root_gb': 384,
+ 'ephemeral_gb': 0},
{'project_id': 'project2',
'vcpus': 2,
'memory_mb': 256,
- 'local_gb': 256}]
+ 'root_gb': 256,
+ 'ephemeral_gb': 0}]
self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host')
self.mox.StubOutWithMock(db, 'instance_get_all_by_host')
@@ -188,15 +191,17 @@ class SchedulerManagerTestCase(test.TestCase):
result = self.manager.show_host_resources(self.context, host)
expected = {'usage': {'project1': {'memory_mb': 384,
'vcpus': 3,
- 'local_gb': 512},
+ 'root_gb': 512,
+ 'ephemeral_gb': 0},
'project2': {'memory_mb': 256,
'vcpus': 2,
- 'local_gb': 256}},
- 'resource': {'vcpus_used': 2,
+ 'root_gb': 256,
+ 'ephemeral_gb': 0}},
+ 'resource': {'vcpus': 4,
+ 'vcpus_used': 2,
+ 'local_gb': 1024,
'local_gb_used': 512,
'memory_mb': 1024,
- 'vcpus': 4,
- 'local_gb': 1024,
'memory_mb_used': 512}}
self.assertDictMatch(result, expected)
@@ -358,7 +363,8 @@ class SchedulerTestCase(test.TestCase):
'volumes': [volume1, volume2],
'power_state': power_state.RUNNING,
'memory_mb': 1024,
- 'local_gb': 1024}
+ 'root_gb': 1024,
+ 'ephemeral_gb': 0}
def test_live_migration_basic(self):
"""Test basic schedule_live_migration functionality"""
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index 83a41250c..f416e4a51 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -151,6 +151,8 @@ class BaseTestCase(test.TestCase):
type_id = instance_types.get_instance_type_by_name(type_name)['id']
inst['instance_type_id'] = type_id
inst['ami_launch_index'] = 0
+ inst['root_gb'] = 0
+ inst['ephemeral_gb'] = 0
inst.update(params)
return db.instance_create(self.context, inst)
@@ -168,7 +170,8 @@ class BaseTestCase(test.TestCase):
inst['name'] = 'm1.small'
inst['memory_mb'] = '1024'
inst['vcpus'] = '1'
- inst['local_gb'] = '20'
+ inst['root_gb'] = '20'
+ inst['ephemeral_gb'] = '10'
inst['flavorid'] = '1'
inst['swap'] = '2048'
inst['rxtx_factor'] = 1
@@ -1458,7 +1461,7 @@ class ComputeAPITestCase(BaseTestCase):
"""Test an instance type with too little disk space"""
inst_type = instance_types.get_default_instance_type()
- inst_type['local_gb'] = 1
+ inst_type['root_gb'] = 1
def fake_show(*args):
img = copy(self.fake_image)
@@ -1470,7 +1473,7 @@ class ComputeAPITestCase(BaseTestCase):
self.compute_api.create, self.context, inst_type, None)
# Now increase the inst_type disk space and make sure all is fine.
- inst_type['local_gb'] = 2
+ inst_type['root_gb'] = 2
(refs, resv_id) = self.compute_api.create(self.context,
inst_type, None)
db.instance_destroy(self.context, refs[0]['id'])
@@ -1479,7 +1482,7 @@ class ComputeAPITestCase(BaseTestCase):
"""Test an instance type with just enough ram and disk space"""
inst_type = instance_types.get_default_instance_type()
- inst_type['local_gb'] = 2
+ inst_type['root_gb'] = 2
inst_type['memory_mb'] = 2
def fake_show(*args):
@@ -1497,7 +1500,7 @@ class ComputeAPITestCase(BaseTestCase):
"""Test an instance type with no min_ram or min_disk"""
inst_type = instance_types.get_default_instance_type()
- inst_type['local_gb'] = 1
+ inst_type['root_gb'] = 1
inst_type['memory_mb'] = 1
def fake_show(*args):
@@ -1951,7 +1954,7 @@ class ComputeAPITestCase(BaseTestCase):
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
instance = self._create_fake_instance()
- inst_params = {'local_gb': 2, 'memory_mb': 256}
+ inst_params = {'root_gb': 2, 'memory_mb': 256}
instance['instance_type'].update(inst_params)
image = self.compute_api.snapshot(self.context, instance, 'snap1',
@@ -2777,12 +2780,12 @@ class ComputeAPITestCase(BaseTestCase):
self.compute.terminate_instance(self.context, instance['uuid'])
def test_volume_size(self):
- local_size = 2
+ ephemeral_size = 2
swap_size = 3
- inst_type = {'local_gb': local_size, 'swap': swap_size}
+ inst_type = {'ephemeral_gb': ephemeral_size, 'swap': swap_size}
self.assertEqual(self.compute_api._volume_size(inst_type,
- 'ephemeral0'),
- local_size)
+ 'ephemeral0'),
+ ephemeral_size)
self.assertEqual(self.compute_api._volume_size(inst_type,
'ephemeral1'),
0)
diff --git a/nova/tests/test_compute_utils.py b/nova/tests/test_compute_utils.py
index 7ba03063f..71463fbc0 100644
--- a/nova/tests/test_compute_utils.py
+++ b/nova/tests/test_compute_utils.py
@@ -66,6 +66,8 @@ class UsageInfoTestCase(test.TestCase):
type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']
inst['instance_type_id'] = type_id
inst['ami_launch_index'] = 0
+ inst['root_gb'] = 0
+ inst['ephemeral_gb'] = 0
inst.update(params)
return db.instance_create(self.context, inst)['id']
diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py
index 2def43731..b0613c757 100644
--- a/nova/tests/test_instance_types.py
+++ b/nova/tests/test_instance_types.py
@@ -68,13 +68,14 @@ class InstanceTypeTestCase(test.TestCase):
original_list = instance_types.get_all_types()
# create new type and make sure values stick
- inst_type = instance_types.create(name, 256, 1, 120, flavorid)
+ inst_type = instance_types.create(name, 256, 1, 120, 100, flavorid)
inst_type_id = inst_type['id']
self.assertEqual(inst_type['flavorid'], flavorid)
self.assertEqual(inst_type['name'], name)
self.assertEqual(inst_type['memory_mb'], 256)
self.assertEqual(inst_type['vcpus'], 1)
- self.assertEqual(inst_type['local_gb'], 120)
+ self.assertEqual(inst_type['root_gb'], 120)
+ self.assertEqual(inst_type['ephemeral_gb'], 100)
self.assertEqual(inst_type['swap'], 0)
self.assertEqual(inst_type['rxtx_factor'], 1)
@@ -108,22 +109,23 @@ class InstanceTypeTestCase(test.TestCase):
def test_invalid_create_args_should_fail(self):
"""Ensures that instance type creation fails with invalid args"""
invalid_sigs = [
- (('Zero memory', 0, 1, 10, 'flavor1'), {}),
- (('Negative memory', -256, 1, 10, 'flavor1'), {}),
- (('Non-integer memory', 'asdf', 1, 10, 'flavor1'), {}),
+ (('Zero memory', 0, 1, 10, 20, 'flavor1'), {}),
+ (('Negative memory', -256, 1, 10, 20, 'flavor1'), {}),
+ (('Non-integer memory', 'asdf', 1, 10, 20, 'flavor1'), {}),
- (('Zero vcpus', 256, 0, 10, 'flavor1'), {}),
- (('Negative vcpus', 256, -1, 10, 'flavor1'), {}),
- (('Non-integer vcpus', 256, 'a', 10, 'flavor1'), {}),
+ (('Zero vcpus', 256, 0, 10, 20, 'flavor1'), {}),
+ (('Negative vcpus', 256, -1, 10, 20, 'flavor1'), {}),
+ (('Non-integer vcpus', 256, 'a', 10, 20, 'flavor1'), {}),
- (('Negative storage', 256, 1, -1, 'flavor1'), {}),
- (('Non-integer storage', 256, 1, 'a', 'flavor1'), {}),
+ (('Negative storage', 256, 1, -1, 20, 'flavor1'), {}),
+ (('Non-integer storage', 256, 1, 'a', 20, 'flavor1'), {}),
- (('Negative swap', 256, 1, 10, 'flavor1'), {'swap': -1}),
- (('Non-integer swap', 256, 1, 10, 'flavor1'), {'swap': -1}),
+ (('Negative swap', 256, 1, 10, 20, 'flavor1'), {'swap': -1}),
+ (('Non-integer swap', 256, 1, 10, 20, 'flavor1'), {'swap': -1}),
- (('Negative rxtx_factor', 256, 1, 10, 'f1'), {'rxtx_factor': -1}),
- (('Non-integer rxtx_factor', 256, 1, 10, 'f1'),
+ (('Negative rxtx_factor', 256, 1, 10, 20, 'f1'),
+ {'rxtx_factor': -1}),
+ (('Non-integer rxtx_factor', 256, 1, 10, 20, 'f1'),
{'rxtx_factor': "d"}),
]
@@ -140,18 +142,18 @@ class InstanceTypeTestCase(test.TestCase):
def test_duplicate_names_fail(self):
"""Ensures that name duplicates raise ApiError"""
name = 'some_name'
- instance_types.create(name, 256, 1, 120, 'flavor1')
+ instance_types.create(name, 256, 1, 120, 200, 'flavor1')
self.assertRaises(exception.ApiError,
instance_types.create,
- name, "256", 1, 120, 'flavor2')
+ name, "256", 1, 120, 200, 'flavor2')
def test_duplicate_flavorids_fail(self):
"""Ensures that flavorid duplicates raise ApiError"""
flavorid = 'flavor1'
- instance_types.create('name one', 256, 1, 120, flavorid)
+ instance_types.create('name one', 256, 1, 120, 200, flavorid)
self.assertRaises(exception.ApiError,
instance_types.create,
- 'name two', 256, 1, 120, flavorid)
+ 'name two', 256, 1, 120, 200, flavorid)
def test_will_not_destroy_with_no_name(self):
"""Ensure destroy sad path of no name raises error"""
@@ -239,14 +241,14 @@ class InstanceTypeFilteringTest(test.TestCase):
expected = ['m1.large', 'm1.medium', 'm1.small', 'm1.xlarge']
self.assertFilterResults(filters, expected)
- def test_min_local_gb_filter(self):
+ def test_min_root_gb_filter(self):
"""Exclude everything but large and xlarge which have >= 80 GB"""
- filters = dict(min_local_gb=80)
+ filters = dict(min_root_gb=80)
expected = ['m1.large', 'm1.xlarge']
self.assertFilterResults(filters, expected)
- def test_min_memory_mb_AND_local_gb_filter(self):
+ def test_min_memory_mb_AND_root_gb_filter(self):
"""Exclude everything but large and xlarge which have >= 80 GB"""
- filters = dict(min_memory_mb=16384, min_local_gb=80)
+ filters = dict(min_memory_mb=16384, min_root_gb=80)
expected = ['m1.xlarge']
self.assertFilterResults(filters, expected)
diff --git a/nova/tests/test_instance_types_extra_specs.py b/nova/tests/test_instance_types_extra_specs.py
index 999e5a126..8f4ea89d3 100644
--- a/nova/tests/test_instance_types_extra_specs.py
+++ b/nova/tests/test_instance_types_extra_specs.py
@@ -29,7 +29,8 @@ class InstanceTypeExtraSpecsTestCase(test.TestCase):
values = dict(name="cg1.4xlarge",
memory_mb=22000,
vcpus=8,
- local_gb=1690,
+ root_gb=1690,
+ ephemeral_gb=2000,
flavorid=105)
specs = dict(cpu_arch="x86_64",
cpu_model="Nehalem",
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index 894ac583e..2dfa277c5 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -303,7 +303,8 @@ class LibvirtConnTestCase(test.TestCase):
'project_id': 'fake',
'bridge': 'br101',
'image_ref': '155d900f-4e14-4e4c-a73d-069cbf4541e6',
- 'local_gb': 20,
+ 'root_gb': 10,
+ 'ephemeral_gb': 20,
'instance_type_id': '5'} # m1.small
def create_fake_libvirt_mock(self, **kwargs):
@@ -1625,7 +1626,8 @@ class NWFilterTestCase(test.TestCase):
inst['name'] = 'm1.small'
inst['memory_mb'] = '1024'
inst['vcpus'] = '1'
- inst['local_gb'] = '20'
+ inst['root_gb'] = '10'
+ inst['ephemeral_gb'] = '20'
inst['flavorid'] = '1'
inst['swap'] = '2048'
inst['rxtx_factor'] = 1
diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py
index 6f2f1161b..3c267b8b0 100644
--- a/nova/tests/test_quota.py
+++ b/nova/tests/test_quota.py
@@ -91,13 +91,13 @@ class QuotaTestCase(test.TestCase):
def _get_instance_type(self, name):
instance_types = {
- 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
- 'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2),
+ 'm1.tiny': dict(memory_mb=512, vcpus=1, root_gb=0, flavorid=1),
+ 'm1.small': dict(memory_mb=2048, vcpus=1, root_gb=20, flavorid=2),
'm1.medium':
- dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3),
- 'm1.large': dict(memory_mb=8192, vcpus=4, local_gb=80, flavorid=4),
+ dict(memory_mb=4096, vcpus=2, root_gb=40, flavorid=3),
+ 'm1.large': dict(memory_mb=8192, vcpus=4, root_gb=80, flavorid=4),
'm1.xlarge':
- dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)}
+ dict(memory_mb=16384, vcpus=8, root_gb=160, flavorid=5)}
return instance_types[name]
def test_quota_overrides(self):
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 180400af4..c3730b3ca 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -107,7 +107,7 @@ class XenAPIVolumeTestCase(test.TestCase):
'image_ref': 1,
'kernel_id': 2,
'ramdisk_id': 3,
- 'local_gb': 20,
+ 'root_gb': 20,
'instance_type_id': '3', # m1.large
'os_type': 'linux',
'architecture': 'x86-64'}
@@ -414,7 +414,7 @@ class XenAPIVMTestCase(test.TestCase):
'image_ref': image_ref,
'kernel_id': kernel_id,
'ramdisk_id': ramdisk_id,
- 'local_gb': 20,
+ 'root_gb': 20,
'instance_type_id': instance_type_id,
'os_type': os_type,
'hostname': hostname,
@@ -700,7 +700,7 @@ class XenAPIVMTestCase(test.TestCase):
'image_ref': 1,
'kernel_id': 2,
'ramdisk_id': 3,
- 'local_gb': 20,
+ 'root_gb': 20,
'instance_type_id': '3', # m1.large
'os_type': 'linux',
'architecture': 'x86-64'}
@@ -797,7 +797,7 @@ class XenAPIMigrateInstance(test.TestCase):
'image_ref': 1,
'kernel_id': None,
'ramdisk_id': None,
- 'local_gb': 5,
+ 'root_gb': 5,
'instance_type_id': '3', # m1.large
'os_type': 'linux',
'architecture': 'x86-64'}
@@ -874,7 +874,7 @@ class XenAPIMigrateInstance(test.TestCase):
self.fake_finish_revert_migration_called = True
self.stubs.Set(stubs.FakeSessionForMigrationTests,
- "VDI_resize_online", fake_vdi_resize)
+ "VDI_resize_online", fake_vdi_resize)
self.stubs.Set(vmops.VMOps, '_start', fake_vm_start)
self.stubs.Set(vmops.VMOps, 'finish_revert_migration',
fake_finish_revert_migration)
@@ -889,7 +889,7 @@ class XenAPIMigrateInstance(test.TestCase):
'gateway_v6': 'dead:beef::1',
'ip6s': [{'enabled': '1',
'ip': 'dead:beef::dcad:beff:feef:0',
- 'netmask': '64'}],
+ 'netmask': '64'}],
'ips': [{'enabled': '1',
'ip': '192.168.0.100',
'netmask': '255.255.255.0'}],
@@ -917,9 +917,9 @@ class XenAPIMigrateInstance(test.TestCase):
def fake_vdi_resize(*args, **kwargs):
self.called = True
- self.stubs.Set(stubs.FakeSessionForMigrationTests,
- "VDI_resize_online", fake_vdi_resize)
self.stubs.Set(vmops.VMOps, '_start', fake_vm_start)
+ self.stubs.Set(stubs.FakeSessionForMigrationTests,
+ "VDI_resize_online", fake_vdi_resize)
stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
stubs.stubout_loopingcall_start(self.stubs)
@@ -949,14 +949,14 @@ class XenAPIMigrateInstance(test.TestCase):
tiny_type_id = \
instance_types.get_instance_type_by_name('m1.tiny')['id']
self.instance_values.update({'instance_type_id': tiny_type_id,
- 'local_gb': 0})
+ 'root_gb': 0})
instance = db.instance_create(self.context, self.instance_values)
def fake_vdi_resize(*args, **kwargs):
raise Exception("This shouldn't be called")
self.stubs.Set(stubs.FakeSessionForMigrationTests,
- "VDI_resize_online", fake_vdi_resize)
+ "VDI_resize_online", fake_vdi_resize)
stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
stubs.stubout_loopingcall_start(self.stubs)
conn = xenapi_conn.get_connection(False)
@@ -1157,7 +1157,7 @@ class XenAPIAutoDiskConfigTestCase(test.TestCase):
'image_ref': 1,
'kernel_id': 2,
'ramdisk_id': 3,
- 'local_gb': 20,
+ 'root_gb': 20,
'instance_type_id': '3', # m1.large
'os_type': 'linux',
'architecture': 'x86-64'}
@@ -1226,6 +1226,87 @@ class XenAPIAutoDiskConfigTestCase(test.TestCase):
self.assertIsPartitionCalled(True)
+class XenAPIGenerateLocal(test.TestCase):
+ """Test generating of local disks, like swap and ephemeral"""
+ def setUp(self):
+ super(XenAPIGenerateLocal, self).setUp()
+ self.stubs = stubout.StubOutForTesting()
+ self.flags(target_host='127.0.0.1',
+ xenapi_connection_url='test_url',
+ xenapi_connection_password='test_pass',
+ xenapi_generate_swap=True,
+ firewall_driver='nova.virt.xenapi.firewall.'
+ 'Dom0IptablesFirewallDriver')
+ stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
+ db_fakes.stub_out_db_instance_api(self.stubs)
+ xenapi_fake.reset()
+ self.conn = xenapi_conn.get_connection(False)
+
+ self.user_id = 'fake'
+ self.project_id = 'fake'
+
+ self.instance_values = {'id': 1,
+ 'project_id': self.project_id,
+ 'user_id': self.user_id,
+ 'image_ref': 1,
+ 'kernel_id': 2,
+ 'ramdisk_id': 3,
+ 'root_gb': 20,
+ 'instance_type_id': '3', # m1.large
+ 'os_type': 'linux',
+ 'architecture': 'x86-64'}
+
+ self.context = context.RequestContext(self.user_id, self.project_id)
+
+ @classmethod
+ def fake_create_vbd(cls, session, vm_ref, vdi_ref, userdevice,
+ bootable=True):
+ pass
+
+ self.stubs.Set(volume_utils.VolumeHelper,
+ "create_vbd",
+ fake_create_vbd)
+
+ def assertCalled(self, instance):
+ disk_image_type = vm_utils.ImageType.DISK_VHD
+ vm_ref = "blah"
+ first_vdi_ref = "blah"
+ vdis = ["blah"]
+
+ self.called = False
+ self.conn._vmops._attach_disks(instance, disk_image_type,
+ vm_ref, first_vdi_ref, vdis)
+ self.assertTrue(self.called)
+
+ def test_generate_swap(self):
+ """Test swap disk generation."""
+ instance = db.instance_create(self.context, self.instance_values)
+ instance = db.instance_update(self.context, instance['id'],
+ {'instance_type_id': 5})
+
+ @classmethod
+ def fake_generate_swap(cls, *args, **kwargs):
+ self.called = True
+ self.stubs.Set(vm_utils.VMHelper, 'generate_swap',
+ fake_generate_swap)
+
+ self.assertCalled(instance)
+
+ def test_generate_ephemeral(self):
+ """Test ephemeral disk generation."""
+ instance = db.instance_create(self.context, self.instance_values)
+ instance = db.instance_update(self.context, instance['id'],
+ {'instance_type_id': 4})
+
+ @classmethod
+ def fake_generate_ephemeral(cls, *args):
+ self.called = True
+ self.stubs.Set(vm_utils.VMHelper, 'generate_ephemeral',
+ fake_generate_ephemeral)
+
+ self.assertCalled(instance)
+
+
class XenAPIBWUsageTestCase(test.TestCase):
def setUp(self):
super(XenAPIBWUsageTestCase, self).setUp()
diff --git a/nova/tests/utils.py b/nova/tests/utils.py
index f78ba3f2e..898eed76a 100644
--- a/nova/tests/utils.py
+++ b/nova/tests/utils.py
@@ -41,7 +41,8 @@ def get_test_instance_type(context=None):
test_instance_type = {'name': 'kinda.big',
'memory_mb': 2048,
'vcpus': 4,
- 'local_gb': 40,
+ 'root_gb': 40,
+ 'ephemeral_gb': 80,
'swap': 1024}
instance_type_ref = nova.db.instance_type_create(context,
@@ -57,6 +58,7 @@ def get_test_instance(context=None):
'basepath': '/some/path',
'bridge_name': 'br100',
'vcpus': 2,
+ 'root_gb': 10,
'project_id': 'fake',
'bridge': 'br101',
'image_ref': 'cedef40a-ed67-4d10-800e-17455edce175',
diff --git a/nova/tests/vmwareapi/db_fakes.py b/nova/tests/vmwareapi/db_fakes.py
index 599ba271c..1425a8751 100644
--- a/nova/tests/vmwareapi/db_fakes.py
+++ b/nova/tests/vmwareapi/db_fakes.py
@@ -31,13 +31,13 @@ def stub_out_db_instance_api(stubs):
"""Stubs out the db API for creating Instances."""
INSTANCE_TYPES = {
- 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
- 'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2),
+ 'm1.tiny': dict(memory_mb=512, vcpus=1, root_gb=0, flavorid=1),
+ 'm1.small': dict(memory_mb=2048, vcpus=1, root_gb=20, flavorid=2),
'm1.medium':
- dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3),
- 'm1.large': dict(memory_mb=8192, vcpus=4, local_gb=80, flavorid=4),
+ dict(memory_mb=4096, vcpus=2, root_gb=40, flavorid=3),
+ 'm1.large': dict(memory_mb=8192, vcpus=4, root_gb=80, flavorid=4),
'm1.xlarge':
- dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)}
+ dict(memory_mb=16384, vcpus=8, root_gb=160, flavorid=5)}
class FakeModel(object):
"""Stubs out for model."""
@@ -76,7 +76,7 @@ def stub_out_db_instance_api(stubs):
'memory_mb': type_data['memory_mb'],
'vcpus': type_data['vcpus'],
'mac_addresses': [{'address': values['mac_address']}],
- 'local_gb': type_data['local_gb'],
+ 'root_gb': type_data['root_gb'],
}
return FakeModel(base_options)
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index c0de0dd37..0c707e14e 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -289,10 +289,15 @@ def stub_out_vm_methods(stubs):
def fake_spawn_rescue(self, context, inst, network_info, image_meta):
inst._rescue = False
+ @classmethod
+ def fake_generate_ephemeral(cls, *args):
+ pass
+
stubs.Set(vmops.VMOps, "_shutdown", fake_shutdown)
stubs.Set(vmops.VMOps, "_acquire_bootlock", fake_acquire_bootlock)
stubs.Set(vmops.VMOps, "_release_bootlock", fake_release_bootlock)
stubs.Set(vmops.VMOps, "spawn_rescue", fake_spawn_rescue)
+ stubs.Set(vm_utils.VMHelper, 'generate_ephemeral', fake_generate_ephemeral)
class FakeSessionForVolumeTests(fake.SessionBase):
@@ -383,6 +388,10 @@ def stub_out_migration_methods(stubs):
def fake_reset_network(*args, **kwargs):
pass
+ @classmethod
+ def fake_generate_ephemeral(cls, *args):
+ pass
+
stubs.Set(vmops.VMOps, '_destroy', fake_destroy)
stubs.Set(vm_utils.VMHelper, 'scan_default_sr', fake_sr)
stubs.Set(vm_utils.VMHelper, 'scan_sr', fake_sr)
@@ -392,3 +401,4 @@ def stub_out_migration_methods(stubs):
stubs.Set(vm_utils.VMHelper, 'get_sr_path', fake_get_sr_path)
stubs.Set(vmops.VMOps, 'reset_network', fake_reset_network)
stubs.Set(vmops.VMOps, '_shutdown', fake_shutdown)
+ stubs.Set(vm_utils.VMHelper, 'generate_ephemeral', fake_generate_ephemeral)