diff --git a/hphp/test/server/debugger/tests/runTest1.php b/hphp/test/server/debugger/tests/runTest1.php index c38a6ac74..a20cdc06e 100644 --- a/hphp/test/server/debugger/tests/runTest1.php +++ b/hphp/test/server/debugger/tests/runTest1.php @@ -7,10 +7,10 @@ function test1Controller($hphpdOutput, $hphpdProcessId, $serverPort) { waitForClientToOutput($hphpdOutput, "Waiting for server response"); $url = "http://".php_uname('n').':'.$serverPort.'/test1.php'; echo "Requesting test1.php\n"; - request($url, 1); // proceed without waiting for a response + request($url, 10); // proceed without waiting for a response // Send ctrl-c to client, which is waiting for a hung server - waitForClientToOutput($hphpdOutput, "Break at cls::pubHardBreak()"); + waitForClientToOutput($hphpdOutput, "Break at cls::pubHardBreak()", $url); waitForClientToOutput($hphpdOutput, "Waiting for server response"); sleep(2); // give server a chance to get itself in the enless loop echo "sending SIGINT to the debugger client.\n"; diff --git a/hphp/test/server/debugger/tests/test_base.php b/hphp/test/server/debugger/tests/test_base.php index 7321b21d8..8d19c9ae2 100644 --- a/hphp/test/server/debugger/tests/test_base.php +++ b/hphp/test/server/debugger/tests/test_base.php @@ -41,6 +41,10 @@ function dumpLogFilesToStdoutAndDie() { readfile("/tmp/hphpd_test_sandbox_access.log"); echo "\n"; error_log('-------------------------------------------'); + error_log("Contents of '/tmp/hphpd_curl$test_run_id.log'"); + readfile("/tmp/hphpd_curl$test_run_id.log"); + echo "\n"; + error_log('-------------------------------------------'); throw new Exception("test failed"); } @@ -102,7 +106,10 @@ function startServer($serverPort, $adminPort, $debugPort) { } function waitForServerToGetGoing($serverPort) { - $url = "http://".php_uname('n').':'.$serverPort.'/hello.php'; + global $test_run_id; + + $host = php_uname('n'); + $url = "http://$host:$serverPort/hello.php"; $r = ""; for ($i = 1; $i <= 20; $i++) { sleep(1); @@ -112,6 +119,9 @@ function waitForServerToGetGoing($serverPort) { if ($r !== "Hello, World!") { tlog('Server is not responding.'); + //repeat request with error trace to log file. + exec("curl --trace-ascii /tmp/hphpd_curl$test_run_id.log ". + "--header 'Host: hphpd.debugger.$host' --url $url"); dumpLogFilesToStdoutAndDie(); } } @@ -227,8 +237,8 @@ function killChildren($pid) { $childIds = exec("pgrep -f -d , -P $pid"); foreach (explode(",", $childIds) as $cid) { if (!$cid) continue; + tlog("killing ".exec("ps -f -p ".$cid)); killChildren($cid); - error_log("killing $cid"); posix_kill($cid, SIGKILL); } } @@ -246,7 +256,9 @@ function getClientProcessId($pipe) { tlog("done reading client output for client process id"); } -function waitForClientToOutput($pipe, $string1, $retryCount = 20) { +function waitForClientToOutput($pipe, $string1, $url = "", $retryCount = 20) { + global $test_run_id; + tlog("reading client output"); $rc = $retryCount; while (!feof($pipe)) { @@ -255,6 +267,13 @@ function waitForClientToOutput($pipe, $string1, $retryCount = 20) { if (strpos($clientOutput, ".....Debugger client still waiting for server response.....") === 0) { if (--$rc > 0) continue; + tlog("refetching $url"); + if ($url != "") { + //repeat request with error trace to log file. + $host = php_uname('n'); + exec("curl --trace-ascii /tmp/hphpd_curl$test_run_id.log ". + "--header 'Host: hphpd.debugger.$host' --url $url"); + } dumpLogFilesToStdoutAndDie(); } echo $clientOutput;