On Fri, Nov 24, 2017 at 2:20 PM, Nir Soffer <nsoffer(a)redhat.com> wrote:
Adding devel@ovirt, the proper mailing list
בתאריך יום ו׳, 24 בנוב׳ 2017, 7:42, מאת Germano Veit Michel
<germano(a)redhat.com>:
>
> Hi,
>
> I'm trying to write a test for a hook. The test will fail if the hook does
> "import hooking", which seems to be the norm for vdsm hooks.
>
> [vdsm_hooks]$ grep -rn "import hooking" | wc -l
> 55
>
> Not sure if I'm doing something wrong, but it looks like I would need vdsm
> installed on my development machine in order for this import to work.
>
> ======================================================================
> ERROR: test suite for <class
> 'virttests.boot_hostdev_test.BootHostdevHookTests'>
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib/python2.7/site-packages/nose/suite.py", line 209, in run
> self.setUp()
> File "/usr/lib/python2.7/site-packages/nose/suite.py", line 292, in
> setUp
> self.setupContext(ancestor)
> File "/usr/lib/python2.7/site-packages/nose/suite.py", line 315, in
> setupContext
> try_run(context, names)
> File "/usr/lib/python2.7/site-packages/nose/util.py", line 471, in
> try_run
> return func()
> File
>
"/home/gveitmic/Source/upstream/vdsm/tests/virttests/boot_hostdev_test.py",
> line 127, in setUpClass
> import before_vm_start as boot_hostdev_hook
> File "../vdsm_hooks/boot_hostdev/before_vm_start.py", line 24, in
> <module>
> import hooking
> ImportError: No module named hooking
>
> I can make it go away by using this in my hook:
>
> from vdsm.hook import hooking
>
> Then the test succeeds fine. But then I see all hooks use "import hooking"
> instead of "from vdsm.hook import hooking".
>
> [vdsm_hooks]$ grep -rn "from vdsm.hook import hooking" | wc -l
> 0
>
> Am I doing something wrong? Can someone put a light here? What is the
> correct way to do this import?
Our approach for it is to modify PYTHONPATH [1] where we add vdsm.hook.
It looks like we do not have similar update in [2] - script which run the tests.
I will push a patch to fix it.
[1]
https://github.com/oVirt/vdsm/blob/master/lib/vdsm/hooks.py#L98
[2]
https://github.com/oVirt/vdsm/blob/master/tests/run_tests_local.sh.in#L21
>
> Thanks,
> Germano
_______________________________________________
Devel mailing list
Devel(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel