canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #03465
[Merge] ~andersson123/autopkgtest-cloud:user-specific-page into autopkgtest-cloud:master
Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:user-specific-page into autopkgtest-cloud:master.
Requested reviews:
Canonical's Ubuntu QA (canonical-ubuntu-qa)
Related bugs:
Bug #2057947 in Auto Package Testing: "Feature: user-specific history page"
https://bugs.launchpad.net/auto-package-testing/+bug/2057947
For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/462713
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:user-specific-page into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
index 810163d..ac2b764 100755
--- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi
+++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
@@ -51,6 +51,18 @@ def init_config():
swift_container_url = os.path.join(url, "autopkgtest-%s")
+def get_package_release_arch(test_id):
+ c = db_con.cursor()
+ c.execute(
+ "SELECT package, release, arch FROM test WHERE id=?",
+ (test_id,),
+ )
+ try:
+ return c.fetchone()
+ except TypeError:
+ return None
+
+
def get_test_id(release, arch, src):
c = db_con.cursor()
c.execute(
@@ -315,6 +327,137 @@ def package_overview(package, _=None):
)
+@app.route("/user/<user>")
+def user_overview(user):
+ """
+ This endpoint provides a "per-user" view for autopkgtest-cloud.
+ It shows a page, much like the package/release/arch pages,
+ except all of the queued, running and historical results are
+ only shown if they were requested by the user provided.
+ """
+ results = []
+ # get previous results!
+ #################### FIXME: Need to only look at results in last X amount of time
+ for row in db_con.execute(
+ "SELECT test_id, run_id, version, triggers, duration, exitcode, requester, env, uuid FROM result "
+ "WHERE requester=? "
+ "ORDER BY run_id DESC "
+ "LIMIT 100 ",
+ (user,),
+ ):
+ test_id = row[0]
+ version = row[2]
+ triggers = row[3]
+ additional_params = row[
+ 7
+ ] # string of comma separated env variables e.g. all-proposed=1,test-name=mytest
+ code = human_exitcode(row[5])
+ package, release, arch = get_package_release_arch(test_id)
+ url = os.path.join(
+ swift_container_url % release,
+ release,
+ arch,
+ srchash(package),
+ package,
+ row[1],
+ )
+ # Maybe this should also not show for multiple of the exact same test? idk.
+ show_retry = code != "pass"
+ all_proposed = (
+ additional_params is not None
+ and "all-proposed=1" in additional_params
+ )
+ # package, release, and arch needs to be embedded here
+ results.append(
+ (
+ version,
+ triggers,
+ additional_params,
+ human_date(row[1]),
+ human_sec(int(row[4])),
+ user,
+ code,
+ url,
+ show_retry,
+ all_proposed,
+ row[7],
+ package,
+ release,
+ arch,
+ )
+ )
+
+ # add queued tests for this user
+ (_, _, queues_info) = get_queues_info()
+ for _, queue in queues_info.items():
+ for release, queue_by_arch in queue.items():
+ for arch, queue_items in queue_by_arch.items():
+ if queue_items[0] == 0:
+ continue
+ requests = queue_items[1]
+ for req in requests:
+ try:
+ req_info = json.loads(req[req.find("{"):])
+ except Exception as _:
+ continue
+ package = req.split("{")[0].replace("\n", "")
+ if req_info.get("requester", "") == user:
+ results.insert(
+ 0,
+ (
+ "N/A",
+ req_info.get("triggers"),
+ "N/A",
+ human_date(req_info.get("submit-time")),
+ "N/A",
+ user,
+ "queued",
+ "",
+ False,
+ "",
+ req_info.get("uuid", ""),
+ package,
+ release,
+ arch,
+ )
+ )
+
+ # add running tests from this user
+ for package, running_hash in get_running_jobs().items():
+ # this isn't actually the release! AAAAAAA! hehehe
+ for _, running in running_hash.items():
+ for release, vals in running.items():
+ for arch, list_of_running_items in vals.items():
+ if len(list_of_running_items) < 1:
+ continue
+ info_dict = list_of_running_items[0]
+ if info_dict.get("requester", "") == user:
+ results.insert(
+ 0,
+ (
+ "N/A",
+ info_dict.get("triggers"),
+ "N/A",
+ human_date(info_dict.get("submit-time")),
+ human_sec(int(list_of_running_items[1])),
+ user,
+ "running",
+ "",
+ False,
+ "",
+ info_dict.get("uuid", "-"),
+ package,
+ release, # AMEND ME!!!!!!!!!!!
+ arch,
+ )
+ )
+
+ return render(
+ "browse-user.html",
+ package_results=results,
+ )
+
+
# backwards-compatible path with debci that specifies the source hash
@app.route("/packages/<_>/<package>/<release>/<arch>")
@app.route("/packages/<package>/<release>/<arch>")
diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-user.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-user.html
new file mode 100644
index 0000000..f51db42
--- /dev/null
+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-user.html
@@ -0,0 +1,72 @@
+
+{% extends "browse-layout.html" %}
+{% import "macros.html" as macros %}
+
+{% block content %}
+ <h2><a href="https://code.launchpad.net/~{{user}}">{{user}}</a></h2>
+
+
+ <table class="table">
+ <tr>
+ <td><b>Package</b></td>
+ <td><b>Release</b></td>
+ <td><b>Arch</b></td>
+ <td><b>Version</b></td>
+ <td><b>Triggers</b></td>
+ <td><b>Env</b></td>
+ <td><b>Date</b></td>
+ <td><b>Duration</b></td>
+ <td><b>Requester</b></td>
+ <td><b>Result</b></td>
+ <td><b>UUID</b></td>
+ <td></td>
+ </tr>
+
+ {% for row in package_results %}
+ <tr {% if row[6] in ["running", "queued"] %}class="unfinished"{% endif %}>
+ {% set package = row[11] %}
+ {% set release = row[12] %}
+ {% set arch = row[13] %}
+ <td>{{package}}</td>
+ <td>{{release}}</td>
+ <td>{{arch}}</td>
+ <td>{{row[0]}}</td>
+ <td>{{row[1]}}</td>
+ <td>{{row[2]}}</td>
+ <td>{{row[3]}}</td>
+ <td>{{row[4]}}</td>
+ <td>
+ {% if row[5] != "-" %}
+ <a href="https://launchpad.net/~{{row[5]}}">{{row[5]}}</a>
+ {% else %}
+ {{row[5]}}
+ {% endif %}
+ </td>
+ <td class="nowrap {{row[6]}}" title={{ row[6] }}>{{row[6]}}</td>
+ <td>{{row[10]}}</td>
+ <td class="nowrap">
+ {% if row[6] not in ["running", "queued"] %}
+ <a href="{{row[7]}}/log.gz">log</a>  
+ <a href="{{row[7]}}/artifacts.tar.gz">artifacts</a>  
+ {% endif %}
+ </td>
+ <!-- 11 - package -->
+ <!-- 12 - release -->
+ <!-- 13 - arch -->
+ <td class="nowrap">
+ {% if row[8] %}
+ {% set ts = row[1].split()|map('urlencode')|join("&trigger=")|safe %}
+ {% set all_proposed = row[9] %}
+
+ {% if all_proposed %}
+ <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}&all-proposed=1">♻</a>
+ {% else %}
+ <a href="{{base_url}}request.cgi?release={{release}}&arch={{arch}}&package={{package|urlencode}}&trigger={{ts}}">♻</a>
+ {% endif %}
+ {% endif %}
+ </td>
+ </tr>
+ {% endfor %}
+
+ </table>
+{% endblock %}
\ No newline at end of file
References