[PATCH 0/3] unit tests - Power arch fixes

This patch set contains fixes to several unit tests that had somewhat the same root cause - the differences between x86 and power/ppc64le in osinfo.py template configurations. Daniel Henrique Barboza (3): tests/test_osinfo.py: fixes for Power architecture Kimchi tests: Power system fixes - removing hardcoded values test/test_model: Power architecture fixes src/kimchi/osinfo.py | 9 +++++++++ tests/iso_gen.py | 3 ++- tests/test_mockmodel.py | 4 +++- tests/test_model.py | 10 ++++++---- tests/test_osinfo.py | 36 ++++++++++++++++++++++++++---------- tests/test_rest.py | 6 ++++-- tests/test_vmtemplate.py | 8 ++++++-- 7 files changed, 56 insertions(+), 20 deletions(-) -- 1.9.3

- osinfo.py now has a function that returns a specific field from a template configuration (old or modern) which considers the current running arch. - a new test was added to explictly test the case where an unknown distro/version should return the configuration of an old distro/version after the lookup. Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- src/kimchi/osinfo.py | 9 +++++++++ tests/test_osinfo.py | 36 ++++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py index 2496e03..3c31346 100644 --- a/src/kimchi/osinfo.py +++ b/src/kimchi/osinfo.py @@ -104,6 +104,15 @@ def _get_arch(): return arch +def get_template_default(template_type, field): + host_arch = _get_arch() + # Assuming 'power' = 'ppc64le' because lookup() does the same, + # claiming libvirt compatibility. + if host_arch in ('power', 'ppc64le'): + return template_specs['power'][template_type][field] + return template_specs[host_arch][template_type][field] + + def lookup(distro, version): """ Lookup all parameters needed to run a VM of a known or unknown operating diff --git a/tests/test_osinfo.py b/tests/test_osinfo.py index d5e90b4..0185f52 100644 --- a/tests/test_osinfo.py +++ b/tests/test_osinfo.py @@ -20,7 +20,8 @@ import unittest -from kimchi.osinfo import lookup, modern_version_bases, _get_arch +from kimchi.osinfo import _get_arch, get_template_default, lookup, \ + modern_version_bases class OSInfoTests(unittest.TestCase): @@ -35,20 +36,35 @@ class OSInfoTests(unittest.TestCase): 'centos': '5.1', 'rhel': '5.1', 'fedora': '15'} for distro, version in old_versions.iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'ide') - self.assertEquals(entry['nic_model'], 'e1000') + self.assertEquals(entry['disk_bus'], + get_template_default('old', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('old', 'nic_model')) def test_modern_bases(self): for distro, version in modern_version_bases[_get_arch()].iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'virtio') - self.assertEquals(entry['nic_model'], 'virtio') + self.assertEquals(entry['disk_bus'], + get_template_default('modern', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('modern', 'nic_model')) def test_modern_distros(self): - modern_versions = {'debian': '7.0', 'ubuntu': '12.04', - 'opensuse': '12.3', 'centos': '6.4', 'rhel': '6.3', - 'fedora': '18', 'gentoo': '12.1'} + # versions based on ppc64 modern distros + modern_versions = {'ubuntu': '14.04', 'opensuse': '13.1', + 'rhel': '6.5', 'fedora': '19', 'sles': '11sp3'} for distro, version in modern_versions.iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'virtio') - self.assertEquals(entry['nic_model'], 'virtio') + self.assertEquals(entry['disk_bus'], + get_template_default('modern', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('modern', 'nic_model')) + + def test_lookup_unknown_distro_version_returns_old_distro(self): + distro = 'unknown_distro' + version = 'unknown_version' + entry = lookup(distro, version) + self.assertEquals(entry['disk_bus'], + get_template_default('old', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('old', 'nic_model')) -- 1.9.3

