def get_artifact(test_id, artifact_type, artifact_name=None): if artifact_type == "graph": return redirect("/graph?command=one_job&stats={test_id}".format(test_id=test_id)) elif artifact_type == "flamegraph" and not artifact_name: artifacts = db.get_test_artifacts(test_id, artifact_type) for artifact in artifacts: artifact["data"] = db.get_test_artifact_data(test_id, artifact_type, artifact["name"]) return render_template("flamegraph.jinja2.html", test_id=test_id, artifacts=artifacts) if not artifact_name: return make_response(jsonify({"error": "No artifact name provided."}), 400) artifact, object_id, artifact_available = db.get_test_artifact_data(test_id, artifact_type, artifact_name) if artifact_name.endswith(".tar.gz"): mimetype = "application/gzip" elif artifact_name.endswith(".json"): mimetype = "application/json" elif artifact_name.endswith(".svg"): mimetype = "image/svg+xml" else: mimetype = "text/plain" if artifact is None and object_id is not None and artifact_available: artifact = db.generate_object_by_chunks(object_id) return Response( response=artifact, status=200, mimetype=mimetype, headers={"Content-Disposition": "filename={name}".format(name=artifact_name)}, )
def get_artifact(test_id, artifact_type, artifact_name=None): if artifact_type == 'graph': return redirect("/graph?command=one_job&stats={test_id}".format(test_id=test_id)) elif artifact_type == 'flamegraph' and not artifact_name: artifacts = db.get_test_artifacts(test_id, artifact_type) for artifact in artifacts: artifact['data'] = db.get_test_artifact_data(test_id, artifact_type, artifact['name']) return render_template('flamegraph.jinja2.html', test_id=test_id, artifacts=artifacts) if not artifact_name: return make_response(jsonify({'error':'No artifact name provided.'}), 400) artifact, object_id, artifact_available = db.get_test_artifact_data(test_id, artifact_type, artifact_name) if artifact_name.endswith(".tar.gz"): mimetype = 'application/gzip' elif artifact_name.endswith(".json"): mimetype = 'application/json' elif artifact_name.endswith(".svg"): mimetype = 'image/svg+xml' else: mimetype = 'text/plain' if artifact is None and object_id is not None and artifact_available: artifact = db.generate_object_by_chunks(object_id) return Response(response=artifact, status=200, mimetype=mimetype, headers={"Content-Disposition": "filename={name}".format(name=artifact_name)})
def get_series_summaries_impl(series, start_timestamp, end_timestamp): series = db.get_series(series, start_timestamp, end_timestamp) summaries = [] for test_id in series: artifact = db.get_test_artifact_data(test_id, 'stats_summary') if artifact: summary = db.get_test_artifact_data(test_id, 'stats_summary')[0] if summary: summaries.append(json.loads(summary)) return summaries
def get_series_summaries_impl(series, start_timestamp, end_timestamp): series = db.get_series( series, start_timestamp, end_timestamp) summaries = [] for test_id in series: artifact = db.get_test_artifact_data(test_id, 'stats_summary') if artifact: summary = db.get_test_artifact_data(test_id, 'stats_summary')[0] if summary: summaries.append(json.loads(summary)) return summaries
def get_series_summaries_impl(series, start_timestamp, end_timestamp): series = db.get_series(series, start_timestamp, end_timestamp) summaries = [] for test_id in series: status = db.get_test_status(test_id) if status == 'completed': artifact = db.get_test_artifact_data(test_id, 'stats_summary', 'stats_summary.{}.json'.format(test_id)) if artifact and artifact[0]: summaries.append(json.loads(artifact[0])) return summaries
def view_test(test_id): try: test = db.get_test(test_id) except UnknownTestError: return make_response('Unknown Test {test_id}.'.format(test_id=test_id), 404) artifacts = db.get_test_artifacts(test_id) has_chart = False for a in artifacts: if a['artifact_type'] in ['failure','link']: # Proactively fetch non-blob artifacts: a['artifact'] = db.get_test_artifact_data(test_id, a['artifact_type'], a['name']) if a['artifact_type'] == 'stats': has_chart = True return render_template('view_test.jinja2.html', test=test, artifacts=artifacts, has_chart=has_chart)
def get_artifact(test_id, artifact_type): if artifact_type == 'graph': return redirect("/graph?command=one_job&stats={test_id}".format(test_id=test_id)) artifact, description = db.get_test_artifact_data(test_id, artifact_type) if description.endswith(".tar.gz"): mimetype = 'application/gzip' elif description.endswith(".json"): mimetype = 'application/json' else: mimetype = 'text/plain' return Response(response=artifact, status=200, mimetype=mimetype, headers={"Content-Disposition": "filename={name}".format(name=description)} )
def view_test(test_id): try: test = db.get_test(test_id) except UnknownTestError: return make_response("Unknown Test {test_id}.".format(test_id=test_id), 404) artifacts = db.get_test_artifacts(test_id) has_chart = False for a in artifacts: if a["artifact_type"] in ["failure", "link"]: # Proactively fetch non-blob artifacts: a["artifact"] = db.get_test_artifact_data(test_id, a["artifact_type"], a["name"]) if a["artifact_type"] == "stats": has_chart = True return render_template("view_test.jinja2.html", test=test, artifacts=artifacts, has_chart=has_chart)
def get_artifact(test_id, artifact_type): if artifact_type == 'graph': return redirect("/graph?stats={test_id}".format(test_id=test_id)) artifact, description = db.get_test_artifact_data(test_id, artifact_type) if description.endswith(".tar.gz"): mimetype = 'application/gzip' elif description.endswith(".json"): mimetype = 'application/json' else: mimetype = 'text/plain' return Response(response=artifact, status=200, mimetype=mimetype, headers={ "Content-Disposition": "filename={name}".format(name=description) })