JSON API and test suite for web UI#846
Conversation
876112b to
baf218e
Compare
baf218e to
fc5c804
Compare
|
@nucleogenic I haven't used Docker in a long while, but I assume there's an obvious additional dependency here in the Docker executable and libraries themselves? For instance, if I want to run the Docker container on my Windows 10 PC, I basically just download and install a package from their website, right? And then execute the first few bootstrap commands in a Windows shell compatible fashion. |
rdmark
left a comment
There was a problem hiding this comment.
This looks great. I only have a few questions and minor suggestions inline. Feel free to merge when you have made any final refinements.
nucleogenic
left a comment
There was a problem hiding this comment.
Thanks for the review @rdmark! Will provide some updates shortly.
|
To run the tests from a Linux Docker host: Where |
Supporting updates to web.py and templates
…n standalone web UI installs
5d09352 to
75b0994
Compare
commit 20ae4b3 Merge: 7c1ae8e 78bab77 Author: Uwe Seimet <Uwe.Seimet@seimet.de> Date: Sat Oct 1 10:44:39 2022 +0200 Merge branch 'develop' into feature_memory_management commit 7c1ae8e Author: Uwe Seimet <Uwe.Seimet@seimet.de> Date: Sat Oct 1 10:35:27 2022 +0200 Merged localizer changes from develop commit cf19ecf Author: Uwe Seimet <Uwe.Seimet@seimet.de> Date: Sat Oct 1 10:17:50 2022 +0200 Merged changes from feature_more_unit_tests commit 600e5b7 Author: Uwe Seimet <Uwe.Seimet@seimet.de> Date: Sat Oct 1 10:00:20 2022 +0200 Formatting update commit 303ea88 Author: Uwe Seimet <Uwe.Seimet@seimet.de> Date: Sat Oct 1 09:57:30 2022 +0200 Improved transparency of geometry data commit 78bab77 Author: Daniel Markstedt <markstedt@gmail.com> Date: Fri Sep 30 19:20:19 2022 -0700 Swedish localization update 2022-09 (#874) * Swedish localization updates * Use LUN for compactness commit 05e0a78 Merge: 71e070b 1938a8b Author: Daniel Markstedt <markstedt@gmail.com> Date: Fri Sep 30 18:57:51 2022 -0700 Merge pull request #851 from akuker/rdmark-rename-host-bridge Rename the Host Bridge INQUIRY product to RASCSI BRIDGE commit dee929f Author: Uwe Seimet <Uwe.Seimet@seimet.de> Date: Fri Sep 30 10:45:12 2022 +0200 Fixed memory issue reported by valgrind commit 71e070b Merge: 3c8e7db 922c3b2 Author: Daniel Markstedt <markstedt@gmail.com> Date: Thu Sep 29 19:31:42 2022 -0700 Merge pull request #853 from akuker/rdmark-issue852 Calculate image sizes for the Product string using MiB/KiB units commit 3c8e7db Author: Daniel Markstedt <markstedt@gmail.com> Date: Tue Sep 27 17:38:34 2022 -0700 Allow the selecting of target dir when uploading or downloading files (#867) Uses a single endpoint for downloading files Adds a select field to pick target dir for both download and upload forms Moves the Macproxy/Netatalk helptext into the helptext blocks, and the related status messages down into the page footer commit 3ac3abb Merge: b04962d 70c073e Author: Daniel Markstedt <markstedt@gmail.com> Date: Tue Sep 27 07:52:24 2022 -0700 Merge pull request #868 from nucleogenic/webui-pytest-warn-on-delete-failures Display a warning when Pytest fixtures fail to delete a file commit 70c073e Author: nucleogenic <nr@nucleogenic.com> Date: Tue Sep 27 15:39:58 2022 +0100 Display a warning when Pytest fixtures fail to delete a file commit b04962d Author: Daniel Markstedt <markstedt@gmail.com> Date: Tue Sep 27 06:09:18 2022 -0700 Swedish translations in localizer.cpp (#865) * Swedish translations * Fix typos commit 5da3d6c Author: Daniel Markstedt <markstedt@gmail.com> Date: Mon Sep 26 17:44:41 2022 -0700 Introduce info.html template and use it to render detailed info (#863) new: - new templates to render structured info contents in - get_diskinfo() class method that calls disktype and returns the results - /diskinfo endpoint in the Flask app that renders the results from get_diskinfo() changed: - /logs/show and /scsi/info endpoints in the Flask app render in templates - Now using the "RaSCSI Reloaded Control Page" header to function as the link back to the homepage (instead of the github project) which is in line with how most webapps work - Removed the center style for "Attached!" to allow the ? button to be placed on the same line - Remove individual device info, and introduced show all device info in a template commit edbaaf6 Author: Daniel Markstedt <markstedt@gmail.com> Date: Sun Sep 25 17:37:28 2022 -0700 Web UI tweaks: Detaching removable devices; SCSI-1 drive profiles (#854) * Display the Detach action for injected removable media * Flag three DEC drives as SCSI-1 commit ed12853 Merge: 016a616 75b0994 Author: nucleogenic <nr@nucleogenic.com> Date: Mon Sep 26 00:18:06 2022 +0100 Merge pull request #846 from nucleogenic/webui-json-responses JSON API and test suite for web UI commit 75b0994 Author: nucleogenic <nr@nucleogenic.com> Date: Sun Sep 25 18:15:35 2022 +0100 Add missing asserts to API tests commit a142af5 Author: nucleogenic <nr@nucleogenic.com> Date: Sat Sep 24 03:10:01 2022 +0100 Improve organisation of tests commit 6f7e611 Author: nucleogenic <nr@nucleogenic.com> Date: Sat Sep 24 03:10:11 2022 +0100 Add missing dev dependency flake8 commit f8e5870 Author: nucleogenic <nr@nucleogenic.com> Date: Sat Sep 24 00:20:49 2022 +0100 Update comments commit 663de06 Author: nucleogenic <nr@nucleogenic.com> Date: Thu Sep 22 21:41:12 2022 +0100 Added tests for extracting .sit and .7z archive formats commit 65c2286 Author: nucleogenic <nr@nucleogenic.com> Date: Tue Sep 20 01:56:22 2022 +0100 Fix shell exit issue in web/start.sh commit 8062e5f Author: nucleogenic <nr@nucleogenic.com> Date: Tue Sep 20 00:33:47 2022 +0100 Updates to allow tests to run against a remote RaSCSI instance commit 1a15c4c Author: nucleogenic <nr@nucleogenic.com> Date: Mon Sep 19 17:00:59 2022 +0100 Expose env info to API clients commit 0e6147e Author: nucleogenic <nr@nucleogenic.com> Date: Mon Sep 19 14:21:31 2022 +0100 Setup pytest, flake8, black + add API tests commit 26aa5eb Author: nucleogenic <nr@nucleogenic.com> Date: Mon Sep 19 14:20:12 2022 +0100 Update Dockerfiles to allow testing of additional RaSCSI web UI features commit 6ad436c Author: nucleogenic <nr@nucleogenic.com> Date: Mon Sep 19 14:18:53 2022 +0100 Add --headless option to easyinstall.sh, enable web auth by default on standalone web UI installs commit dd40d71 Author: nucleogenic <nr@nucleogenic.com> Date: Mon Sep 19 14:16:34 2022 +0100 Fix issue causing stale reservations after loading a config commit fb8f306 Author: nucleogenic <nr@nucleogenic.com> Date: Mon Sep 26 00:00:18 2022 +0100 Implement response generator for HTML and JSON requests Supporting updates to web.py and templates commit 1e9a7d2 Author: nucleogenic <nr@nucleogenic.com> Date: Thu Sep 22 01:20:22 2022 +0100 Move flattening of file type lists to template layer commit 4ef2e20 Author: nucleogenic <nr@nucleogenic.com> Date: Sat Sep 10 02:58:47 2022 +0100 Update get_supported_locales to return a JSON serializable result commit edf65a8 Author: nucleogenic <nr@nucleogenic.com> Date: Sat Sep 10 02:58:35 2022 +0100 Update RaCtlCmds methods to return JSON serializable results commit 922c3b2 Author: Daniel Markstedt <markstedt@gmail.com> Date: Thu Sep 22 11:50:47 2022 -0700 Calculate image sizes for the Product string using MiB/KiB units commit 1938a8b Author: Daniel Markstedt <markstedt@gmail.com> Date: Thu Sep 22 09:03:36 2022 -0700 Rename the Host Bridge INQUIRY product to RASCSI BRIDGE, as expected by the RASETHER.SYS driver.
Introduction
This change set offers a light take on "API" functionality for the web UI.
An initial suite of tests covering all of the endpoints (except reboot/shutdown) has been provided. These are high-level, happy path tests, which provide some basic assurance that the web UI features work as expected in normal circumstances.
Changes
For convenience, a summary of changes:
web.pyandcommonmoduleAccept: application/jsonheader get a JSON responserender_template()HTML responseflash()are superseded by a single call toresponse(message=str|list)envvar in templates/envendpoint exposes the above data for API clientsrender_template()that wasn't JSON serializable has been amended at sourceDependencies and Tooling
requirements-dev.txtto separate production and dev dependenciespytestandpytest-httpserveras dev dependencies for running testsflake8andblackas dev dependencies for code style feedback and reformattingTry It Out
Build and launch Docker containers:
Install dependencies:
(new terminal, from 'RASCSI' dir)
Run tests:
Create image via API:
Run tests against a real RaSCSI:
Disclaimer: Make a backup first!
Any attached devices will be automatically detached when the test suite starts.
Each test attempts to clean up the resources it creates.
Firewall note:
pytest-httpserverbinds to a random port on the computer running the tests, and the RaSCSI instance needs to be able to connect in to this. This is required for the following tests:test_download_url_to_afp_dir,test_download_url_to_images_dir,test_download_url_to_isoandtest_extract_file. Please adjust your firewall configuration as necessary.Future Direction
Some other ideas, which don't quite fit in this (already large) PR, and in no particular order:
messagesproperty to individual properties indatapropertyCredits