End to End System Testing in Dev Mode
In addition to writing automated unit tests for each project module and integrated tests across modules, we occasionally need to manually walk through the system to experience it the same way as an end user would. Manual testing sometimes leads to discovering new issues that can be then covered with new automated tests.
Following is the recommended way to manually test an Ambianic system end to end in development mode, but as close as possible to realistic deployment conditions.
First, start the Ambianic UI and Ambianic Edge gitpod environments. If you haven't done this before, then follow these instructions.
Next, go to the Ambianic Edge dev environment and make sure that all main modules are running: 1. Core Monitoring and Inference Engine 1. REST API server (fastapi) 1. WebRTC - HTTP proxy
In your main workspace directory you should see a file named
.peerjsrc with a contents similar to this:
Copy to the system clipboard the peerId value from this json formatted file. Just the
Notice that this value is a randomly generated UUID4 which will be unique for your environment.
Next, go to the Ambianic UI environment, and make sure that the Ambianic PWA is being served by nodejs. Your terminal window should look like the screenshot below.
Open a browser window pointing to port 8080 of the gitpod environment serving the Ambianic PWA on nodejs in dev mode.
Click on Begin Setup then on the next page click Skip in the upper right corner of the app.
On the next page, select the Main menu drop down in the Nav Bar and click Settings.
Then scroll down to the section titled "Pair with remote Ambianic Edge device".
Paste the peerjs key value that you copied from the Ambianic Edge CDE. Click on Pair Remotely. In a few moments you will see snackbar status messages indicating that the UI is connecting to Ambianic Edge followed by a confirmation that connection is established.
If you now scroll up to the top of the Settings page you will see the Peer ID and Version of the Ambianic Edge device you are connected to. This is in fact a connection to the gitpod CDE running Ambianic Edge in dev mode.
Notice that we did not have to open any public HTTP/S ports on the Ambianic Edge CDE in order for the UI to access the virtual device. This is exactly how the UI and Edge connect in a real world deployment. Instead of relying on access to public HTTP/S endpoints, the UI and Edge connect securely and directly via WebRTC DataChannel (using peerfetch - an HTTP over WebRTC proxy).
If you now navigate to the Timeline page, you will see a timeline view.
The source for this view is populated from the video file configured in
dev-config.yaml in the Ambianic Edge CDE.
You can change the file with your own recorded video file for testing various detection scenarios.
Notice how the
peerfetch terminal shows a log of HTTP fetch requests and responses from the Ambianic UI instance. This is an indication that the UI and Edge are communicating. If you switch to the Fastapi terminal it will also show REST API requests served to the
peerfetch proxy on behalf of the UI app (PWA).
Now you have a fully setup live and realistic system that runs both Ambianic UI and Ambianic Edge in dev mode. This setup represents as closely as possible the real world experience of an end user, while allowing you, dear developer, to test, experiment and commit code.