Skip to content

Lotterleben/aodvv2_test_management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

What this is

A tool to run automated tests on a network of RIOTs which lets you invoke an action and then check if the code behaves as expected. To do this, it uses desvirt to spawn a line of interconnected RIOT instances, which can now be triggered and queried through the functions provided by management.go.

note that:

  • I've originally written this to test my RIOT-AODVv2 code, but it can be used for other purposes as well. However, some paths are hard-coded because I was pressed for time, so if you actually intend to use this, drop me a line and I'll be happy to make it more accessible.
  • I'm using a desvirt fork because the original version doesn't properly support lines and I've never gotten around to open a PR (note to self: to that.)

Usage

Prerequisites

Setting up DesVirt

  1. Clone desvirt desvirt, change into the directory ind run ./setup.py build install

  2. Create a topology (test mgmt currently only works with line topologies)

    ./topology_creator --node-type riot_native --type line --binary-file path/to/your/binary --size

This should return something like:

created: .desvirt/line4.xml

This tells you the name of your topology (in this case, "line4"). Use that to set up the topology:

./vnet --define --name "<name of your topology>"

Writing tests

The main idea is that you trigger some kind of action in one (or more) RIOTs and check if the other RIOTs respond as expected. The former is accomplished by sending a valid command to a RIOT (If the default set of shell commands don't do what you want your RIOT to do, you'll have to write your own):

/* run our custom send command on the first RIOT of the line */
riot_line := mgmt.Create_clean_setup("my_first_test")
riot_line[0].Channels.Send(fmt.Sprintf("send %s %s\n", end.Ip, mgmt.Test_string))

Now, we can query all RIOTs in the line about the data they've received, processed and sent. More specifically, we can specify what we expect them to have received/output/sent, yielding an error if this is not the case:

/* Discover route at node 0...  */
riot_line[0].Channels.Expect_JSON(mgmt.Make_JSON_str(mgmt.Tmpl_sent_rreq, map[string]string{
    "Orig_addr": beginning.Ip,
    "Targ_addr": end.Ip,
    "Orig_seqnum": "1",
    "Metric": "0",
}))

/* check node 1 */
riot_line[1].Channels.Expect_JSON(mgmt.Make_JSON_str(mgmt.Tmpl_received_rreq, map[string]string{
    "Last_hop": beginning.Ip,
    "Orig_addr": beginning.Ip,
    "Targ_addr": end.Ip,
    "Orig_seqnum": "1",
    "Metric": "0",
}))
riot_line[1].Channels.Expect_JSON(mgmt.Make_JSON_str(mgmt.Tmpl_added_rt_entry, map[string]string{
    "Addr": beginning.Ip,
    "Next_hop": beginning.Ip,
    "Seqnum": "1",
    "Metric": "1",
    "State": strconv.Itoa(mgmt.ROUTE_STATE_ACTIVE),
}))
riot_line[1].Channels.Expect_JSON(mgmt.Make_JSON_str(mgmt.Tmpl_sent_rreq, map[string]string{
    "Orig_addr": beginning.Ip,
    "Targ_addr": end.Ip,
    "Orig_seqnum": "1",
    "Metric": "1",
}))

/* check node 2... */

Full examples for these tests can be found in https://github.com/Lotterleben/aodvv2_test_blackboxtests.

(Note that the code you're trying to test has to output the information you're looking for as a JSON in order for this to work.)

Running tests

TODO

About

Create a test environment for AODVv2.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages