14 **NETCONF testtool is a set of standalone runnable jars that can:**
16 - Simulate NETCONF devices (suitable for scale testing)
18 - Stress/Performance test NETCONF devices
20 - Stress/Performance test RESTCONF devices
22 These jars are part of OpenDaylight’s controller project and are built
23 from the NETCONF codebase in OpenDaylight.
27 Download the Sodium SR2 testtool from OpenDaylight Nexus at:
28 https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/netconf/netconf-testtool/1.7.2/
30 **Nexus contains 3 executable tools:**
32 - executable.jar - device simulator
34 - stress.client.tar.gz - NETCONF stress/performance measuring tool
36 - perf-client.jar - RESTCONF stress/performance measuring tool
40 Each executable tool provides help. Just invoke ``java -jar
41 <name-of-the-tool.jar> --help``
43 NETCONF device simulator
44 ~~~~~~~~~~~~~~~~~~~~~~~~
46 NETCONF testtool (or NETCONF device simulator) is a tool that
48 - Simulates 1 or more NETCONF devices
50 - Is suitable for scale, performance or crud testing
52 - Uses core implementation of NETCONF server from OpenDaylight
54 - Generates configuration files for controller so that the OpenDaylight
55 distribution (Karaf) can easily connect to all simulated devices
57 - Provides broad configuration options
59 - Can start a fully fledged MD-SAL datastore
61 - Supports notifications
66 1. Check out latest NETCONF repository from
67 `git <https://git.opendaylight.org/gerrit/admin/repos/netconf>`__
69 2. Move into the ``opendaylight/netconf/tools/netconf-testtool/`` folder
71 3. Build testtool using the ``mvn clean install`` command
76 Netconf-testtool is now part of default maven build profile for
77 controller and can be also downloaded from nexus. The executable jars for
78 testtool can be found by release at this parent directory:
79 `nexus-artifacts <https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/netconf/netconf-testtool/>`__
84 1. After successfully building or downloading, move into the
85 ``opendaylight/netconf/tools/netconf-testtool/target/`` folder and
86 there is file ``netconf-testtool-1.1.0-SNAPSHOT-executable.jar`` (or
87 if downloaded from nexus just take that jar file)
89 2. Execute this file using, e.g.:
93 java -jar netconf-testtool-1.1.0-SNAPSHOT-executable.jar
95 This execution runs the testtool with default for all parameters and
96 you should see this log output from the testtool :
100 10:31:08.206 [main] INFO o.o.c.n.t.t.NetconfDeviceSimulator - Starting 1, SSH simulated devices starting on port 17830
101 10:31:08.675 [main] INFO o.o.c.n.t.t.NetconfDeviceSimulator - All simulated devices started successfully from port 17830 to 17830
106 The default parameters for testtool are:
110 - Run 1 simulated device
112 - Device port is 17830
114 - YANG modules used by device are only: ietf-netconf-monitoring,
115 ietf-yang-types, ietf-inet-types (these modules are required for
116 device in order to support NETCONF monitoring and are included in the
119 - Connection timeout is set to 30 minutes (quite high, but when testing
120 with 10000 devices it might take some time for all of them to fully
121 establish a connection)
123 - Debug level is set to false
125 - No distribution is modified to connect automatically to the NETCONF
131 To verify that the simulated device is up and running, we can try to
132 connect to it using command line ssh tool. Execute this command to
133 connect to the device:
137 ssh admin@localhost -p 17830 -s netconf
139 Just accept the server with yes (if required) and provide any password
140 (testtool accepts all users with all passwords). You should see the
141 hello message sent by simulated device.
148 usage: netconf testtool [-h] [--edit-content EDIT-CONTENT] [--async-requests {true,false}]
149 [--thread-amount THREAD-AMOUNT] [--throttle THROTTLE]
150 [--controller-auth-username CONTROLLER-AUTH-USERNAME]
151 [--controller-auth-password CONTROLLER-AUTH-PASSWORD] [--controller-ip CONTROLLER-IP]
152 [--controller-port CONTROLLER-PORT] [--device-count DEVICES-COUNT]
153 [--devices-per-port DEVICES-PER-PORT] [--schemas-dir SCHEMAS-DIR]
154 [--notification-file NOTIFICATION-FILE]
155 [--initial-config-xml-file INITIAL-CONFIG-XML-FILE] [--starting-port STARTING-PORT]
156 [--generate-config-connection-timeout GENERATE-CONFIG-CONNECTION-TIMEOUT]
157 [--generate-config-address GENERATE-CONFIG-ADDRESS]
158 [--generate-configs-batch-size GENERATE-CONFIGS-BATCH-SIZE]
159 [--distribution-folder DISTRO-FOLDER] [--ssh {true,false}] [--exi {true,false}]
160 [--debug {true,false}] [--md-sal {true,false}] [--time-out TIME-OUT] [--ip IP]
161 [--thread-pool-size THREAD-POOL-SIZE] [--rpc-config RPC-CONFIG]
166 -h, --help show this help message and exit
167 --edit-content EDIT-CONTENT
168 --async-requests {true,false}
170 --thread-amount THREAD-AMOUNT
171 The number of threads to use for configuring devices. (default: 1)
172 --throttle THROTTLE Maximum amount of async requests that can be open at a time, with mutltiple threads
173 this gets divided among all threads (default: 5000)
174 --controller-auth-username CONTROLLER-AUTH-USERNAME
175 Username for HTTP basic authentication to destination controller. (default: admin)
176 --controller-auth-password CONTROLLER-AUTH-PASSWORD
177 Password for HTTP basic authentication to destination controller. (default: admin)
178 --controller-ip CONTROLLER-IP
179 Ip of controller if available it will be used for spawning netconf connectors via
180 topology configuration as a part of URI(http://<controller-ip>:<controller-
181 port>/rests/data/...) otherwise it will just start simulated devices and skip the
182 execution of PATCH requests
183 --controller-port CONTROLLER-PORT
184 Port of controller if available it will be used for spawning netconf connectors via
185 topology configuration as a part of URI(http://<controller-ip>:<controller-
186 port>/rests/data/...) otherwise it will just start simulated devices and skip the
187 execution of PATCH requests
188 --device-count DEVICES-COUNT
189 Number of simulated netconf devices to spin. This is the number of actual ports open
190 for the devices. (default: 1)
191 --devices-per-port DEVICES-PER-PORT
192 Amount of config files generated per port to spoof more devices than are actually
194 --schemas-dir SCHEMAS-DIR
195 Directory containing yang schemas to describe simulated devices. Some schemas e.g.
196 netconf monitoring and inet types are included by default
197 --notification-file NOTIFICATION-FILE
198 Xml file containing notifications that should be sent to clients after create
199 subscription is called
200 --initial-config-xml-file INITIAL-CONFIG-XML-FILE
201 Xml file containing initial simulatted configuration to be returned via get-config rpc
202 --starting-port STARTING-PORT
203 First port for simulated device. Each other device will have previous+1 port number
205 --generate-config-connection-timeout GENERATE-CONFIG-CONNECTION-TIMEOUT
206 Timeout to be generated in initial config files (default: 1800000)
207 --generate-config-address GENERATE-CONFIG-ADDRESS
208 Address to be placed in generated configs (default: 127.0.0.1)
209 --generate-configs-batch-size GENERATE-CONFIGS-BATCH-SIZE
210 Number of connector configs per generated file (default: 1)
211 --distribution-folder DISTRO-FOLDER
212 Directory where the karaf distribution for controller is located
213 --ssh {true,false} Whether to use ssh for transport or just pure tcp (default: true)
214 --exi {true,false} Whether to use exi to transport xml content (default: true)
215 --debug {true,false} Whether to use debug log level instead of INFO (default: false)
216 --md-sal {true,false} Whether to use md-sal datastore instead of default simulated datastore. (default: false)
217 --time-out TIME-OUT the maximum time in seconds for executing each PATCH request (default: 20)
218 -ip IP Ip address which will be used for creating a socket address.It can either be a machine
219 name, such as java.sun.com, or a textual representation of its IP address. (default:
221 --thread-pool-size THREAD-POOL-SIZE
222 The number of threads to keep in the pool, when creating a device simulator. Even if
223 they are idle. (default: 8)
224 --rpc-config RPC-CONFIG
225 Rpc config file. It can be used to define custom rpc behavior, or override the default
226 one.Usable for testing buggy device behavior.
233 Testtool default simple datastore supported operations:
236 returns YANG schemas loaded from user specified directory,
239 always returns OK and stores the XML from the input in a local
240 variable available for get-config and get RPC. Every edit-config
241 replaces the previous data,
244 always returns OK, but does not actually commit the data,
247 returns local XML stored by edit-config,
250 returns local XML stored by edit-config with netconf-state subtree,
251 but also supports filtering.
254 returns always OK with no lock guarantee
257 returns always OK and after the operation is triggered, provided
258 NETCONF notifications (if any) are fed to the client. No filtering
259 or stream recognition is supported.
261 Note: when operation="delete" is present in the payload for edit-config,
262 it will wipe its local store to simulate the removal of data.
264 When using the MD-SAL datastore testtool behaves more like normal
265 NETCONF server and is suitable for crud testing. create-subscription is
266 not supported when testtool is running with the MD-SAL datastore.
271 Testtool supports notifications via the --notification-file switch. To
272 trigger the notification feed, create-subscription operation has to be
273 invoked. The XML file provided should look like this example file:
277 <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
280 <!-- Notifications are processed in the order they are defined in XML -->
282 <!-- Notification that is sent only once right after create-subscription is called -->
284 <!-- Content of each notification entry must contain the entire notification with event time. Event time can be hardcoded, or generated by testtool if XXXX is set as eventtime in this XML -->
286 <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
287 <eventTime>2011-01-04T12:30:46</eventTime>
288 <random-notification xmlns="http://www.opendaylight.org/netconf/event:1.0">
289 <random-content>single no delay</random-content>
290 </random-notification>
295 <!-- Repeated Notification that is sent 5 times with 2 second delay inbetween -->
297 <!-- Delay in seconds from previous notification -->
299 <!-- Number of times this notification should be repeated -->
302 <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
303 <eventTime>XXXX</eventTime>
304 <random-notification xmlns="http://www.opendaylight.org/netconf/event:1.0">
305 <random-content>scheduled 5 times 10 seconds each</random-content>
306 </random-notification>
311 <!-- Single notification that is sent only once right after the previous notification -->
315 <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
316 <eventTime>XXXX</eventTime>
317 <random-notification xmlns="http://www.opendaylight.org/netconf/event:1.0">
318 <random-content>single with delay</random-content>
319 </random-notification>
326 Connecting testtool with controller Karaf distribution
327 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
329 Auto connect to OpenDaylight
330 ''''''''''''''''''''''''''''
332 It is possible to make OpenDaylight auto connect to the simulated
333 devices spawned by testtool (so user does not have to post a
334 configuration for every NETCONF connector via RESTCONF). The testtool is
335 able to modify the OpenDaylight distribution to auto connect to the
336 simulated devices after feature ``odl-netconf-connector-all`` is
337 installed. When running testtool, issue this command (just point the
338 testool to the distribution:
342 java -jar netconf-testtool-1.1.0-SNAPSHOT-executable.jar --device-count 10 --distribution-folder ~/distribution-karaf-0.4.0-SNAPSHOT/ --debug true
344 With the distribution-folder parameter, the testtool will modify the
345 distribution to include configuration for netconf-connector to connect
346 to all simulated devices. So there is no need to spawn
347 netconf-connectors via RESTCONF.
349 Running testtool and OpenDaylight on different machines
350 '''''''''''''''''''''''''''''''''''''''''''''''''''''''
352 The testtool binds by default to 0.0.0.0 so it should be accessible from
353 remote machines. However you need to set the parameter
354 "generate-config-address" (when using autoconnect) to the address of
355 machine where testtool will be run so OpenDaylight can connect. The
356 default value is localhost.
358 Executing operations via RESTCONF on a mounted simulated device
359 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
361 Simulated devices support basic RPCs for editing their config. This part
362 shows how to edit data for simulated device via RESTCONF.
367 The controller and RESTCONF assume that the data that can be manipulated
368 for mounted device is described by a YANG schema. For demonstration, we
369 will define a simple YANG model:
375 namespace "urn:opendaylight:test";
378 revision "2014-10-17";
389 Save this schema in file called test@2014-10-17.yang and store it a
390 directory called test-schemas/, e.g., your home folder.
392 Editing data for simulated device
393 '''''''''''''''''''''''''''''''''
395 - Start the device with following command:
399 java -jar netconf-testtool-1.1.0-SNAPSHOT-executable.jar --device-count 10 --distribution-folder ~/distribution-karaf-0.4.0-SNAPSHOT/ --debug true --schemas-dir ~/test-schemas/
403 - Install odl-netconf-connector-all feature
405 - Install odl-restconf feature
407 - Check that you can see config data for simulated device by executing
412 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount/
414 - The data should be just and empty data container
416 - Now execute edit-config request by executing a POST request to:
420 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount
426 Accept application/xml
427 Content-Type application/xml
433 <cont xmlns="urn:opendaylight:test">
437 - Check that you can see modified config data for simulated device by
438 executing GET request to
442 http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount/
444 - Check that you can see the same modified data in operational for
445 simulated device by executing GET request to
449 http://localhost:8181/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/17830-sim-device/yang-ext:mount/
453 Data will be mirrored in operational datastore only when using the
454 default simple datastore.
457 Testing User defined RPC
458 ^^^^^^^^^^^^^^^^^^^^^^^^
460 The NETCONF test-tool allows using custom RPC. Custom RPC needs to be defined in yang model provide to test-tool along
461 with parameter ``--schemas-dir``.
463 The input and output of the custom RPC should be provided with ``--rpc-config`` parameter as a path to the file containing
464 definition of input and output. The format of the custom RPC file is xml as shown below.
466 Start the device with following command:
470 java -jar netconf/tools/netconf-testtool/target/netconf-testtool-1.7.0-SNAPSHOT-executable.jar --schemas-dir ~/test-schemas/ --rpc-config ~/tmp/customrpc.xml --debug=true
472 Example YANG model file:
477 namespace "urn:example-ops:reboot";
480 import ietf-yang-types {
485 revision "2016-07-07" {
486 description "Initial version.";
487 reference "example document.";
492 description "Reboot operation.";
511 Example payload (RPC config file customrpc.xml):
518 <reboot xmlns="urn:example-ops:reboot">
520 <message>message</message>
524 <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
537 POST http://localhost:8181/restconf/operations/network-topology:network-topology/topology/topology-netconf/node/new-netconf-device/yang-ext:mount/example-ops:get-reboot-info
539 If successful the command will return code 200.
545 A working example of user defined RPC can be found in TestToolTest.java class of the tools[netconf-testtool] project.
551 Slow creation of devices on virtual machines
552 ''''''''''''''''''''''''''''''''''''''''''''
554 When testtool seems to take unusually long time to create the devices
555 use this flag when running it:
559 -Dorg.apache.sshd.registerBouncyCastle=false
564 When testtool or OpenDaylight starts to fail with TooManyFilesOpen
565 exception, you need to increase the limit of open files in your OS. To
566 find out the limit in linux execute:
572 Example sufficient configuration in linux:
576 core file size (blocks, -c) 0
577 data seg size (kbytes, -d) unlimited
578 scheduling priority (-e) 0
579 file size (blocks, -f) unlimited
580 pending signals (-i) 63338
581 max locked memory (kbytes, -l) 64
582 max memory size (kbytes, -m) unlimited
583 open files (-n) 500000
584 pipe size (512 bytes, -p) 8
585 POSIX message queues (bytes, -q) 819200
586 real-time priority (-r) 0
587 stack size (kbytes, -s) 8192
588 cpu time (seconds, -t) unlimited
589 max user processes (-u) 63338
590 virtual memory (kbytes, -v) unlimited
591 file locks (-x) unlimited
593 To set these limits edit file: /etc/security/limits.conf, for example:
599 root hard nofile 500000
600 root soft nofile 500000
605 The testtool might end unexpectedly with a simple message: "Killed".
606 This means that the OS killed the tool due to too much memory consumed
607 or too many threads spawned. To find out the reason on linux you can use
612 dmesg | egrep -i -B100 'killed process'
614 Also take a look at this file: /proc/sys/kernel/threads-max. It limits
615 the number of threads spawned by a process. Sufficient (but probably
616 much more than enough) value is, e.g., 126676