[Checkins] SVN: z3c.recipe.ldap/trunk/ Use a local openldap CMMI build for tests.

Ross Patterson me at rpatterson.net
Mon Dec 10 13:54:56 EST 2007


Log message for revision 82246:
  Use a local openldap CMMI build for tests.
  

Changed:
  U   z3c.recipe.ldap/trunk/buildout.cfg
  U   z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt
  U   z3c.recipe.ldap/trunk/z3c/recipe/ldap/tests/test_docs.py

-=-
Modified: z3c.recipe.ldap/trunk/buildout.cfg
===================================================================
--- z3c.recipe.ldap/trunk/buildout.cfg	2007-12-10 18:50:00 UTC (rev 82245)
+++ z3c.recipe.ldap/trunk/buildout.cfg	2007-12-10 18:54:55 UTC (rev 82246)
@@ -1,7 +1,12 @@
 [buildout]
 develop = .
-parts = test
+parts = openldap test
 
+[openldap]
+recipe = zc.recipe.cmmi
+url = ftp://ftp.openldap.org/pub/OpenLDAP/openldap-stable/openldap-stable-20071118.tgz
+extra_options = --enable-local --enable-bdb --disable-overlays --disable-slurpd --disable-shared --enable-fast-install
+
 [test]
 recipe = zc.recipe.testrunner
 eggs = z3c.recipe.ldap

Modified: z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt
===================================================================
--- z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt	2007-12-10 18:50:00 UTC (rev 82245)
+++ z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt	2007-12-10 18:54:55 UTC (rev 82246)
@@ -28,9 +28,9 @@
 
 The only required option is the suffix argupent.  Specifying the
 suffix with a dc requires that the "dc" LDAP attribute type
