Problem/Motivation

#3031379: Add a new test type to do real update testing gives us a new testing framework in Drupal core: BuildTests.

This framework allows for building a site (or a number of sites) within a workspace in the file system, and then using an HTTP server to make requests against it.

This framework was designed to allow 'real' updates between different Drupal versions, as PHPUnit tests.

As a side-effect, we can also perform other build-oriented tests.

Child issues

Proposed resolution

Determine which existing tests we wish to perform as build tests.

Convert them.

Remaining tasks

Identify other conversions needed.

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Mile23 created an issue. See original summary.

mile23’s picture

Status: Active » Postponed

Postponed because #3031379: Add a new test type to do real update testing is still in process.

heddn’s picture

Status: Postponed » Needs review
StatusFileSize
new17.92 KB
new18.08 KB

Let's see if one big patch is enough or if we need to bikeshed into multiple sub issues. The interdiff is against what I think is the last patch where all of these things were included in #3031379: Add a new test type to do real update testing.

mile23’s picture

I'm pretty sure we changed the testing API since those tests were written.

I converted one for documentation and the change record: https://www.drupal.org/node/3082383

heddn’s picture

StatusFileSize
new2 KB
new17.92 KB

The lint errors was a trailing comma issue when calling into a function. Hopefully this works more better this time on the test bot.

heddn’s picture

StatusFileSize
new17.92 KB
new991 bytes

Caught another issue.

heddn’s picture

StatusFileSize
new17.92 KB
heddn’s picture

