diff --git a/core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php b/core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php index 2e3597ea72946db3496584fc84945d0baac60382..87778095200083ca97f0e52551611c028859c81e 100644 --- a/core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +++ b/core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php @@ -20,10 +20,23 @@ class OpenTelemetryNodePagePerformanceTest extends PerformanceTestBase { */ protected $profile = 'demo_umami'; + /** + * Test canonical node page performance with various cache permutations. + */ + public function testNodePage(): void { + $this->testNodePageColdCache(); + sleep(1); + $this->testNodePageCoolCache(); + sleep(1); + $this->testNodePageWarmCache(); + sleep(1); + $this->testNodePageHotCache(); + } + /** * Logs node page tracing data with a cold cache. */ - public function testNodePageColdCache(): void { + protected function testNodePageColdCache(): 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 +53,7 @@ public function testNodePageColdCache(): void { * * Hot here means that all possible caches are warmed. */ - public function testNodePageHotCache(): void { + protected function testNodePageHotCache(): void { // Request the page twice so that asset aggregates are definitely cached in // the browser cache. $this->drupalGet('node/1'); @@ -64,7 +77,7 @@ public function testNodePageHotCache(): void { * Cool here means that 'global' site caches are warm but anything * specific to the route or path is cold. */ - public function testNodePageCoolCache(): void { + protected function testNodePageCoolCache(): void { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); @@ -82,7 +95,7 @@ public function testNodePageCoolCache(): void { * Warm here means that 'global' site caches and route-specific caches are * warm but caches specific to this particular node/path are not. */ - public function testNodePageWarmCache(): void { + protected function testNodePageWarmCache(): void { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); diff --git a/core/tests/Drupal/Tests/PerformanceTestTrait.php b/core/tests/Drupal/Tests/PerformanceTestTrait.php index 3cecbd18f05ba57f1ce1f48ea18aaac1f39954d1..3476462b20f878174bfb347647617f849ecbfd6c 100644 --- a/core/tests/Drupal/Tests/PerformanceTestTrait.php +++ b/core/tests/Drupal/Tests/PerformanceTestTrait.php @@ -103,6 +103,7 @@ public function collectPerformanceData(callable $callable, ?string $service_name // no performance data logged by the child request within one second, that // this means everything has finished. $collection = \Drupal::keyValue('performance_test'); + sleep(1); while ($collection->get('performance_test_data')) { $collection->deleteAll(); sleep(1); @@ -110,7 +111,6 @@ public function collectPerformanceData(callable $callable, ?string $service_name $session = $this->getSession(); $session->getDriver()->getWebDriverSession()->log('performance'); - $collection = \Drupal::keyValue('performance_test'); $collection->deleteAll(); $return = $callable(); $performance_data = $this->processChromeDriverPerformanceLogs($service_name);