Update Authors and testsuite
This commit is contained in:
1
Authors
1
Authors
@@ -11,6 +11,7 @@ Chiradeep Vittal <chiradeep@cloud.com>
|
|||||||
Chmouel Boudjnah <chmouel@chmouel.com>
|
Chmouel Boudjnah <chmouel@chmouel.com>
|
||||||
Chris Behrens <cbehrens@codestud.com>
|
Chris Behrens <cbehrens@codestud.com>
|
||||||
Christian Berendt <berendt@b1-systems.de>
|
Christian Berendt <berendt@b1-systems.de>
|
||||||
|
Chuck Short <chuck.short@canonical.com>
|
||||||
Cory Wright <corywright@gmail.com>
|
Cory Wright <corywright@gmail.com>
|
||||||
Dan Prince <dan.prince@rackspace.com>
|
Dan Prince <dan.prince@rackspace.com>
|
||||||
David Pravec <David.Pravec@danix.org>
|
David Pravec <David.Pravec@danix.org>
|
||||||
|
|||||||
@@ -228,16 +228,16 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
expect_ramdisk=True, rescue=True)
|
expect_ramdisk=True, rescue=True)
|
||||||
|
|
||||||
def test_lxc_container_and_uri(self):
|
def test_lxc_container_and_uri(self):
|
||||||
instance_data = dict(self.test_instace)
|
instance_data = dict(self.test_instance)
|
||||||
self._check_xml_and_container(instance_data)
|
self._check_xml_and_container(instance_data)
|
||||||
|
|
||||||
def _check_xml_and_container(self, instance):
|
def _check_xml_and_container(self, instance):
|
||||||
user_context = context.RequestContext(project=self.project,
|
user_context = context.RequestContext(project=self.project,
|
||||||
user=self.user)
|
user=self.user)
|
||||||
instance_ref = db.instance_create(user_context,instance)
|
instance_ref = db.instance_create(user_context, instance)
|
||||||
host = self.network.get_network_host(user_context.elevated())
|
host = self.network.get_network_host(user_context.elevated())
|
||||||
network_ref= db.project_get_network(context.get_admin_context(),
|
network_ref = db.project_get_network(context.get_admin_context(),
|
||||||
self.project.id)
|
self.project.id)
|
||||||
|
|
||||||
fixed_ip = {'address': self.test_ip,
|
fixed_ip = {'address': self.test_ip,
|
||||||
'network_id': network_ref['id']}
|
'network_id': network_ref['id']}
|
||||||
@@ -245,24 +245,28 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
fixed_ip_ref = db.fixed_ip_create(ctxt, fixed_ip)
|
fixed_ip_ref = db.fixed_ip_create(ctxt, fixed_ip)
|
||||||
db.fixed_ip_update(ctxt, self.test_ip,
|
db.fixed_ip_update(ctxt, self.test_ip,
|
||||||
{'allocated': True,
|
{'allocated': True,
|
||||||
'instance_id': instance_ref['id']})
|
'instance_id': instance_ref['id']})
|
||||||
|
|
||||||
FLAGS.libvirt_type = 'lxc'
|
FLAGS.libvirt_type = 'lxc'
|
||||||
|
conn = libvirt_conn.LibvirtConnection(True)
|
||||||
|
|
||||||
|
uri = conn.get_uri()
|
||||||
self.assertEquals(uri, 'lxc:///')
|
self.assertEquals(uri, 'lxc:///')
|
||||||
|
|
||||||
xml = conn.to_xml(instance_ref)
|
xml = conn.to_xml(instance_ref)
|
||||||
tree = xml_to_tree(xml)
|
tree = xml_to_tree(xml)
|
||||||
|
|
||||||
check = [
|
check = [
|
||||||
(lambda t: t.find('.').get('type'), 'lxc'),
|
(lambda t: t.find('.').get('type'), 'lxc'),
|
||||||
(lambda t: t.find('./os/type').text, 'exe')
|
(lambda t: t.find('./os/type').text, 'exe'),
|
||||||
]
|
]
|
||||||
|
|
||||||
for i (check, expected_result) in enumerate(check):
|
for i, (check, expected_result) in enumerate(check):
|
||||||
self.aseertEqual(check(time),
|
self.assertEqual(check(tree),
|
||||||
expected_result,
|
expected_result,
|
||||||
'%s failed common check %d' % (xml, i))
|
'%s failed common check %d' % (xml, i))
|
||||||
|
|
||||||
def _check_xml_and_uri(self, instance, expect_ramdisk, expect_kernel,
|
def _check_xml_and_uri(self, instance, expect_ramdisk, expect_kernel,
|
||||||
rescue=False):
|
rescue=False):
|
||||||
user_context = context.RequestContext(project=self.project,
|
user_context = context.RequestContext(project=self.project,
|
||||||
@@ -322,6 +326,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
check = (lambda t: t.find('./os/initrd'), None)
|
check = (lambda t: t.find('./os/initrd'), None)
|
||||||
check_list.append(check)
|
check_list.append(check)
|
||||||
|
|
||||||
|
|
||||||
common_checks = [
|
common_checks = [
|
||||||
(lambda t: t.find('.').tag, 'domain'),
|
(lambda t: t.find('.').tag, 'domain'),
|
||||||
(lambda t: t.find(
|
(lambda t: t.find(
|
||||||
@@ -338,8 +343,9 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
(lambda t: t.find('./devices/serial/source').get(
|
(lambda t: t.find('./devices/serial/source').get(
|
||||||
'path').split('/')[1], 'console.log'),
|
'path').split('/')[1], 'console.log'),
|
||||||
(lambda t: t.find('./memory').text, '2097152')]
|
(lambda t: t.find('./memory').text, '2097152')]
|
||||||
|
|
||||||
if rescue:
|
if rescue:
|
||||||
common_checks += [
|
common_checks = [
|
||||||
(lambda t: t.findall('./devices/disk/source')[0].get(
|
(lambda t: t.findall('./devices/disk/source')[0].get(
|
||||||
'file').split('/')[1], 'disk.rescue'),
|
'file').split('/')[1], 'disk.rescue'),
|
||||||
(lambda t: t.findall('./devices/disk/source')[1].get(
|
(lambda t: t.findall('./devices/disk/source')[1].get(
|
||||||
@@ -362,14 +368,15 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
xml = conn.to_xml(instance_ref, rescue)
|
xml = conn.to_xml(instance_ref, rescue)
|
||||||
tree = xml_to_tree(xml)
|
tree = xml_to_tree(xml)
|
||||||
for i, (check, expected_result) in enumerate(checks):
|
for i, (check, expected_result) in enumerate(checks):
|
||||||
self.assertEqual(check(tree),
|
self.assertEqual(check(tree),
|
||||||
expected_result,
|
expected_result,
|
||||||
'%s failed check %d' % (xml, i))
|
'%s failed check %d' % (xml, i))
|
||||||
|
|
||||||
|
|
||||||
for i, (check, expected_result) in enumerate(common_checks):
|
for i, (check, expected_result) in enumerate(common_checks):
|
||||||
self.assertEqual(check(tree),
|
self.assertEqual(check(tree),
|
||||||
expected_result,
|
expected_result,
|
||||||
'%s failed common check %d' % (xml, i))
|
'%s failed common check %d' % (xml, i))
|
||||||
|
|
||||||
# This test is supposed to make sure we don't
|
# This test is supposed to make sure we don't
|
||||||
# override a specifically set uri
|
# override a specifically set uri
|
||||||
|
|||||||
Reference in New Issue
Block a user