Manual:SimTest: Difference between revisions
Line 132: | Line 132: | ||
|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 158: | ||
: '''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''' ==== | ==== '''Simulation''' ==== |
Revision as of 09:57, 3 April 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
sim <name> { <param> <value>; events { ... } }
Simulation Events
Possible Events:
print "Hello World\n";
- delay
delay 4;
- wait
- config_set
config_set { id { <API CMD> } cmd { <API CMD> } }
- config_check
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; } } }