Does this patch replace the former [Kimchi-devel] [PATCH] tests/test_osinfo.py: fixes for Power architecture ? Some comments below: On 16/03/2015 16:29, Daniel Henrique Barboza wrote:
- osinfo.py now has a function that returns a specific field from a template configuration (old or modern) which considers the current running arch.
- a new test was added to explictly test the case where an unknown distro/version should return the configuration of an old distro/version after the lookup.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- src/kimchi/osinfo.py | 9 +++++++++ tests/test_osinfo.py | 36 ++++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py index 2496e03..3c31346 100644 --- a/src/kimchi/osinfo.py +++ b/src/kimchi/osinfo.py @@ -104,6 +104,15 @@ def _get_arch(): return arch
+def get_template_default(template_type, field): + host_arch = _get_arch() + # Assuming 'power' = 'ppc64le' because lookup() does the same, + # claiming libvirt compatibility. + if host_arch in ('power', 'ppc64le'): + return template_specs['power'][template_type][field] + return template_specs[host_arch][template_type][field] + + def lookup(distro, version): """ Lookup all parameters needed to run a VM of a known or unknown operating diff --git a/tests/test_osinfo.py b/tests/test_osinfo.py index d5e90b4..0185f52 100644 --- a/tests/test_osinfo.py +++ b/tests/test_osinfo.py @@ -20,7 +20,8 @@ import unittest
-from kimchi.osinfo import lookup, modern_version_bases, _get_arch +from kimchi.osinfo import _get_arch, get_template_default, lookup, \ + modern_version_bases
We usually do not break the import line. Instedd of that we create 2 import lines from kimchi.osinfo import ... from kimchi.osinfo import ...
class OSInfoTests(unittest.TestCase): @@ -35,20 +36,35 @@ class OSInfoTests(unittest.TestCase): 'centos': '5.1', 'rhel': '5.1', 'fedora': '15'} for distro, version in old_versions.iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'ide') - self.assertEquals(entry['nic_model'], 'e1000') + self.assertEquals(entry['disk_bus'], + get_template_default('old', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('old', 'nic_model'))
def test_modern_bases(self): for distro, version in modern_version_bases[_get_arch()].iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'virtio') - self.assertEquals(entry['nic_model'], 'virtio') + self.assertEquals(entry['disk_bus'], + get_template_default('modern', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('modern', 'nic_model'))
def test_modern_distros(self): - modern_versions = {'debian': '7.0', 'ubuntu': '12.04', - 'opensuse': '12.3', 'centos': '6.4', 'rhel': '6.3', - 'fedora': '18', 'gentoo': '12.1'} + # versions based on ppc64 modern distros + modern_versions = {'ubuntu': '14.04', 'opensuse': '13.1', + 'rhel': '6.5', 'fedora': '19', 'sles': '11sp3'} for distro, version in modern_versions.iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'virtio') - self.assertEquals(entry['nic_model'], 'virtio') + self.assertEquals(entry['disk_bus'], + get_template_default('modern', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('modern', 'nic_model')) + + def test_lookup_unknown_distro_version_returns_old_distro(self): + distro = 'unknown_distro' + version = 'unknown_version' + entry = lookup(distro, version) + self.assertEquals(entry['disk_bus'], + get_template_default('old', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('old', 'nic_model'))

On 03/20/2015 10:27 AM, Aline Manera wrote:
Does this patch replace the former [Kimchi-devel] [PATCH] tests/test_osinfo.py: fixes for Power architecture ?
yes
Some comments below:
On 16/03/2015 16:29, Daniel Henrique Barboza wrote:
- osinfo.py now has a function that returns a specific field from a template configuration (old or modern) which considers the current running arch.
- a new test was added to explictly test the case where an unknown distro/version should return the configuration of an old distro/version after the lookup.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- src/kimchi/osinfo.py | 9 +++++++++ tests/test_osinfo.py | 36 ++++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py index 2496e03..3c31346 100644 --- a/src/kimchi/osinfo.py +++ b/src/kimchi/osinfo.py @@ -104,6 +104,15 @@ def _get_arch(): return arch
+def get_template_default(template_type, field): + host_arch = _get_arch() + # Assuming 'power' = 'ppc64le' because lookup() does the same, + # claiming libvirt compatibility. + if host_arch in ('power', 'ppc64le'): + return template_specs['power'][template_type][field] + return template_specs[host_arch][template_type][field] + + def lookup(distro, version): """ Lookup all parameters needed to run a VM of a known or unknown operating diff --git a/tests/test_osinfo.py b/tests/test_osinfo.py index d5e90b4..0185f52 100644 --- a/tests/test_osinfo.py +++ b/tests/test_osinfo.py @@ -20,7 +20,8 @@ import unittest
-from kimchi.osinfo import lookup, modern_version_bases, _get_arch +from kimchi.osinfo import _get_arch, get_template_default, lookup, \ + modern_version_bases
We usually do not break the import line. Instedd of that we create 2 import lines
from kimchi.osinfo import ... from kimchi.osinfo import ...
Ok! I'll create 2 imports instead of breaking the import line
class OSInfoTests(unittest.TestCase): @@ -35,20 +36,35 @@ class OSInfoTests(unittest.TestCase): 'centos': '5.1', 'rhel': '5.1', 'fedora': '15'} for distro, version in old_versions.iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'ide') - self.assertEquals(entry['nic_model'], 'e1000') + self.assertEquals(entry['disk_bus'], + get_template_default('old', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('old', 'nic_model'))
def test_modern_bases(self): for distro, version in modern_version_bases[_get_arch()].iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'virtio') - self.assertEquals(entry['nic_model'], 'virtio') + self.assertEquals(entry['disk_bus'], + get_template_default('modern', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('modern', 'nic_model'))
def test_modern_distros(self): - modern_versions = {'debian': '7.0', 'ubuntu': '12.04', - 'opensuse': '12.3', 'centos': '6.4', 'rhel': '6.3', - 'fedora': '18', 'gentoo': '12.1'} + # versions based on ppc64 modern distros + modern_versions = {'ubuntu': '14.04', 'opensuse': '13.1', + 'rhel': '6.5', 'fedora': '19', 'sles': '11sp3'} for distro, version in modern_versions.iteritems(): entry = lookup(distro, version) - self.assertEquals(entry['disk_bus'], 'virtio') - self.assertEquals(entry['nic_model'], 'virtio') + self.assertEquals(entry['disk_bus'], + get_template_default('modern', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('modern', 'nic_model')) + + def test_lookup_unknown_distro_version_returns_old_distro(self): + distro = 'unknown_distro' + version = 'unknown_version' + entry = lookup(distro, version) + self.assertEquals(entry['disk_bus'], + get_template_default('old', 'disk_bus')) + self.assertEquals(entry['nic_model'], + get_template_default('old', 'nic_model'))

This patch uses the new 'get_template_default' function to remove the hardcoded values of memory, disk_bus and nic_model from the unit tests to make them compatible with Power systems. Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- tests/test_mockmodel.py | 4 +++- tests/test_rest.py | 6 ++++-- tests/test_vmtemplate.py | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py index 542f845..68a28d3 100644 --- a/tests/test_mockmodel.py +++ b/tests/test_mockmodel.py @@ -28,6 +28,7 @@ import kimchi.mockmodel from utils import get_free_port, patch_auth, request, run_server from utils import wait_task from kimchi.control.base import Collection, Resource +from kimchi.osinfo import get_template_default test_server = None @@ -158,7 +159,8 @@ class MockModelTests(unittest.TestCase): self.assertEquals(keys, set(info.keys())) self.assertEquals('shutoff', info['state']) self.assertEquals('test-vm', info['name']) - self.assertEquals(1024, info['memory']) + self.assertEquals(get_template_default('old', 'memory'), + info['memory']) self.assertEquals(1, info['cpus']) self.assertEquals('images/icon-vm.png', info['icon']) self.assertEquals(stats_keys, set(info['stats'].keys())) diff --git a/tests/test_rest.py b/tests/test_rest.py index d5dd766..4ecf3ce 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -33,6 +33,7 @@ from functools import partial import iso_gen import kimchi.mockmodel import kimchi.server +from kimchi.osinfo import get_template_default from kimchi.rollbackcontext import RollbackContext from kimchi.utils import add_task from utils import fake_auth_header, get_free_port, patch_auth, request @@ -730,7 +731,8 @@ class RestTests(unittest.TestCase): iface['mac']).read()) self.assertEquals('default', res['network']) self.assertEquals(17, len(res['mac'])) - self.assertEquals('e1000', res['model']) + self.assertEquals(get_template_default('old', 'nic_model'), + res['model']) # attach network interface to vm req = json.dumps({"type": "network", @@ -957,7 +959,7 @@ class RestTests(unittest.TestCase): self.assertEquals('test', t['name']) self.assertEquals('unknown', t['os_distro']) self.assertEquals('unknown', t['os_version']) - self.assertEquals(1024, t['memory']) + self.assertEquals(get_template_default('old', 'memory'), t['memory']) # Deactivate or destroy scan pool return 405 resp = self.request('/storagepools/kimchi_isos/storagevolumes' diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py index 550bb2a..991cea1 100644 --- a/tests/test_vmtemplate.py +++ b/tests/test_vmtemplate.py @@ -22,6 +22,7 @@ import unittest import uuid +from kimchi.osinfo import get_template_default from kimchi.vmtemplate import VMTemplate from kimchi.xmlutils.utils import xpath_get_text @@ -35,10 +36,13 @@ class VMTemplateTests(unittest.TestCase): os.unlink(self.iso) def test_minimal_construct(self): + disk_bus = get_template_default('old', 'disk_bus') + memory = get_template_default('old', 'memory') + nic_model = get_template_default('old', 'nic_model') fields = (('name', 'test'), ('os_distro', 'unknown'), ('os_version', 'unknown'), ('cpus', 1), - ('memory', 1024), ('networks', ['default']), - ('disk_bus', 'ide'), ('nic_model', 'e1000'), + ('memory', memory), ('networks', ['default']), + ('disk_bus', disk_bus), ('nic_model', nic_model), ('graphics', {'type': 'vnc', 'listen': '127.0.0.1'}), ('cdrom', self.iso)) -- 1.9.3

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 16/03/2015 16:29, Daniel Henrique Barboza wrote:
This patch uses the new 'get_template_default' function to remove the hardcoded values of memory, disk_bus and nic_model from the unit tests to make them compatible with Power systems.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- tests/test_mockmodel.py | 4 +++- tests/test_rest.py | 6 ++++-- tests/test_vmtemplate.py | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py index 542f845..68a28d3 100644 --- a/tests/test_mockmodel.py +++ b/tests/test_mockmodel.py @@ -28,6 +28,7 @@ import kimchi.mockmodel from utils import get_free_port, patch_auth, request, run_server from utils import wait_task from kimchi.control.base import Collection, Resource +from kimchi.osinfo import get_template_default
test_server = None @@ -158,7 +159,8 @@ class MockModelTests(unittest.TestCase): self.assertEquals(keys, set(info.keys())) self.assertEquals('shutoff', info['state']) self.assertEquals('test-vm', info['name']) - self.assertEquals(1024, info['memory']) + self.assertEquals(get_template_default('old', 'memory'), + info['memory']) self.assertEquals(1, info['cpus']) self.assertEquals('images/icon-vm.png', info['icon']) self.assertEquals(stats_keys, set(info['stats'].keys())) diff --git a/tests/test_rest.py b/tests/test_rest.py index d5dd766..4ecf3ce 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -33,6 +33,7 @@ from functools import partial import iso_gen import kimchi.mockmodel import kimchi.server +from kimchi.osinfo import get_template_default from kimchi.rollbackcontext import RollbackContext from kimchi.utils import add_task from utils import fake_auth_header, get_free_port, patch_auth, request @@ -730,7 +731,8 @@ class RestTests(unittest.TestCase): iface['mac']).read()) self.assertEquals('default', res['network']) self.assertEquals(17, len(res['mac'])) - self.assertEquals('e1000', res['model']) + self.assertEquals(get_template_default('old', 'nic_model'), + res['model'])
# attach network interface to vm req = json.dumps({"type": "network", @@ -957,7 +959,7 @@ class RestTests(unittest.TestCase): self.assertEquals('test', t['name']) self.assertEquals('unknown', t['os_distro']) self.assertEquals('unknown', t['os_version']) - self.assertEquals(1024, t['memory']) + self.assertEquals(get_template_default('old', 'memory'), t['memory'])
# Deactivate or destroy scan pool return 405 resp = self.request('/storagepools/kimchi_isos/storagevolumes' diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py index 550bb2a..991cea1 100644 --- a/tests/test_vmtemplate.py +++ b/tests/test_vmtemplate.py @@ -22,6 +22,7 @@ import unittest import uuid
+from kimchi.osinfo import get_template_default from kimchi.vmtemplate import VMTemplate from kimchi.xmlutils.utils import xpath_get_text
@@ -35,10 +36,13 @@ class VMTemplateTests(unittest.TestCase): os.unlink(self.iso)
def test_minimal_construct(self): + disk_bus = get_template_default('old', 'disk_bus') + memory = get_template_default('old', 'memory') + nic_model = get_template_default('old', 'nic_model') fields = (('name', 'test'), ('os_distro', 'unknown'), ('os_version', 'unknown'), ('cpus', 1), - ('memory', 1024), ('networks', ['default']), - ('disk_bus', 'ide'), ('nic_model', 'e1000'), + ('memory', memory), ('networks', ['default']), + ('disk_bus', disk_bus), ('nic_model', nic_model), ('graphics', {'type': 'vnc', 'listen': '127.0.0.1'}), ('cdrom', self.iso))

