Example #1
0
def _get_boots_count(result):
    """Get the boot counts.

    :param result: The boot element for which to get the count of.
    :type result: dict
    :return: A dictionary with the counts.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % result

    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    result["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    result["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0,
        }

    return count_results
Example #2
0
def _get_boots_count(result):
    """Get the boot counts.

    :param result: The boot element for which to get the count of.
    :type result: dict
    :return: A dictionary with the counts.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % result

    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    result["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    result["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0,
        }

    return count_results
Example #3
0
def _get_job_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_params["job_id"] = query_params["_id"]["$oid"]
    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % query_params

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_builds",
        "resource": "count",
        "document": "build",
        "query": total_query_str
    })
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_builds",
        "resource": "count",
        "document": "build",
        "query": query_str % query_params
    })

    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_builds",
        "resource": "count",
        "document": "build",
        "query": query_str % query_params
    })

    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60 * 60)

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": u"N/A",
            "failed_builds": u"N/A",
            "other_boots": u"N/A",
            "other_builds": u"N/A",
            "passed_boots": u"N/A",
            "passed_builds": u"N/A",
            "total_boots": u"N/A",
            "total_builds": u"N/A"
        }

    return count_results
Example #4
0
def _get_boot_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&mach=%(mach)s"
    total_query_str = "job=%(job)s&mach=%(mach)s" % query_params

    if query_params.get("job_id", None):
        query_str += "&job_id=" + query_params["job_id"]["$oid"]
        total_query_str += "&job_id=" + query_params["job_id"]["$oid"]

    # In the aggregation result, the _id field is the one that gets aggregated.
    if all([query_params["kernel"],
            query_params["kernel"] == query_params.get("_id", None)]):
        query_str += "&kernel=" + query_params["kernel"]
        total_query_str += "&kernel=" + query_params["kernel"]

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append(
        {
            "method": "GET",
            "operation_id": "passed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append(
        {
            "method": "GET",
            "operation_id": "failed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    data, status, headers = backend.request_post(
        BACKEND_BATCH_URL,
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0
        }

    return count_results
Example #5
0
def _get_job_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_params["job_id"] = query_params["_id"]["$oid"]
    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % query_params

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_builds",
        "resource": "count",
        "document": "build",
        "query": total_query_str
    })
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append(
        {
            "method": "GET",
            "operation_id": "passed_builds",
            "resource": "count",
            "document": "build",
            "query": query_str % query_params
        }
    )

    queries.append(
        {
            "method": "GET",
            "operation_id": "passed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append(
        {
            "method": "GET",
            "operation_id": "failed_builds",
            "resource": "count",
            "document": "build",
            "query": query_str % query_params
        }
    )

    queries.append(
        {
            "method": "GET",
            "operation_id": "failed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": u"N/A",
            "failed_builds": u"N/A",
            "other_boots": u"N/A",
            "other_builds": u"N/A",
            "passed_boots": u"N/A",
            "passed_builds": u"N/A",
            "total_boots": u"N/A",
            "total_builds": u"N/A"
        }

    return count_results
Example #6
0
def _get_boot_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&mach=%(mach)s"
    total_query_str = "job=%(job)s&mach=%(mach)s" % query_params

    if query_params.get("job_id", None):
        query_str += "&job_id=" + query_params["job_id"]["$oid"]
        total_query_str += "&job_id=" + query_params["job_id"]["$oid"]

    # In the aggregation result, the _id field is the one that gets aggregated.
    if all([
            query_params["kernel"],
            query_params["kernel"] == query_params.get("_id", None)
    ]):
        query_str += "&kernel=" + query_params["kernel"]
        total_query_str += "&kernel=" + query_params["kernel"]

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    data, status, headers = backend.request_post(
        BACKEND_BATCH_URL,
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60 * 60)

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0
        }

    return count_results