Manual:SimTest: Difference between revisions
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Configuration Syntax Explained== | ==Configuration Syntax Explained== | ||
Line 32: | Line 31: | ||
</pre> | </pre> | ||
'''include''' works only from 'tests' directory. So, for example, if file test.cfg is in 'tests/lala/ and 'host.cfg' is in the same dir, then include should be <code>#include "lala/host.cfg" | '''include''' works only from 'tests' directory. So, for example, if file test.cfg is in 'tests/lala/ and 'host.cfg' is in the same dir, then include should be <code>#include "lala/host.cfg"</code> | ||
{{Note | './' and '../' does not work}} | {{Note | './' and '../' does not work}} | ||
Line 132: | Line 131: | ||
|arg=vlans | |arg=vlans | ||
|type=integer [0..1] | |type=integer [0..1] | ||
|desc=Whether to use vlans for link simulations instead of virtual interfaces. Vlans should be used in [[MetaROUTER]] mode, since metarouters has limited amount of available virtual ethernets | |desc=Whether to use vlans for link simulations instead of virtual interfaces. Vlans should be used in [[M:Metarouter | MetaROUTER]] mode, since metarouters has limited amount of available virtual ethernets | ||
}} | }} | ||
Line 158: | Line 157: | ||
: '''router''' scope allows to define two sub-scopes: | : '''router''' scope allows to define two sub-scopes: | ||
: * META - this scope should contain configuration in API syntax which will be applied to the router. | : * META - this scope should contain configuration in [[M:API | API]] syntax which will be applied to the router. | ||
: * KVM - this scope should contain configuration in RouterOS CLI syntax which will be applied during KVM image creation process. | : * KVM - this scope should contain configuration in RouterOS [[CLI]] syntax which will be applied during KVM image creation process. | ||
==== '''Simulation''' ==== | |||
Defines actual simulation process. | |||
<pre> | <pre> | ||
sim <name> { | sim <name> { | ||
Line 174: | Line 174: | ||
</pre> | </pre> | ||
Sim configuration allows following parameters: | |||
{{Mr-arg-table-h | |||
|prop=Param | |||
|desc=Description | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=desc | |||
|type=string | |||
|desc=Simple description, can be left blank | |||
}} | |||
{{Mr-arg-ro-table-end | |||
|arg=network | |||
|type=string | |||
|desc=Which [[#Network | network]] to use from all defined networks. | |||
}} | |||
===== '''Simulation Events''' ===== | ===== '''Simulation Events''' ===== | ||
Possible | Event scope defines all events during simulation in actual order. | ||
Possible events: | |||
; print | |||
: Output to the screen; | |||
<pre> print "Hello World\n";</pre> | <pre> print "Hello World\n";</pre> | ||
;delay | |||
: Delay in seconds before moving to the next event. | |||
<pre> delay 4; </pre> | <pre> delay 4; </pre> | ||
; wait | |||
: Pause simulation and timer until manually continued. | |||
; reboot | |||
: Reboot the router | |||
<pre> | |||
reboot <router_name> ; | |||
</pre> | |||
; reconnect | |||
: Reconnect to the router, necessary after virtual router reboot | |||
<pre> | |||
reconnect <router_name> ; | |||
</pre> | |||
; ping | |||
: Run the ping command and check the result. If received packet count < configured count, event returns failure. | |||
<pre> | |||
ping <router_name> { | |||
<param> <value>; | |||
... | |||
} | |||
</pre> | |||
Currently ping allows following parameters: | |||
{{Mr-arg-table-h | |||
|prop=Param | |||
|desc=Description | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=src | |||
|type=IP|IPv6 | |||
|desc=Used Source address of the ICMP packet | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=dst | |||
|type=IP|IPv6|MAC | |||
|desc=Destination where to send ping. | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=count | |||
|type=integer | |||
|desc=Number of ping packets to send. NOTE: if count is not specified infinite loop will occur. | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=size | |||
|type=integer [64..1500] | |||
|desc=Size of the packet | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=table | |||
|type=string | |||
|desc=Name of the routing table which will be used for nexthop lookup. | |||
}} | |||
{{Mr-arg-ro-table-end | |||
|arg=status | |||
|type=string | |||
|desc=Status returned at least on one response. If specified status is not found then event exits with failure. | |||
}} | |||
For example: | |||
<pre> | <pre> | ||
config_set { | ping "R1" { | ||
dst 10.5.101.1; | |||
src 10.5.101.21; | |||
count 1; | |||
size 64; | |||
table main; | |||
} | |||
</pre> | |||
; trace | |||
: Run the traceroute command and check the result. If recorded path is not the same as specified path, event returns failure. | |||
<pre> | |||
trace <router_name> { | |||
<param> <value>; | |||
... | |||
} | |||
</pre> | |||
Currently trace allows following parameters: | |||
{{Mr-arg-table-h | |||
|prop=Param | |||
|desc=Description | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=src | |||
|type=IP|IPv6 | |||
|desc=Used Source address of the ICMP packet | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=dst | |||
|type=IP|IPv6|MAC | |||
|desc=Destination where to send ping. | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=size | |||
|type=integer [64..1500] | |||
|desc=Size of the packet | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=table | |||
|type=string | |||
|desc=Name of the routing table which will be used for nexthop lookup. | |||
}} | |||
{{Mr-arg-ro-table-end | |||
|arg=path | |||
|type=string | |||
|desc=List of the hops in the path. Hops should be separated by comma (e.g. "1.1.1.1,2.2.2.2") | |||
}} | |||
For example: | |||
<pre> | |||
trace "R1" { | |||
dst 10.5.101.1; | |||
src 10.1.101.21; | |||
path "1.1.1.1,2.2.2.10,10.5.101.1"; | |||
size 64; | |||
table main; | |||
} | |||
</pre> | |||
; config_set | |||
: Add or modify configuration of the specified virtual router | |||
<pre> | |||
config_set <router_name> { | |||
id { | id { | ||
<API CMD> | <API CMD> | ||
Line 196: | Line 362: | ||
</pre> | </pre> | ||
Sometimes it is needed to get ID of the item which should be modify. In this case use '''id''' scope to get ID, which will be automatically set in '''cmd''' scope. If multiple IDs are returned then config is applied to all of them. | |||
For example: | |||
<pre> | |||
config_set "R2" { | |||
id { | |||
/ip/route/print | |||
?dst-address=0.0.0.0/0 | |||
=.proplist=.id | |||
} | |||
cmd { | |||
/ip/route/set | |||
=disabled=yes | |||
} | |||
} | |||
</pre> | |||
; config_check | |||
: Check parameters on the specified virtual router. Scope can have multiple 'cmd' sections, if any of those fails event will return failure. | |||
<pre> | |||
config_check <router_name> { | |||
cmd { | |||
<API CMD> | |||
} | |||
<param> <value> | |||
} | |||
</pre> | |||
Config check allows following parameters: | |||
{{Mr-arg-table-h | |||
|prop=Param | |||
|desc=Description | |||
}} | |||
{{Mr-arg-ro-table | |||
|arg=data | |||
|type=yes {{!}} no | |||
|desc=What to do if API command returns data. If not set then it is considered as <code> data no;</code> | |||
If set to 'yes', event will return failure if API command returns non empty data. | |||
If set to 'no', event will return failure if API command returns empty data. | |||
}} | |||
{{Mr-arg-ro-table-end | |||
|arg=status | |||
|type=inconclusive {{!}} failed {{!}} completed | |||
|desc=What status to set if event returns failure. | |||
* inconclusive - something failed before actual test is possible. For example, BGP failed to establish connection in the test which should test routing filters. | |||
* failed - actual test failed | |||
* completed - test completed. If nothing failed, then 'completed' is always returned at the end of simulation. | |||
}} | |||
==Sample Configuration== | ==Sample Configuration== | ||
Line 386: | Line 605: | ||
</pre> | </pre> | ||
[[Category:Manual]] |
Latest revision as of 11:36, 10 July 2012
Configuration Syntax Explained
Version definition
Version always should be defined at the beginning of the file.
Syntax:
version 1;
Description
Description is used to show detailed description of what this simulation do.
Syntax:
desc { ... }
Include
Allows to include parts of configuration located in another files. For example include common host information or common network configuration.
Syntax:
#include "host.cfg"
include works only from 'tests' directory. So, for example, if file test.cfg is in 'tests/lala/ and 'host.cfg' is in the same dir, then include should be #include "lala/host.cfg"
Note: './' and '../' does not work
Host
Defines host login information, where tester application should log in and add virtual network.
Host should always be at the same broadcast network as tester, since ipv6 link-local addresses are used to connect to virtual guests from the tester.
Syntax:
host <name> { <param> <value>; }
Host configuration allows following parameters:
Param | Description |
---|---|
desc (string) | Simple description, can be left blank |
addr (ipv4 | ipv6) | IP/IPv6 address of the host |
port (integer | string) | API port on the host |
user (string) | Username used to login |
pass (string) | Password used to login |
bridge (string) | Name of the bridge where management interfaces of guests are added. This is needed for tester to be able to connect to the guest routers and apply configuration. |
Network
Define all routers and links between routers in virtual network.
network <name> { <param> <value>; router <ref_name> { META { <api_commands> } } }
Network configuration allows following parameters:
Param | Description |
---|---|
desc (string) | Simple description, can be left blank |
host (string) | Which of the defined hosts to use |
vlans (integer [0..1]) | Whether to use vlans for link simulations instead of virtual interfaces. Vlans should be used in MetaROUTER mode, since metarouters has limited amount of available virtual ethernets |
routers (list of router names separated by comma (R1, R2;)) | Define all routers in virtual network. All routers are separated by comma |
link (list of routers (R1 R2;)) | Define links between routers. It is possible to define point to point and broadcast links. Link definition will also make an interface name for the guest interface.
For example
Another example,
|
- router scope allows to define two sub-scopes:
- * META - this scope should contain configuration in API syntax which will be applied to the router.
- * KVM - this scope should contain configuration in RouterOS CLI syntax which will be applied during KVM image creation process.
Simulation
Defines actual simulation process.
sim <name> { <param> <value>; events { ... } }
Sim configuration allows following parameters:
Param | Description |
---|---|
desc (string) | Simple description, can be left blank |
network (string) | Which network to use from all defined networks. |
Simulation Events
Event scope defines all events during simulation in actual order.
Possible events:
- Output to the screen;
print "Hello World\n";
- delay
- Delay in seconds before moving to the next event.
delay 4;
- wait
- Pause simulation and timer until manually continued.
- reboot
- Reboot the router
reboot <router_name> ;
- reconnect
- Reconnect to the router, necessary after virtual router reboot
reconnect <router_name> ;
- ping
- Run the ping command and check the result. If received packet count < configured count, event returns failure.
ping <router_name> { <param> <value>; ... }
Currently ping allows following parameters:
Param | Description |
---|---|
src (IP) | Used Source address of the ICMP packet |
dst (IP) | Destination where to send ping. |
count (integer) | Number of ping packets to send. NOTE: if count is not specified infinite loop will occur. |
size (integer [64..1500]) | Size of the packet |
table (string) | Name of the routing table which will be used for nexthop lookup. |
status (string) | Status returned at least on one response. If specified status is not found then event exits with failure. |
For example:
ping "R1" { dst 10.5.101.1; src 10.5.101.21; count 1; size 64; table main; }
- trace
- Run the traceroute command and check the result. If recorded path is not the same as specified path, event returns failure.
trace <router_name> { <param> <value>; ... }
Currently trace allows following parameters:
Param | Description |
---|---|
src (IP) | Used Source address of the ICMP packet |
dst (IP) | Destination where to send ping. |
size (integer [64..1500]) | Size of the packet |
table (string) | Name of the routing table which will be used for nexthop lookup. |
path (string) | List of the hops in the path. Hops should be separated by comma (e.g. "1.1.1.1,2.2.2.2") |
For example:
trace "R1" { dst 10.5.101.1; src 10.1.101.21; path "1.1.1.1,2.2.2.10,10.5.101.1"; size 64; table main; }
- config_set
- Add or modify configuration of the specified virtual router
config_set <router_name> { id { <API CMD> } cmd { <API CMD> } }
Sometimes it is needed to get ID of the item which should be modify. In this case use id scope to get ID, which will be automatically set in cmd scope. If multiple IDs are returned then config is applied to all of them.
For example:
config_set "R2" { id { /ip/route/print ?dst-address=0.0.0.0/0 =.proplist=.id } cmd { /ip/route/set =disabled=yes } }
- config_check
- Check parameters on the specified virtual router. Scope can have multiple 'cmd' sections, if any of those fails event will return failure.
config_check <router_name> { cmd { <API CMD> } <param> <value> }
Config check allows following parameters:
Param | Description |
---|---|
data (yes | no) | What to do if API command returns data. If not set then it is considered as data no;
If set to 'yes', event will return failure if API command returns non empty data. If set to 'no', event will return failure if API command returns empty data. |
status (inconclusive | failed | completed) | What status to set if event returns failure.
|
Sample Configuration
- host.cfg
version 1; // host login information host "default" { desc "Default host"; addr "10.5.101.14"; port "8728"; user "admin"; pass ""; bridge "bypass"; }
- network_2_routers.cfg
/* Configuration template for two interconnected routers * * R1 ---- R2 * */ version 1; #include "host.cfg" network "2_router_network" { desc ""; host "default"; vlans 0; routers R1, R2; link R1 R2; router "R1" { META { /ip/address/add =address=1.1.1.1/30 =interface=R1_R2 } } router "R2" { META { /ip/address/add =address=1.1.1.2/30 =interface=R2_R1 } } }
- bgp/001-auth.cfg
version 1; desc { +=================================================================== | BGP connection establishment with authentication | +=================================================================== . .Test setup creates a simple link between 2 routers . . . R1------R2 . . Simulator actions: . * Check if BGP connection is established . * Change to incorrect MD5 key . * Check if BGP connection is NOT established . * Change back to correct MD5 key . * Check if BGP connection is established } #include "network_2_routers.cfg" sim "simple"{ desc "MD5 authentication test"; network "2_router_network"; events { print "Set initial config...\n"; config_set "R1" { cmd { /routing/bgp/peer/add =name=R2 =remote-address=1.1.1.2 =remote-as=65530 =tcp-md5-key=helloworld } } config_set "R2" { cmd { /routing/bgp/peer/add =name=R1 =remote-address=1.1.1.1 =remote-as=65530 =tcp-md5-key=helloworld } } delay 7; print "Check if BGP session is established..\n"; config_check "R1" { cmd { /routing/bgp/peer/print ?state=established =.proplist=.id } status inconclusive; } print "Change MD5 key..\n"; config_set "R1" { // id can be only one and should contain only one command id { /routing/bgp/peer/print ?name=R2 =.proplist=.id } cmd { /routing/bgp/peer/set =tcp-md5-key=lalala } } print "Waiting...\n"; delay 3; print "Check if BGP session is NOT established..\n"; config_check "R1" { cmd { /routing/bgp/peer/print ?state=established =.proplist=.id } data yes; // failure if returns any entries status failed; } print "Change MD5 key..\n"; config_set "R1" { // id can be only one and should contain only one command id { /routing/bgp/peer/print ?name=R2 =.proplist=.id } cmd { /routing/bgp/peer/set =tcp-md5-key=helloworld } } print "Waiting...\n"; delay 3; print "Check if BGP session is established..\n"; config_check "R1" { cmd { /routing/bgp/peer/print ?state=established =.proplist=.id } data no; status failed; } } }