Skip to content
Snippets Groups Projects

Issue #3463351: consolidate OpenTelemetryNodePagePerformanceTest methods.

Closed catch requested to merge issue/drupal-3463351:3463351-consolidate-methods-in into 11.x
Files
5
@@ -4,6 +4,7 @@
namespace Drupal\Tests\demo_umami\FunctionalJavascript;
use Drupal\Core\Cache\Cache;
use Drupal\FunctionalJavascriptTests\PerformanceTestBase;
/**
@@ -20,10 +21,19 @@ class OpenTelemetryFrontPagePerformanceTest extends PerformanceTestBase {
*/
protected $profile = 'demo_umami';
/**
* Tests performance of the Umami demo front page.
*/
public function testFrontPagePerformance(): void {
$this->testFrontPageColdCache();
$this->testFrontPageCoolCache();
$this->testFrontPageHotCache();
}
/**
* Logs front page tracing data with a cold cache.
*/
public function testFrontPageColdCache(): void {
protected function testFrontPageColdCache(): void {
// @todo Chromedriver doesn't collect tracing performance logs for the very
// first request in a test, so warm it up.
// https://www.drupal.org/project/drupal/issues/3379750
@@ -40,7 +50,7 @@ public function testFrontPageColdCache(): void {
*
* Hot here means that all possible caches are warmed.
*/
public function testFrontPageHotCache(): void {
protected function testFrontPageHotCache(): void {
// Request the page twice so that asset aggregates and image derivatives are
// definitely cached in the browser cache. The first response builds the
// file and serves from PHP with private, no-store headers. The second
@@ -76,10 +86,10 @@ public function testFrontPageHotCache(): void {
* Cool here means that 'global' site caches are warm but anything
* specific to the front page is cold.
*/
public function testFrontPageCoolCache(): void {
protected function testFrontPageCoolCache(): void {
// First of all visit the front page to ensure the image style exists.
$this->drupalGet('<front>');
$this->rebuildAll();
$this->clearCaches();
// Now visit a different page to warm non-route-specific caches.
$this->drupalGet('user/login');
$this->collectPerformanceData(function () {
@@ -87,4 +97,13 @@ public function testFrontPageCoolCache(): void {
}, 'umamiFrontPageCoolCache');
}
/**
* Clear caches.
*/
protected function clearCaches(): void {
foreach (Cache::getBins() as $bin) {
$bin->deleteAll();
}
}
}
Loading