When a test crashes due to a PHP error that doesn't let the tearDown method run it leaves the prefix tables in the database.

I have created a patch that checks for any left over tables and deletes them when simpletest_entrypoint function is called.

My only concern is that it may not run in non-MySQL databases, but I don't know for sure.



chx’s picture

SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_name LIKE 'simpletest%' is the code to run on postgresql.

chx’s picture

Status: Needs review » Needs work

This needs to be a separate page. We are passing the prefix in the reuqest so that the same Drupal install can run multiple tests at the same time. If you drop every table beginning with simpletest, this won't happen.

boombatower’s picture

Status: Needs work » Needs review
3.24 KB

I tried to add a button that could be pressed and then the database would be cleaned, but for some reason it never invokes the form_submit hook.

boombatower’s picture

Status: Needs review » Fixed

Made a button on the tests page that can be pressed and the specified query run.


chx’s picture

Category: task » bug
Status: Fixed » Active

You only commented the postgresql query. There is no trace of the mysql query. Are we the first to make a module that only works with postgresql :D ?

boombatower’s picture

Status: Active » Needs review

The query works for me on MySQL. I thought that it works for both since you said it would work on postgresql.

Let me know.

chx’s picture

Status: Needs review » Needs work

Well, this needs complete rework. Store the tables (coming from schema) with a timestamp and after, say, an hour, clean up automatically. No introspection. No button to press. And yet, you can happily run multiple requests at the same time. As noted in the other issue: we can pass the original db_prefix in the user_agent too, switch back to the original database and store there.

dlangevin’s picture

That seems a little overly complex to me. Can we assume that all db tables with the prefix simpletest are from tests that died before tearDown() and just remove them with cron? Why do you think we should store this in the db?

boombatower’s picture

I'm not sure that having a some sort of time interval will do much good since we don't know how long the tests may take to run. From what I understand the tests easily take an hour+ to run, so automatic deletion would have some issues. Similar issue with cron.

The tables shouldn't ever be left over on the test server since that will only occur if a PHP error causes the test to completely crash or some other catastrophic failure. I suppose that could happen if someone submits a patch with a syntax error. Not really sure, but in that case maybe the testing box should reset itself between test patch (which I think was already in the plan).

The intention of the button was to make it easy when writing tests to cleanup database which I run into somewhat often.

chx’s picture

Status: Needs work » Fixed

So, MySQL 5.0 has information_schema and all is well. Indeed, it does not worth the bothering to do automated cleanup.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.