All testing is currently broken for sqlite mostly because of notices throw in ::setUp()

Undefined index: username
Notice	WebTestBase.php	649	Drupal\simpletest\WebTestBase->setUp()

and other fields that is not used for sqlite

This caused by hard-coded $settings array

Also here another bug
Failed to find test tables to drop. Other simpletest.module 181 _simpletest_batch_operation()

Comments

andypost’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

Patch fixes WebTestBase->setUp()

andypost’s picture

Tables are not found because sqlite does not uses prefixes for tables but creates new database with .ht.sqlite-simpletest289381 names

So WebTestBase->tearDown() does not find a tables with
$tables = db_find_tables($connection_info['default']['prefix']['default'] . '%'); code

andypost’s picture

Title: WebTestBase->setUp() broken for sqlite » WebTestBase->setUp() & tearDown() completely broken for sqlite
Priority: Normal » Major
StatusFileSize
new2.56 KB

A sqlite makes new database file for each test* so it needs to cleanup it.

Patch just isolates table clean-up to allow test runs

agentrickard’s picture

Would this work so we don't have SQLite-specific exception handling?

if ($tables = db_find_tables($connection_info['default']['prefix']['default'] . '%');
 // Do stuff here...
}
else {
  $this->fail('Failed to find test tables to drop.');
}
andypost’s picture

I fount that dont because sqlite db_find_tables() returns not only a drupal-related tables but some internal (sqlite_sequences for example) and loop that deletes tables can't delete some of them and sometimes stops to delete them because implementation to search tables are different for db_drop_table and db_find_tables

sun’s picture

Priority: Major » Normal
Status: Needs review » Needs work
Issue tags: +Testing system

1) I no longer know why I assigned the database settings manually, instead of just assigning the entire $connection_info['default'] as form values to submit to $edit. We should probably do that instead.

2) If db_find_tables() returns internal/native tables on sqlite, then we need to fix the database driver, instead of hacking around it in a single spot.

webchick’s picture

Priority: Normal » Major

Sorry, but if the title of this issue is true, this is at least major.

damien tournoud’s picture

2) If db_find_tables() returns internal/native tables on sqlite, then we need to fix the database driver, instead of hacking around it in a single spot.

There is another issue for prefixed database files failing to be cleaned-up on SQLite after testing. That is supposed to work (we have code in __destruct() of the SQLite implementation for that), but it seems to have been broken somewhere along the way.

chx’s picture

Note that sqlite (and postgresql) will likely remain in this half-supported state until the new test infrastructure happens and we have test bots for them. This is a fact.

damien tournoud’s picture

Component: sqlite database » simpletest.module

As far as I know, this is not a SQLite bug.

andypost’s picture

I still think that sqlite implementation has some troubles because looping through tables for delete mostly always fails

lotyrin’s picture

Component: simpletest.module » sqlite database

I think this is certainly a bug in Drupal's SQLite abstraction.

Everywhere in core we make the assumption that database table prefixes are database table prefixes (we don't have a generic namespacing interface that can be backed however it wants) SQLite violates that assumption and uses attached databases.

We could eventually change the db abstraction to add methods like "Create namespace" "Destroy namespace" or the like, but that's not the current case.

Because Simpltest (rightfully) assumes that it's dealing with table prefixes, it searches for and drops tables, but the sqlite abstraction layer fails to behave properly, and instead leaks its internal implementation details.

lotyrin’s picture

Title: WebTestBase->setUp() & tearDown() completely broken for sqlite » WebTestBase->setUp() completely broken for sqlite

Actually, in order to allow for some progress to be made on setUp(), for which we have a solution in SimpleTest, I'm moving the tearDown() issue to another ticket (as it's possible the fix will be out in sqlite abstraction rather than simpletest.) New issue is here: #1814706: WebTestBase->tearDown() broken for sqlite

lotyrin’s picture

Component: sqlite database » simpletest.module
Status: Needs work » Needs review
StatusFileSize
new1.43 KB

And here's my patch for this issue.

It matches sun's suggestion in #6

sun’s picture

Title: WebTestBase->setUp() completely broken for sqlite » WebTestBase->setUp() broken for sqlite
Priority: Major » Normal
Status: Needs review » Reviewed & tested by the community

Thanks, simple and passes tests; looks good to me.

andypost’s picture

+1 rtbc!!! Manually testing sqlite and it works, also there's no tearDown() exception

andypost’s picture

just a re-roll because applies with offset

dries’s picture

Status: Reviewed & tested by the community » Fixed

Looks good, and actually simplified things. Committed to 8.x. Thanks.

lotyrin’s picture

I'm not seeing the tearDown problem anymore either. I guess I'll close that issue.

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