Verified Commit 9a2af767 authored by Dave Long's avatar Dave Long
Browse files

test: #3616193 Rationalise cache warming in OpenTelemetryPerformanceTest

By: catch
By: berdir
parent 4ef3e3b7
Loading
Loading
Loading
Loading
+13 −28
Changes for core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryPerformanceTest.php: 13 added lines, 28 removed lines.
Original line number Diff line number Diff line
@@ -68,11 +68,9 @@ protected function testNodePageColdCache(): void {
   * Hot here means that all possible caches are warmed.
   */
  protected function testNodePageHotCache(): void {
    // Request the page twice so that asset aggregates are definitely cached in
    // the browser cache.
    // The node/1 asset aggregates and image styles have already been warmed by
    // ::testNodePageColdCache().
    $this->drupalGet('node/1');
    $this->drupalGet('node/1');

    $performance_data = $this->collectPerformanceData(function () {
      $this->drupalGet('node/1');
    }, 'umamiNodePageHotCache');
@@ -88,10 +86,9 @@ protected function testNodePageHotCache(): void {
   * specific to the route or path is cold.
   */
  protected function testNodePageCoolCache(): void {
    // First of all visit the node page to ensure the image style exists.
    $this->drupalGet('node/1');
    // The node/1 asset aggregates and image styles have already been warmed by
    // ::testNodePageColdCache().
    $this->clearCaches();
    // Now visit a non-node page to warm non-route-specific caches.
    $this->drupalGet('user/login');
    $performance_data = $this->collectPerformanceData(function () {
      $this->drupalGet('node/1');
@@ -108,10 +105,8 @@ protected function testNodePageCoolCache(): void {
   * warm but caches specific to this particular node/path are not.
   */
  protected function testNodePageWarmCache(): void {
    // First of all visit the node page to ensure the image style exists.
    $this->drupalGet('node/1');
    // Allow time for the image style and asset aggregate requests to finish.
    sleep(1);
    // The node/1 asset aggregates and image styles have already been warmed by
    // ::testNodePageColdCache().
    $this->clearCaches();
    // Now visit a different node page to warm non-path-specific caches.
    $this->drupalGet('node/2');
@@ -130,12 +125,11 @@ protected function testNodePageWarmCache(): void {
   * Logs front page tracing data with a cold cache.
   */
  protected function testFrontPageColdCache(): void {
    // Request the front page twice then clear caches, this allows asset
    // aggregate requests to complete so they are excluded from the performance
    // test itself. Including the asset aggregates would lead to
    // a non-deterministic test since they happen in parallel and therefore post
    // response tasks run in different orders each time.
    $this->drupalGet('<front>');
    // Request the front page then clear caches, this allows asset aggregate
    // requests to complete so they are excluded from the performance test
    // itself. Including the asset aggregates would lead to a non-deterministic
    // test since they happen in parallel and therefore post response tasks run
    // in different orders each time.
    $this->drupalGet('<front>');
    sleep(2);
    $this->clearCaches();
@@ -153,14 +147,7 @@ protected function testFrontPageColdCache(): void {
   * Hot here means that all possible caches are warmed.
   */
  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
    // request will get the file served directly from disk by the browser with
    // cacheable headers, so only the third request actually has the files
    // in the browser cache.
    $this->drupalGet('<front>');
    $this->drupalGet('<front>');
    // The front page has already been warmed by ::testFrontPageCoolCache();
    $performance_data = $this->collectPerformanceData(function () {
      $this->drupalGet('<front>');
    }, 'umamiFrontPageHotCache');
@@ -176,9 +163,7 @@ protected function testFrontPageHotCache(): void {
   * specific to the front page is cold.
   */
  protected function testFrontPageCoolCache(): void {
    // First of all visit the front page to ensure the image style exists.
    $this->drupalGet('<front>');
    sleep(2);
    // The front page has already been warmed by ::testFrontPageColdCache().
    $this->clearCaches();
    // Now visit a different page to warm non-route-specific caches.
    $this->drupalGet('user/login');