testconf

The aim of this project is to provide a NETCONF testing suite.

testconf is implemented in Node.js and supports testing of both NETCONF clients and NETCONF servers. That way developers can easily test new features, precision-test various requests, find out if there are any regressions and experiment with NETCONF in general. It can be used to run interoperability tests as well. In other words, testconf is an extensive testing tool which eases communication with NETCONF.

Extending testconf with your custom defined tests shortens the time spent on repetitive tasks and helps to pinpoint bugs. Docker container description of testconf can be found at here.

Project history

This project developed out of the NETCONF support for the OpenCPE project, more specifically out of the NETCONF model and data storage daemon (mand). As said, the daemon is model driven and is used for device management applications. The idea behind OpenCPE mand daemon was to be the binding and storage element between the connection protocol specific frontends (e.g. freenetconfd for NETCONF) and configuration agents that apply changes on a given target device.

In early 2016 - with the Sysrepo project beginning to use libyang as one of its most important dependencies - libyang was extended with unit testing features including testconf. As more and more 3rd party language bindings have been added to the Sysrepo project, the testconf project grew as well and now supports end-to-end application testing for Lua 5.2, Java, Python 3 and even end-to-end OpenSSH integration tests.

Now testconf serves as one of the main testing utilities in the Sysrepo/Netopeer2 projects. For example, the tool was used on IETF 96 Hackathon in Berlin and Bits-N-Bites in 2016.

Getting started with testconf

Obtaining testconf

Obtaining testconf is done via Docker. Copy/paste the following command in the terminal:

docker pull sysrepo/testconf

Run testconf with:

docker run -i -t --rm sartura/testconf:latest

where default username and password is root, and this container should connect to sysrepo address. Flags explanation:

-i, --interactive                 Keep STDIN open even if not attached
-t              : Allocate a pseudo-tty for sartura/testconf:latest
--rm                          Automatically removes the sartura/testconf:latest container when it exits

Connection to sysrepo can be tested by pulling sysrepo-netopeer2 in another terminal:

docker pull sysrepo/sysrepo-netopeer2:latest

and running it with:

docker run -i -t --name sysrepo --rm sartura/sysrepo-netopeer2:latest

Installing testconf on Ubuntu

This section will show how to install testconf on a fresh Ubuntu 16.04. Follow the instructions or watch the video below:

https://asciinema.org/a/89233

First we run the docker container with Ubuntu 16.04:

docker run -i -t --name testconf --rm ubuntu:16.04 bash

Then we run:

[email protected]: apt-get update

and install the necessary packages:

[email protected]: apt-get install nodejs npm libkrb5-dev libssl-dev git libpcre3-dev

Due to a known nodejs binary naming conflict, we will also need to symlink /usr/bin/node to /usr/bin/nodejs. We will also use python2 version:

[email protected]: ln -sf /usr/bin/nodejs /usr/bin/node
[email protected]: export PYTHON=python2

Now we head into /opt directory where we clone the testconf GitHub repository:

[email protected]: cd /opt/
[email protected]:/opt# git clone https://github.com/freenetconf/testconf.git
Cloning into 'testconf'...                                                                                                                         
remote: Counting objects: 1110, done.
remote: Total 1110 (delta 0), reused 0 (delta 0), pack-reused 1110
...

After which we navigate to this repo and issue npm install:

[email protected]:/opt# cd testconf/
[email protected]:/opt/testconf# npm install
> [email protected] install /opt/testconf/node_modules/libxmljs
> node-gyp rebuild                               
...

We can now run testconf's default server example by issuing:

[email protected]:/opt/testconf# node netconf_server/tests/default_server_example.js &
[1] 6619
[email protected]:/opt/testconf# . executing test named "default_server_example.js"
.. reading yang directory
... iana-if-type.yang
... ietf-inet-types.yang
... [email protected]
... ietf-interfaces.yang
... ietf-ip.yang
... ietf-ipfix-psamp.yang
... ietf-netconf-acm.yang
... ietf-netconf-monitoring.yang
... ietf-netconf-notifications.yang
... ietf-netconf-partial-lock.yang
... ietf-netconf-with-defaults.yang
... ietf-netconf.yang
... ietf-syslog-types.yang
... ietf-syslog.yang
... ietf-yang-smiv2.yang
... ietf-yang-types.yang
... [email protected]
... [email protected]
... [email protected] 
.. starting ssh server
.. listening on 127.0.0.1:830

