public function testJsonResultArrayGeneration()
 {
     global $SINGLESTEP_JSON_RESULT_ARRAY;
     $this->tempDir = TestUtil::extractToTemp(__DIR__ . '/data/singlestepResults.zip');
     $testInfo = TestInfo::fromFiles($this->tempDir . '/singlestepResults');
     $imitatedPath = $this->imitatedResultPath($testInfo->getId());
     // we need to move the results to a directory structure that equal to the real one.
     // Then, we can go into the parent directory, so the relatece "testRoot" is the same as it would be in production
     // This is important, as during XML generation, some URLs contain the test path
     mkdir($this->tempDir . $imitatedPath, 0777, true);
     rename($this->tempDir . '/singlestepResults', $this->tempDir . $imitatedPath);
     $this->orgDir = getcwd();
     chdir($this->tempDir);
     $testRoot = "." . $imitatedPath;
     $testInfo = TestInfo::fromFiles($testRoot);
     $testResults = TestResults::fromFiles($testInfo);
     $jsonGenerator = new JsonResultGenerator($testInfo, "http://wpt-test-vm", new FileHandler());
     $resultArray = $jsonGenerator->resultDataArray($testResults, "loadTime");
     $this->assertThat($resultArray, new IsArraySubsetConstraint($SINGLESTEP_JSON_RESULT_ARRAY));
 }
 public function testCompleteXmlGeneration()
 {
     $this->tempDir = TestUtil::extractToTemp(__DIR__ . '/data/singlestepResults.zip');
     $testInfo = TestInfo::fromFiles($this->tempDir . '/singlestepResults');
     $imitatedPath = $this->imitatedResultPath($testInfo->getId());
     // we need to move the results to a directory structure that equal to the real one.
     // Then, we can go into the parent directory, so the relatece "testRoot" is the same as it would be in production
     // This is important, as during XML generation, some URLs contain the test path
     mkdir($this->tempDir . $imitatedPath, 0777, true);
     rename($this->tempDir . '/singlestepResults', $this->tempDir . $imitatedPath);
     $this->orgDir = getcwd();
     chdir($this->tempDir);
     $testRoot = "." . $imitatedPath;
     $testInfo = TestInfo::fromFiles($testRoot);
     $expectedXmlFile = __DIR__ . '/data/singlestepXmlResult.xml.gz';
     $testResults = TestResults::fromFiles($testInfo);
     $xmlGenerator = new XmlResultGenerator($testInfo, "http://wpt-test-vm", new FileHandler(), $this->allAdditionalInfo, true);
     $xmlGenerator->printAllResults($testResults, "loadTime", null);
     $this->assertThat(ob_get_contents(), IsCompatibleXMLConstraint::fromFile($expectedXmlFile));
 }
Example #3
0
     }
     $test['url'] = $info['url'];
     if (isset($info['medianMetric'])) {
         $test_median_metric = $info['medianMetric'];
     }
 }
 $testInfo = parse_ini_file("./{$test['path']}/testinfo.ini", true);
 if ($testInfo !== FALSE) {
     if (array_key_exists('test', $testInfo) && array_key_exists('location', $testInfo['test'])) {
         $test['location'] = $testInfo['test']['location'];
     }
     if (isset($testInfo['test']) && isset($testInfo['test']['completeTime'])) {
         $test['done'] = true;
         $testInfoObject = TestInfo::fromFiles("./" . $test['path']);
         if (!array_key_exists('run', $test) || !$test['run']) {
             $testResults = TestResults::fromFiles($testInfoObject);
             $test['run'] = $testResults->getMedianRunNumber($test_median_metric, $test['cached']);
             $runResults = $testResults->getRunResult($test['run'], $test['cached']);
             $stepResult = $runResults->getStepResult($test['step']);
         } else {
             $stepResult = TestStepResult::fromFiles($testInfoObject, $test['run'], $test['cached'], $test['step']);
         }
         $test['stepResult'] = $stepResult;
         $test['aft'] = (int) $stepResult->getMetric('aft');
         $loadTime = $stepResult->getMetric('fullyLoaded');
         if (isset($loadTime) && (!isset($fastest) || $loadTime < $fastest)) {
             $fastest = $loadTime;
         }
         // figure out the real end time (in ms)
         if (isset($test['end'])) {
             $visualComplete = $stepResult->getMetric("visualComplte");
Example #4
0
$pagespeed = 0;
if (array_key_exists('pagespeed', $_REQUEST)) {
    $pagespeed = (int) $_REQUEST['pagespeed'];
}
if (isset($test['test']) && $test['test']['batch']) {
    BatchResult($id, $testPath);
} else {
    // see if the test is actually finished
    $status = GetTestStatus($id);
    if (isset($test['test']['completeTime'])) {
        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
        $host = $_SERVER['HTTP_HOST'];
        $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
        $path = substr($testPath, 1);
        $testInfo = TestInfo::fromValues($id, $testPath, $test);
        $testResults = TestResults::fromFiles($testInfo);
        $msLoad = microtime(true);
        // if we don't have an url, try to get it from the page results
        if (!strlen($url)) {
            $url = $testResults->getUrlFromRun();
        }
        $additionalInfo = array();
        if ($pagespeed) {
            $additionalInfo[] = XmlResultGenerator::INFO_PAGESPEED;
        }
        if (array_key_exists("requests", $_REQUEST) && $_REQUEST["requests"]) {
            $additionalInfo[] = XmlResultGenerator::INFO_MEDIAN_REQUESTS;
            if ($_REQUEST["requests"] != "median") {
                $additionalInfo[] = XmlResultGenerator::INFO_REQUESTS;
            }
        }