+++ b/core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php
@@ -0,0 +1,64 @@
+class QuickStartTestBase extends BuildTestBase {

This class should probably be abstract.

heddn’s picture

+++ b/core/tests/Drupal/BuildTests/Update/UpdateSiteDrushTest.php
@@ -0,0 +1,76 @@
+    $this->executeCommand('git config user.email "drupalci@no-reply.drupal.org"');
...
+    $this->executeCommand('git config user.name "Drupal CI"');

Instead of the above, the following is what seems to be used on test bots.

git config --global user.email "drupalci@drupalci.org" &&
git config --global user.name "The Testbot"

Status: Needs review » Needs work

The last submitted patch, 7: 3082230-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new17.78 KB
new5.25 KB

This fixes everything but one failure. Still investigating it.

Status: Needs review » Needs work

The last submitted patch, 11: 3082230-11.patch, failed testing. View results

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new697 bytes
new17.78 KB

Its confusing because I can't reproduce the failures on local. But let's try this.

mile23’s picture

Looking good.

Not so much a review as some comments to maybe steer discussion...

  1. +++ b/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php
    @@ -139,6 +139,13 @@ abstract class BuildTestBase extends TestCase {
    +  private $phpFinder;
    
    @@ -247,6 +254,15 @@ public function getMink() {
    +  protected function getPhpFinder() {
    

    See #3031379-208: Add a new test type to do real update testing item 6.

  2. +++ b/core/tests/Drupal/BuildTests/QuickStart/InstallTest.php
    @@ -0,0 +1,52 @@
    +  public function providerProfile() {
    +    return [
    +      'minimal' => ['minimal'],
    +    ];
    +  }
    

    This used to have more profiles, so if we want this test we should add them back.

  3. +++ b/core/tests/Drupal/BuildTests/Update/UpdateSiteDrushTest.php
    @@ -0,0 +1,77 @@
    + * @requires externalCommand drush
    ...
    +class UpdateSiteDrushTest extends BuildTestBase {
    

    So the question here is: Is drush an official way to update, such that we're going to test for it? Also, I'm not sure which version of drush drupalci has, and whether that's the best test or not.

  4. +++ b/core/tests/Drupal/BuildTests/Update/UpdateTest.php
    @@ -0,0 +1,101 @@
    +class UpdateTest extends QuickStartTestBase {
    +
    +  public function provideVersions() {
    +    return [
    +      ['8.6.x'],
    +      ['8.7.x'],
    +      ['8.8.x'],
    +    ];
    +  }
    +
    +  /**
    +   * Test updates from the provided version to HEAD.
    +   *
    +   * @dataProvider provideVersions
    +   */
    +  public function testUpdateGit($version_branch) {
    

    The downside of this test is that it uses quickstart, which might not be a thorough enough test of installation.

  5. --- a/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php
    +++ b/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php
    

    I'm not sure why we're changing this file.

  6. +++ b/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
    @@ -49,6 +49,7 @@ protected function setUp() {
       public function testInstallWithNonExistingFile() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -67,6 +68,7 @@ public function testInstallWithNonExistingFile() {
       public function testInstallWithFileWithNoClass() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -106,6 +108,7 @@ public function testInstallWithNonSetupClass() {
       public function testInstallScript() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -206,6 +209,7 @@ public function testInstallScript() {
       public function testInstallInDifferentLanguage() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -243,6 +247,7 @@ public function testInstallInDifferentLanguage() {
       public function testTearDownDbPrefixValidation() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -317,6 +322,7 @@ public function testUserLogin() {
       protected function addTestDatabase($db_prefix) {
    +    $this->markTestIncomplete('Replace with build test.');
    

    Each of these could be a follow-up, assuming we do want to replace them.

heddn’s picture

StatusFileSize
new8.42 KB
new18.97 KB
new19.88 KB

14.1-3: done
14.3: I've added all 3 major versions of drush 8,9,10(master). Drush supports chaining so we should cover all the bases this way. And given the strong complaints last time w/ Phar and drush, testing w/ drush is a good idea.
14.4: not addressed
14.5: Drupal\BuildTests\TestSiteApplication\InstallTest will fail in fail patch because I removed the changes to TestSiteInstallCommand. The tests uncovers an existing bug w/ TestSiteInstallCommand that needs to be resolved. See #3031379-114: Add a new test type to do real update testing for more background.
14.6: not addressed

heddn’s picture

Will pick up the following w/ a later round of feedback.

  1. +++ b/core/tests/Drupal/BuildTests/Update/UpdateSiteDrushTest.php
    @@ -4,6 +4,7 @@
    +use Symfony\Component\Finder\Finder;
    

    Unused import.

  2. +++ b/core/tests/Drupal/BuildTests/Update/UpdateSiteDrushTest.php
    @@ -17,9 +18,16 @@
    +      ->notPath('/sites\/default\/settings\..*php/');
    

    This should be ->notName('drushrc.php');

The last submitted patch, 15: 3082230-15-fail.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mile23’s picture

+++ b/core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php
@@ -97,6 +98,18 @@ protected function execute(InputInterface $input, OutputInterface $output) {
+    // Make sure there is an entry in sites.php for the new site.

This looks like a bug that should be a separate issue. Then we even have a legitimate reason to write a new test. :-)

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

heddn’s picture

#3087862: TestSiteInstallCommand doesn't work with build tests is now opened. And #3085728: Add access rules for build tests as well. The later has bits of the patch in this meta included in it. So, it does look like we're going the meta route here. Once some of those land, I'll open up a few more follow-ups to catch the rest of the things.

alexpott’s picture

  1. +++ b/core/tests/Drupal/BuildTests/Update/UpdateSiteDrushTest.php
    @@ -0,0 +1,98 @@
    +class UpdateSiteDrushTest extends BuildTestBase {
    

    This test has to be allowed to fail. And we're not used to dealing with tests that are allowed to fail.

  2. +++ b/core/tests/Drupal/BuildTests/Update/UpdateTest.php
    @@ -0,0 +1,101 @@
    +  public function provideVersions() {
    +    return [
    +      ['8.6.x'],
    +      ['8.7.x'],
    +      ['8.8.x'],
    +    ];
    +  }
    

    This is cool

  3. +++ b/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
    @@ -49,6 +49,7 @@ protected function setUp() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -67,6 +68,7 @@ public function testInstallWithNonExistingFile() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -106,6 +108,7 @@ public function testInstallWithNonSetupClass() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -206,6 +209,7 @@ public function testInstallScript() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -243,6 +247,7 @@ public function testInstallInDifferentLanguage() {
    +    $this->markTestIncomplete('Replace with build test.');
    
    @@ -317,6 +322,7 @@ public function testUserLogin() {
    +    $this->markTestIncomplete('Replace with build test.');
    

    This shouldn't be done in this issue. We shouldn't end up with less test coverage.

xjm’s picture

Issue tags: +beta target

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

xjm’s picture

Issue tags: -beta target

Cleaning up leftover beta targets from 9.0.x.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

StatusFileSize
new7.8 KB
new12.73 KB

this is just a reroll, done because #3087862: TestSiteInstallCommand doesn't work with build tests was committed. The new tests are failing locally, but first the reroll.

anchal_gupta’s picture

StatusFileSize
new479 bytes
new12.69 KB

I have fixed cs error. please review it

quietone’s picture

StatusFileSize
new439 bytes
new12.72 KB

@Anchal_gupta, thanks for the interest in the issue. What we both failed to do was to run the code quality checks before uploading the patch. Have a look at the instructions for running the coding standard checks locally so you can be sure the tests will run before uploading a patch.

Status: Needs review » Needs work

The last submitted patch, 31: 3082230-31.patch, failed testing. View results

quietone’s picture

I get different test results locally. For example, both of these pass locally.

This Drupal\BuildTests\Composer\Component\ComponentsIsolatedBuildTest::testComponentComposerJson with data set #0 ('/Version') fails on the testbot but passes locally.

 Drupal\BuildTests\QuickStart\InstallTest::testInstall with data set "standard" ('standard')
Symfony\Component\Filesystem\Exception\IOException: Failed to copy "/var/www/html/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php" to "/tmp/build_workspace_ed518620268abc3a4dd2565fb31bf3abK6ZztE/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php" because target file could not be opened for writing.

Not sure what the next step is.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new3.18 KB
new12.74 KB

Rerolling.

Status: Needs review » Needs work

The last submitted patch, 35: 3082230-35.patch, failed testing. View results

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new6.13 KB
new10.3 KB

#16.1 and 2. Done
#18. Not done, added it to the remaining tasks
#21.3 Removed the changes and added the list of test to the remaining tasks.

UpdateSiteDrushTest is failing with:

Fatal error: Cannot redeclare theme_get_registry() (previously declared in /tmp/build_workspace_386b42cbab37b393ba776f4c01dadb4dSHCm06/core/includes/theme.inc:91) in /var/www/html/core/includes/theme.inc on line 91\n
' contains "Installation complete.".

How to address that?

Status: Needs review » Needs work

The last submitted patch, 37: 3082230-37.patch, failed testing. View results

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.31 KB
new10.78 KB

Just a reroll. And type to run just the Build tests.

quietone’s picture

StatusFileSize
new10.24 KB

I should have known that would not work.

Status: Needs review » Needs work

The last submitted patch, 41: 3082230-41.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new4.62 KB
new12.38 KB

I noticed that other quickstart tests are checking the sqlite version, so I copied that code block to these tests. Also, updated version numbers.

Local testing isn't working for me because I use a personal git hook and that causes failures for chmod. I haven't looked closely but it may be because it is a symbolic link.

Status: Needs review » Needs work

The last submitted patch, 43: 3082230-43.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review

I don't know why this is failing with

1) Drupal\BuildTests\Update\UpdateSiteDrushTest::testSiteUpdateWithDrush with data set "12.x" ('drush/drush:12.x')
Failed asserting that ' You are about to:\n
 * Create a sites/default/settings.php file\n
 * CREATE the 'db.sqlite' database.\n
\n
 // Do you want to continue?: yes.                                              \n
\n
' contains "Installation complete.".

what it should be non-interactive, $this->executeCommand('drush site-install --db-url=sqlite://db.sqlite -y');.

quietone’s picture

StatusFileSize
new799 bytes
new12.42 KB

Show the error output using an assert.

Status: Needs review » Needs work

The last submitted patch, 46: 3082230-46.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new12.38 KB
new12.38 KB

Well, that is a different error than what I get locally.

Status: Needs review » Needs work

The last submitted patch, 48: 3082230-48.patch, failed testing. View results

quietone’s picture

Moved past that error and on to a new one.

1) Drupal\BuildTests\Update\UpdateSiteDrushTest::testSiteUpdateWithDrush with data set "12.x" ('drush/drush:12.x')
COMMAND: drush updb -y
OUTPUT:
ERROR: PHP Fatal error:  Declaration of Drush\Command\DrushInputAdapter::getFirstArgument() must be compatible with Symfony\Component\Console\Input\InputInterface::getFirstArgument(): ?string in phar:///usr/local/bin/drush/lib/Drush/Command/DrushInputAdapter.php on line 54
Drush command terminated abnormally due to an unrecoverable error.   �[31;40m�[1m[error]�[0m
Error: Declaration of
Drush\Command\DrushInputAdapter::getFirstArgument() must be
compatible with
Symfony\Component\Console\Input\InputInterface::getFirstArgument():
?string in
phar:///usr/local/bin/drush/lib/Drush/Command/DrushInputAdapter.php,
line 54

Should it not be using vendor/bin/drush?

DrushInputAdapter was Removed from Drush in 2017.

quietone’s picture

Issue summary: View changes
Status: Needs work » Active

I moved the Drush test to #3377980: Add BuildTest for testing update using Drush, with links to the core ideas issue about adding drush.
And the quickstart tests to #3377981: Add BuildTest for testing Quickstart install and update

I think Drupal\Tests\Scripts\TestSiteApplicationTest is covered by #2962157: TestSiteApplicationTest requires a database despite being a unit test

Changing to active because the patches have moved to other issues.

+++ b/core/tests/Drupal/BuildTests/Framework/BuildTestBase.php
@@ -155,7 +155,6 @@ abstract class BuildTestBase extends TestCase {
-    $this->phpFinder = new PhpExecutableFinder();

This is the only change that is not yet in another issue. This currently an unused property.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.