I'm not sure how does it happened, but after running simpletests couple of times, my tables in Drupal installation were removed somehow.
Now I've the errors like:

Warning: Table 'drupal.access' doesn't exist query
Warning: Table 'drupal.users' doesn't exist

I've checked and the tables aren't there.

The only possible code which could do that, is probably this one (file: drupal_web_test_case.php):

    // Remove all prefixed tables (all the tables in the schema).
    $schema = drupal_get_schema(NULL, TRUE);
    $ret = array();
    foreach ($schema as $name => $table) {
      db_drop_table($ret, $name);
    }

I can't see here any conditions like preg_match('/simpletest\d+.*/', as I've seen in the .module file.
I've to recover my db, which takes more than 1h, and I'll do some other testing why this happened.

This could be related to option 'dependencies' in getInfo() which I was testing instead of enabling modules in setUp().

CommentFileSizeAuthor
#3 drupal_web_test_case.php-1781018.patch699 byteskenorb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kenorb’s picture

Priority: Normal » Critical

I've checked and the function $schema = drupal_get_schema(NULL, TRUE); is actually returning the real table list, so I don't understand what this code exactly trying to do and why it's dropping the tables from the real instance (tearDown method).
It suppose to delete the tables only created by setUp().

kenorb’s picture

Title: Simpletest dropped the real Drupal tables instead of simpletest tables » Simpletest dropping the real Drupal tables instead of simpletest tables

I've checked few times more, definitely it's a Simpletest bug in the code mentioned above.

SQL queries executed:


120912 11:01:19	  104 Query	/* admin : update_sql */ DROP TABLE blocks
		  104 Query	/* admin : update_sql */ DROP TABLE blocks_roles
		  104 Query	/* admin : update_sql */ DROP TABLE boxes
120912 11:01:20	  104 Query	/* admin : update_sql */ DROP TABLE cache_block
		  104 Query	/* admin : update_sql */ DROP TABLE comments
		  104 Query	/* admin : update_sql */ DROP TABLE node_comment_statistics
		  104 Query	/* admin : update_sql */ DROP TABLE watchdog
...
		  104 Query	/* admin : update_sql */ DROP TABLE performance_summary
		  104 Query	/* admin : update_sql */ DROP TABLE performance_detail

Basically all of them.

Some data from xdebug:

 25.0561   40476064                       -> DrupalWebTestCase->tearDown() modules/simpletest/drupal_web_test_case.php:494
...
   25.0571   40491200                         -> simpletest_file_unmanaged_delete_recursive($path = '/simpletest/') modules/simpletest/drupal_web_test_case.php:1372
   25.0571   40491280                           -> is_dir('/simpletest/') modules/simpletest/simpletest.module:566
                                                 >=> FALSE
   25.0572   40491280                           -> is_file('/simpletest/') modules/simpletest/simpletest.module:578
                                                 >=> FALSE
   25.0572   40491216                         -> drupal_get_schema($table = NULL, $rebuild = TRUE) modules/simpletest/drupal_web_test_case.php:1375
                                               => $schema = array () includes/common.inc:3305
   25.0600   38084336                           -> module_load_all_includes($type = 'install', $name = ???) includes/common.inc:3307
   25.0601   38084416                             -> module_list($refresh = ???, $bootstrap = ???, $sort = ???, $fixed_list = ???) includes/module.inc:285
                                                   >=> array ('strongarm' => 'strongarm', 'fivestar' => 'fivestar', ...(all the modules)
...
                                             => $name = 'blocks' modules/simpletest/drupal_web_test_case.php:1377
   25.7510   40846136                         -> db_drop_table($ret = array (), $table = 'blocks') modules/simpletest/drupal_web_test_case.php:1378
   25.7510   40846288                           -> update_sql($sql = 'DROP TABLE {blocks}') includes/database.mysql-common.inc:269
   25.7510   40846368                             -> db_query($query = 'DROP TABLE {blocks}', TRUE) includes/database.inc:64
   25.7510   40846448                               -> func_get_args() includes/database.mysql-common.inc:33
                                                     >=> array (0 => 'DROP TABLE {blocks}', 1 => TRUE)
                                                   => $args = array (0 => 'DROP TABLE {blocks}', 1 => TRUE) includes/database.mysql-common.inc:33
   25.7510   40847240                               -> array_shift(array (0 => 'DROP TABLE {blocks}', 1 => TRUE)) includes/database.mysql-common.inc:34
                                                     >=> 'DROP TABLE {blocks}'
   25.7510   40846888                               -> db_prefix_tables($sql = 'DROP TABLE {blocks}') includes/database.mysql-common.inc:35
   25.7511   40847112                                 -> is_array('') includes/database.inc:84
                                                       >=> FALSE
   25.7511   40847856                                 -> strtr('DROP TABLE {blocks}', array ('{' => '', '}' => '')) includes/database.inc:101
                                                       >=> 'DROP TABLE blocks'
                                                     >=> 'DROP TABLE blocks'
                                                   => $query = 'DROP TABLE blocks' includes/database.mysql-common.inc:35

It happens only when I'm using 'dependencies' key in getInfo()
E.g.:

  function getInfo() {
    return array(
      'name' => 'Foo',
      'description' => 'Test functionality of Foo.',
      'group' => 'Foo',
      'dependencies' => array('flag'),
    );
  }

Write any test function, it happens at the end of cleaning the environment.

kenorb’s picture

Status: Needs work » Needs review
FileSize
699 bytes

The patch fixes the problem.

kenorb’s picture

Issue summary: View changes

updated

Status: Active » Needs work

The last submitted patch, drupal_web_test_case.php-1781018.patch, failed testing.

Status: Needs review » Needs work
kenorb’s picture

Priority: Critical » Major
Issue summary: View changes
Lendude’s picture

Status: Needs work » Closed (outdated)

This version is not supported anymore.