[Freeipa-devel] [PATCH] 1 Do lazy initializiation ipalib
Alexander Bokovoy
abokovoy at redhat.com
Wed Nov 2 14:01:53 UTC 2011
On Wed, 02 Nov 2011, Martin Kosek wrote:
> Hmm, this looks impressive! It would brings us considerably faster CLI
> calls.
>
> And again, I would feel much safer if we do these optimizations only
> for CLI and let server do all the initialization right on start.
Well, that could be done in API.finalize() as we would know context at
that point already.
> Unit tests show few errors though. But these may not be the actual
> problems in the patch, it may be just wrong test assumptions:
>
> ======================================================================
> FAIL: Doctest: ipalib.crud
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib64/python2.7/doctest.py", line 2166, in runTest
> raise self.failureException(self.format_failure(new.getvalue()))
> AssertionError: Failed doctest test for ipalib.crud
> File "/home/mkosek/freeipa/ipalib/crud.py", line 19, in crud
these are examples that doctest extracts and tries to run.
I can make Finalizer class iterable and that will solve all these:
> ----------------------------------------------------------------------
> File "/home/mkosek/freeipa/ipalib/crud.py", line 76, in ipalib.crud
> Failed example:
> list(api.Command.user_add.args)
> Exception raised:
> Traceback (most recent call last):
> File "/usr/lib64/python2.7/doctest.py", line 1254, in __run
> compileflags, 1) in test.globs
> File "<doctest ipalib.crud[13]>", line 1, in <module>
> list(api.Command.user_add.args)
> TypeError: 'Finalizer' object is not iterable
> ----------------------------------------------------------------------
> File "/home/mkosek/freeipa/ipalib/crud.py", line 78, in ipalib.crud
> Failed example:
> list(api.Command.user_add.options)
> Exception raised:
> Traceback (most recent call last):
> File "/usr/lib64/python2.7/doctest.py", line 1254, in __run
> compileflags, 1) in test.globs
> File "<doctest ipalib.crud[14]>", line 1, in <module>
> list(api.Command.user_add.options)
> TypeError: 'Finalizer' object is not iterable
> ----------------------------------------------------------------------
> File "/home/mkosek/freeipa/ipalib/crud.py", line 94, in ipalib.crud
> Failed example:
> list(api.Command.user_show.args)
> Exception raised:
> Traceback (most recent call last):
> File "/usr/lib64/python2.7/doctest.py", line 1254, in __run
> compileflags, 1) in test.globs
> File "<doctest ipalib.crud[15]>", line 1, in <module>
> list(api.Command.user_show.args)
> TypeError: 'Finalizer' object is not iterable
> ----------------------------------------------------------------------
> File "/home/mkosek/freeipa/ipalib/crud.py", line 96, in ipalib.crud
> Failed example:
> list(api.Command.user_show.options)
> Exception raised:
> Traceback (most recent call last):
> File "/usr/lib64/python2.7/doctest.py", line 1254, in __run
> compileflags, 1) in test.globs
> File "<doctest ipalib.crud[16]>", line 1, in <module>
> list(api.Command.user_show.options)
> TypeError: 'Finalizer' object is not iterable
> ----------------------------------------------------------------------
> File "/home/mkosek/freeipa/ipalib/crud.py", line 114, in ipalib.crud
> Failed example:
> list(api.Command.user_add.output_params)
> Exception raised:
> Traceback (most recent call last):
> File "/usr/lib64/python2.7/doctest.py", line 1254, in __run
> compileflags, 1) in test.globs
> File "<doctest ipalib.crud[18]>", line 1, in <module>
> list(api.Command.user_add.output_params)
> TypeError: 'NoneType' object is not iterable
Output params could be run through finalizer as well.
> ----------------------------------------------------------------------
> File "/home/mkosek/freeipa/ipalib/crud.py", line 116, in ipalib.crud
> Failed example:
> list(api.Command.user_show.output_params)
> Exception raised:
> Traceback (most recent call last):
> File "/usr/lib64/python2.7/doctest.py", line 1254, in __run
> compileflags, 1) in test.globs
> File "<doctest ipalib.crud[19]>", line 1, in <module>
> list(api.Command.user_show.output_params)
> TypeError: 'NoneType' object is not iterable
Same here.
Errors below are about assumptions that before finalizing args,
options
> ======================================================================
> FAIL: Test the ``ipalib.frontend.Command.args`` instance attribute.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib/python2.7/site-packages/nose/case.py", line 187, in
> runTest
> self.test(*self.arg)
> File "/home/mkosek/freeipa/tests/test_ipalib/test_frontend.py", line
> 255, in test_args
> assert self.cls().args is None
> AssertionError
>
> ======================================================================
> FAIL: Test the `ipalib.frontend.Command.get_output_params` method.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib/python2.7/site-packages/nose/case.py", line 187, in
> runTest
> self.test(*self.arg)
> File "/home/mkosek/freeipa/tests/test_ipalib/test_frontend.py", line
> 710, in test_get_output_params
> assert list(inst.get_output_params()) == ['one', 'two', 'three']
> AssertionError
>
> ======================================================================
> FAIL: Test the ``ipalib.frontend.Command.options`` instance attribute.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib/python2.7/site-packages/nose/case.py", line 187, in
> runTest
> self.test(*self.arg)
> File "/home/mkosek/freeipa/tests/test_ipalib/test_frontend.py", line
> 304, in test_options
> assert self.cls().options is None
> AssertionError
>
>
>
> I found one more issue with our ./makeapi script.
>
> $ ./makeapi
> Writing API to API.txt
> Traceback (most recent call last):
> File "./makeapi", line 392, in <module>
> sys.exit(main())
> File "./makeapi", line 376, in main
> rval |= make_api()
> File "./makeapi", line 167, in make_api
> fd.write('args: %d,%d,%d\n' % (len(cmd.args), len(cmd.options),
> len(cmd.output)))
> TypeError: object of type 'Finalizer' has no len()
This is expectation that Finalizer is iteratable.
I think these all can be fixed in two relatively simple shots. Let me
look at that later today.
--
/ Alexander Bokovoy
More information about the Freeipa-devel
mailing list