Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1929 (closed defect: worksforme)

Opened 11 years ago

Last modified 10 years ago

Exceptions during test suite run because visit extension model tables not present

Reported by: Chris Arndt Owned by: anonymous
Priority: low Milestone: 1.1.x bugfix
Component: Tests Version: 1.1 HEAD
Severity: normal Keywords:

Description (last modified by Chris Arndt) (diff)

When I run the unit test suite in TG 1.1 with python setup.py test on my Linux dev computer, I get the following exception, although all tests pass:

Test that logout works and session is gets invalid afterwards. ... Exception in thread VisitManager:
Traceback (most recent call last):
  File "threading.py", line 460, in __bootstrap
  File "/home/chris/tmp/build/turbogears-svn/branches/1.1/turbogears/visit/api.py", line 344, in run
  File "/home/chris/tmp/build/turbogears-svn/branches/1.1/turbogears/visit/sovisit.py", line 78, in update_queued_visits
  File "/home/chris/lib/tg11py25/lib/python2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/dbconnection.py", line 682, in query
    return self._dbConnection._query(self._connection, s)
  File "/home/chris/lib/tg11py25/lib/python2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/dbconnection.py", line 334, in _query
    self._executeRetry(conn, conn.cursor(), s)
  File "/home/chris/lib/tg11py25/lib/python2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/sqlite/sqliteconnection.py", line 177, in _executeRetry
    raise OperationalError(ErrorMessage(e))
OperationalError: no such table: tg_visit


The exception usually occurs at the same test case in identity.tests.test_identity but I had it occur at other times as well, so this seems to be a timing issue or race condition.

It seems to me, that the visit extension is not properly initialized for some tests or does not get the right configuration. Looking through turbogears.testutil, I could not find out, where the visit extension is started for tests, but apparently the VisitManager thread is started somewhere.

Furthermore, as a test, I inserted some code into SqlqObjectVisitManager. In create_model:

    def create_model(self):
            # Create the Visit table if it doesn't already exist
            self._model_created = True
        except KeyError:
            # No database configured...
            log.info("No database is configured: Visit Tracking is disabled.")

and in update_queued_visits:

    def update_queued_visits(self, queue):
        if hub is None: # if VisitManager extension wasn't shutted down cleanly
        if not getattr(self, '_model_created', False):

and the exception still occurs! This means that the database is dropped somewhere and not recreated properly on the next test run.

Change History

comment:1 Changed 11 years ago by Chris Arndt

  • Description modified (diff)

comment:2 Changed 11 years ago by droggisch

I just ran the tests on OSX/leopard - none of the above appeared. I got one failure,

File "/Users/deets/projects/privat/TurboGears/Versions/TG11/turbogears/turbogears/tests/test_controllers.py", line 252, in test_js_files

but that's it.

I did see the spurious exception myself though - yet it never caused any troubles for me.

Sorry that I can't shed more insight to this.

comment:3 Changed 11 years ago by chrisz

I don't see this error either, but can you test whether it helps when you first set up DBTest and then start turbogears in TestTGUser.setUp and first stop turbogears and then tear down DBTest in TestTGUser.tearDown? It looks like the current order drops the visit database tables while the visit manager thread is still running.

comment:4 Changed 11 years ago by faide

  • Milestone changed from 1.5 to 1.1

comment:5 Changed 11 years ago by faide

Is this still happening ? I don't see that exception on Windows nor Linux.

comment:6 Changed 11 years ago by faide

  • Milestone changed from 1.1 to 1.1 maintenance

comment:7 Changed 11 years ago by Chris Arndt

Yes, still happening on my Linux laptop. This is how I found out about the strange nosetests behavior we chatted about and why I put in r5693. I'm really puzzled by this error. It seems to be a strange timing issue or race condition. Just leave this open and with low priority, please.

comment:8 Changed 11 years ago by faide

I have put it in maintenance so I don't see it in the 1.1 milestone :)

comment:9 Changed 10 years ago by Chris Arndt

  • Status changed from new to closed
  • Resolution set to worksforme

I cannot reproduce this error on any of my computers any more. Since visit test now are SQLAlchemy based in TG 1.1 anyway, this is not surprising. Closing ticket as "worksforme".

comment:10 Changed 10 years ago by chrisz

This problem seems to have resurrected as #2375.

Note: See TracTickets for help on using tickets.