From 0ed0cd66bf31aacf785ecd0959fe2c30c0330428 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 20 Aug 2004 16:12:49 +0000 Subject: [PATCH] more on back-sql test --- servers/slapd/back-sql/rdbms_depend/README | 157 +++++++++++++++++++++ tests/data/sqlmods.out | 20 +-- tests/scripts/defines.sh | 1 + tests/scripts/test031-sql | 28 ++-- 4 files changed, 189 insertions(+), 17 deletions(-) create mode 100644 servers/slapd/back-sql/rdbms_depend/README diff --git a/servers/slapd/back-sql/rdbms_depend/README b/servers/slapd/back-sql/rdbms_depend/README new file mode 100644 index 0000000000..c2aeb4d124 --- /dev/null +++ b/servers/slapd/back-sql/rdbms_depend/README @@ -0,0 +1,157 @@ +Author: Pierangelo Masarati + +Back-sql can be tested with test031-sql; it requires a bit of work to get +everything up and running appropriately. + +This document briefly describes the steps that are required to prepare +a quick'n'dirty installation of back-sql and of the related RDBMS +and ODBC; Examples are provided, but by no means they pretent +to represent an exaustive source of info about how to setup the ODBC; +refer to the docs for any problem or detail. + +Currently, the system has been tested with PostgreSQL and with MySQL; +basic support and test data for other RDBMSes is in place, but as of +today (August 2004) it's totally untested. If you succeed in running +any of the other RDBMSes, please provide feedback about any required +change either in the code or in the test scripts by means of OpenLDAP's +Issue Tracking System (http://www.openldap.org/its/). + +1) slapd must be compiled with back-sql support, i.e. configure +with --enable-sql switch. This requires an implementation of the ODBC +to be installed. + +2) The ODBC must be set up appropriately, by editing the odbc.ini file +in /etc/ (or wherever your installation puts it) and, if appropriate, +the odbcinst.ini file. Note: you can also use custom odbc.ini and +odbcinst.ini files, provided you export in ODBCINI the full path to the +odbc.ini file, and in ODBCSYSINI the directory where the odbcinst.ini +file resides. +Relevant info for our test setup is highlighted with '<===' on the right. + +2.1) PostgreSQL + +2.1.1) Add to the odbc.ini file a block of the form + +[example] <=== +Description = Example for OpenLDAP's back-sql +Driver = PostgreSQL +Trace = No +Database = example <=== +Servername = localhost +UserName = manager <=== +Password = secret <=== +Port = 5432 +;Protocol = 6.4 +ReadOnly = No +RowVersioning = No +ShowSystemTables = No +ShowOidColumn = No +FakeOidIndex = No +ConnSettings = + +2.1.2) Add to the odbcinst.ini file a block of the form + +[PostgreSQL] +Description = ODBC for PostgreSQL +Driver = /usr/lib/libodbcpsql.so +Setup = /usr/lib/libodbcpsqlS.so +FileUsage = 1 + +2.2) MySQL + +2.2.1) Add to the odbc.ini file a block of the form + +[example] <=== +Description = Example for OpenLDAP's back-sql +Driver = MySQL +Trace = No +Database = example <=== +Servername = localhost +UserName = manager <=== +Password = secret <=== +ReadOnly = No +RowVersioning = No +ShowSystemTables = No +ShowOidColumn = No +FakeOidIndex = No +ConnSettings = +SOCKET = /var/lib/mysql/mysql.sock + +2.2.2) Add to the odbcinst.ini file a block of the form + +[MySQL] +Description = ODBC for MySQL +Driver = /usr/lib/libmyodbc.so +FileUsage = 1 + +3) The RDBMS must be setup; examples are provided for my installations +of PostgreSQL and MySQL, but details may change; other RDBMSes should +be configured in a similar manner, you need to find out the details by +reading their documentation. + +3.1) PostgreSQL + +3.1.1) Start the server +on RedHat: +[root@localhost]# service postgresql start +on other systems: read the docs... + +3.1.2) Create the database: +[root@localhost]# su - postgres +[postgres@localhost]$ createdb example + +3.1.3) Create the user: +[root@localhost]# su - postgres +[postgres@localhost]$ psql example +example=> create user manager with password 'secret'; +example=> + +3.1.4) Populate the database: +[root@localhost]# cd $SOURCES/servers/slapd/back-sql/rdbms_depend/pgsql/ +[root@localhost]# psql -U manager -W example +example=> +[root@localhost]# psql -U manager example < backsql_create.sql +[root@localhost]# psql -U manager example < testdb_create.sql +[root@localhost]# psql -U manager example < testdb_data.sql +[root@localhost]# psql -U manager example < testdb_metadata.sql + +3.1.5) Run the test: +[root@localhost]# cd $SOURCES/tests +[root@localhost]# SLAPD_USE_SQL=postgres ./run test031 + +3.2) MySQL + +3.2.1) Start the server +on RedHat: +[root@localhost]# service mysqld start +on other systems: read the docs... + +3.2.2) Create the database: +[root@localhost]# mysqladmin -u root -p create example +(hit for the empty password). + +3.2.3) Create the user: +[root@localhost]# mysql -u root -p example +(hit for the empty password) +mysql> grant all privileges on *.* \ + to 'manager'@'localhost' identified by 'secret' with grant option; +mysql> exit; + +3.2.4) Populate the database: +[root@localhost]# cd $SOURCES/servers/slapd/back-sql/rdbms_depend/mysql/ +[root@localhost]# mysql -u manager -p example < backsql_create.sql +[root@localhost]# mysql -u manager -p example < testdb_create.sql +[root@localhost]# mysql -u manager -p example < testdb_data.sql +[root@localhost]# mysql -u manager -p example < testdb_metadata.sql + +3.2.5) Run the test: +[root@localhost]# cd $SOURCES/tests +[root@localhost]# SLAPD_USE_SQL=mysql ./run test031 + +4) Cleanup: +The basic portion of the test is readonly; this is performed by all RDBMSes. +The secondary part involves write operations. Currently, the write +portion of the test is enabled only for PostgreSQL. Note that after +a successful run of the write portion, the database is no longer in the +correct state to restart the test, and step 3.X.4 needs to be re-run first. + diff --git a/tests/data/sqlmods.out b/tests/data/sqlmods.out index 637fac5ee5..54d5ef33db 100644 --- a/tests/data/sqlmods.out +++ b/tests/data/sqlmods.out @@ -1,18 +1,21 @@ -# refldap://localhost/o=example,c=ru??sub - -dn: cn=Torvlobnor Puzdoy,o=Example,c=RU +dn: cn=Pierangelo Masarati,o=Example,c=RU objectClass: inetOrgPerson -cn: Torvlobnor Puzdoy -telephoneNumber: 545-4563 -sn: Torvlobnor Puzdoy -documentIdentifier: documentTitle=book1,o=Example,c=RU +cn: Pierangelo Masarati +telephoneNumber: +39 333 ZZZ 1234 +givenName: Pierangelo +sn: Masarati + +# refldap://localhost/o=Example,c=RU??sub dn: cn=Mitya Kovalev,o=Example,c=RU objectClass: inetOrgPerson +objectClass: posixAccount cn: Mitya Kovalev telephoneNumber: 332-2334 telephoneNumber: 222-3234 -sn: Mitya Kovalev +telephoneNumber: +1 800 123 4567 +givenName: Mitya +sn: Kovalev documentIdentifier: documentTitle=book1,o=Example,c=RU documentIdentifier: documentTitle=book2,o=Example,c=RU @@ -27,7 +30,6 @@ objectClass: document description: abstract1 documentTitle: book1 documentAuthor: cn=Mitya Kovalev,o=Example,c=RU -documentAuthor: cn=Torvlobnor Puzdoy,o=Example,c=RU dn: o=Example,c=RU objectClass: organization diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index 5961db56c3..a1212d6b27 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -18,6 +18,7 @@ BACKLDAP=${AC_ldap-ldapno} BACKRELAY=${AC_relay-relayno} BACKSQL=${AC_sql-sqlno} RDBMS=${SLAPD_USE_SQL-rdbmsno} +RDBMSWRITE=${SLAPD_USE_SQLWRITE-no} PROXYCACHE=${AC_pcache-pcacheno} PPOLICY=${AC_ppolicy-ppolicyno} REFINT=${AC_refint-refintno} diff --git a/tests/scripts/test031-sql b/tests/scripts/test031-sql index 812de2d8a5..607529f318 100755 --- a/tests/scripts/test031-sql +++ b/tests/scripts/test031-sql @@ -21,6 +21,9 @@ echo "### ODBC and a database poulated with data from the applicable" echo "### servers/slapd/back-sql/rdbms_depend/* files." echo "### Set SLAPD_USE_SQL to the desired RDBMS to enable this test;" echo "### Supported RDBMSes are: mysql,postgres" +echo "### Set SLAPD_USE_SQLWRITE=yes to enable the write test" +echo "### See servers/slapd/back-sql/rdbms_depend/README for more " +echo "### details on how to set up the RDBMS and the ODBC" if test $BACKSQL = "sqlno" ; then echo "SQL backend not available, test skipped" @@ -219,8 +222,11 @@ if test $? != 0 ; then fi echo "Testing modify, add, and delete..." -case ${RDBMS} in - # list here the RDBMSes whose mapping allows writes +if test "${RDBMSWRITE}" != "yes"; then + echo "write test disabled; set SLAPD_USE_SQLWRITE=yes to enable" +else + case ${RDBMS} in + # list here the RDBMSes whose mapping allows writes postgres) MANAGERDN="cn=Manager,${BASEDN}" $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ @@ -228,10 +234,7 @@ case ${RDBMS} in $TESTOUT 2>&1 << EOMODS version: 1 -# LEADING COMMENT AND WHITE SPACE - dn: cn=Mitya Kovalev,${BASEDN} -# EMBEDDED COMMENT changetype: modify add: telephoneNumber telephoneNumber: +1 800 123 4567 @@ -239,13 +242,21 @@ telephoneNumber: +1 800 123 4567 dn: cn=Pierangelo Masarati,${BASEDN} changetype: add -# EMBEDDED COMMENT - CONTINUED objectClass: inetOrgPerson cn: Pierangelo Masarati sn: Masarati givenName: Pierangelo telephoneNumber: +39 02 XXXX YYYY +telephoneNumber: +39 02 XXXX ZZZZ + +dn: cn=Pierangelo Masarati,${BASEDN} +changetype: modify +delete: telephoneNumber +telephoneNumber: +39 02 XXXX YYYY +- +add: telephoneNumber +telephoneNumber: +39 333 ZZZ 1234 +- dn: cn=Torvlobnor Puzdoy,${BASEDN} changetype: delete @@ -287,7 +298,8 @@ EOMODS *) echo "apparently ${RDBMS} does not support writes; skipping..." ;; -esac + esac +fi test $KILLSERVERS != no && kill -HUP $KILLPIDS -- 2.39.5