- test_vm_disk now uses osinfo 'get_template_default' to get the default value for 'disk_bus'. - kimchi_iso now generates a Ubuntu 14.04 fake iso to allow modern Power template in the tests (Ubuntu 12.04 is not considered a modern distro for Power). - iso_gen.py was updated to allow the creation of Ubuntu 14.04 fake isos. Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- tests/iso_gen.py | 3 ++- tests/test_model.py | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/iso_gen.py b/tests/iso_gen.py index 5a0262f..096161d 100644 --- a/tests/iso_gen.py +++ b/tests/iso_gen.py @@ -48,7 +48,8 @@ iso_des = [ ('debian', lambda v: True, lambda v: 'Debian %s' % v), ('ubuntu', lambda v: v in ('7.10', '8.04', '8.10', '9.04', '9.10', '10.04', '10.10', - '11.04', '11.10', '12.04', '12.10', '13.04', '13.10'), + '11.04', '11.10', '12.04', '12.10', '13.04', '13.10', + '14.04'), lambda v: 'Ubuntu %s' % v), ('fedora', lambda v: v in ('16', '17', '18', '19'), diff --git a/tests/test_model.py b/tests/test_model.py index decc5f1..76deb12 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -40,6 +40,7 @@ from kimchi import netinfo from kimchi.config import config from kimchi.exception import InvalidOperation from kimchi.exception import InvalidParameter, NotFoundError, OperationFailed +from kimchi.osinfo import get_template_default from kimchi.model import model from kimchi.model.libvirtconnection import LibvirtConnection from kimchi.rollbackcontext import RollbackContext @@ -59,7 +60,7 @@ class ModelTests(unittest.TestCase): if not os.path.exists(self.iso_path): os.makedirs(self.iso_path) self.kimchi_iso = self.iso_path + 'ubuntu12.04.iso' - iso_gen.construct_fake_iso(self.kimchi_iso, True, '12.04', 'ubuntu') + iso_gen.construct_fake_iso(self.kimchi_iso, True, '14.04', 'ubuntu') def tearDown(self): # FIXME: Tests using 'test:///default' URI should be moved to @@ -337,8 +338,9 @@ class ModelTests(unittest.TestCase): def test_vm_disk(self): disk_path = '/tmp/existent2.iso' open(disk_path, 'w').close() + modern_disk_bus = get_template_default('modern', 'disk_bus') - def _attach_disk(expect_bus='virtio'): + def _attach_disk(expect_bus=modern_disk_bus): disk_args = {"type": "disk", "pool": pool, "vol": vol} @@ -432,8 +434,8 @@ class ModelTests(unittest.TestCase): inst.vms_create(params) rollback.prependDefer(inst.vm_delete, vm_name) - # Attach will choose IDE bus for old distro - disk = _attach_disk('ide') + # Need to check the right disk_bus for old distro + disk = _attach_disk(get_template_default('old', 'disk_bus')) inst.vmstorage_delete('kimchi-ide-bus-vm', disk) # Hot plug IDE bus disk does not work -- 1.9.3

On 16/03/2015 16:29, Daniel Henrique Barboza wrote:
- test_vm_disk now uses osinfo 'get_template_default' to get the default value for 'disk_bus'.
- kimchi_iso now generates a Ubuntu 14.04 fake iso to allow modern Power template in the tests (Ubuntu 12.04 is not considered a modern distro for Power).
- iso_gen.py was updated to allow the creation of Ubuntu 14.04 fake isos.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- tests/iso_gen.py | 3 ++- tests/test_model.py | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tests/iso_gen.py b/tests/iso_gen.py index 5a0262f..096161d 100644 --- a/tests/iso_gen.py +++ b/tests/iso_gen.py @@ -48,7 +48,8 @@ iso_des = [ ('debian', lambda v: True, lambda v: 'Debian %s' % v), ('ubuntu', lambda v: v in ('7.10', '8.04', '8.10', '9.04', '9.10', '10.04', '10.10', - '11.04', '11.10', '12.04', '12.10', '13.04', '13.10'), + '11.04', '11.10', '12.04', '12.10', '13.04', '13.10', + '14.04'), lambda v: 'Ubuntu %s' % v), ('fedora', lambda v: v in ('16', '17', '18', '19'), diff --git a/tests/test_model.py b/tests/test_model.py index decc5f1..76deb12 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -40,6 +40,7 @@ from kimchi import netinfo from kimchi.config import config from kimchi.exception import InvalidOperation from kimchi.exception import InvalidParameter, NotFoundError, OperationFailed +from kimchi.osinfo import get_template_default from kimchi.model import model from kimchi.model.libvirtconnection import LibvirtConnection from kimchi.rollbackcontext import RollbackContext @@ -59,7 +60,7 @@ class ModelTests(unittest.TestCase): if not os.path.exists(self.iso_path): os.makedirs(self.iso_path) self.kimchi_iso = self.iso_path + 'ubuntu12.04.iso' - iso_gen.construct_fake_iso(self.kimchi_iso, True, '12.04', 'ubuntu') + iso_gen.construct_fake_iso(self.kimchi_iso, True, '14.04', 'ubuntu')
Just update the kimchi_iso value as it is still pointing to 12.04
def tearDown(self): # FIXME: Tests using 'test:///default' URI should be moved to @@ -337,8 +338,9 @@ class ModelTests(unittest.TestCase): def test_vm_disk(self): disk_path = '/tmp/existent2.iso' open(disk_path, 'w').close() + modern_disk_bus = get_template_default('modern', 'disk_bus')
- def _attach_disk(expect_bus='virtio'): + def _attach_disk(expect_bus=modern_disk_bus): disk_args = {"type": "disk", "pool": pool, "vol": vol} @@ -432,8 +434,8 @@ class ModelTests(unittest.TestCase): inst.vms_create(params) rollback.prependDefer(inst.vm_delete, vm_name)
- # Attach will choose IDE bus for old distro - disk = _attach_disk('ide') + # Need to check the right disk_bus for old distro + disk = _attach_disk(get_template_default('old', 'disk_bus')) inst.vmstorage_delete('kimchi-ide-bus-vm', disk)
# Hot plug IDE bus disk does not work

On 03/20/2015 10:29 AM, Aline Manera wrote:
On 16/03/2015 16:29, Daniel Henrique Barboza wrote:
- test_vm_disk now uses osinfo 'get_template_default' to get the default value for 'disk_bus'.
- kimchi_iso now generates a Ubuntu 14.04 fake iso to allow modern Power template in the tests (Ubuntu 12.04 is not considered a modern distro for Power).
- iso_gen.py was updated to allow the creation of Ubuntu 14.04 fake isos.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82@gmail.com> --- tests/iso_gen.py | 3 ++- tests/test_model.py | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/tests/iso_gen.py b/tests/iso_gen.py index 5a0262f..096161d 100644 --- a/tests/iso_gen.py +++ b/tests/iso_gen.py @@ -48,7 +48,8 @@ iso_des = [ ('debian', lambda v: True, lambda v: 'Debian %s' % v), ('ubuntu', lambda v: v in ('7.10', '8.04', '8.10', '9.04', '9.10', '10.04', '10.10', - '11.04', '11.10', '12.04', '12.10', '13.04', '13.10'), + '11.04', '11.10', '12.04', '12.10', '13.04', '13.10', + '14.04'), lambda v: 'Ubuntu %s' % v), ('fedora', lambda v: v in ('16', '17', '18', '19'), diff --git a/tests/test_model.py b/tests/test_model.py index decc5f1..76deb12 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -40,6 +40,7 @@ from kimchi import netinfo from kimchi.config import config from kimchi.exception import InvalidOperation from kimchi.exception import InvalidParameter, NotFoundError, OperationFailed +from kimchi.osinfo import get_template_default from kimchi.model import model from kimchi.model.libvirtconnection import LibvirtConnection from kimchi.rollbackcontext import RollbackContext @@ -59,7 +60,7 @@ class ModelTests(unittest.TestCase): if not os.path.exists(self.iso_path): os.makedirs(self.iso_path) self.kimchi_iso = self.iso_path + 'ubuntu12.04.iso' - iso_gen.construct_fake_iso(self.kimchi_iso, True, '12.04', 'ubuntu') + iso_gen.construct_fake_iso(self.kimchi_iso, True, '14.04', 'ubuntu')
Just update the kimchi_iso value as it is still pointing to 12.04
ok!
def tearDown(self): # FIXME: Tests using 'test:///default' URI should be moved to @@ -337,8 +338,9 @@ class ModelTests(unittest.TestCase): def test_vm_disk(self): disk_path = '/tmp/existent2.iso' open(disk_path, 'w').close() + modern_disk_bus = get_template_default('modern', 'disk_bus')
- def _attach_disk(expect_bus='virtio'): + def _attach_disk(expect_bus=modern_disk_bus): disk_args = {"type": "disk", "pool": pool, "vol": vol} @@ -432,8 +434,8 @@ class ModelTests(unittest.TestCase): inst.vms_create(params) rollback.prependDefer(inst.vm_delete, vm_name)
- # Attach will choose IDE bus for old distro - disk = _attach_disk('ide') + # Need to check the right disk_bus for old distro + disk = _attach_disk(get_template_default('old', 'disk_bus')) inst.vmstorage_delete('kimchi-ide-bus-vm', disk)
# Hot plug IDE bus disk does not work
participants (2)
-
Aline Manera
-
Daniel Henrique Barboza