-configuration.  Write a buildout.cfg with a suffix and including the
-attribute type configuration.  Also specify that the server should use
-a socket instead of a network port::
+configuration.  Write a buildout.cfg with a suffix and include
+core.schema for the attribute type configuration.  Also specify that
+the server should use a socket instead of a network port::
 
     >>> write(sample_buildout, 'buildout.cfg',
     ... """
@@ -39,24 +39,20 @@
     ...
     ... [slapd]
     ... recipe = z3c.recipe.ldap
+    ... slapd = %(openldap)s/libexec/slapd
     ... use-socket = True
     ... include =
+    ...     %(openldap)s/etc/openldap/schema/core.schema
     ...     foo.schema
     ...     bar.conf
+    ... modulepath = 
+    ... moduleload = 
     ... suffix = "dc=localhost"
-    ... """)
+    ... """ % globals())
 
 Create the files to be included::
 
-    >>> write(sample_buildout, 'foo.schema',
-    ... """
-    ... attributetype ( 0.9.2342.19200300.100.1.25
-    ... 	NAME ( 'dc' 'domainComponent' )
-    ... 	DESC 'RFC1274/2247: domain component'
-    ... 	EQUALITY caseIgnoreIA5Match
-    ... 	SUBSTR caseIgnoreIA5SubstringsMatch
-    ... 	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
-    ... """)
+    >>> write(sample_buildout, 'foo.schema', '\n')
     >>> write(sample_buildout, 'bar.conf', '\n')
 
 Run the buildout::
@@ -69,13 +65,24 @@
 keys that can be specified multiple times in slapd.conf, such as
 include, will be constitued from multiple line separated values when
 present.  Also note that keys that contain file paths in slapd.conf,
-such as include, will be expanded from the buildout directory::
+such as include, will be expanded from the buildout directory.
+Finally note that options specified with blank values will be
+excluded::
 
     >>> ls(sample_buildout, 'parts', 'slapd')
     -  slapd.conf
     >>> cat(sample_buildout, 'parts', 'slapd', 'slapd.conf')
+    include	.../etc/openldap/schema/core.schema
     include	/sample-buildout/foo.schema
-    include	/sample-buildout/bar.conf...
+    include	/sample-buildout/bar.conf
+    pidfile	/sample-buildout/parts/slapd/slapd.pid
+    database	bdb
+    suffix	"dc=localhost"
+    directory	/sample-buildout/var/slapd
+    dbconfig	set_cachesize	0	268435456	1
+    dbconfig	set_lg_regionmax	262144
+    dbconfig	set_lg_bsize	2097152
+    index	objectClass	eq
 
 An empty directory is created for the LDAP database::
 
@@ -91,13 +98,16 @@
 
 Start the slapd server::
 
+    >>> import time
     >>> bin = join(sample_buildout, 'bin', 'slapd')
     >>> print system(bin+' start'),
+    >>> time.sleep(0.1)
 
 On first run, the LDAP database is created::
 
     >>> ls(sample_buildout, 'var', 'slapd')
-    - __db.001...
+    -  DB_CONFIG
+    -  __db.001...
 
 While the server is running a pid file is created::
 
@@ -108,10 +118,6 @@
 Stop the slapd server::
 
     >>> print system(bin+' stop'),
-
-Wait for it to shutdown::
-
-    >>> import time
     >>> time.sleep(0.1)
 
 When the slapd server finishes shutting down the pid file is deleted::
@@ -119,21 +125,20 @@
     >>> ls(sample_buildout, 'parts', 'slapd')
     -  slapd.conf
 
-Specifying the slapd binary
----------------------------
+The slapd binary
+----------------
 
-The slapd binary to be used can be specified.  A buildout could, for
-example, include a part using a CMMI recipe and use the slapd binary
-from that build.
+The slapd binary to be used can be specified as we did above when we
+specified the slapd binary from the buildout OpenLDAP CMMI part::
 
-Before specifying the slapd to use, it's left up to the environment::
-
     >>> cat(sample_buildout, '.installed.cfg')
     [buildout]...
     [slapd]...
-    slapd = slapd...
+    slapd = .../parts/openldap/libexec/slapd
+    ...
 
-Specify a slapd in the buildout.cfg::
+If no binary is specified, it's left up to the environment.
+Write a buildout.cfg with no slapd specified::
 
     >>> write(sample_buildout, 'buildout.cfg',
     ... """
@@ -142,12 +147,7 @@
     ...
     ... [slapd]
     ... recipe = z3c.recipe.ldap
-    ... slapd = /usr/sbin/slapd
     ... use-socket = True
-    ... include =
-    ...     foo.schema
-    ...     bar.conf
-    ... suffix = "dc=localhost"
     ... """)
 
 Run the buildout::
@@ -157,12 +157,13 @@
     Installing slapd.
     Generated script '/sample-buildout/bin/slapd'.
 
-Now it uses the specific slapd binary::
+Now it will find the binary on the system path::
 
     >>> cat(sample_buildout, '.installed.cfg')
     [buildout]...
     [slapd]...
-    slapd = /usr/sbin/slapd...
+    slapd = slapd
+    ...
 
 ----------------------------
 Initalizing an LDAP database
@@ -172,21 +173,8 @@
 from an LDIF file.  In the simplest form, simply provide an "ldif"
 option in the part with one or more filenames.
 
-Write some LDIF files::
+Write a buildout.cfg that lists some LDIF files::
 
-    >>> write(sample_buildout, 'foo.ldif',
-    ... """
-    ... olcAttributeTypes: ( 0.9.2342.19200300.100.1.25
-    ...   NAME ( 'dc' 'domainComponent' )
-    ...   DESC 'RFC1274/2247: domain component'
-    ...   EQUALITY caseIgnoreIA5Match
-    ...   SUBSTR caseIgnoreIA5SubstringsMatch
-    ...   SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
-    ... """)
-    >>> write(sample_buildout, 'bar.ldif', '\n')
-
-Write a buildout.cfg that lists those files::
-
     >>> write(sample_buildout, 'buildout.cfg',
     ... """
     ... [buildout]
@@ -195,29 +183,83 @@
     ... [slapd]
     ... recipe = z3c.recipe.ldap
     ... include =
-    ...     foo.schema
+    ...     %(openldap)s/etc/openldap/schema/core.schema
+    ...     %(openldap)s/etc/openldap/schema/cosine.schema
+    ... modulepath = 
+    ... moduleload = 
     ... suffix = "dc=localhost"
     ...
     ... [slapadd]
     ... recipe = z3c.recipe.ldap:slapadd
+    ... slapadd = %(openldap)s/sbin/slapadd
     ... conf = ${slapd:conf}
     ... ldif =
-    ...     foo.ldif
-    ...     bar.ldif
+    ...     dc.ldif
+    ...     admin.ldif
+    ... """ % globals())
+
+Write the LDIF files::
+
+    >>> write(sample_buildout, 'dc.ldif',
+    ... """
+    ... dn: dc=localhost
+    ... dc: localhost
+    ... objectClass: top
+    ... objectClass: domain
     ... """)
+    >>> write(sample_buildout, 'admin.ldif',
+    ... """
+    ... dn: cn=admin,dc=localhost
+    ... objectClass: person
+    ... cn: admin
+    ... sn: Manager
+    ... """)
 
-Running the buildout adds the LDIF files to the LDAP database::
+Run the buildout::
 
     >>> print system(buildout),
     Uninstalling slapd.
     Installing slapd.
     Generated script '/sample-buildout/bin/slapd'.
     Installing slapadd.
-    bdb_db_open:...
 
-The LDIF files are added on update also::
+The entries have been added to the LDAP database::
 
+    >>> print system(os.path.join(openldap, 'sbin', 'slapcat')+' -f '+
+    ...        os.path.join(sample_buildout,
+    ...                     'parts', 'slapd', 'slapd.conf')),
+    dn: dc=localhost
+    dc: localhost
+    objectClass: top
+    objectClass: domain...
+    dn: cn=admin,dc=localhost
+    objectClass: person
+    cn: admin
+    sn: Manager...
+
+The LDIF files are added on update also.
+
+Remove the existing LDAP database::
+
+    >>> rmdir(sample_buildout, 'var', 'slapd')
+    >>> mkdir(sample_buildout, 'var', 'slapd')
+
+Run the Buildout to add the LDIF files again::
+
     >>> print system(buildout),
     Updating slapd.
     Updating slapadd.
-    bdb_db_open:...
+
+The entries have been added to the LDAP database::
+
+    >>> print system(os.path.join(openldap, 'sbin', 'slapcat')+' -f '+
+    ...        os.path.join(sample_buildout,
+    ...                     'parts', 'slapd', 'slapd.conf')),
+    dn: dc=localhost
+    dc: localhost
+    objectClass: top
+    objectClass: domain...
+    dn: cn=admin,dc=localhost
+    objectClass: person
+    cn: admin
+    sn: Manager...

Modified: z3c.recipe.ldap/trunk/z3c/recipe/ldap/tests/test_docs.py
===================================================================
--- z3c.recipe.ldap/trunk/z3c/recipe/ldap/tests/test_docs.py	2007-12-10 18:50:00 UTC (rev 82245)
+++ z3c.recipe.ldap/trunk/z3c/recipe/ldap/tests/test_docs.py	2007-12-10 18:54:55 UTC (rev 82246)
@@ -18,6 +18,10 @@
     zc.buildout.testing.buildoutSetUp(test)
     zc.buildout.testing.install_develop('zc.recipe.egg', test)
     zc.buildout.testing.install_develop('z3c.recipe.ldap', test)
+    test.globs['openldap'] = os.path.join(
+        reduce(lambda path, _: os.path.dirname(path),
+               range(5), __file__),
+        'parts', 'openldap')
 
 def doc_suite(test_dir, setUp=setUp,
               tearDown=zc.buildout.testing.buildoutTearDown,



More information about the Checkins mailing list