On 2014年03月08日 04:48, Aline Manera wrote:
On 03/06/2014 05:32 AM, Royce Lv wrote:
> On 2014年03月06日 02:21, Aline Manera wrote:
>>
>> This change was causing a lot of duplicate work to run the tests.
>>
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> ...Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
>> .Loading AptUpdate features.
> I saw this in my test. After each testcase singleton dict is cleared
> and software update is reload:
>
> class SoftwareUpdate(object):
> __metaclass__ = Singleton
>
> In fact every time a test finished, its variables and tmp info need
> to be cleared. If singleton is not cleared, all testcases use same
> SoftwareUpdate instance.
> So I suppose reload is a right behaviour, what do you think?
>
> The belowing is not related I assume.
All this output only appears with this patch set applied.
What do you think about:
@staticmethod
def get_vms(conn):
<do the work>
def get_list(self):
return self.get_vms(self.conn)
And in your ref_count patch:
VMsModel.get_vms(conn)
So instead of use Singleton for VMsModel() we use static_method
It will avoid thos problems while running the tests
ACK.
>
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:30] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:31] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> *** Running feature tests ***
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /images/icon-fedora.png
>> HTTP/1.1" 206 4449 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "HEAD /images/icon-fedora.png
>> HTTP/1.1" 200 4449 "" ""
>> *** Feature tests completed ***
>> [05/Mar/2014:15:17:32] ENGINE Bus STARTED
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "POST
>> /plugins/sample/rectangles HTTP/1.1" 400 734 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "POST
>> /plugins/sample/rectangles HTTP/1.1" 400 753 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "POST
>> /plugins/sample/rectangles HTTP/1.1" 400 755 "" ""
>> .127.0.0.1 - - [05/Mar/2014:15:17:32] "POST
>> /plugins/sample/rectangles HTTP/1.1" 201 48 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET
>> /plugins/sample/rectangles/small HTTP/1.1" 200 48 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "POST
>> /plugins/sample/rectangles HTTP/1.1" 201 47 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET
>> /plugins/sample/rectangles/big HTTP/1.1" 200 47 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /plugins/sample/rectangles
>> HTTP/1.1" 200 121 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "PUT
>> /plugins/sample/rectangles/big HTTP/1.1" 200 47 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET
>> /plugins/sample/rectangles/big HTTP/1.1" 200 47 "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "DELETE
>> /plugins/sample/rectangles/big HTTP/1.1" 204 - "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "DELETE
>> /plugins/sample/rectangles/small HTTP/1.1" 204 - "" ""
>> 127.0.0.1 - - [05/Mar/2014:15:17:32] "GET /plugins/sample/rectangles
>> HTTP/1.1" 200 2 "" ""
>> .[05/Mar/2014:15:17:32] ENGINE Bus STOPPING
>> [05/Mar/2014:15:17:32] ENGINE HTTP Server
>> cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 58348)) shut down
>> [05/Mar/2014:15:17:32] ENGINE HTTP Server
>> cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 52200)) shut down
>> [05/Mar/2014:15:17:32] ENGINE Stopped thread '_TimeoutMonitor'.
>> [05/Mar/2014:15:17:32] ENGINE Stopped thread 'Session cleanup'.
>> [05/Mar/2014:15:17:32] ENGINE Bus STOPPED
>> [05/Mar/2014:15:17:32] ENGINE Bus EXITING
>> [05/Mar/2014:15:17:32] ENGINE Bus EXITED
>>
>>
>> Isn't there other solution?
>>
>>
>> On 03/05/2014 05:14 AM, lvroyce(a)linux.vnet.ibm.com wrote:
>>> From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
>>>
>>> Because test_model have singleton import for its whole life cycle,
>>> the dict of singleton class not cleared even though instance deleted.
>>> Hack it so that model instance can be generated again.
>>>
>>> Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
>>> ---
>>> tests/test_model.py | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/tests/test_model.py b/tests/test_model.py
>>> index 9df4994..cb24b0e 100644
>>> --- a/tests/test_model.py
>>> +++ b/tests/test_model.py
>>> @@ -33,6 +33,7 @@ import iso_gen
>>> import kimchi.objectstore
>>> import utils
>>> from kimchi import netinfo
>>> +from kimchi.basemodel import Singleton
>>> from kimchi.exception import InvalidOperation, InvalidParameter
>>> from kimchi.exception import NotFoundError, OperationFailed
>>> from kimchi.iscsi import TargetClient
>>> @@ -46,6 +47,7 @@ class ModelTests(unittest.TestCase):
>>> self.tmp_store = '/tmp/kimchi-store-test'
>>>
>>> def tearDown(self):
>>> + Singleton._instances = {}
>>> os.unlink(self.tmp_store)
>>>
>>> def test_vm_info(self):
>>
>