The two-phase testing approach
- preparation phase: This phase initiates the long-running backend task. It sets up the necessary conditions and triggers the backend process without waiting for it to complete.
- validation phase: After an appropriate waiting period, this phase verifies the results of the backend task to ensure correctness.
Setting up Octomind CLI
To use Octomind’s CLI, install it vianpm
:
Running the two-phase test
Test run will follow this flow:1. Preparation phase: Trigger backend task
Set up a specific tag, for example -preparation
- to run only the test cases that set up the environment and start the long-running task:
preparation
tag, ensuring that the backend task is triggered.
2. Validation phase: Check results
Once the backend task has had enough time to complete, run the validation tests using a different tag, let’s say -validation
.
Example: Testing a demo app
Let’s consider a demo application that processes user data asynchronously. The preparation phase will trigger data processing, while the validation phase will check if the processing is complete. The see how this works we created such a demo app: https://github.com/sker65/orchestration-demo/. It is written in python and uses flask and celery. Flask provides an API and a web UI, while celery provides background tasks. The application can be started using docker:Preparation: Start processing
Wait for the background task to finish
After the test case execution is triggered we will use a bash script to monitor the progress. This is rather simple as we can just use the app’s API to look for tasks and their status.Validation: Verify processing completion
After the background tasks has finished, we validate:success
.