[python-ldap] How to get the python-ldap test suite working in Ubuntu 16.10

Karl Kornel akkornel at stanford.edu
Sun Jun 4 17:26:03 EDT 2017


Hello!

I was just working on getting the python-ldap test suite working on an Ubuntu 16.10 (yakkety) VM, and I wanted to let people know the changes I needed to make, so that the test suite would work.

Assuming that you are already able to build and install python-ldap, you need to DO four more things to get the test suite working:

DO: Install the `slapd` package.
Python-ldap starts an instance of slapd in order to run tests.  So, you need slapd support!
During installation, you will be asked to choose an LDAP administrator password.  This can be anything you want, and it is _not_ needed for python-ldap tests, so you can make it random if you want.

DO: After installing slapd, disable it by running `systemctl stop slapd` and `systemctl disable slapd`.
Even though you need slapd, it doesn’t need to be running as a service.  So, let’s stop and disable it!
This is especially important if you are running this on a system that is not restricted.  In my case, I’m running it as a Virtual Box VM behind a NAT.  In your case, you might be running it on a server that is more open.

DO: Make a symlink from /etc/openldap to /etc/ldap
The test suite expects to find core schema files in /etc/openldap/schema, but Ubuntu installs to /etc/ldap.  So, make a symlink!

DO: Put the python-ldap source directory into /var/tmp
For example, let’s say you wanted to run a single test suite.  You could do so with this command:

PYTHONPATH=../Lib LOGLEVEL=4 python2.7 ./t_cext.py

When run from inside the ‘Tests’ directory, that runs the t_cext.py test suite.  For some test suites, this will work, but others will fail with this exception:

> RuntimeError: configuration test failed

The reason for this is, python-ldap is asking slapd to open a local socket file in a non-standard directory (for testing), and AppArmor is preventing this.  So, the server dies during startup, and python-ldap interprets this as a configuration issue.

One solution would be to modify slapd’s AppArmor profile (it lives in /etc/apparmor.d/usr.sbin.slapd), but the easier thing to do is to run things from inside /var/tmp.  That is because there is an existing rule allowing writing to sub-directories of /var/tmp.  So, just move your entire python-ldap directory into /var/tmp, and run from there:

cd /var/tmp
mv ~/python-ldap-2.4.39 .
cd python-ldap-2.4.39
LOGLEVEL=4 python2.7 setup.py test

With the above 4 commands, all 94 tests run fine!

--
A. Karl Kornel | System Administrator
Research Computing | Stanford University
+1 (650) 736-9327

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20170604/2860c29a/attachment.html>


More information about the python-ldap mailing list