[Checkins] SVN: zope.sqlalchemy/branches/elro-retry-support/ Tests working with Oracle
Laurence Rowe
l at lrowe.co.uk
Sat Jul 24 12:06:10 EDT 2010
Log message for revision 115026:
Tests working with Oracle
Changed:
U zope.sqlalchemy/branches/elro-retry-support/oracle.cfg
U zope.sqlalchemy/branches/elro-retry-support/postgres.cfg
U zope.sqlalchemy/branches/elro-retry-support/src/zope/sqlalchemy/tests.py
-=-
Modified: zope.sqlalchemy/branches/elro-retry-support/oracle.cfg
===================================================================
--- zope.sqlalchemy/branches/elro-retry-support/oracle.cfg 2010-07-24 16:05:17 UTC (rev 115025)
+++ zope.sqlalchemy/branches/elro-retry-support/oracle.cfg 2010-07-24 16:06:09 UTC (rev 115026)
@@ -1,6 +1,12 @@
+# To run the oracle tests I use the oracle developer days VirtualBox image:
+# http://www.oracle.com/technology/software/products/virtualbox/appliances/index.html
+# For cx_Oracle to build, download instantclient basiclite and sdk from:
+# http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
+
[buildout]
extends = buildout.cfg
-parts += python-oracle cx_Oracle test
+# extends = postgres.cfg
+parts += python-oracle cx_Oracle testora
python = python-oracle
allow-hosts += *.sourceforge.net
@@ -15,10 +21,13 @@
[test]
eggs += cx_Oracle
-environment = testenv
+[testora]
+<= test
+environment = oraenv
+
[scripts]
eggs += cx_Oracle
-[testenv]
+[oraenv]
TEST_DSN = oracle://system:oracle@192.168.56.101/orcl
Modified: zope.sqlalchemy/branches/elro-retry-support/postgres.cfg
===================================================================
--- zope.sqlalchemy/branches/elro-retry-support/postgres.cfg 2010-07-24 16:05:17 UTC (rev 115025)
+++ zope.sqlalchemy/branches/elro-retry-support/postgres.cfg 2010-07-24 16:06:09 UTC (rev 115026)
@@ -1,16 +1,22 @@
-# INCLUDEDIR=/opt/local/include/postgresql90 PATH=/opt/local/lib/postgresql90/bin:$PATH bin/buildout -vvvc postgres.cfg
+# PATH=/opt/local/lib/postgresql90/bin:$PATH bin/buildout -c postgres.cfg
+# sudo -u postgres /opt/local/lib/postgresql90/bin/createdb zope_sqlalchemy_tests
+# sudo -u postgres /opt/local/lib/postgresql90/bin/createuser -s <username>
# sudo -u postgres /opt/local/lib/postgresql90/bin/postgres -D /opt/local/var/db/postgresql90/defaultdb -d 1
[buildout]
extends = buildout.cfg
find-links = http://initd.org/pub/software/psycopg/
allow-hosts += initd.org
+parts += testpg
[test]
eggs += psycopg2
-environment = testenv
+[testpg]
+<= test
+environment = pgenv
+
[scripts]
eggs += psycopg2
-[testenv]
+[pgenv]
TEST_DSN = postgres:///zope_sqlalchemy_tests
Modified: zope.sqlalchemy/branches/elro-retry-support/src/zope/sqlalchemy/tests.py
===================================================================
--- zope.sqlalchemy/branches/elro-retry-support/src/zope/sqlalchemy/tests.py 2010-07-24 16:05:17 UTC (rev 115025)
+++ zope.sqlalchemy/branches/elro-retry-support/src/zope/sqlalchemy/tests.py 2010-07-24 16:06:09 UTC (rev 115026)
@@ -471,8 +471,10 @@
self.tm1 = transaction.TransactionManager()
self.tm2 = transaction.TransactionManager()
- e1 = sa.create_engine(TEST_DSN, isolation_level='SERIALIZABLE', echo=True)
- e2 = sa.create_engine(TEST_DSN, isolation_level='SERIALIZABLE', echo=True)
+ # With psycopg2 you might supply isolation_level='SERIALIZABLE' here,
+ # unfortunately that is not supported by cx_Oracle.
+ e1 = sa.create_engine(TEST_DSN)
+ e2 = sa.create_engine(TEST_DSN)
self.s1 = orm.sessionmaker(
bind=e1,
extension=tx.ZopeTransactionExtension(transaction_manager=self.tm1),
@@ -494,6 +496,7 @@
orm.clear_mappers()
def testRetry(self):
+ # sqlite is unable to run this test as the databse is locked
tm1, tm2, s1, s2 = self.tm1, self.tm2, self.s1, self.s2
# make sure we actually start a session.
tm1.begin()
@@ -519,6 +522,7 @@
tm1.begin()
self.failUnless(len(s1.query(User).all())==1, "Users table should have one row")
tm2.begin()
+ s2.connection().execute("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE")
self.failUnless(len(s2.query(User).all())==1, "Users table should have one row")
s1.query(User).delete()
raised = False
@@ -576,8 +580,10 @@
import doctest
optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
suite = TestSuite()
- for cls in (ZopeSQLAlchemyTests, MultipleEngineTests, RetryTests):
- suite.addTest(makeSuite(cls))
+ suite.addTest(makeSuite(ZopeSQLAlchemyTests))
+ suite.addTest(makeSuite(MultipleEngineTests))
+ if TEST_DSN.startswith('postgres') or TEST_DSN.startswith('oracle'):
+ suite.addTest(makeSuite(RetryTests))
suite.addTest(doctest.DocFileSuite('README.txt', optionflags=optionflags, tearDown=tearDownReadMe,
globs={'TEST_DSN': TEST_DSN, 'TEST_TWOPHASE': TEST_TWOPHASE}))
return suite
More information about the checkins
mailing list