Add basic tests for lxc containers.
This commit is contained in:
@@ -227,6 +227,42 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self._check_xml_and_uri(instance_data, expect_kernel=True,
|
||||
expect_ramdisk=True, rescue=True)
|
||||
|
||||
def test_lxc_container_and_uri(self):
|
||||
instance_data = dict(self.test_instace)
|
||||
self._check_xml_and_container(instance_data)
|
||||
|
||||
def _check_xml_and_container(self, instance):
|
||||
user_context = context.RequestContext(project=self.project,
|
||||
user=self.user)
|
||||
instance_ref = db.instance_create(user_context,instance)
|
||||
host = self.network.get_network_host(user_context.elevated())
|
||||
network_ref= db.project_get_network(context.get_admin_context(),
|
||||
self.project.id)
|
||||
|
||||
fixed_ip = {'address': self.test_ip,
|
||||
'network_id': network_ref['id']}
|
||||
|
||||
ctxt = context.get_admin_context()
|
||||
fixed_ip_ref = db.fixed_ip_create(ctxt, fixed_ip)
|
||||
db.fixed_ip_update(ctxt, self.test_ip,
|
||||
{'allocated': True,
|
||||
'instance_id': instance_ref['id']})
|
||||
|
||||
FLAGS.libvirt_type = 'lxc'
|
||||
self.assertEquals(uri, 'lxc:///')
|
||||
|
||||
xml = conn.to_xml(instance_ref)
|
||||
tree = xml_to_tree(xml)
|
||||
|
||||
check = [
|
||||
(lambda t: t.find('.').get('type'), 'lxc'),
|
||||
(lambda t: t.find('./os/type').text, 'exe')
|
||||
]
|
||||
|
||||
for i (check, expected_result) in enumerate(check):
|
||||
self.aseertEqual(check(time),
|
||||
expected_result,
|
||||
'%s failed common check %d' % (xml, i))
|
||||
def _check_xml_and_uri(self, instance, expect_ramdisk, expect_kernel,
|
||||
rescue=False):
|
||||
user_context = context.RequestContext(project=self.project,
|
||||
|
||||
Reference in New Issue
Block a user