Verified Commit b7f5b83b authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3406707 by catch: Increase range of db query assertions

(cherry picked from commit 4b5cc115)
parent 3607f960
Loading
Loading
Loading
Loading
Loading
+21 −15
Original line number Diff line number Diff line
@@ -53,16 +53,16 @@ public function testAnonymous() {
      $this->drupalGet('');
    });
    $this->assertNoJavaScript($performance_data);
    // This test observes a variable number of cache gets and sets, so to avoid
    // random test failures, assert greater than equal the highest and lowest
    // number of observed during test runs.
    // This test observes a variable number of cache operations and database
    // queries, so to avoid  random test failures, assert greater than equal
    // the highest and lowest number of observed during test runs.
    // See https://www.drupal.org/project/drupal/issues/3402610
    $this->assertGreaterThanOrEqual(58, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(66, $performance_data->getQueryCount());

    $this->assertLessThanOrEqual(67, $performance_data->getQueryCount());
    $this->assertGreaterThanOrEqual(129, $performance_data->getCacheGetCount());
    $this->assertLessThanOrEqual(132, $performance_data->getCacheGetCount());
    $this->assertSame(59, $performance_data->getCacheSetCount());
    $this->assertGreaterThanOrEqual(59, $performance_data->getCacheSetCount());
    $this->assertLessThanOrEqual(68, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());

    // Test node page.
@@ -70,15 +70,18 @@ public function testAnonymous() {
      $this->drupalGet('node/1');
    });
    $this->assertNoJavaScript($performance_data);
    $this->assertSame(38, $performance_data->getQueryCount());

    // This test observes a variable number of cache gets and sets, so to avoid
    // random test failures, assert greater than equal the highest and lowest
    // number of queries observed during test runs.
    // This test observes a variable number of cache operations and database
    // queries, so to avoid  random test failures, assert greater than equal
    // the highest and lowest number of observed during test runs.
    // See https://www.drupal.org/project/drupal/issues/3402610

    $this->assertGreaterThanOrEqual(38, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(39, $performance_data->getQueryCount());
    $this->assertGreaterThanOrEqual(87, $performance_data->getCacheGetCount());
    $this->assertLessThanOrEqual(88, $performance_data->getCacheGetCount());
    $this->assertSame(20, $performance_data->getCacheSetCount());
    $this->assertGreaterThanOrEqual(20, $performance_data->getCacheSetCount());
    $this->assertLessThanOrEqual(28, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());

    // Test user profile page.
@@ -95,7 +98,8 @@ public function testAnonymous() {
    // See https://www.drupal.org/project/drupal/issues/3402610
    $this->assertGreaterThanOrEqual(74, $performance_data->getCacheGetCount());
    $this->assertLessThanOrEqual(80, $performance_data->getCacheGetCount());
    $this->assertSame(19, $performance_data->getCacheSetCount());
    $this->assertGreaterThanOrEqual(19, $performance_data->getCacheSetCount());
    $this->assertLessThanOrEqual(27, $performance_data->getCacheSetCount());
    $this->assertSame(0, $performance_data->getCacheDeleteCount());
  }

@@ -125,10 +129,11 @@ public function testLogin(): void {
    // random test failures, assert greater than equal the highest and lowest
    // number of queries observed during test runs.
    // See https://www.drupal.org/project/drupal/issues/3402610
    $this->assertLessThanOrEqual(40, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(42, $performance_data->getQueryCount());
    $this->assertGreaterThanOrEqual(39, $performance_data->getQueryCount());
    $this->assertSame(28, $performance_data->getCacheGetCount());
    $this->assertSame(1, $performance_data->getCacheSetCount());
    $this->assertLessThanOrEqual(2, $performance_data->getCacheSetCount());
    $this->assertGreaterThanOrEqual(1, $performance_data->getCacheSetCount());
    $this->assertSame(1, $performance_data->getCacheDeleteCount());
  }

@@ -156,7 +161,8 @@ public function testLoginBlock(): void {
    $performance_data = $this->collectPerformanceData(function () use ($account) {
      $this->submitLoginForm($account);
    });
    $this->assertSame(48, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(51, $performance_data->getQueryCount());
    $this->assertGreaterThanOrEqual(48, $performance_data->getQueryCount());
    $this->assertSame(30, $performance_data->getCacheGetCount());

    // This test observes a variable number of cache sets, so to avoid random