1

I'm trying to speed up a functional Drupal test. Given a test...

...
  public function the_front_page_loads_for_anonymous_users() {
    $this->config('system.site')
      ->set('page.front', '/node')
      ->save(TRUE);

    $this->drupalGet('<front>');

    $assert = $this->assertSession();
    $assert->pageTextContains('Welcome to Drupal');
    $assert->pageTextContains('No front page content has been created yet.');
  }

This test runs really slow against my database ... 2+ mins.

If I use a test sqlite database, it drops to around 1.6 mins <env name="SIMPLETEST_DB" value="sqlite://localhost/logs/test.sqlite"/>

If I use a in-memory database, <env name="SIMPLETEST_DB" value="sqlite://localhost/:memory:"/>, Drupal detects no database and runs install.php

How can I set up an sqlite memory database to improve test speeds?

0

On Linux, we use sqlite://localhost/dev/shm/test.sqlite where /dev/shm is memory mapped

2
  • OK ... unfortunately I'm on a work PC, which runs Win10 and I have been unable to get hardware virtualization working which prevents me from using WSL2. – tyler36 Dec 4 '20 at 7:02
  • Thank you for sharing your approach though. I appreciate it. Hopefully, next upgrade cycle, I can implment a Docker or WSL2 solution. I'll be sure your try out your method. :) – tyler36 Dec 4 '20 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.