Skip to content
Permalink
Browse files

Fix to Health Check crash if HTTP downloads fail multiple times

  • Loading branch information...
chrisgraham committed Jun 26, 2019
1 parent 60bf1e6 commit 9b5f73c58b75b9604bc86125090a1766b6d322c2
Showing with 8 additions and 2 deletions.
  1. +8 −2 sources_custom/hooks/systems/health_checks/network.php
@@ -124,6 +124,9 @@ public function testTransferLatency($check_context, $manual_checks = false, $aut
$threshold = floatval(get_option('hc_transfer_latency_threshold'));
$ok = false;
$time = null;
for ($i = 0; $i < 3; $i++) { // Try a few times in case of some temporary network issue or Google issue
$time_before = microtime(true);
@@ -151,7 +154,7 @@ public function testTransferLatency($check_context, $manual_checks = false, $aut
}
}
$this->assert_true($ok, 'Slow transfer latency @ ' . float_format($time) . ' seconds (downloading Google home page)');
$this->assert_true($ok, 'Slow transfer latency @ ' . (($time === null) ? 'N/A' : float_format($time)) . ' seconds (downloading Google home page)');
}
/**
@@ -179,6 +182,9 @@ public function testTransferSpeed($check_context, $manual_checks = false, $autom
$data_to_send = str_repeat(file_get_contents($test_file_path), 5);
$post_params = array('test_data' => $data_to_send);
$ok = false;
$megabits_per_second = null;
for ($i = 0; $i < 3; $i++) { // Try a few times in case of some temporary network issue or compo.sr issue
$time_before = microtime(true);
@@ -210,6 +216,6 @@ public function testTransferSpeed($check_context, $manual_checks = false, $autom
}
}
$this->assert_true($ok, 'Slow speed transfering data to a remote machine @ ' . float_format($megabits_per_second) . ' Megabits per second');
$this->assert_true($ok, 'Slow speed transfering data to a remote machine @ ' . (($megabits_per_second === null) ? 'N/A' : float_format($megabits_per_second)) . ' Megabits per second');
}
}

0 comments on commit 9b5f73c

Please sign in to comment.
You can’t perform that action at this time.