Skip to content
Snippets Groups Projects
Commit 0886b28a authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3291147 by phenaproxima, tedbow, effulgentsia, heddn: Successfully...

Issue #3291147 by phenaproxima, tedbow, effulgentsia, heddn: Successfully applying an update puts the remainder of the request into an unreliable state
parent 09df1539
No related branches found
Tags 11-127002
No related merge requests found
...@@ -42,6 +42,19 @@ abstract class UpdateTestBase extends TemplateProjectTestBase { ...@@ -42,6 +42,19 @@ abstract class UpdateTestBase extends TemplateProjectTestBase {
'automatic_updates_test_cron', 'automatic_updates_test_cron',
'automatic_updates_test_release_history', 'automatic_updates_test_release_history',
]); ]);
// When checking for updates, we need to be able to make sub-requests, but
// the built-in PHP server is single-threaded. Therefore, open a second
// server instance on another port, which will serve the metadata about
// available updates.
$port = $this->findAvailablePort();
$this->metadataServer = $this->instantiateServer($port);
$code = <<<END
\$config['automatic_updates.settings']['cron_port'] = $port;
\$config['update.settings']['fetch']['url'] = 'http://localhost:$port/test-release-history';
END;
$this->writeSettings($code);
} }
/** /**
...@@ -54,22 +67,7 @@ abstract class UpdateTestBase extends TemplateProjectTestBase { ...@@ -54,22 +67,7 @@ abstract class UpdateTestBase extends TemplateProjectTestBase {
*/ */
protected function setReleaseMetadata(array $xml_map): void { protected function setReleaseMetadata(array $xml_map): void {
$xml_map = var_export($xml_map, TRUE); $xml_map = var_export($xml_map, TRUE);
$code = <<<END $this->writeSettings("\$config['update_test.settings']['xml_map'] = $xml_map;");
\$config['update_test.settings']['xml_map'] = $xml_map;
END;
// When checking for updates, we need to be able to make sub-requests, but
// the built-in PHP server is single-threaded. Therefore, if needed, open a
// second server instance on another port, which will serve the metadata
// about available updates.
if (empty($this->metadataServer)) {
$port = $this->findAvailablePort();
$this->metadataServer = $this->instantiateServer($port);
$code .= <<<END
\$config['update.settings']['fetch']['url'] = 'http://localhost:$port/test-release-history';
END;
}
$this->writeSettings($code);
} }
/** /**
......
...@@ -5,6 +5,7 @@ namespace Drupal\Tests\automatic_updates\Kernel; ...@@ -5,6 +5,7 @@ namespace Drupal\Tests\automatic_updates\Kernel;
use Drupal\automatic_updates\CronUpdater; use Drupal\automatic_updates\CronUpdater;
use Drupal\automatic_updates\Updater; use Drupal\automatic_updates\Updater;
use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Url;
use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait; use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait;
use Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase; use Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase;
use Drupal\Tests\package_manager\Kernel\TestStageTrait; use Drupal\Tests\package_manager\Kernel\TestStageTrait;
...@@ -53,6 +54,11 @@ abstract class AutomaticUpdatesKernelTestBase extends PackageManagerKernelTestBa ...@@ -53,6 +54,11 @@ abstract class AutomaticUpdatesKernelTestBase extends PackageManagerKernelTestBa
if (in_array('package_manager.validator.file_system', $this->disableValidators, TRUE)) { if (in_array('package_manager.validator.file_system', $this->disableValidators, TRUE)) {
$this->disableValidators[] = 'automatic_updates.validator.file_system_permissions'; $this->disableValidators[] = 'automatic_updates.validator.file_system_permissions';
} }
// If Package Manager's symlink validator is disabled, also disable the
// Automatic Updates validator which wraps it.
if (in_array('package_manager.validator.symlink', $this->disableValidators, TRUE)) {
$this->disableValidators[] = 'automatic_updates.validator.symlink';
}
// Always disable the Xdebug validator to allow test to run with Xdebug on. // Always disable the Xdebug validator to allow test to run with Xdebug on.
$this->disableValidators[] = 'automatic_updates.validator.xdebug'; $this->disableValidators[] = 'automatic_updates.validator.xdebug';
parent::setUp(); parent::setUp();
...@@ -168,4 +174,14 @@ class TestCronUpdater extends CronUpdater { ...@@ -168,4 +174,14 @@ class TestCronUpdater extends CronUpdater {
use TestStageTrait; use TestStageTrait;
/**
* {@inheritdoc}
*/
protected function triggerPostApply(Url $url): void {
// Subrequests don't work in kernel tests, so just call the post-apply
// handler directly.
$parameters = $url->getRouteParameters();
$this->handlePostApply($parameters['stage_id'], $parameters['installed_version'], $parameters['target_version']);
}
} }
...@@ -60,6 +60,9 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase { ...@@ -60,6 +60,9 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
$this->disableValidators[] = 'automatic_updates.validator.staged_database_updates'; $this->disableValidators[] = 'automatic_updates.validator.staged_database_updates';
$this->disableValidators[] = 'automatic_updates.staged_projects_validator'; $this->disableValidators[] = 'automatic_updates.staged_projects_validator';
$this->disableValidators[] = 'automatic_updates.validator.scaffold_file_permissions'; $this->disableValidators[] = 'automatic_updates.validator.scaffold_file_permissions';
// Since staging operations are bypassed, ignore any symbolic links in the
// running code base.
$this->disableValidators[] = 'package_manager.validator.symlink';
parent::setUp(); parent::setUp();
$this->logger = new TestLogger(); $this->logger = new TestLogger();
......
...@@ -257,6 +257,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { ...@@ -257,6 +257,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
$updater->begin(['drupal' => '9.8.1']); $updater->begin(['drupal' => '9.8.1']);
$updater->stage(); $updater->stage();
$updater->apply(); $updater->apply();
$updater->postApply();
$updater->destroy(); $updater->destroy();
// The readiness validation manager shouldn't have any stored results. // The readiness validation manager shouldn't have any stored results.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment