[Kimchi-devel] [kimchi-devel][PATCH 2/2] Ignore cpu test case when exceed host cpu count

Aline Manera alinefm at linux.vnet.ibm.com
Wed Mar 11 14:36:39 UTC 2015



On 11/03/2015 11:26, Aline Manera wrote:
>
> I can not apply it. Please, rebase and resend.
> I will apply only the first patch.
>

Ops... seems I can't apply only the first one.

======================================================================
ERROR: test_vm_edit (test_model.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "test_model.py", line 568, in test_vm_edit
     inst.templates_create(orig_params)
   File "/home/alinefm/kimchi/src/kimchi/model/templates.py", line 68, 
in create
     CPUInfoModel(conn=self.conn).check_vcpus(params['cpus'])
   File "/home/alinefm/kimchi/src/kimchi/model/cpuinfo.py", line 128, in 
check_vcpus
     raise InvalidParameter("KCHCPUINF0001E")
InvalidParameter: KCHCPUINF0001E: The number of vCPUs is too large for 
this system.

----------------------------------------------------------------------


> On 09/03/2015 10:52, lvroyce at linux.vnet.ibm.com wrote:
>> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>>
>> If vpu given exceed host cpu count, ignore corresponding test.
>> Because test model does not support host cpu topology query,
>> using real model instead of test model in cpu related tests.
>>
>> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
>> ---
>>   tests/test_model.py | 54 
>> +++++++++++++++++++++++++++++++++++------------------
>>   tests/utils.py      |  5 +++++
>>   2 files changed, 41 insertions(+), 18 deletions(-)
>>
>> diff --git a/tests/test_model.py b/tests/test_model.py
>> index f80f1c9..c3f5595 100644
>> --- a/tests/test_model.py
>> +++ b/tests/test_model.py
>> @@ -622,7 +622,7 @@ class ModelTests(unittest.TestCase):
>>         @unittest.skipUnless(utils.running_as_root(), 'Must be run as 
>> root')
>>       def test_template_create(self):
>> -        inst = model.Model('test:///default',
>> +        inst = model.Model('qemu:///system',
>>                              objstore_loc=self.tmp_store)
>>           # Test non-exist path raises InvalidParameter
>>           params = {'name': 'test',
>> @@ -664,7 +664,7 @@ class ModelTests(unittest.TestCase):
>>         @unittest.skipUnless(utils.running_as_root(), 'Must be run as 
>> root')
>>       def test_template_integrity(self):
>> -        inst = model.Model('test:///default',
>> +        inst = model.Model('qemu:///system',
>>                              objstore_loc=self.tmp_store)
>>             with RollbackContext() as rollback:
>> @@ -723,6 +723,37 @@ class ModelTests(unittest.TestCase):
>>               for key in clone_temp.keys():
>>                   self.assertEquals(clone_temp[key], orig_temp[key])
>>   +    @unittest.skipUnless(utils.allow_vcpu_change(2), 'Host does 
>> not have enough CPUs')
>> +    @unittest.skipUnless(utils.running_as_root(), 'Must be run as 
>> root')
>> +    def test_template_update_vcpu(self):
>> +        params = {'name': 'new-test', 'memory': 512, 'cpus': 2}
>> +        inst.template_update('new-test', params)
>> +        rollback.prependDefer(inst.template_delete, 'new-test')
>> +
>> +        info = inst.template_lookup('new-test')
>> +        for key in params.keys():
>> +            self.assertEquals(params[key], info[key])
>> +
>> +        params = {'name': 'new-test', 'memory': 1024, 'cpus': 1,
>> +                  'networks': ['default', 'test-network', 
>> u'kīмсhī-пet']}
>> +        inst.template_update('new-test', params)
>> +        info = inst.template_lookup('new-test')
>> +        for key in params.keys():
>> +            self.assertEquals(params[key], info[key])
>> +
>> +        # test cpu_info
>> +        # new-test has 1 cpu, so this should fail:
>> +        params['cpu_info'] = {"topology":
>> +                              {"sockets": 1, "cores": 1, "threads": 2}}
>> +        self.assertRaises(InvalidParameter, inst.template_update,
>> +                          'new-test', params)
>> +
>> +        params['cpus'] = 2
>> +        inst.template_update('new-test', params)
>> +        info = inst.template_lookup('new-test')
>> +        for key in params.keys():
>> +            self.assertEquals(params[key], info[key])
>> +
>>       @unittest.skipUnless(utils.running_as_root(), 'Must be run as 
>> root')
>>       def test_template_update(self):
>>           inst = model.Model(None,
>> @@ -754,7 +785,7 @@ class ModelTests(unittest.TestCase):
>>               self.assertEquals('new-test', 
>> inst.template_update('test', params))
>>               self.assertRaises(NotFoundError, inst.template_delete, 
>> 'test')
>>   -            params = {'name': 'new-test', 'memory': 512, 'cpus': 2}
>> +            params = {'name': 'new-test', 'memory': 512}
>>               inst.template_update('new-test', params)
>>               rollback.prependDefer(inst.template_delete, 'new-test')
>>   @@ -770,19 +801,6 @@ class ModelTests(unittest.TestCase):
>>               for key in params.keys():
>>                   self.assertEquals(params[key], info[key])
>>   -            # test cpu_info
>> -            # new-test has 1 cpu, so this should fail:
>> -            params['cpu_info'] = {"topology":
>> -                                  {"sockets": 1, "cores": 1, 
>> "threads": 2}}
>> -            self.assertRaises(InvalidParameter, inst.template_update,
>> -                              'new-test', params)
>> -
>> -            params['cpus'] = 2
>> -            inst.template_update('new-test', params)
>> -            info = inst.template_lookup('new-test')
>> -            for key in params.keys():
>> -                self.assertEquals(params[key], info[key])
>> -
>>               # test update with non-existent network
>>               params = {'networks': ["no-exist"]}
>>               self.assertRaises(InvalidParameter, inst.template_update,
>> @@ -798,10 +816,10 @@ class ModelTests(unittest.TestCase):
>>         def test_vm_edit(self):
>>           config.set("authentication", "method", "pam")
>> -        inst = model.Model(None,
>> +        inst = model.Model("qemu:///system",
>>                              objstore_loc=self.tmp_store)
>>   -        orig_params = {'name': 'test', 'memory': '1024', 'cpus': '1',
>> +        orig_params = {'name': 'test', 'memory': '1024', 'cpus': 1,
>>                          'cdrom': self.kimchi_iso}
>>           inst.templates_create(orig_params)
>>   diff --git a/tests/utils.py b/tests/utils.py
>> index 2a8929f..7650433 100644
>> --- a/tests/utils.py
>> +++ b/tests/utils.py
>> @@ -23,6 +23,7 @@ import cherrypy
>>   import grp
>>   import httplib
>>   import json
>> +import multiprocessing
>>   import os
>>   import socket
>>   import sys
>> @@ -135,6 +136,10 @@ def running_as_root():
>>       return os.geteuid() == 0
>>     +def allow_vcpu_change(vcpu_cnt):
>> +    return multiprocessing.cpu_count() >= vcpu_cnt
>> +
>> +
>>   def _request(conn, path, data, method, headers):
>>       if headers is None:
>>           headers = {'Content-Type': 'application/json',
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel




More information about the Kimchi-devel mailing list