[PATCH] [Kimchi] Issue #982 - Fix broken testcases.

From: Paulo Vital <pvital@linux.vnet.ibm.com> Several testcases started to fail in Fedora 24 after commit 24cc635 added a solution to create a temporary file to represent the Virt Viewer script contents in mockmodel.py. The solution is not able to create the directory in where this temporary file will be created and is failing. This patch adds a control to make sure the directory exists. Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- mockmodel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mockmodel.py b/mockmodel.py index 2f55af7..cd06ee3 100644 --- a/mockmodel.py +++ b/mockmodel.py @@ -141,8 +141,12 @@ class MockModel(Model): cherrypy.engine.subscribe('exit', self.virtviewertmpfile_cleanup) def _create_virt_viewer_tmp_file(self): + path = '../data/virtviewerfiles/' + if not os.path.isdir(path): + os.makedirs(path) + self.virtviewerfile_tmp = tempfile.NamedTemporaryFile( - dir='../data/virtviewerfiles/', + dir=path, delete=False ) file_content = "[virt-viewer]\ntype=vnc\nhost=127.0.0.1\nport=5999\n" -- 2.7.4

Reviewed-By: Ramon Medeiros <ramonn@br.ibm.com> On 08/17/2016 03:18 PM, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
Several testcases started to fail in Fedora 24 after commit 24cc635 added a solution to create a temporary file to represent the Virt Viewer script contents in mockmodel.py. The solution is not able to create the directory in where this temporary file will be created and is failing.
This patch adds a control to make sure the directory exists.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- mockmodel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mockmodel.py b/mockmodel.py index 2f55af7..cd06ee3 100644 --- a/mockmodel.py +++ b/mockmodel.py @@ -141,8 +141,12 @@ class MockModel(Model): cherrypy.engine.subscribe('exit', self.virtviewertmpfile_cleanup)
def _create_virt_viewer_tmp_file(self): + path = '../data/virtviewerfiles/' + if not os.path.isdir(path): + os.makedirs(path) + self.virtviewerfile_tmp = tempfile.NamedTemporaryFile( - dir='../data/virtviewerfiles/', + dir=path, delete=False ) file_content = "[virt-viewer]\ntype=vnc\nhost=127.0.0.1\nport=5999\n"
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

Applied to master. Thanks! On 08/17/2016 03:18 PM, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
Several testcases started to fail in Fedora 24 after commit 24cc635 added a solution to create a temporary file to represent the Virt Viewer script contents in mockmodel.py. The solution is not able to create the directory in where this temporary file will be created and is failing.
This patch adds a control to make sure the directory exists.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- mockmodel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mockmodel.py b/mockmodel.py index 2f55af7..cd06ee3 100644 --- a/mockmodel.py +++ b/mockmodel.py @@ -141,8 +141,12 @@ class MockModel(Model): cherrypy.engine.subscribe('exit', self.virtviewertmpfile_cleanup)
def _create_virt_viewer_tmp_file(self): + path = '../data/virtviewerfiles/' + if not os.path.isdir(path): + os.makedirs(path) + self.virtviewerfile_tmp = tempfile.NamedTemporaryFile( - dir='../data/virtviewerfiles/', + dir=path, delete=False ) file_content = "[virt-viewer]\ntype=vnc\nhost=127.0.0.1\nport=5999\n"

On 08/17/2016 03:18 PM, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
Several testcases started to fail in Fedora 24 after commit 24cc635 added a solution to create a temporary file to represent the Virt Viewer script contents in mockmodel.py. The solution is not able to create the directory in where this temporary file will be created and is failing.
This patch adds a control to make sure the directory exists.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- mockmodel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mockmodel.py b/mockmodel.py index 2f55af7..cd06ee3 100644 --- a/mockmodel.py +++ b/mockmodel.py @@ -141,8 +141,12 @@ class MockModel(Model): cherrypy.engine.subscribe('exit', self.virtviewertmpfile_cleanup)
def _create_virt_viewer_tmp_file(self):
+ path = '../data/virtviewerfiles/' + if not os.path.isdir(path): + os.makedirs(path) +
This path is not the correct one. Once the Kimchi package is installed it will be wrong. Also if I start the wokd process from another directory the directory will be related to it and not related to Kimchi structure. We need to fix that ASAP.
self.virtviewerfile_tmp = tempfile.NamedTemporaryFile( - dir='../data/virtviewerfiles/', + dir=path, delete=False ) file_content = "[virt-viewer]\ntype=vnc\nhost=127.0.0.1\nport=5999\n"
participants (4)
-
Aline Manera
-
Daniel Henrique Barboza
-
pvital@linux.vnet.ibm.com
-
Ramon Medeiros