PLAN_018 The device's API maintains an uptime of at least 99% over a one-month period
Description​
To ensure the API maintains at least 99% uptime during the test period, we'll use an internally developed Python program to monitor its availability within the deployed infrastructure.
This program continuously sends GET requests to the API's root endpoint of the medical device. It processes each response, logging key information in a local SQLite database: the date of the request, whether the communication was successful or not, and the HTTP status code of the response.
System requirements​
The software requirements to run this test are listed below:
- Python >= 3.10
No special hardware is required.
Preconditions​
- The entire system (including the reverse proxy, REST API, and all upstream services) is deployed, operational, and accessible online.
- You have access to the "Legit Health" workspace on Bitbucket, as well as read permissions to clone the
non-functional-testing
repository.
Setup​
-
Before cloning or working with a Bitbucket Cloud repository using Git, you need to set up an SSH key on your computer. Select the guide that matches your operating system. You can skip this step if you have already configured SSH keys previously.
-
Clone the code repository, which contains the program for monitoring API availability, into your working directory. Run this command in your terminal:
git clone git@bitbucket.org:legithealth/non-functional-testing.git
-
Change your working directory to the
stability_testing
directory within the cloned project. -
To prevent software package conflicts, create a new Python virtual environment with this command:
<Path-to-your-python-interpreter> -m venv .venv
Replace
<Path-to-your-python-interpreter>
with the full path to the Python interpreter binary file on your system. -
Once the virtual environment is created, activate it in your terminal session.
-
Install the required libraries (dependencies) for the program using the
pip
package manager:pip install -r requirements.txt
-
Create an
.env
file to set the necessary environment variables for the program. These variables include:API_URL
: The URL to access the device's API.CHECK_INTERVAL_SECONDS
: The interval at which the program sends a GET request to the API. This checking frequency should not exceed one minute (e.g., 30 seconds).UPTIME_DATABASE_NAME
: The name of the SQLite database file where the monitoring records will be stored.
Input data​
No test data is required.
Steps​
- After navigating to the
stability_testing
directory in the cloned repository and activating the virtual environment, start the monitoring service in the background by running this command:
python monitor.py
- Let the program to run uninterrupted for a month. During this time, periodically check the SQLite database located in the
stability_testing
directory, named according to theUPTIME_DATABASE_NAME
environment variable. - After one month, gracefully terminate the program and review the database entries.
- Extract, analyze and process the collected data to complete the following tasks:
- Count the total number of checks performed.
- Count the number of successful responses (status codes from 200 to 299).
- Calculate the uptime percentage using the formula:
Uptime percentage = (Number of successful responses / Total number of checks) × 100
- The repository includes a script to start a local server with a dashboard that shows some relevant metrics. This script automatically computes the metrics from the data recorded in the database during the API monitorization, such as the number of requests sent and the percentage of uptime. Optionally, you can launch the dashboard with the following command:
streamlit run web_ui.py
Expected outcome​
- The monitoring program is running continuously for one month, sending GET requests to the API at the specified interval.
- The database contains records of each request and the corresponding response information.
- The total uptime, calculated as the percentage of successful requests out of the total requests sent, is at least 99% over the period of one month.
Verifies software requirements​
- REQ_005
Risk control for​
-
- Interruption of service
Signature meaning
The signatures for the approval process of this document can be found in the verified commits at the repository for the QMS. As a reference, the team members who are expected to participate in this document and their roles in the approval process, as defined in Annex I Responsibility Matrix
of the GP-001
, are:
- Tester: JD-017, JD-009, JD-004
- Approver: JD-005