A Robotframework Extension for Network Automated Testing
The Authors assume no responsibility for damage or loss of system performance as a direct or indirect result of the use of this software. This software is provided "as is" without express or implied warranty.
All product names and trademarks are the property of their respective owners, which are in no way associated or affiliated with this software. Use of these names does not imply any co-operation or endorsement.
- Ixia, IxiaNetwork, IxiaLoad are trademarks of IXIA
- Spirent, Avalanche are trademarks of Spirent
- Calient is a trademark of CALIENT NETWORKS, INC.
- Junos, Juniper are trademarks of Junipter Networks.
- Cisco is a trademark of Cisco Systems, Inc.
For details about Robot Framework see RobotFramework
- Disclaimer
- Table Of Contents
- Features
- A glimpse of RENAT by docker
- Installation by Ansible
- Installation for CentOS7
- Installation for other CentOSes
- RENAT checkout and preparation
- Create scenarios
- More Examples
- Manual
- Copying And Copyrights
- Thanks
For the impatient users, see renat by docker for a quick trial.
The framework provides an simple way to conduct Network Automated Testing by using simple scenario
RENAT features:
- a Robot-framework (RF) library aims to support NW testing with easy-to-write plain-text scenario utilizing all features of current RF
- supports end-to-end NW testing process in a large scale lab environment
- highly reusable scenarios with data-logic separated format and well-structured test project/ items
- supports multi access types to NW appliances including telnet/ssh (ssh proxy) and web access
- simulates user’s actions, keystrokes in details with virtual terminals
- conceals common access, logging process to focus on the test’s content easily
- supports a wide range of NW devices including routers, switches, L1 optic switch and web appliances out-of-the-shelves
- supports hypervisors and webMKS
- flexible modular and multi-vendors architecture, easy to customize
- currently supported platforms:
- routers/switches: Cisco, Junipers, GR, Alcatel Lucent, Yamaha
- L1 switches: Calient, G4NMT
- testers: IxiaNetwork, IxiaLoad, IxiaBreakingPoint, Spirent Avalanche
- hypervisors: VMware
- servers: *unix system
- others platforms: SmartCS, ArborSP, Samurai (a NTTCOM product)
Notes: Supports could be variant on OS versions
A super simple way to try RENAT is running it from a container. Below are instructions.
Notes: this container does not include proprietary softwares. See manuals for more details on how to install those.
-
Import docker image from dockerhub
docker pull bachng/renat:latest -
Start the container that open port 80 and 10022
mkdir -p /opt/renat docker run --rm -d --privileged -v /opt/renat:/opt/renat -p 80:80 -p 10022:22 --name renat bachng/renat:latestAt this point, a RENAT server will all necessary packages and latest RENAT is ready with predefined
robotuser.The folder
/opt/renaton the container is also bound to/opt/renaton the host. -
Login to the container as
robotuserdocker exec -it --user robot renat /bin/bash --loginor using SSH with
robot/password!secretaccountssh -l robot -p 10022 <host_ip> -
Create a test scenario. Enter
yto create a local configuration file andEnterfor other questions.[robot@afeb42da1974 renat]$RENAT_PATH/tools/project.sh renat-sample [robot@afeb42da1974 renat]cd renat-sample [robot@afeb42da1974 renat]$RENAT_PATH/tools/item.sh test01A
do nothingscenario is made. Check test01/main.robot for more details -
Run and check the result
[robot@afeb42da1974 renat]cd test01 [robot@afeb42da1974 renat]./run.shTest results and logs could be checked by
http://<this machine IP>/~robot/result.log -
Edit following configuration files
- $RENAT_PATH/config/device.yaml: device's IP
- $RENAT_PATH/config/auth.yaml: authentication (username/password)
- $RENAT_PATH/config/template.yaml(optional): in case current templates are not fit for your devices
Notes: By default,
configis a symbolic link tomisc/config.sample. Change it to other permanent path to keep your configurations if it is necessary.
See Create scenarios for more details about creating a sample to interact with routers.
Installation instructions using Ansible
-
Prepare an Ansible server Prepare an Ansible service with necessary packages
-
Install a base CentOS
- install a base CentOS7 with
minimum distributionanddeveloper package - set and remember password for the root account
- install a base CentOS7 with
-
Prepare the playbook
-
extract playbooks from
misc/ansible-renat-github.tar.gz -
add an entry in ansible server for the install target
genesisin/etc/hostsfile10.128.64.2 genesis -
edit
ansible-renat-github/inventories/hostand change the passwordpasswordto the correct password set in step #2[renat:vars] ansible_ssh_user=root ansible_ssh_pass=password -
if the target is behind a proxy, configure the proxy IP in
host_vars/genesis
-
-
Run the playbook
cd ansible-renat-github ansible-playbook -i inventories/host -e "hosts=genesis" RENAT_INSTALL.yml -vvvv --diff
The playbook will install necessary packages and environment for RENAT
Add necessary more users and go to here to continue
Basic install instruction for Centos7 and Python3
Install a typical Centos7 with following parameters:
- memory: 16G (or more)
- HDD: 64G (or more)
- NIC: 2
- package: minimum (+developer package)
- ip address: 10.128.64.10/16 (sample)
- gw: 10.128.1.1 (sample)
- dns: 10.128.3.101 (sample)
- hostname: renat.localhost (sample)
-
disable SE linux:
-
disable the feature
set enforce 0 -
configure
SELINUX=disabledin the/etc/selinux/configfile:
-
-
update install package and
rebootthe systemyum update -y reboot
-
install python3 and related library
yum install -y python3 python3-libs python3-devel python3-pip pip3.6 install --upgrade pip -
install extra libraries
yum install -y net-snmp net-snmp-devel net-snmp-utils czmq czmq-devel python3-tkinter xorg-x11-server-Xvfb vim httpd xorg-x11-fonts-75dpi nfs samba4 samba-client samba-winbind cifs-utils tcpdump hping3 telnet nmap wireshark java-1.8.0-openjdk firefox telnet ld-linux.so.2 ghostscript ImageMagick vlgothic-fonts vlgothic-p-fonts ntp openssl sshpass pip3.6 install pytest-runner pip3.6 install numpy pyte PyYAML openpyxl Jinja2 pandas lxml requests netsnmp-py pdfkit robotframework robotframework-selenium2library robotframework-sshlibrary docutils pyvmomi PyVirtualDisplay pyscreenshot pillow decorator imgurscrot opencv-python pytesseract -
install libraries (besides yum)
cd /root mkdir -p work/download cd /root/work/download wget https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz tar xzvf /root/work/download/geckodriver-v0.21.0-linux64.tar.gz -C /usr/local/bin cd /root/work/download wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm rpm -Uvh wkhtmltox-0.12.5-1.centos7.x86_64.rpm -
install jenkins (optional)
cd work/download sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key yum install -y jenkins
-
modify NTP server
- modify /etc/ntp.conf for favourite NTP server
- activate and make the service auto start
service ntpd start chkconfig ntpd on - check the current NTP
ntpq -p
-
sudo privilege
-
add a file named
renat(permision 0440) to folder/etc/sudoers.dDefaults env_keep += "PATH PYTHONPATH LD_LIBRARY_PATH MANPATH XDG_DATA_DIRS PKG_CONFIG_PATH RENAT_PATH" Cmnd_Alias CMD_ROBOT_ALLOW = /bin/kill,/usr/local/bin/nmap,/usr/sbin/hping3,/usr/sbin/tcpdump %renat ALL=NOPASSWD: CMD_ROBOT_ALLOW %jenkins ALL=NOPASSWD: CMD_ROBOT_ALLOW -
comment out the line including
secure_pathin the file/etc/sudoers# Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
-
-
change some system default behaviours
-
create a folder name
workunder/etc/skelwith permission0775 -
change
UMASKto022in the file/etc/login.defs# UMASK 077 UMASK 022
-
-
add a default group and user and set its password
groupadd renat -o -g 1000 useradd robot -g renat passwd robotNote: the password of this
robotaccount is set in the RENAT config file${RENAT_PATH}/config/config.yaml -
configure renat log
- prepare a log folder
mkdir /var/log/renat chown root:renat /var/log/renat chmod 0775 /var/log/renat- add setting for renat to the end of
/etc/rsyslog.conf
# All renat log to same place local5.* /var/log/renat/renat.log- and restart the rsyslog daemon
service rsyslog restart- prepare a logrotate file
/etc/logrotate.d/renat
/var/log/renat/renat.log { daily rotate 90 missingok notifempty copytruncate dateext dateformat %Y-%m-%d } -
configure jenkins (optional):
-
Change jenkins listen port
JENNKINS_PORTto8002in file/etc/sysconfig/jenkins# JENKINS_PORT="8080" JENKINS_PORT="8082" -
enable the service
systemctl enable jenkins systemctl start jenkins
-
-
configure iptables: By default, Centos7 does not support saving iptables from
servicecommand.systemctl stop firewalld systemctl disable firewalld yum install -y iptables-services systemctl enable iptables.service systemctl start iptables.serviceThen configure
iptablesto allow necessary ports like80,8082,22and traffic from IxiaAppServer. Or allow access for your whole local network:-A INPUT -s 10.128.0.0/16 -j ACCEPT -
configure httpd service
-
add
apachetorenatgroup -
modify
userdir.confunder folder/etc/httpd/conf.dto show list theworkfolder of each user# UserDir disabled UserDir enabled # UserDir public_html UserDir work # <Directory "/home/*/public_html"> <Directory "/home/*/work"> IndexOptions +NameWidth=*Note: Do not for get the
<Directory>section -
add robot to mime type in file
/etc/mime.types# text/plain txt asc text pm el c h cc hh cxx hxx f90 conf log text/plain txt asc text pm el c h cc hh cxx hxx f90 conf log robot -
prepare the document folder
mkdir -p /var/www/html/renat-doc chown apache:renat /var/www/html/renat-doc/ chmod 0775 /var/www/html/renat-doc/ -
enable and restart the service
systemctl restart httpd systemctl enable httpd
-
-
make skeleton for users
- create a folder call
workunder/etc/skelwith mode0750
- create a folder call
-
add a user (e.g. robot) to the group
renatuseradd robot -g renat passwd robot -
login as the new user
-
create a key for the account
robotthat would be used for using with SSH proxy. PushEnterwhen asked for password (2 times)mkdir ~/.ssh cd ~/.ssh ssh-keygen -C for_robot_`whoami` -f robot_id_rsa -
push to key to proxy server using
robotpasswordssh-copy-id -i robot_id_rsa.pub robot@<proxy server IP>
-
download necessary files (below are samples. Use the correct install files in your environment)
BPSRobotLibrary.tgz IxNetworkTclClient7.41.945.9Linux.bin.tgz IxOS6.80.1100.9Linux64.bin.tar.gz -
install IxOS. Choose
Tcl8.5and default destination folder/opt/ixia/ixos/6.80-EA-SP1tar xzvf IxOS6.80.1100.9Linux64.bin.tar.gz ./IxOS6.80.1100.9Linux64.bin -i console -
install IxNetwork. Choose
/opt/ixia/ixnet/7.41-EAfor default destination folder and1-YesforHTLAPIwhen asked (let other option as default)tar xzvf IxNetworkTclClient7.41.945.9Linux.bin.tgz ./IxNetworkTclClient7.41.945.9Linux.bin -i console -
install IOxLoad. Choose
/opt/ixia/ixload/8.01.99.14for default destination folder.tar xzvf IxLoadTclApi8.01.99.14Linux_x64.bin.tgz ./IxLoadTclApi8.01.99.14Linux_x64.bin -i console
Note:
- if it is necessary remove the folder if you chose wrong destination folder and reinstall
- Ixia library need to be patched to run in python3 env. Check
patchfolder for details
-
install avalanch api
pip3.6 install avalancheapi -
install avaproxy
Detail for
avaproxycould be found inmiscfolder
- CentOS 6: Install instructions for CentOS6 Python2.x environment could be found in here
- CentOS 8: is almost identical with CenOS 7 with following differences
- Installing epel8 before other packages
yum -y install epel-release - Using
chronyinstead of ntp. Editing/etc/chrony.conffor proper NTP server and active byservice chronyd start chkconfig chronyd on chronyc source - Using wkhtmltox with newer version
cd /root/work/download wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos8.x86_64.rpm rpm -Uvh wkhtmltox-0.12.6-1.centos8.x86_64.rpm
- Installing epel8 before other packages
-
Checkout Prepare a RENAT folder in user working folder and check out the source
cd mkdir work cd work git clone https://github.com/bachng2017/RENAT.git renat -
RENAT configuration
Make an environment varible
$RENAT_PATHpointing the correct RENAT folder.If you have multi renat (different version) checked out, modify this varible to use the correct RENAT version.
export RENAT_PATH=~/work/renatOr edit your startup script
echo "export RENAT_PATH=~/work/renat" >> ~/.bashrc -
Adjust the test enviroment
Configure device and authencation information in
$RENAT_PATH/config/device.yamland$RENAT_PATH/config/auth.yamlto suite to lab environment.The relation between configuration files as follow:
device.yaml template.yaml auth.yaml ------------- ------------------ -------------------- type: juniper ----->juniper: ip:x.x.x.x acess: telnet auth: plaintext ------->plain-text: profile: default -------->default: user: <user> pass: <password>
Below example assumes that you've already have a router running JunOS with name vmx11
For example change the IP for device vmx11 in device.yaml and change the default section for the telnet account that is used to login into vmx11 router.
-
Create a sample project
cd ~/work $RENAT_PATH/tools/project.sh sample created test project: sample use item.sh to create test case $tree sample sample ├── lab.robot ├── renat.rc ├── run.sh └── setpath.bashrc -
Create a sample test item
cd sample $RENAT_PATH/tools/item.sh item01 Create local configuration file (local.yaml) or not [yes,no=default]:y Use tester [ex:ixnet03_8009]: Use tester config file [ex:traffic.ixncfg]: Use node list (comma separated) [ex:vmx11]:vmx11 Use web app list (comma separated)[ex:samurai1]: === Created `item01` test item === Case scenario: /home/user/work/renat/tools/item01/main.robot Case run file: /home/user/work/renat/tools/item01/run.sh Local config file: /home/user/work/renat/tools/item01/config/local.yaml Tester config file:/home/user/work/renat/tools/item01/config/ Check and change the `local.yaml` local config file if necessary tree item01 item01 ├── config │ ├── local.yaml │ └── vmx11.conf ├── lab.robot -> ../lab.robot ├── main.robot ├── readme.txt ├── renat.rc ├── result ├── run.sh └── tmp 4 directories, 10 files -
Edit scenario file
config/local.yamlfile includes local information for each test item. Edit this file to add more test devices, tester or other item specific information. Editmain.robotfile in test item folder to look like this# Basic setting *** Setting *** Documentation This is a sample test item Metadata Log File [.|${CURDIR}/result] Suite Setup Lab Setup Suite Teardown Lab Teardown # Common setting Resource lab.robot # Variable setting *** Variables *** *** Test Cases *** 01. First item: Router.Switch vmx11 Router.Cmd show version -
Use
--dryrunoption to check the syntax./run.sh --dryrun Current RENAT path: /home/user/work/renat Run only once Current local.yaml: /home/user/work/renat/sample/item01/config/local.yaml Loaded extra library `Tester` Loaded extra library `Arbor` ============================================================================== Main :: Testing item01 ============================================================================== 01. First item: | PASS | ------------------------------------------------------------------------------ Main :: Testing item01 | PASS | 1 critical test, 1 passed, 0 failed 1 test total, 1 passed, 0 failed ============================================================================== Output: /home/user/work/renat/sample/item01/result/output.xml Log: /home/user/work/renat/sample/item01/result/log.html Report: /home/user/work/renat/sample/item01/result/report.html -
Execute
./run.shto run the test. Test result and log files are in the./resultfolder../run.sh Current RENAT path: /home/user/work/renat Run only once Current local.yaml: /home/user/work/renat/sample/item01/config/local.yaml Loaded extra library `Tester` Loaded extra library `Arbor` Loaded extra library `OpticalSwitch` ============================================================================== Main :: item01: very simple sample ============================================================================== RENAT Ver:: RENAT 0.1.6 ------------------------------------------------------------------------------ README: The sample requires a running Juniper router ------------------------------------------------------------------------------ 00. Lab Setup ------------------------------------------------------------------------------ 01. First item: | PASS | ------------------------------------------------------------------------------ 99. Lab Teardown ------------------------------------------------------------------------------ Main :: item01: very simple sample | PASS | 1 critical test, 1 passed, 0 failed 1 test total, 1 passed, 0 failed ============================================================================== Output: /home/user/work/renat/sample/item01/result/output.xml Log: /home/user/work/renat/sample/item01/result/log.html Report: /home/user/work/renat/sample/item01/result/report.html -
Check the result In case you has configured a web server, access
http://<server-ip>/~<username>/tes01/result/log.htmlorhttp://<server-ip>/~<username>/result/report.htmlfor more details about the result.
When running with --debug options likes ./run.sh --debug debug.txt, the system creates detail debug information in the file result/debug.txt. Use this to see in details or bug report. Please make sure your passwords are removed before submit the files.
- See item02 for sample about
Exec Filekeyword - See item03 for sample about
BGP Best Path Selectiontesting for a JunOS router
See manual for more details about RENAT keywords and its modules. Or checking the doc folder in your renat (html/pdf)
Copyright 2018-2019 NTT Communications
This project is licensed under the Apache v2.0 license. For more detail see license
Thanks to everybody has encouraged, tested and supported this project. All comments, advices and co-operation are appreciated.
