When clicking the "clean environment" button, I get:

user warning: Unknown table 'dev_dev_simpletest' query: DROP TABLE dev_dev_simpletest in drupal-6/includes/database.mysql-common.inc on line 261.
user warning: Unknown table 'dev_dev_simpletest_test_id' query: DROP TABLE dev_dev_simpletest_test_id in drupal-6/includes/database.mysql-common.inc on line 261.
/**
 * Removed prefixed talbes from the database that are left over from crashed tests.
 */
function simpletest_clean_database() {
  $tables = simpletest_get_like_tables(); // --> This returns the tables already prefixed.

  $ret = array();
  foreach ($tables as $table) {
    db_drop_table($ret, $table); // --> the function expects un-prefixed table names! 
  }

Comments

beginner’s picture

Also, i don't know if it's related, but my database has accumulated 300+ simpletest_* tables that have not been properly cleaned.

beginner’s picture

I am actually surprised that simpletest actually tries to drop {simpletest} and {simpletest_test_id}.
Is that the intended behavior?

beginner’s picture

Status: Active » Needs work
StatusFileSize
new1.19 KB

I am not sure what's the intended behavior.
I fixed the issue for myself with the attached patch:
the tables {simpletest} and {simpletest_test_id} are kept, but the countless simpletest* tables have been removed.
I removed the $prefix from the SELECT query, and I don't use db_drop_table() which will add the unwanted prefix.

boombatower’s picture

Project: SimpleTest » Drupal core
Version: 6.x-2.x-dev » 7.x-dev
Component: Code » simpletest.module

This is an issue with SimpleTest 7.x and should be fixed in core then backported.

boombatower’s picture

Title: prefix added twice to tables to drop » SimpleTest: Database prefix added twice when cleaning database

1) The get like tables needs to return either non-prefixed tables, 2) the prefixes need to be removed from the table names before running drop command, or 3) the $db_prefix could be set to '' just before running drops.

Wesley Tanaka’s picture

Project: SimpleTest » Drupal core
Version: 6.x-2.x-dev » 7.x-dev
Component: Code » simpletest.module

subscribing (for 6.x-2.x branch)

http://drupal.org/files/issues/table_prefix_simpletest.patch fixes this bug for me too.

damien tournoud’s picture

Project: Drupal core » SimpleTest
Version: 7.x-dev » 6.x-2.x-dev
Component: simpletest.module » Code

Core is not affected.

boombatower’s picture

Project: Drupal core » SimpleTest
Version: 7.x-dev » 6.x-2.x-dev
Component: simpletest.module » Code

I'm not following the problem here....can you give me detailed instructions on how to re-create.

simpletest_get_like_tables() should be looking for tables that were created with random prefix (ie. simpletest438928095)

and should return them as such.

beginner’s picture

See the comments in the php code in comment #0 above.

boombatower’s picture

Yes, and from reading that and patch I wasn't sure...as I think they are inconsistent.

Changing the drop to a manual query if it auto adds prefix makes sense...otherwise we could do

$db_prefix = '';
db_drop..()
$db_prefix = $original;

But I don't get why the get query would change.

$result = db_query("SELECT $select FROM information_schema.tables WHERE table_schema = '$database' AND table_name LIKE '$base_table%'");

That would seem to fry simpletest tables ONLY if the $db_prefix = ''; ?

Wesley Tanaka’s picture

Status: Needs work » Fixed

This no longer happens for me in simpletest 6.x-2.8, and the patch no longer applies, since the underlying code changed, so I am assuming that it is fixed.

Status: Fixed » Closed (fixed)

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

westbywest’s picture

Version: 6.x-2.x-dev » 6.x-2.10
Status: Closed (fixed) » Active

I'm running SimpleTest v 6.x-2.10 on D 6.12, and I get warnings in the status message box like these when I click the "Clean Environment" button after running tests.

User warning: Unknown table 'simpletest150449access' query: DROP TABLE simpletest150449access in _db_query() (line 128 of /blah/blah/drupal/includes/database.mysqli.inc).
User warning: Unknown table 'simpletest150449actions' query: DROP TABLE simpletest150449actions in _db_query() (line 128 of /blah/blah/drupal/includes/database.mysqli.inc).

Sure enough, see a bunch of tables in the DB with names like the following:

Arraysimpletest150449access
Arraysimpletest150449actions
Arraysimpletest150449actions_aid
Arraysimpletest150449authmap
Arraysimpletest150449batch
Arraysimpletest150449blocks
Arraysimpletest150449blocks_roles

HTML entity ' is an apostrophe, which presumably is being used in an attempt to escape table names.

westbywest’s picture

Whatever was causing the warnings described in the previous comment has now gone away on my site. I still see the word "Array" prepended to temporary DB table names for some reason, but it is not interfering with temp DB tables being creating and then deleted.

boombatower’s picture

Status: Active » Closed (fixed)

That is a different issue which is due to $db_prefix being an array and has been fixed.

kenorb’s picture

Version: 6.x-2.10 » 6.x-2.x-dev
Status: Closed (fixed) » Needs work

The problem still exists, tested with dev version on 6.22.
Errors:

Unknown table 'simpletest418826simpletest418826simpletest' query: DROP TABLE simpletest418826simpletest418826simpletest
Unknown table 'simpletest418826simpletest418826simpletest_test_id' query: DROP TABLE simpletest418826simpletest418826simpletest_test_id

The prefix is added twice.

First part of #3 patch fixes the problem.

kenorb’s picture

Status: Needs work » Needs review
StatusFileSize
new482 bytes

Find the patch in the attachment.
Unfortunately I can't create a proper git patch passing the QA, I'm behind the proxy.

The last submitted patch, simpletest.module-345115.patch, failed testing.

kenorb’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Version 6.x is no longer supported due to Drupal 6 End of Life.