Automated Flamegraph Generation with nanolab-lxd: Nano Integration Testing Simplified

Automated Flamegraph Generation with nanolab-lxd: Nano Integration Testing Simplified

nanolab-lxd provides an integration test environment for the Nano network. With this tool, you can efficiently spin up local Nano networks and execute tests inside an LXD container. While a similar setup is possible with nanolab, LXD offers the added advantage of isolation, ensuring that your host environment remains untouched.

In this guide, we'll walk you through setting up nanoLab-lxd, executing test cases, and retrieving the results.

0. Getting Started with nanolab-lxd

To begin, clone the nanolab-lxd repository and switch to the wip/host-to-lxd branch:

git clone
cd nanolab-lxd
git checkout wip/host-to-lxd

1. Setting up the LXD environment

For Ubuntu users:

sudo apt-get install lxd lxd-client
lxd init # Accept the default options when prompted

2. Initialize your nanolab-lxd container

To launch nanoLab inside an LXD container, execute:


You can then verify that the container is operational using:

lxc ls nanolab22

The expected output resembles:

|   NAME    |  STATE  |      IPV4    |   IPV6     |   TYPE    | SNAPSHOTS |
| nanolab22 | RUNNING | 17.. (br..)  | fd42: (eth)| CONTAINER | 0         |
|           |         | 17.. (dock..)|            |           |           |
|           |         | 10.. (eth0)  |            |           |           |

3. Exploring and Running Test Cases

To see all available test cases, use:

./run-lab-lxd list

This will display a series of available test cases:


To execute a specific test case:

./run-lab-lxd run -t flamegraph_bintree -i "nanocurrency/nano:V26.0DB13"

Here, the -i flag specifies the Docker image for the Nano nodes.

4. Utilizing Local Docker Builds within the LXD Container

To test custom Nano Docker images compiled from the NanoCurrency source:

git clone --recursive
cd nano-node
docker build -f docker/node/Dockerfile -t your_nano_image .

Then, transition to the nanolab-lxd directory and transfer the Docker image to LXD:

./ your_nano_image

To run your test:

./run-lab-lxd run -t flamegraph_bintree -i "your_nano_image"

5. Extracting Results

To retrieve flamegraphs from the LXD to your host:

lxc exec nanolab22 -- ls | grep flame | xargs -I{} lxc file pull nanolab22/root/{} .

Note: Flamegraph test cases typically record for around 20 seconds. The Docker container might also retrieve additional dependencies, causing minor delays:

apt-get update && apt-get install -y linux-tools-generic binutils

6. Customizing Test Cases

You can tailor test cases to your requirements by adjusting the config.json file inside the LXD container. Execute:

lxc exec nanolab22 /bin/bash
nanolab list --local # This displays all the downloaded test case configurations.

This command showcases the available configurations:


Adjust these configurations using your favorite text editor.