Problem/Motivation

In #3074993-31: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates it became clear that our tests that extend \Drupal\FunctionalTests\Update\UpdatePathTestBase and some other tests make real calls out to updates.drupal.org that fetch XML. These test aren't actually meant to test this XML request. They just happen to make it.

If the requests aren't successful the tests don't fail because the test aren't asserting anything about the responses. If the requests are successful but the XML isn't in an expected format the test will fail.

So basically we are inadvertently testing the format of live XML on updates.drupal.org and these requests may be slowing down our test suite.

Proposed resolution

Make sure we aren't making calls to updates.drupal.org.

All tests that extend UpdatePathTestBase or otherwise would trigger requests to updates.drupal.org should actually be calling something like \Drupal\Tests\update\Functional\UpdateTestBase::refreshUpdateStatus() to change the update URL so we aren't making real requests to updates.drupal.org

Remaining tasks

all

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#6 3095755-6.patch2.09 KBgábor hojtsy
#4 3095755-4.patch2.09 KBgábor hojtsy

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Issue summary: View changes

should have been \Drupal\FunctionalTests\Update\UpdatePathTestBase in summary. updating

dww’s picture

Issue summary: View changes

Great find! Big +1 to doing what you propose.

Fixed a few grammar bugs and typos in the summary that made this harder to parse / understand.

Also copied over (and slightly edited for clarity) the proposed resolution from the end of #3074993-31: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates:

All tests that extend UpdatePathTestBase or otherwise would trigger requests to updates.drupal.org should actually be calling something like \Drupal\Tests\update\Functional\UpdateTestBase::refreshUpdateStatus() to change the update URL so we aren't making real requests to updates.drupal.org

Thanks!
-Derek

gábor hojtsy’s picture

Title: Avoid calls to updates.drupal.org during test when not necessary » Tests should not do requests to updates.drupal.org
Category: Task » Bug report
Status: Active » Needs review
StatusFileSize
new2.09 KB

Hm, I wanted to re-upload that patch from #3074993-31: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates, to produce a list of tests that will fail. But I am not convinced. Since that is changing the suffix of the path to /current, changing how the base path is calculated would not necessarily resolve the fails. I decided to took a go at this by changing out all code instances of updates.drupal.org and see what happens :)

Status: Needs review » Needs work

The last submitted patch, 4: 3095755-4.patch, failed testing. View results

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new2.09 KB

Fix serialisation format. Curiously there were no other fails though.

tedbow’s picture

@Gábor Hojtsy yep. there are no fails because in all these tests we don't actually confirm the results of the update xml request.

#3074993: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates failed because the XML was different than expected from updates.drupal.org and the test tries process the XML which leads undefined index problems.

+++ b/core/modules/update/src/UpdateFetcher.php
@@ -17,7 +17,7 @@ class UpdateFetcher implements UpdateFetcherInterface {
-  const UPDATE_DEFAULT_URL = 'http://updates.drupal.org/release-history';
+  const UPDATE_DEFAULT_URL = 'http://example.com/release-history';

Changing to example.com will just lead to failed to get updates. which doesn't actually fail test because it doesn't return any XML in a different format

gábor hojtsy’s picture

Hm, none of the tests that should fail check anything about the XML data or the contents of the XML data? Then what do they test about it?

tedbow’s picture

So for example \Drupal\Tests\system\Functional\Update\UpdatePathTestBaseFilledTest::testPathAliasProcessing() fails with patch at #3074993-27: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates.

\Drupal\update\UpdateFetcher::fetchProjectData() is called because cron is run and update_cron() is called. So then \update_calculate_project_update_status() is ultimately called and gets the error

Exception : Notice: Undefined index: version_major
update_calculate_project_update_status()() (Line: 364)

Because it does receive XML from drupal.org but in an unexpected format.

So the test was not specifically testing the XML fetching and the returned XML from drupal.org but the call was being made.

In the patch in #6 the same happens up to \Drupal\update\UpdateFetcher::fetchProjectData() but at that point but

try {
      $data = (string) $this->httpClient
        ->get($url, ['headers' => ['Accept' => 'text/xml']])
        ->getBody();
    }
    catch (RequestException $exception) {
      watchdog_exception('update', $exception);
    }

Gets a 404 and then calls watchdog_exception() this does not fail the test. No XML is fetched so we don't get the same error.

I stepped debugged \Drupal\Tests\system\Functional\Update\UpdatePathTestBaseFilledTest::testPathAliasProcessing() with both patches to be sure. I think it is likely the other 78 fails in #3074993-27: Use "current" in update URLs instead of CORE_COMPATIBILITY to retrieve all future updates are also because update_cron is run. So even when the Drupalci test can't connect to updates.drupal.org the test won't fail because the exception is caught.

gábor hojtsy’s picture

Ah, ok. Thanks for the background. It is clearly more complicated than I expected.

xjm’s picture

Is the correct status for this issue NW?

gábor hojtsy’s picture

Status: Needs review » Needs work

Yes. The uploaded patch was more of a proof of fail and it did not even suffice at that.

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.

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.

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.

dww’s picture

Issue tags: +Bug Smash Initiative

Forgot about this issue, but just re-found it. Tagging to be smashed.

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.

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.

quietone’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is this still valid?

I just disconnected and ran the following tests that extend \Drupal\FunctionalTests\Update\UpdatePathTestBase and tests passed.

  • core/modules/help/tests/src/Functional/HelpNoSearchUpgradeTest.ph
  • core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php
  • core/modules/system/tests/src/Functional/UpdateSystem/PreventDowngradeTest.php