Skip to content

Using Third party Test Tools with LNST

Ondrej Lichtner edited this page Nov 27, 2015 · 5 revisions

When testing networks with LNST, you might find that using only the supported commands is not enough to test a specific feature and you need to use a third-party tool instead. For this reason LNST supports adding external tools that can later be used in recipes. This gives you the benefit of easily extending the testing capabilities of LNST without having to individually distribute these tools as it is done automatically.

1. Location of Test Tools

LNST searches the directory /usr/share/lnst/test_tools/ for system-wide tool files, and by default it contains tools distributed with the package. Currently there is no default location for user supplied test tools, however this can be changed with the option test_tool_dirs within configuration files. You can use as many directories as you need if you want to organize your test tools, and we strongly suggest using at least one location for user supplied test tools. For details on how to configure LNST, visit the wiki page Configure LNST.

2. Adding new Test Tools

Since we wanted to make the process of testing as automatized as possible we made LNST take care of everything concerning test tools from the moment you add one. There are almost no limitations as to what the test tool really is, it can be a short bash script or the source code of a C program. To create a new test tool you only need to create a new directory in one of the searched paths and name it after the tool name, for example:

cd ~/.lnst/test_tools                 #(directory specified in the configuration file)
mkdir MyTestTool                      #(create the directory for test tool MyTestTool)

After this there is only one more thing you need to do so that your Test Tool works correctly, you need to create the file lnst-setup.sh place it within the tools directory, and give it executable permissions. This file will be executed after the Test Tool is transferred to a test machine, and its purpose is to prepare the tool for use on this machine. This is used for tools distributed in source code format that need to be compiled on each individual machine. Example file contents are:

make

Even if your tool does not need any setting up on test machines, you still need to create this file but you can just leave it blank.

At this point you can start creating your own Test Tool, simply by placing files in this directory. LNST considers this directory to be a package containing a test tool and will automatically transfer it to test machines every time there are changes.

3. Usage of a Test Tool within a test recipe

The main purpose of Test Tools is to be able to run commands that are not, by default, supported in LNST or on the testing machine. In order to run something from your Test Tool all you need to do is addition of <run> tag and set it's attribute from to the name of your test tool and command to the command line content that will execute the 3rd party tool.

For example, suppose you have a Test Tool named MyTestTool which contains a binary called run_test and you want to use this tool on machine machine1. In order to do so you add the following line to the command sequence in your recipe file:

<run command="./run_test" from="MyTestTool" host="machine1">

Or when using Python Tasks:

m1.run("./run_test", tool="MyTestTool")

When the test execution reaches this point what happens is that the following commands are executed:

cd <path_to_test_tool_MyTestTool> && ./run_test

As you can see what you can do here is not limited by what the Test Tool actually is. This allows you to create Test Tools that do not actually contain any executables, only files that you want to distribute to test machines and use in any way you need.