and now we can run tests available in /tests/ directory, e.g. generic_hello.js

[email protected]:/opt/testconf# node netconf_client/tests/generic_hello.js
. executing test named "generic_hello.js"
... authenticated "netconf" using password
.. received connection
.. ssh connection ready                                                                               
(truncated output)

Configuration commands

testconf also has CLI and the commands, similarly to snmp commands, are get (get only last data node from NETCONF), set (set only one value node at a time) and walk (similar to get but will show all data nodes under xpath) commands. This section will show an example of those commands.

First we pull the relevant docker containers. In one terminal insert:

$ docker pull sysrepo/sysrepo-netopeer2:latest

and in the other pull testconf:

$ docker pull sysrepo/testconf:snmp

now run the sysrepo/sysrepo-netopeer2:latest container:

$ docker run -i -t --name sysrepo --rm sysrepo/sysrepo-netopeer2:latest bash

once in the container, we navigate to /opt/dev/sysrepo/build directory and add xml config data on which we will test the commands:

[email protected]:/# cd /opt/dev/sysrepo/build/
[email protected]:/opt/dev/sysrepo/build# cp ../examples/yang/ietf-interfaces.data.xml /etc/sysrepo/data/ietf-interfaces.startup

and follow that by running sysrepod and netopeer2-server:

[email protected]:/opt/dev/sysrepo/build# sysrepod -l 0
[email protected]:/opt/dev/sysrepo/build# netopeer2-server                                       

We can run the ietf-interfaces.data.xml to see the configuration with:

[email protected]:/opt/dev/sysrepo/build# ./examples/application_example ietf-interfaces &

In the other terminal we now run the container sysrepo/testconf:snmp and navigate to /opt/dev/testconf/netconf_client/snmp directory:

[email protected]:/# docker run -i -t --link sysrepo --rm sysrepo/testconf:snmp bash
[email protected]:/# cd /opt/dev/testconf/netconf_client/snmp/

get

To get a value from a single node, we would use netconf_get as such:

[email protected]:/opt/dev/testconf/netconf_client/snmp# node netconf_get.js "/ietf-interfaces:interfaces/interface[name='eth0']/enabled"
true

walk

To show all data nodes under a certain xpath we would use netconf_walk, e.g.:

[email protected]:/opt/dev/testconf/netconf_client/snmp# node netconf_walk.js "/ietf-interfaces:interfaces/interface[name='eth0']"
/ietf-interfaces:interfaces/interface[name='eth0']/description => Ethernet 0
/ietf-interfaces:interfaces/interface[name='eth0']/type => ethernetCsmacd
/ietf-interfaces:interfaces/interface[name='eth0']/enabled => true
/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/enabled => true
/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/mtu => 1500
/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/address[ip='192.168.2.100']/prefix-length => 24

set

We can use set to set only one value node at a time, for example here we set value "false" on xpath "/ietf-interfaces:interfaces/interface[name='eth0']/enabled":

[email protected]:/opt/dev/testconf/netconf_client/snmp# node netconf_set.js "/ietf-interfaces:interfaces/interface[name='eth0']/enabled" "true"

and in the first terminal we can see that the value has been set:

/ietf-interfaces:interfaces/interface[name='eth0']/enabled = true                                

GitHub

testconf is an open source project hosted on GitHub: https://github.com/freenetconf/testconf

The project welcomes pull requests and any other form of contribution from the community.

Contact

For any information regarding testconf - as for the rest of the Sysrepo ecosystem - one can send inquiries to the official Sysrepo http://lists.sysrepo.org or to the respective GitHub project.

testconf (last edited 2016-12-07 15:41:01 by akrog)