Skia has proposed merging ~hyask/autopkgtest-cloud:skia/amend_running_jobs into autopkgtest-cloud:master.
Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/461041 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/amend_running_jobs into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/README.md b/charms/focal/autopkgtest-web/webcontrol/README.md new file mode 100644 index 0000000..e489c2a --- /dev/null +++ b/charms/focal/autopkgtest-web/webcontrol/README.md @@ -0,0 +1,12 @@ +# autopkgtest-cloud web frontend + +## Developing browse.cgi locally + +Install the dependencies: +`sudo apt install python3-flask python3-distro-info libjs-jquery libjs-bootstrap` + +Then simply run `./browse-test-py`, it will launch the flask application locally +with some mocked data. +As the import of `browse.cgi` is done trough `importlib`, changes in that file +will not be reloaded automatically, so you'll still need to restart the app +manually. diff --git a/charms/focal/autopkgtest-web/webcontrol/browse-test.py b/charms/focal/autopkgtest-web/webcontrol/browse-test.py new file mode 100755 index 0000000..a5c5b4e --- /dev/null +++ b/charms/focal/autopkgtest-web/webcontrol/browse-test.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +"""Run browse app in local debug mode for testing.""" + +import importlib +from pathlib import Path + +from helpers import tests, utils + +# import browse.cgi +browse_path = str(Path(__file__).parent / "browse.cgi") +loader = importlib.machinery.SourceFileLoader("browse", browse_path) +spec = importlib.util.spec_from_loader("browse", loader) +browse = importlib.util.module_from_spec(spec) +loader.exec_module(browse) + + +if __name__ == "__main__": + browse.db_con = utils.init_db(":memory:", check_same_thread=False) + with browse.db_con: + tests.populate_dummy_db(browse.db_con) + browse.swift_container_url = "swift-%s" + browse.AMQP_QUEUE_CACHE = Path("/dev/shm/queue.json") + tests.populate_dummy_amqp_cache(browse.AMQP_QUEUE_CACHE) + browse.RUNNING_CACHE = Path("/dev/shm/running.json") + tests.populate_dummy_running_cache(browse.RUNNING_CACHE) + + browse.app.run(host="0.0.0.0", debug=True) diff --git a/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py b/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py new file mode 100644 index 0000000..3e61e8c --- /dev/null +++ b/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py @@ -0,0 +1,171 @@ +import json +from datetime import datetime +from uuid import uuid4 + +from .utils import get_supported_releases + + +def populate_dummy_db(db_con): + supported_releases = get_supported_releases() + + c = db_con.cursor() + tests = [ + (1, supported_releases[0], "amd64", "hello"), + (2, supported_releases[1], "amd64", "hello"), + (3, supported_releases[0], "ppc64el", "hello"), + (4, supported_releases[1], "ppc64el", "hello"), + (5, supported_releases[2], "amd64", "hello"), + ] + c.executemany("INSERT INTO test values(?, ?, ?, ?)", tests) + results = [ + # fmt: off + # test_id | run_id | version | trigger | duration | exit_code | requester | env | uuid + (1, datetime.now(), "1.2.3", "hello/1.2.3", 42, 0, "hyask", "", str(uuid4())), + (1, datetime.now(), "1.2.3", "hello/1.2.3", 42, 0, "hyask", "all-proposed=1", str(uuid4())), + (2, datetime.now(), "1.2.3", "hello/1.2.3", 42, 0, "", "", str(uuid4())), + (3, datetime.now(), "1.2.3", "hello/1.2.3", 42, 20, "", "", str(uuid4())), + # fmt: on + ] + c.executemany( + "INSERT INTO result values(?, ?, ?, ?, ?, ?, ?, ?, ?)", results + ) + db_con.commit() + + +def populate_dummy_amqp_cache(path): + supported_releases = get_supported_releases() + with open(path, "w") as f: + # pylint: disable=line-too-long + json.dump( + { + "arches": ["amd64", "ppc64el"], + "queues": { + "ubuntu": { + supported_releases[0]: { + "amd64": { + "size": 1, + "requests": [ + 'hello\n{"triggers": ["hello/1.2.3ubuntu1"], "submit-time": "2024-02-22 01:55:03"}', + ], + } + } + }, + "huge": { + supported_releases[1]: { + "amd64": { + "size": 1, + "requests": [ + 'hello\n{"triggers": ["migration-reference/0"], "submit-time": "2024-02-22 01:55:03"}', + ], + } + } + }, + "ppa": { + supported_releases[2]: { + "amd64": { + "size": 2, + "requests": [ + 'hello\n{"triggers": ["hello/1.2.4~ppa1"], "submit-time": "2024-02-22 01:55:03"}', + 'hello2\n{"triggers": ["hello2/2.0.0~ppa1"], "submit-time": "2024-02-22 01:55:03"}', + ], + } + } + }, + "upstream": { + supported_releases[3]: { + "amd64": { + "size": 1, + "requests": [ + 'hello\n{"triggers": ["hello/1.2.4~ppa1"], "submit-time": "2024-02-22 01:55:03"}', + ], + } + } + }, + }, + }, + f, + ) + + +def populate_dummy_running_cache(path): + supported_releases = get_supported_releases() + with open(path, "w") as f: + json.dump( + { + "hello": { + "hash1": { + supported_releases[0]: { + "amd64": [ + { + "requester": "hyask", + "submit-time": "2024-02-21 11:00:51", + "triggers": [ + "hello/1.2.3", + ], + "uuid": "84669a9c-ac08-46a3-a5fd-6247d0d2021c", + }, + 3504, + """ +3071s hello/test_XYZ.hello . [ 54%] +3153s hello/test_XYZ.hello ...... [ 64%] +3271s hello/test_XYZ.hello .......... [ 74%] +3292s hello/test_XYZ.hello .................. [ 84%] +3493s hello/test_XYZ.hello ............................ [ 94%] +3494s hello/test_XYZ.hello .................................... [ 98%] +""", + ] + } + }, + "hash2": { + supported_releases[1]: { + "amd64": [ + { + "requester": "hyask", + "submit-time": "2024-02-21 11:00:52", + "triggers": [ + "hello/1.2.3", + ], + "uuid": "12339a9c-ac08-46a3-a5fd-6247d0d2021c", + }, + 3614, + """ +3071s hello/test_XYZ.hello . [ 54%] +3153s hello/test_XYZ.hello ...... [ 64%] +3271s hello/test_XYZ.hello .......... [ 74%] +3292s hello/test_XYZ.hello .................. [ 84%] +3493s hello/test_XYZ.hello ............................ [ 94%] +3594s hello/test_XYZ.hello .................................... [ 98%] +""", + ] + } + }, + }, + "hello2": { + "hash1": { + supported_releases[4]: { + "amd64": [ + { + "all-proposed": "1", + "requester": "hyask", + "submit-time": "2024-02-21 11:01:21", + "triggers": [ + "hello2/1.2.3-0ubuntu1", + ], + "uuid": "42369a9c-ac08-46a3-a5fd-6247d0d2021c", + }, + 3504, + """ +3071s hello2/test_XYZ.hello [ 54%] +3153s hello2/test_XYZ.hello [ 64%] +3271s hello2/test_XYZ.hello [ 74%] +3292s hello2/test_XYZ.hello [ 84%] +3493s hello2/test_XYZ.hello [ 94%] +3494s hello2/test_XYZ.hello [ 98%] +""", + ] + } + } + }, + }, + f, + ) diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-admin.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-admin.html index 266f584..72d5d5b 100644 --- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-admin.html +++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-admin.html @@ -8,6 +8,7 @@ <!-- Running tests --> {% for p, info in running.items()|sort %} + <h2 id="pkg-{{ p }}"><a href="/packages/{{ p }}">{{ p }}</a></h2> {{ macros.display_running_job(p, info) }} {% endfor %} diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html index fb12afa..a313617 100644 --- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html +++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html @@ -20,6 +20,9 @@ {% endfor %} </table> + <hr> + <h3>Running tests</h3> + {% for p, info in running.items()|sort %} {{ macros.display_running_job(p, info) }} {% endfor %} diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html index 53ae2f9..c876a22 100644 --- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html +++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-running.html @@ -39,6 +39,7 @@ <!-- Running tests --> {% for p, info in running.items()|sort %} + <h2 id="pkg-{{ p }}"><a href="/packages/{{ p }}">{{ p }}</a></h2> {{ macros.display_running_job(p, info) }} {% endfor %} diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html index 7d43d20..244d64b 100644 --- a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html +++ b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html @@ -1,5 +1,4 @@ {% macro display_running_job(package, info) -%} -<h2 id="pkg-{{ package }}"><a href="/packages/{{ package }}">{{ package }}</a></h2> {% for runhash, relinfo in info.items() %} {% for release, archinfo in relinfo.items() %} {% for arch, (params, duration, logtail) in archinfo.items() %} @@ -22,5 +21,6 @@ </pre> {% endfor %} {% endfor %} + <hr> {% endfor %} {%- endmacro %}
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp