Unit Test server and interface - Liturgical-Calendar/LiturgicalCalendarAPI GitHub Wiki
Frontend
The Unit Test frontend can be found at https://litcal-tests.johnromanodorazio.com. This interface has a repository of it's own, the source code is at Liturgical-Calendar/UnitTestInterface.
The frontend will automatically pick up on unit tests that are created in the LiturgicalCalendar API backend, through the discovery endpoint https://litcal.johnromanodorazio.com/api/${version}/LitCalTestsIndex.php . Here ${version}
can have a value of dev
for the latest cutting edge updates to the LitCal API, or a fixed version such as v3
for the latest stable api endpoint. The LitCalTestsIndex.php
endpoint is curated in the Liturgical-Calendar/LiturgicalCalendarAPI repository.
It communicates with the Unit Test backend via websockets, sending requests for tests to be run, gathering the results and updating the UI based on those results.
Discovery endpoint
The LitCalTestsIndex.php
discovery endpoint will pick up all Unit Tests defined in the tests
folder within the Liturgical-Calendar/LiturgicalCalendarAPI
repository (https://github.com/Liturgical-Calendar/LiturgicalCalendarAPI/tree/development/tests) and serve a response in JSON format that is readable by the fronted.
Backend
The Unit Test backend is a websocket server listening at https://litcal-test.johnromanodorazio.com.
Websocket server
The backend websocket server is created in the PHP script LitCalTestServer.php which is also curated in the LiturgicalCalendarAPI
repository alongside the API itself.
The PHP websocket server is run as a system service defined in /etc/systemd/system/litcal-tests.service
as follows:
[Unit]
Description=LitCal Unit tests service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
User=**********
Group=*********
WorkingDirectory=/**********/api/dev/
Restart=always
RestartSec=1
ExecStart=/usr/bin/env php8.1 /**********/api/dev/LitCalTestServer.php
[Install]
WantedBy=multi-user.target
Note: cannot update to php8.2
or php8.3
until ratchetphp/Ratchet issue #1003 is fixed...
LitCalHealth class
The websocket server LitCalTestServer.php
depends on the LitCalHealth
class which is also curated in the LiturgicalCalendarAPI
repository (LitCalHealth.php)
The LitCalHealth
class can run single unit tests requested by the frontend, as it has knowledge of the available tests in the same way that the LitCalTestsIndex.php
endpoint gathers the same information for the frontend.
The LitCalHealth
class can be considered the orchestrator, assisting the backend end websocket server in running specific tests requested by the frontend and formulating a response with the test results in JSON format.