Skip to content

Commit

Permalink
Merge pull request #187 from phil-davis/testSendToGetLargeContent
Browse files Browse the repository at this point in the history
Allow testSendToGetLargeContent peak memory usage to be specified externally
  • Loading branch information
phil-davis authored Jul 15, 2022
2 parents 87fbcab + 94321c1 commit 4cb5502
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/HTTP/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,24 @@ public function testSendToGetLargeContent()
$this->markTestSkipped('Set an environment value BASEURL to continue');
}

// Allow the peak memory usage limit to be specified externally, if needed.
// When running this test in different environments it may be appropriate to set a different limit.
$maxPeakMemoryUsageEnvVariable = 'SABRE_HTTP_TEST_GET_LARGE_CONTENT_MAX_PEAK_MEMORY_USAGE';
$maxPeakMemoryUsage = \getenv($maxPeakMemoryUsageEnvVariable);
if (false === $maxPeakMemoryUsage) {
$maxPeakMemoryUsage = 60 * pow(1024, 2);
}

$request = new Request('GET', $url);
$client = new Client();
$response = $client->send($request);

$this->assertEquals(200, $response->getStatus());
$this->assertLessThan(60 * pow(1024, 2), memory_get_peak_usage());
$this->assertLessThan(
(int) $maxPeakMemoryUsage,
memory_get_peak_usage(),
"Hint: you can adjust the max peak memory usage allowed for this test by defining env variable $maxPeakMemoryUsageEnvVariable to be the desired max bytes"
);
}

/**
Expand Down

0 comments on commit 4cb5502

Please sign in to comment.