diff -r 20f45a9b385c -r ad0615d4500d server/test/unittest_postgres.py --- a/server/test/unittest_postgres.py Wed Mar 05 13:51:28 2014 +0100 +++ b/server/test/unittest_postgres.py Tue May 06 10:28:23 2014 +0200 @@ -28,8 +28,14 @@ from unittest_querier import FixedOffset +class PostgresTimeoutConfiguration(PostgresApptestConfiguration): + default_sources = PostgresApptestConfiguration.default_sources.copy() + default_sources['system'] = PostgresApptestConfiguration.default_sources['system'].copy() + default_sources['system']['db-statement-timeout'] = 200 + + class PostgresFTITC(CubicWebTC): - configcls = PostgresApptestConfiguration + configcls = PostgresTimeoutConfiguration def test_eid_range(self): # concurrent allocation of eid ranges @@ -131,6 +137,13 @@ yield self.assertEqual, sql("SELECT limit_size('a>b', 'text/html', 2)"), \ 'a>...' + def test_statement_timeout(self): + with self.admin_access.repo_cnx() as cnx: + cnx.system_sql('select pg_sleep(0.1)') + with self.assertRaises(Exception): + cnx.system_sql('select pg_sleep(0.3)') + + if __name__ == '__main__': from logilab.common.testlib import unittest_main unittest_main()