Add functional test that proves there is reasonable UX whenever Composer Stager operations have a hard failure

Created on 13 April 2023, about 1 year ago
Updated 23 May 2023, about 1 year ago

Problem/Motivation

Quoting #3252299-27: Reliably support cweagans/composer-patches in Package Manager & Automatic Updates: validate stage :

  1. instead, we do want for MVP a build test that proves there is a reasonable UX whenever composer has a hard failure — no matter whether that is due to a patch failing to apply from composer-patches or whether that is from a networking error, wrong requirement, whatever → this needs a separate issue

In that issue we thought about having a build test that proves that specifically we could handle failures from composer-patches when I patch does not apply. But instead we decided we should a general functional test for when staged Composer operations fail

Proposed resolution

Create test to prove if the staging a composer operation fails we handle that with good UX.

Basically \Drupal\Tests\automatic_updates\Functional\UpdateErrorTest::testExceptionFromEventSubscriber() added in 📌 Add functional test that proves there is reasonable UX whenever a stage event subscriber has an exception Fixed only covers what happens if an exception is thrown in subscribers to this module's event.

But this test does not cover if an error happens in Stage in \Drupal\package_manager\StageBase::require() particularly in
$this->stager->stage($command, $active_dir, $stage_dir, NULL, $timeout);.
This would happen for many reasons:

  1. You try to update core and there was no possible way because of restriction of another dependency
  2. A patch fails to apply and composer-patches throws exception
  3. Any composer plugin throws an error during the composer require operation
  4. Composer has a network error
  5. Composer stager has some unrelated exception before the composer command

We can simulate an error in $this->stager->stage($command, $active_dir, $stage_dir, NULL, $timeout);.
by using NoOpStager::setException to because when package_manager_bypass is enabled $this->stager will be in instance of \Drupal\package_manager_bypass\NoOpStager

  • Create a functional test for updating core
  • Use NoOpStager::setException(in a trait) to set an exception.

    This is not exactly a composer error but this will happen when we hand off to Composer Stage in \Drupal\package_manager\StageBase::require in the same place we would catch a Composer error and since we catch throwable it should the same UX except for the actual message

  • Start the update and prove that we are shown the error and can get back to the start form
  • We should not see "delete existing update" button because we the stage should have been deleted.

We should also simulate an error with LoggingCommitter to simulate an error during apply, and LoggingBeginner to simulate an error during create. The UI behavior might be somewhat different, particularly when LoggingCommitter has an error (because the failure marker will not be deleted), but it should, in general, be reasonable.

📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024