Exemple #1
0
function process_latest_five_builds($db)
{
    $build_rows = $db->query_and_fetch_all('SELECT id, builder FROM builds
        WHERE start_time IS NOT NULL AND is_processed = FALSE ORDER BY end_time DESC LIMIT 5');
    if (!$build_rows) {
        return FALSE;
    }
    foreach ($build_rows as $row) {
        echo "Build {$row['id']} for builder {$row['builder']}:\n";
        echo "    Updating flakiness...";
        flush();
        $start_time = microtime(true);
        update_flakiness_after_inserting_build($db, $row['id']);
        $time = microtime(true) - $start_time;
        echo "({$time} s)\n";
        echo "    Generating JSONs...";
        flush();
        $start_time = microtime(true);
        $generator = new ResultsJSONGenerator($db, $row['builder']);
        $generator->generate('wrongexpectations');
        $generator->generate('flaky');
        $time = microtime(true) - $start_time;
        echo "({$time} s)\n";
        flush();
        $db->query_and_get_affected_rows('UPDATE builds SET is_processed = TRUE where id = $1', array($row['id']));
        sleep(1);
    }
    return TRUE;
}
Exemple #2
0
function main()
{
    require_existence_of($_GET, array('builder' => '/^[A-Za-z0-9 \\(\\)\\-_]+$/'));
    $builder_param = $_GET['builder'];
    $db = connect();
    $builder_row = $db->select_first_row('builders', NULL, array('name' => $builder_param));
    if (!$builder_row) {
        $builder_row = $db->select_first_row('builders', NULL, array('id' => $builder_param));
        if (!$builder_row) {
            exit_with_error('BuilderNotFound');
        }
    }
    $builder_id = $builder_row['id'];
    $generator = new ResultsJSONGenerator($db, $builder_id);
    if (!$generator->generate('wrongexpectations')) {
        exit_with_error('ResultsWithWrongExpectationsNotFound', array('builderId' => $builder_id));
    } else {
        if (!$generator->generate('flaky')) {
            exit_with_error('FlakyResultsNotFound', array('builderId' => $builder_id));
        } else {
            exit_with_success();
        }
    }
}
Exemple #3
0
function main()
{
    require_existence_of($_GET, array('builder' => '/^[A-Za-z0-9 \\(\\)\\-_]+$/'));
    $builder_name = $_GET['builder'];
    $db = connect();
    $builder_row = $db->select_first_row('builders', NULL, array('name' => $builder_name));
    if (!$builder_row) {
        exit_with_error('BuilderNotFound');
    }
    $builder_id = $builder_row['id'];
    $generator = new ResultsJSONGenerator($db, $builder_id);
    if ($generator->generate()) {
        exit_with_success();
    } else {
        exit_with_error('ResultsNotFound');
    }
}
Exemple #4
0
$start_time = float_to_time($_POST['start_time']);
$end_time = float_to_time($_POST['end_time']);
$builder_id = add_builder($db, $master, $builder_name);
if (!$builder_id) {
    exit_with_error('FailedToInsertBuilder', array('master' => $master, 'builderName' => $builder_name));
}
$build_id = add_build($db, $builder_id, $build_number);
if (!$build_id) {
    exit_with_error('FailedToInsertBuild', array('builderId' => $builder_id, 'buildNumber' => $build_number));
}
foreach ($revisions as $repository_name => $revision_data) {
    $repository_id = $db->select_or_insert_row('repositories', NULL, array('name' => $repository_name));
    if (!$repository_id) {
        exit_with_error('FailedToInsertRepository', array('name' => $repository_name));
    }
    $revision_data = array('repository' => $repository_id, 'build' => $build_id, 'value' => $revision_data['revision'], 'time' => array_get($revision_data, 'timestamp'));
    $db->select_or_insert_row('build_revisions', NULL, array('repository' => $repository_id, 'build' => $build_id), $revision_data, 'value') or exit_with_error('FailedToInsertRevision', array('name' => $repository_name, 'data' => $revision_data));
}
$slave_id = add_slave($db, $_POST['build_slave']);
if (!store_test_results($db, $test_results, $build_id, $start_time, $end_time, $slave_id)) {
    exit_with_error('FailedToStoreResults', array('buildId' => $build_id));
}
echo_success();
@ob_end_flush();
flush();
if (function_exists('fastcgi_finish_request')) {
    fastcgi_finish_request();
}
$generator = new ResultsJSONGenerator($db, $builder_id);
$generator->generate();