/**
  * Statement execution supports fallthrough retry policy (read exception).
  *
  * This test will ensure that the PHP driver supports the ability to
  * provide any exception that occurs  when executing statements. This test
  * will ensure that a ReadTimeoutException occurs when a consistency level
  * cannot be achieved.
  *
  * @test
  * @ticket PHP-60
  *
  * @cassandra-version-2.0
  *
  * @expectedException \Cassandra\Exception\UnavailableException
  * @expectedExceptionMessageRegExp |Cannot achieve consistency level .*|
  */
 public function testFallThroughPolicyRead()
 {
     // Create the retry policy (RF = 3 with 1 node)
     $policy = new RetryPolicy\Fallthrough();
     // Iterate over each statement type
     foreach (range(1, 3) as $statementType) {
         // Determine if the statement type should be skipped
         if ($statementType == self::BATCH_STATEMENT && version_compare(\Cassandra::CPP_DRIVER_VERSION, "2.2.3") < 0) {
             if (Integration::isDebug()) {
                 fprintf(STDOUT, "Skipping Batch Statements in %s: Issue fixed in DataStax C/C++ v2.2.3" . PHP_EOL, $this->getName());
             }
         } else {
             // Create an exception during read
             $this->insert($statementType, $policy, 0, self::NUMBER_OF_INSERTS, \Cassandra::CONSISTENCY_ONE);
             $this->assert($policy, 0, self::NUMBER_OF_INSERTS, \Cassandra::CONSISTENCY_ALL);
         }
     }
 }
 /**
  * Page through the results while validating no memory leaks exists
  *
  * @param $start Starting memory value
  * @return int Number of rows visited
  */
 private function validatePageResults($rows)
 {
     // Get the starting memory usage
     $start = memory_get_usage() / 1024;
     if (Integration::isDebug() && Integration::isVerbose()) {
         fprintf(STDOUT, "Start Usage: %dkb" . PHP_EOL, $start);
     }
     // Page over each result set and count the number of rows visited
     $count = $rows->count();
     while ($rows = $rows->nextPage()) {
         if ($rows->count() != 0) {
             $count += $rows->count();
             if (Integration::isDebug() && Integration::isVerbose()) {
                 fprintf(STDOUT, "Page %d: Current memory usage is %dkb" . PHP_EOL, $count / 2, memory_get_usage() / 1024 - $start);
             }
         }
     }
     // Get the final memory usage (and apply a tolerance to compensate for GC)
     $end = memory_get_usage() / 1024;
     if (Integration::isDebug() && Integration::isVerbose()) {
         fprintf(STDOUT, "End Usage: %dkb [%dkb]" . PHP_EOL, $end, $end - $start);
     }
     $difference = $end - $start - 20;
     // 20KB tolerance
     $this->assertLessThanOrEqual(0, $difference);
     // Return the number of rows visited
     return $count;
 }