Exemplo n.º 1
0
function store_results($db, $master, $builder_name, $build_number, $start_time, $end_time, $revisions, $json_path)
{
    $test_results = fetch_and_parse_test_results_json($json_path);
    if (!$test_results) {
        exit_with_error('InvalidResultsJSON');
    }
    $builder_id = add_builder($db, $master, $builder_name);
    if (!$builder_id) {
        exit_with_error('FailedToInsertBuilder', array('master' => $master, 'builderName' => $builder_name));
    }
    $slave_id = add_slave($db, $_POST['build_slave']);
    $build_id = add_build($db, $builder_id, $build_number, $slave_id);
    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));
    }
    if (!store_test_results($db, $test_results, $build_id, $start_time, $end_time)) {
        exit_with_error('FailedToStoreResults', array('buildId' => $build_id));
    }
}
Exemplo n.º 2
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();