lib389: cleanup __init__
by Roberto Polli
Hi @all,
I started investigating in mocking with fakeldap, and it seems an easy and
viable way of adding unittests.
A main issue is the DSAdmin.__init__ complexity.
I thought - a long time ago actually - to remove from DSAdmin all cached
references to backends, suffixes and configuration.
If we want to add a cache layer we can do it afterward. And with some cache
pattern.
Let me know + Peace,
R.
--
Roberto Polli
Community Manager
Babel S.r.l. - http://www.babel.it
T: +39.06.9826.9651 M: +39.340.652.2736 F: +39.06.9826.9680
P.zza S.Benedetto da Norcia, 33 - 00040 Pomezia (Roma)
CONFIDENZIALE: Questo messaggio ed i suoi allegati sono di carattere
confidenziale per i destinatari in indirizzo.
E' vietato l'inoltro non autorizzato a destinatari diversi da quelli indicati
nel messaggio originale.
Se ricevuto per errore, l'uso del contenuto e' proibito; si prega di
comunicarlo al mittente e cancellarlo immediatamente.
10 years, 7 months
Proof of concept: mocking DS in lib389
by Jan Rusnacko
Hello Roberto and Thierry,
as I promised, I am sending you a proof-of-concept code that demonstrates, how
we can mock DS in unit tests for library function (see attachment). You can run
tests just by executing py.test in tests directory.
Only 3 files are of interest here:
lib389/dsmodules/repl.py - this is a Python module with functions - they expect
DS instance as the first argument. Since they are functions, not methods, I can
just mock DS and pass that fake one as the first argument to them in unit tests.
tests/test_dsmodules/conftest.py - this file contains definition of mock DS
class along with py.test fixture, that returns it.
tests/test_dsmodules/test_repl.py - this contains unit tests for functions from
repl.py.
What I do is quite simple - I override ldapadd, ldapdelete .. methods of mock DS
class, so that instead of sending command to real DS instance, they just store
the data in 'dit' dictionary (which represents content stored in DS). This way,
I can check that when I call e.g. function enable_changelog(..), in the end DS
will have correct changelog entry.
To put it very bluntly - enable_changelog(..) function just adds correct
changelog entry to whatever is passed to it as the first argument. In unit
tests, it is mock DS, otherwise it would be real DS class that sends real ldap
commands to real DS instance behind.
Now I can successfully test that enable_changelog really works, without going
into trouble defining DSInstance or ldap calls at all. Also, I believe this
approach would work for 95% of all functions in lib389. Another benefit is that
unit tests are much faster, than on real DS instance.
Sidenote: even though everything is defined in separate namespace of 'repl'
module as function, in runtime they can be used as normal methods of class
DSInstance. That is handled by DSModuleProxy. We already went through this, but
not with Roberto.
Hopefully, now with some code in our hands, we will be able to understand each
other on this 'mocking' issue and come to conclusions more quickly.
Let me know what you think.
Thank you,
Jan
10 years, 7 months
Building 389-ds-base-1.3.2.3
by Noriko Hosoi
Building 389-ds-base-1.3.2.3 including the following patches (in
addition to 1.3.2.2).
144869f bump version to 1.3.2.3
a4073a8 Ticket #47515 Fedora 20: setup-ds-admin.pl
b5676ab Ticket 47569 - Fix build warnings
2b7cbb8 Ticket 47569 - ACIs do not allow attribute subtypes in
targetattr keyword
8bfefb6 Ticket 47565 - Content Sync update file needs extensibleObject
9b0e6a3 Ticket 47560: fixup memberof task does not work: task entry
not added
7b3b2fe Ticket #47559 hung server - related to sasl and initialize
Please let me know if there's something else we'd like to add to the
release.
Thanks,
--noriko
10 years, 7 months
Please review: [389 Project] #47555: db2bak.pl issue when specifying non-default directory
by Noriko Hosoi
https://fedorahosted.org/389/attachment/ticket/47555/0001-Ticket-47555-db...
Bug description: db2bak.pl takes an option "-a backupdir", which is
supposed to be generated by the server and used as a backup directory.
But since the created directory inherits the parent's selinux context,
it may fail to store the backup files in the directory.
Fix description: As the reporter agaviola suggested, it should be a
good idea to add one more level to the archive directory.
$archivedir = "${archivedir}/ID-${yr}_${mn}_${dy}_${h}_${m}_${s}";
But to keep the backward compatibility, introducing a new option "-A
backupdir" and when "-A" is given, storing the backup files in the
nested backup directory. If the option is "-a backupdir", the backup
files are stored in the backupdir.
Also, this patch sets the right ownership and selinux context to the
generated directory. Note: if the parent directories of the created
backupdir do not have the correct selinux context, even if the last
directory's setting is correct, storing the backup files fails. It
is the user's responsibility to set them correctly.
10 years, 7 months