MDL-48624 behat: Added extended timeout to ensure step pass
following_should_download_between_and_bytes step sometimes fails because of server speed. Added extended timout ensuring they wait enough before failing. Also, not calling force download while running behat site
This commit is contained in:
@@ -1220,7 +1220,20 @@ class behat_general extends behat_base {
|
||||
* @param number $expectedsize the expected file size in bytes.
|
||||
*/
|
||||
public function following_should_download_bytes($link, $expectedsize) {
|
||||
$result = $this->download_file_from_link($link);
|
||||
$exception = new ExpectationException('Error while downloading data from ' . $link, $this->getSession());
|
||||
|
||||
// It will stop spinning once file is downloaded or time out.
|
||||
$result = $this->spin(
|
||||
function($context, $args) {
|
||||
$link = $args['link'];
|
||||
return $this->download_file_from_link($link);
|
||||
},
|
||||
array('link' => $link),
|
||||
self::EXTENDED_TIMEOUT,
|
||||
$exception
|
||||
);
|
||||
|
||||
// Check download size.
|
||||
$actualsize = (int)strlen($result);
|
||||
if ($actualsize !== (int)$expectedsize) {
|
||||
throw new ExpectationException('Downloaded data was ' . $actualsize .
|
||||
@@ -1249,7 +1262,21 @@ class behat_general extends behat_base {
|
||||
list($minexpectedsize, $maxexpectedsize) = array($maxexpectedsize, $minexpectedsize);
|
||||
}
|
||||
|
||||
$result = $this->download_file_from_link($link);
|
||||
$exception = new ExpectationException('Error while downloading data from ' . $link, $this->getSession());
|
||||
|
||||
// It will stop spinning once file is downloaded or time out.
|
||||
$result = $this->spin(
|
||||
function($context, $args) {
|
||||
$link = $args['link'];
|
||||
|
||||
return $this->download_file_from_link($link);
|
||||
},
|
||||
array('link' => $link),
|
||||
self::EXTENDED_TIMEOUT,
|
||||
$exception
|
||||
);
|
||||
|
||||
// Check download size.
|
||||
$actualsize = (int)strlen($result);
|
||||
if ($actualsize < $minexpectedsize || $actualsize > $maxexpectedsize) {
|
||||
throw new ExpectationException('Downloaded data was ' . $actualsize .
|
||||
|
||||
Reference in New Issue
Block a user