-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
770 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = '1.2.0' | ||
VERSION = '1.3.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.2.0 | ||
1.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
============================================ | ||
Simple Test Example usign BDD style keywords | ||
============================================ | ||
|
||
.. raw:: html | ||
|
||
<!-- This class allows us to hide the test setup part --> | ||
<style type="text/css">.hidden { display: none; }</style> | ||
|
||
.. contents:: | ||
:local: | ||
|
||
This example demonstrates how RobotFramework tests can be embedded in | ||
ReStructuredText documentation and use the Behavior Driven Development (BDD) | ||
(gherkin) style language. If you are converting an existing tab-separated test | ||
suite, convert tabs to 4-spaces within the RST file. | ||
|
||
“Given”, “When”, “Then” and “And” are ignored at the beginning of user keywords. | ||
|
||
See http://robotframework.googlecode.com/svn/tags/robotframework-2.1.2/doc/userguide/RobotFrameworkUserGuide.html#embedding-arguments-into-keyword-name | ||
|
||
The testcases should be in `code:: robotframework` blocks. | ||
|
||
Installing RobotFramework | ||
========================= | ||
|
||
To execute this test, setup the following:: | ||
|
||
pip install robotframework docutils Pygments | ||
git clone https://github.com/arista-eosplus/robotframework-aristalibrary.git | ||
cd robotframework-aristalibrary/ | ||
python setup.py install | ||
|
||
|
||
Executing tests | ||
=============== | ||
|
||
Start tests using one of the examples, below:: | ||
|
||
robot demo/sample_test_refactored.rst | ||
|
||
robot --variable SW1_HOST:localhost --variable SW1_PORT:61080 \ | ||
--variable USERNAME:eapiuser --variable PASSWORD:icanttellyou \ | ||
demo/sample_test_refactored.rst | ||
|
||
robot --variablefile demo/myvariables.py | ||
demo/sample_test_refactored.rst | ||
|
||
Variable files | ||
-------------- | ||
|
||
Variable files are just python modules with KEY = value pairs. | ||
|
||
Example `myvariables.py`:: | ||
|
||
""" My custom values for this test suite | ||
""" | ||
|
||
SW1_HOST = 'localhost' | ||
SW1_PORT = 61080 | ||
USERNAME = 'eapiuser' | ||
PASSWORD = 'icanttellyou' | ||
|
||
Suite Setup | ||
=========== | ||
|
||
.. code:: robotframework | ||
:class: hidden | ||
*** Settings *** | ||
Documentation This is a sample Robot Framework suite which takes advantage of | ||
... the AristaLibrary for communicating with and controlling Arista switches. | ||
... Run with: | ||
... pybot --pythonpath=AristaLibrary --noncritical new demo/sample-test-refactored.txt | ||
Library AristaLibrary | ||
Library Collections | ||
Suite Setup Connect To Switches | ||
Suite Teardown Clear All Connections | ||
*** Variables *** | ||
${TRANSPORT} http | ||
${SW1_HOST} localhost | ||
${SW1_PORT} 2080 | ||
${SW2_HOST} localhost | ||
${SW2_PORT} 2081 | ||
${USERNAME} vagrant | ||
${PASSWORD} vagrant | ||
*** Keywords *** | ||
Connect To Switches | ||
[Documentation] Establish connection to a switch which gets used by test cases. | ||
Connect To host=${SW1_HOST} transport=${TRANSPORT} username=${USERNAME} password=${PASSWORD} port=${SW1_PORT} | ||
Configure hostname veos0 | ||
#Connect To host=${SW2_HOST} transport=${TRANSPORT} username=${USERNAME} password=${PASSWORD} port=${SW2_PORT} | ||
#Configure hostname veos1 | ||
Configure IP Int | ||
[Arguments] ${switch} ${interface} ${ip} | ||
Change To Switch ${switch} | ||
Configure default interface ${interface} | ||
@{cmds}= Create List default interface ${interface} interface ${interface} no switchport ip address ${ip} no shutdown | ||
Configure ${cmds} | ||
Switch ${switch} interface ${interface} has ip ${ip} | ||
Configure IP Int ${switch} ${interface} ${ip} | ||
Switch ${switch} pings ${ip} | ||
${output}= Enable ping 10.1.1.0 text | ||
${result}= Get From Dictionary ${output[0]} result | ||
Log ${result} | ||
${match} ${group1}= Should Match Regexp ${result['output']} (\\d+)% packet loss | ||
Set Suite Variable ${PING_RESULT} ${group1} | ||
ping packet loss should be ${expected} | ||
${result} = Get Variable Value ${PING_RESULT} "No_data" | ||
Should Be Equal As Integers ${result} ${expected} msg="Packets lost percent is ${result}, not ${expected}!!!" | ||
Set Suite Variable ${PING_RESULT} ${EMPTY} | ||
Test Cases | ||
=============== | ||
|
||
.. code:: robotframework | ||
*** Test Cases *** | ||
BDD Style Ping Self | ||
Given switch 1 interface Ethernet1 has ip 10.1.1.0/31 | ||
When switch 1 pings 10.1.1.0 | ||
Then ping packet loss should be 0 | ||
#BDD Style Ping Peer | ||
# Given switch 1 interface Ethernet1 has ip 10.1.1.0/31 | ||
# And switch 2 interface Ethernet1 has ip 10.1.1.1/31 | ||
# When switch 2 pings 10.1.1.0 | ||
# Then ping packet loss should be 0 | ||
There you go... Tests, embedded within documentation! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
======================================== | ||
Sample Test Example in RST documentation | ||
======================================== | ||
|
||
.. raw:: html | ||
|
||
<!-- This class allows us to hide the test setup part --> | ||
<style type="text/css">.hidden { display: none; }</style> | ||
|
||
.. contents:: | ||
:local: | ||
|
||
This example demonstrates how RobotFramework tests can be embedded in | ||
ReStructuredText documentation. If you are converting an existing | ||
tab-separated test suite, convert tabs to 4-spaces within the RST file. | ||
|
||
The testcases should be in `code:: robotframework` blocks. | ||
|
||
Installing RobotFramework | ||
========================= | ||
|
||
To execute this test, setup the following:: | ||
|
||
pip install robotframework docutils Pygments | ||
git clone https://github.com/arista-eosplus/robotframework-aristalibrary.git | ||
cd robotframework-aristalibrary/ | ||
python setup.py install | ||
|
||
|
||
Executing tests | ||
=============== | ||
|
||
Start tests using one of the examples, below:: | ||
|
||
robot demo/sample_test_refactored.rst | ||
|
||
robot --variable SW1_HOST:localhost --variable SW1_PORT:61080 \ | ||
--variable USERNAME:eapiuser --variable PASSWORD:icanttellyou \ | ||
demo/sample_test_refactored.rst | ||
|
||
robot --variablefile demo/myvariables.py | ||
demo/sample_test_refactored.rst | ||
|
||
Variable files | ||
-------------- | ||
|
||
Variable files are just python modules with KEY = value pairs. | ||
|
||
Example `myvariables.py`:: | ||
|
||
""" My custom values for this test suite | ||
""" | ||
|
||
SW1_HOST = 'localhost' | ||
SW1_PORT = 61080 | ||
USERNAME = 'eapiuser' | ||
PASSWORD = 'icanttellyou' | ||
|
||
Suite Setup | ||
=========== | ||
|
||
.. code:: robotframework | ||
:class: hidden | ||
*** Settings *** | ||
Documentation This is a sample Robot Framework suite which takes advantage of | ||
... the AristaLibrary for communicating with and controlling Arista switches. | ||
... Run with: | ||
... pybot --pythonpath=AristaLibrary --noncritical new demo/sample-test-refactored.txt | ||
Library AristaLibrary | ||
Library AristaLibrary.Expect | ||
Library Collections | ||
Suite Setup Connect To Switches | ||
Suite Teardown Clear All Connections | ||
*** Variables *** | ||
${TRANSPORT} http | ||
${SW1_HOST} localhost | ||
${SW1_PORT} 2080 | ||
${SW2_HOST} localhost | ||
${SW2_PORT} 2081 | ||
${USERNAME} vagrant | ||
${PASSWORD} vagrant | ||
*** Keywords *** | ||
Connect To Switches | ||
[Documentation] Establish connection to a switch which gets used by test cases. | ||
Connect To host=${SW1_HOST} transport=${TRANSPORT} username=${USERNAME} password=${PASSWORD} port=${SW1_PORT} | ||
Configure hostname veos0 | ||
#Connect To host=${SW2_HOST} transport=${TRANSPORT} username=${USERNAME} password=${PASSWORD} port=${SW2_PORT} | ||
#Configure hostname veos1 | ||
Test Cases | ||
=============== | ||
|
||
.. code:: robotframework | ||
*** Test Cases *** | ||
eAPI Command Revision | ||
[tags] Production | ||
# Default revision | ||
${output}= Enable show cvx | ||
${result}= Get From Dictionary ${output[0]} result | ||
Log ${result} | ||
Dictionary Should Not Contain Key ${result} clusterMode | ||
# Specify revision 2 for this command | ||
${show_cvx}= Create Dictionary cmd=show cvx revision=${2} | ||
${cmds}= Create List ${show_cvx} | ||
Log List ${cmds} | ||
${output}= Enable ${cmds} | ||
${result}= Get From Dictionary ${output[0]} result | ||
Log ${result} | ||
Dictionary Should Contain Key ${result} clusterMode | ||
eAPI Command Revision with Expect | ||
[tags] Production | ||
# Specify revision 2 for this command | ||
${show_cvx}= Create Dictionary cmd=show cvx revision=${2} | ||
${cmds}= Create List ${show_cvx} | ||
Log List ${cmds} | ||
Get Command Output cmd=${cmds} | ||
Expect clusterMode is False | ||
eAPI Command Revision with Eapi Command | ||
[tags] Production | ||
${show_cvx2}= Create Dictionary cmd=show cvx revision=${2} | ||
${cmds2}= Create List ${show_cvx2} | ||
# Specify revision 2 for this command | ||
${show_cvx}= Eapi Command cmd=show cvx revision=2 | ||
${show_ver}= Eapi Command cmd=show version | ||
${cmds}= Combine Lists ${show_cvx} ${show_ver} | ||
Log List ${cmds} | ||
Log List ${show_cvx} | ||
Log List ${cmds2} | ||
#Dictionaries Should Be Equal ${show_cvx}[0] ${show_cvx2}[0] | ||
Lists Should Be Equal ${show_cvx} ${cmds2} | ||
${output}= Enable ${cmds} | ||
Log List ${output} | ||
Log Dictionary ${output[0]['result']} | ||
There you go... Tests, embedded within documentation! |
Oops, something went wrong.