예제 #1
0
/**
* Write out the actual job file
*/
function WriteJob($location, &$test, &$job, $testId)
{
    $ret = false;
    global $error;
    global $locations;
    if ($locations[$location]['relayServer']) {
        // upload the test to a the relay server
        $test['id'] = $testId;
        $ret = SendToRelay($test, $job);
    } else {
        // make sure the work directory exists
        if (!is_dir($test['workdir'])) {
            mkdir($test['workdir'], 0777, true);
        }
        $workDir = $test['workdir'];
        $locationLock = LockLocation($location);
        if (isset($locationLock)) {
            if (isset($test['affinity'])) {
                $test['job'] = "Affinity{$test['affinity']}.{$test['job']}";
            }
            $fileName = $test['job'];
            $file = "{$workDir}/{$fileName}";
            if (file_put_contents($file, $job)) {
                if (AddJobFile($workDir, $fileName, $test['priority'], $test['queue_limit'])) {
                    // store a copy of the job file with the original test in case the test fails and we need to resubmit it
                    $test['job_file'] = realpath($file);
                    if (ValidateTestId($testId)) {
                        $testPath = GetTestPath($testId);
                        if (strlen($testPath)) {
                            $testPath = './' . $testPath;
                            if (!is_dir($testPath)) {
                                mkdir($testPath, 0777, true);
                            }
                            file_put_contents("{$testPath}/test.job", $job);
                        }
                    }
                    $tests = json_decode(file_get_contents("./tmp/{$location}.tests"), true);
                    if (!$tests) {
                        $tests = array();
                    }
                    $testCount = $test['runs'];
                    if (!$test['fvonly']) {
                        $testCount *= 2;
                    }
                    if (array_key_exists('tests', $tests)) {
                        $tests['tests'] += $testCount;
                    } else {
                        $tests['tests'] = $testCount;
                    }
                    file_put_contents("./tmp/{$location}.tests", json_encode($tests));
                    $ret = true;
                } else {
                    unlink($file);
                    $error = "Sorry, that test location already has too many tests pending.  Pleasy try again later.";
                }
            }
            UnlockLocation($locationLock);
        }
    }
    return $ret;
}
예제 #2
0
/**
* Write out the actual job file
*/
function WriteJob($location, &$test, &$job, $testId)
{
    $ret = false;
    global $error;
    global $locations;
    if ($locations[$location]['relayServer']) {
        // upload the test to a the relay server
        $test['id'] = $testId;
        $ret = SendToRelay($test, $job);
    } else {
        // Submit the job locally
        if (AddTestJob($location, $job, $test)) {
            $ret = true;
        } else {
            $error = "Sorry, that test location already has too many tests pending.  Pleasy try again later.";
        }
    }
    return $ret;
}