This document aims to provide the OSM community an easy way of testing and debugging OSM.
Benefits:
juju config <module> debug_mode=True debug_pubkey="ssh-rsa ...".Download the installer:
wget http://osm-download.etsi.org/ftp/osm-10.0-ten/install_osm.sh chmod +x install_osm.sh
Install OSM from master (tag=testing-daily):
./install_osm.sh -R testing-daily -r testing --charmed
Install OSM from a specific tag:
./install_osm.sh -R testing-daily -r testing --charmed --tag <X.Y.Z>
Once the Charmed OSM installation has finished, you can select which applications you want to run with the debug mode.
juju config lcm debug_mode=True debug_pubkey="ssh-rsa ..."juju config mon debug_mode=True debug_pubkey="ssh-rsa ..."juju config nbi debug_mode=True debug_pubkey="ssh-rsa ..."juju config ro debug_mode=True debug_pubkey="ssh-rsa ..."juju config pol debug_mode=True debug_pubkey="ssh-rsa ..."Enabling the debug_mode will put a sleep infinity as the entrypoint of the container. That way, we can later connect to the pod through SSH in VSCode, and run the entrypoint of the application from the debugger.
Preparing the pods includes setting up the ~/.ssh/config so the VSCode can easily discover which ssh hosts are available
Just execute:
./prepare_pods.sh
NOTE: The public key that will be used will be
$HOME/.ssh/id_rsa.pub. If you want to use a different one, add the absolute path to it as a first argument:./prepare_pods.sh /path/to/key.pub.
In VScode, navigate to Remote Explorer, and select the pod to which you want to connect.
You should be able to see the following hosts in the Remote Explorer:
Right click on the host, and "Connect to host in a New Window".
The ./prepare_pods.sh script adds a workspace to the /root folder of each pod, with the following name: <module>.code-workspace.
In the window of the connected host, go to File/Open Workspace.... Then select the <module>.code-workspace file.
Go to extensions and install the Python extension. It will be installed in the remote pod.
Now we need to add a debug configuration. For that, go to the Run and Debug tab, and click on create a launch.json file.
Now you will be asked to select a folder in your workspace. Select the folder of the main component:
Then select Python as the environment. And finally, select Module and enter the module of the component you are going to test (LCM example: osm_lcm.lcm)