[PATCHv2 0/2] Make vms model singleton

From: Royce Lv <lvroyce@linux.vnet.ibm.com> Everytime when when VMsModel.get_list() need to be called one more background task to collect vm status is started. Fix this by making vms model singleton. Royce Lv (2): Make vms model to be a singleton Hack test_model to support vm model singleton src/kimchi/model/vms.py | 3 +++ tests/test_model.py | 2 ++ 2 files changed, 5 insertions(+) -- 1.8.1.2

From: Royce Lv <lvroyce@linux.vnet.ibm.com> In vms model __init__ function, a backgroud task is started: self.guests_stats_thread = BackgroundTask(GUESTS_STATS_INTERVAL, self._update_guests_stats) self.guests_stats_thread.start() when VMsModel.get_list() need to be called ([PATCH]Add volume ref_cnt: Add model and mockmodel implementation) one more background task is started. This is not able to be fixed by staticmethod because connection will not be passed by controller. So make vms model a singleton. Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com> --- src/kimchi/model/vms.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 3f3a152..0d029eb 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -27,6 +27,7 @@ from cherrypy.process.plugins import BackgroundTask from kimchi import vnc from kimchi import xmlutils +from kimchi.basemodel import Singleton from kimchi.config import READONLY_POOL_TYPE from kimchi.exception import InvalidOperation, InvalidParameter from kimchi.exception import MissingParameter, NotFoundError, OperationFailed @@ -53,6 +54,8 @@ stats = {} class VMsModel(object): + __metaclass__ = Singleton + def __init__(self, **kargs): self.conn = kargs['conn'] self.objstore = kargs['objstore'] -- 1.8.1.2

Reviewed-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> So you will add a new patch and instantiate the VMsModel right? Sure you can use Model instance. I'm not sure VMsModel instance or Model instance which is better. But IMO, it seems good to Make vms model to be a singleton. But there is not a lock for our Singleton. not sure there is a race. On 03/05/2014 04:14 PM, lvroyce@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@linux.vnet.ibm.com>
In vms model __init__ function, a backgroud task is started:
self.guests_stats_thread = BackgroundTask(GUESTS_STATS_INTERVAL, self._update_guests_stats) self.guests_stats_thread.start()
when VMsModel.get_list() need to be called ([PATCH]Add volume ref_cnt: Add model and mockmodel implementation) one more background task is started.
This is not able to be fixed by staticmethod because connection will not be passed by controller. So make vms model a singleton.
Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com> --- src/kimchi/model/vms.py | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 3f3a152..0d029eb 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -27,6 +27,7 @@ from cherrypy.process.plugins import BackgroundTask
from kimchi import vnc from kimchi import xmlutils +from kimchi.basemodel import Singleton from kimchi.config import READONLY_POOL_TYPE from kimchi.exception import InvalidOperation, InvalidParameter from kimchi.exception import MissingParameter, NotFoundError, OperationFailed @@ -53,6 +54,8 @@ stats = {}
class VMsModel(object): + __metaclass__ = Singleton + def __init__(self, **kargs): self.conn = kargs['conn'] self.objstore = kargs['objstore']
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

Reviewed-by: Shu Ming <shuming@linux.vnet.ibm.com> 2014/3/5 16:14, lvroyce@linux.vnet.ibm.com:
From: Royce Lv <lvroyce@linux.vnet.ibm.com>
In vms model __init__ function, a backgroud task is started:
self.guests_stats_thread = BackgroundTask(GUESTS_STATS_INTERVAL, self._update_guests_stats) self.guests_stats_thread.start()
when VMsModel.get_list() need to be called ([PATCH]Add volume ref_cnt: Add model and mockmodel implementation) one more background task is started.
This is not able to be fixed by staticmethod because connection will not be passed by controller. So make vms model a singleton.
Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com> --- src/kimchi/model/vms.py | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 3f3a152..0d029eb 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -27,6 +27,7 @@ from cherrypy.process.plugins import BackgroundTask
from kimchi import vnc from kimchi import xmlutils +from kimchi.basemodel import Singleton from kimchi.config import READONLY_POOL_TYPE from kimchi.exception import InvalidOperation, InvalidParameter from kimchi.exception import MissingParameter, NotFoundError, OperationFailed @@ -53,6 +54,8 @@ stats = {}
class VMsModel(object): + __metaclass__ = Singleton + def __init__(self, **kargs): self.conn = kargs['conn'] self.objstore = kargs['objstore']

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 03/05/2014 05:14 AM, lvroyce@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@linux.vnet.ibm.com>
In vms model __init__ function, a backgroud task is started:
self.guests_stats_thread = BackgroundTask(GUESTS_STATS_INTERVAL, self._update_guests_stats) self.guests_stats_thread.start()
when VMsModel.get_list() need to be called ([PATCH]Add volume ref_cnt: Add model and mockmodel implementation) one more background task is started.
This is not able to be fixed by staticmethod because connection will not be passed by controller. So make vms model a singleton.
Signed-off-by: Royce Lv <lvroyce@linux.vnet.ibm.com> --- src/kimchi/model/vms.py | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index 3f3a152..0d029eb 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -27,6 +27,7 @@ from cherrypy.process.plugins import BackgroundTask
from kimchi import vnc from kimchi import xmlutils +from kimchi.basemodel import Singleton from kimchi.config import READONLY_POOL_TYPE from kimchi.exception import InvalidOperation, InvalidParameter from kimchi.exception import MissingParameter, NotFoundError, OperationFailed @@ -53,6 +54,8 @@ stats = {}
class VMsModel(object): + __metaclass__ = Singleton + def __init__(self, **kargs): self.conn = kargs['conn'] self.objstore = kargs['objstore']

From: Royce Lv <lvroyce@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@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): -- 1.8.1.2

Reviewed-by: Shu Ming <shuming@linux.vnet.ibm.com> 2014/3/5 16:14, lvroyce@linux.vnet.ibm.com:
From: Royce Lv <lvroyce@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@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):

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. *** 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@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@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@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):

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.
*** 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@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@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@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):

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
*** 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@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@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@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):

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@linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce@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@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):
participants (5)
-
Aline Manera
-
lvroyce@linux.vnet.ibm.com
-
Royce Lv
-
Sheldon
-
Shu Ming