Bug 53229 - Create first version of the general ucsschool-apis app
Create first version of the general ucsschool-apis app
Status: VERIFIED FIXED
Product: Components
Classification: Unclassified
Component: ucsschool-apis
unspecified
Other Mac OS X 10.1
: P5 normal (vote)
: ---
Assigned To: Ole Schwiegert
Tobias Wenzel
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2021-05-06 09:32 CEST by Ole Schwiegert
Modified: 2021-05-19 08:51 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
dummy plugin (1.91 KB, text/x-python)
2021-05-17 09:36 CEST, Tobias Wenzel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ole Schwiegert univentionstaff 2021-05-06 09:32:27 CEST
To be able to extend and add network resources to UCS@school in product and projects we want to add a "general purpose" API app that can expose resources defined by arbitrary plugins. An idea and architectural proposal can be found in the research library (https://git.knut.univention.de/jbaach/research-library)

The QA would have to check the following points:
- Code Review
- Is the App installable from the TestAppCenter (we do not do a full release yet)
- Are the automatic tests present and valid and all pass
- Is there an automatic Jenkins job for the app that runs the tests?
- Does the App work with the provided default plugin?
- Does the app work with multiple plugins (write one yourself quickly)?
- Is the documentation on how the app works, what it does and how to develop a plugin for it, good and easy to understand?
- Do exposed resources via plugins work?
Comment 1 Ole Schwiegert univentionstaff 2021-05-06 09:49:00 CEST
The app is currently being developed in the components/ucsschool-apis repo in branch oschwieg/v1
Comment 2 Ole Schwiegert univentionstaff 2021-05-07 10:04:15 CEST
An Example plugin can be found in https://git.knut.univention.de/univention/components/ucsschool-api-plugins/example-plugin
Comment 3 Tobias Wenzel univentionstaff 2021-05-14 15:10:57 CEST
QA Code review


=== ucsschool-api ===

build_docker_image on dev machine

pyproject.toml
-> add description

constants.py
APP_ID = "ucsschool-kelvin-rest-api"
-> this should be different

README.md
MASTER=UCS_IP ./setup_dev_environ -> MASTER=$UCS_IP ./setup_dev_environ
-v $PATH_TO_PLUGIN/:/var/lib/univention-appcenter/apps/ucsschool-apis/data/plugins/$PLUGIN_NAME 
-> missing "\" at line end

build_docker_image

Will this be handled in the plugins?

Updating/Downloading patched UCR
Create empty import configs
Downloading OpenAPI Generator JAR file 

Copying files to build directory -> now in dockerfile
Downloading Open Policy Agent -> now in dockerfile
Collecting all Python dependencies -> now in dockerfile

Dockerfile
Same question for univention-directory-manager-modules-slim & univention-lib-slim 

pre-commit-config -> ok, let's try that (pytest)
pre-commit run -a
Check for added large files..............................................Passed
Check JSON...............................................................Passed
Check Xml............................................(no files to check)Skipped
Check Yaml...............................................................Passed
Trim Trailing Whitespace.................................................Passed
isort....................................................................Passed
black....................................................................Passed
flake8...................................................................Passed
pytest-check.............................................................Passed

(unit-) tests so far -> code looks good & tests pass


service files -> OK
appcenter -> OK

ucsschool

constants.py
APP_DESCRIPTION = "" -> add description

models.py -> OK
scripts.py -> OK, +1 for helpful comments
main.py -> OK
opa -> OK
auth.py  -> OK
utils.py -> OK



=== example-plugin ===
code -> OK

------------------------------------------------

- Does the App work with the provided default plugin?
-> yes. Tested using the swagger ui.

------------------------------------------------

- Does the app work with multiple plugins (write one yourself quickly)?
-> yes. I wrote a very simple plugin "randomnumbers" which returns random numbers, 42 and it's version (cf. echo-plugin). No problems running them together.



------------------------------------------------

- Is the App installable from the TestAppCenter (we do not do a full release yet)
-> yes

univention-app info
UCS: 4.4-8 errata969
Installed: cups=2.2.1 samba4=4.10 squid=3.5 ucsschool=4.4 v9 ucsschool-apis=0.1.0

------------------------------------------------


- Do exposed resources via plugins work?
-> yes


------------------------------------------------

todo/ not qa ready

- Is the documentation on how the app works, what it does and how to develop a plugin for it, good and easy to understand?
- Is there an automatic Jenkins job for the app that runs the tests?
- Is the documentation on how the app works, what it does and how to develop a plugin for it, good and easy to understand?
Comment 4 Tobias Wenzel univentionstaff 2021-05-17 09:36:06 CEST
Created attachment 10728 [details]
dummy plugin

The dummy plugin I used to QA on 

 single-server → OK
 multi-server → OK
 dev laptop → OK

along with the provided echo plugin.
Comment 5 Ole Schwiegert univentionstaff 2021-05-17 10:36:51 CEST
QA mentions fixed (DESCRIPTION, README, APP_ID)

About UCR, import configs, etc

All of these things are Kelvin specific and thus I excluded them from this "general purpose App" for now. As soon as we have a better picture about the requirements for our first plugins, I would revisit this topic and decide how we can integrate necessary parts into the app, either baked in as UCS@school utilities or per (not yet existing) mechanism for plugins.
Comment 6 Tobias Wenzel univentionstaff 2021-05-17 14:08:11 CEST
QA 
Thanks for the fixes.

Test-code for auth → OK

test_check_policy_true
test_check_policy
→ as discussed please write comments to explain what is happening.

Tests pass except for 
unittests/test_main.py

ImportError: cannot import name 'activate_plugin' from 'ucsschool.apis.main' (/usr/local/lib/python3.9/site-packages/ucsschool/apis/main.py)

→ not sure if this is my vm. The code looks OK.
Comment 7 Ole Schwiegert univentionstaff 2021-05-18 10:35:38 CEST
Fixed the problem with the main test -  should run now (missing __init__.py)

Tests are run on every commit via gitlab CI: https://git.knut.univention.de/univention/components/ucsschool-apis/-/pipelines

Only the documentation is missing now
Comment 8 Tobias Wenzel univentionstaff 2021-05-18 16:47:18 CEST
QA

ci pipeline passes, but I had trouble running the tests on my vm
-> test_correct_auth

I suspect something is wrong with my vm

Other than that everything looks fine.
...


QA Documentation

Create a working directory, and check out the *UCS@School API* code and the
example plugin code
-> Create a working directory and check out the *UCS@School API* code, as well as the
example plugin code

we check that the api server as such will run. 
-> in the future? Why not "runs"?

   mv ${MYPLUGIN}-plugin/echo_plugin ${MYPLUGIN}-plugin/${MYPLUGIN}_plugin
   mv ${MYPLUGIN}-plugin/${MYPLUGIN}_plugin/echo_plugin.py ${MYPLUGIN}-plugin/${MYPLUGIN}_plugin/${MYPLUGIN}_plugin.py
   mv ${MYPLUGIN}-plugin/tests/unittests/test_echo_plugin.py ${MYPLUGIN}-plugin/tests/unittests/test_${MYPLUGIN}_plugin.py

-> Do we need this to be so explicit? This is hard to read (but correct).


this where you can define models that describe what
-> this is where you can define models that describe what


In theory, if you go to http://localhost:8080/ucsschool/apis/docs, you
-> why in theory? 

All the best with writing your plugins, and don't hesitate to contact the UCS@school team if you
have questions!
-> Who is supposed to read this? If profS then this is OK. If not I'm not so sure.
Comment 9 Ole Schwiegert univentionstaff 2021-05-18 22:22:54 CEST
- App image was build today with current code for version 0.1.0
- App exists in TestAppCenter
- Documentation is written in a first version in the repo (Email will be sent to support and profService after review)
- Example Plugin exists (echo)
- Opa is integrated in the app
- Auth plugin is shipped in app and allows for LDAP bind auth
- Automatic tests are run via Gitlab CI on every commit: https://git.knut.univention.de/univention/components/ucsschool-apis/-/jobs

Regarding the comments for the documentation: My proposal is to open a new bug about improving the documentation, copy your comments there and integrate them together with feedback from support and prof. service. Is that sufficient for you? -- If yes then VERIFY and I open the new Bug.
Comment 10 Tobias Wenzel univentionstaff 2021-05-19 08:50:18 CEST
QA → All OK → verify

code is in main branch → OK
App image was build today with current code for version 0.1.0
→ correct version is installed with test appcenter

Automatic tests are run via Gitlab CI on every commit
→ this looks very helpful, has been qat.


Regarding the comments for the documentation: My proposal is to open a new bug about improving the documentation, copy your comments there and integrate them together with feedback from support and prof. service. Is that sufficient for you? -- If yes then VERIFY and I open the new Bug.
→ this is OK for me
Comment 11 Ole Schwiegert univentionstaff 2021-05-19 08:51:30 CEST
This is the Bug for the Documentation:

https://forge.univention.org/bugzilla/show_bug.cgi?id=53286