Re: [PATCH stable-2.16] Hide errors for expected inotify failures in unittest

2016-08-12 Thread 'Iustin Pop' via ganeti-devel
On 12 August 2016 at 15:38, Brian Foley  wrote:

> On Fri, Aug 12, 2016 at 03:13:53PM +0200, Iustin Pop wrote:
> >On 12 August 2016 at 15:04, 'Brian Foley' via ganeti-devel
> ><[1]ganeti-devel@googlegroups.com> wrote:
> >
> >  This makes it a little easier to eyeball the output of make
> >  py-tests.
> >
> >Ooh, nice, this is a very old bug, thanks!
> >
> >  +logger = logging.getLogger('pyinotify')
> >  +logger.propagate = False
> >   self.assertRaises(errors.InotifyError, handler.enable)
> >   self.assertRaises(errors.InotifyError, handler.enable)
> >   handler.disable()
> >   self.assertRaises(errors.InotifyError, handler.enable)
> >  +logger.propagate = True
> >
> >Do you want to put a try/finally around the asserts that ensure
> >propagate is restored?
> >iustin
>
> Good point. There are paths in pyinotify's add_watch that can throw
> exceptions
> (although I don't think we use them). Submitted with your change.
>

Excellent, LGTM :)

iustin


Re: [PATCH stable-2.16] Hide errors for expected inotify failures in unittest

2016-08-12 Thread 'Brian Foley' via ganeti-devel
On Fri, Aug 12, 2016 at 03:13:53PM +0200, Iustin Pop wrote:
>On 12 August 2016 at 15:04, 'Brian Foley' via ganeti-devel
><[1]ganeti-devel@googlegroups.com> wrote:
> 
>  This makes it a little easier to eyeball the output of make
>  py-tests.
> 
>Ooh, nice, this is a very old bug, thanks!
> 
>  +logger = logging.getLogger('pyinotify')
>  +logger.propagate = False
>   self.assertRaises(errors.InotifyError, handler.enable)
>   self.assertRaises(errors.InotifyError, handler.enable)
>   handler.disable()
>   self.assertRaises(errors.InotifyError, handler.enable)
>  +logger.propagate = True
> 
>Do you want to put a try/finally around the asserts that ensure
>propagate is restored?
>iustin

Good point. There are paths in pyinotify's add_watch that can throw exceptions
(although I don't think we use them). Submitted with your change.

Cheers,
Brian.


Re: [PATCH stable-2.16] Hide errors for expected inotify failures in unittest

2016-08-12 Thread 'Iustin Pop' via ganeti-devel
On 12 August 2016 at 15:04, 'Brian Foley' via ganeti-devel <
ganeti-devel@googlegroups.com> wrote:

> This makes it a little easier to eyeball the output of make py-tests.
>

Ooh, nice, this is a very old bug, thanks!

+logger = logging.getLogger('pyinotify')
> +logger.propagate = False
>  self.assertRaises(errors.InotifyError, handler.enable)
>  self.assertRaises(errors.InotifyError, handler.enable)
>  handler.disable()
>  self.assertRaises(errors.InotifyError, handler.enable)
> +logger.propagate = True
>

Do you want to put a try/finally around the asserts that ensure propagate
is restored?

iustin


[PATCH stable-2.16] Hide errors for expected inotify failures in unittest

2016-08-12 Thread 'Brian Foley' via ganeti-devel
This makes it a little easier to eyeball the output of make py-tests.

Signed-off-by: Brian Foley 
---
 test/py/ganeti.asyncnotifier_unittest.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/test/py/ganeti.asyncnotifier_unittest.py 
b/test/py/ganeti.asyncnotifier_unittest.py
index 2b3098f..b7d7171 100755
--- a/test/py/ganeti.asyncnotifier_unittest.py
+++ b/test/py/ganeti.asyncnotifier_unittest.py
@@ -30,6 +30,7 @@
 
 """Script for unittesting the asyncnotifier module"""
 
+import logging
 import unittest
 import signal
 import os
@@ -178,10 +179,13 @@ class TestSingleFileEventHandlerError(unittest.TestCase):
 handler = asyncnotifier.SingleFileEventHandler(wm, None,
utils.PathJoin(self.tmpdir,
   "nonexist"))
+logger = logging.getLogger('pyinotify')
+logger.propagate = False
 self.assertRaises(errors.InotifyError, handler.enable)
 self.assertRaises(errors.InotifyError, handler.enable)
 handler.disable()
 self.assertRaises(errors.InotifyError, handler.enable)
+logger.propagate = True
 
 
 if __name__ == "__main__":
-- 
2.8.0.rc3.226.g39d4020