Add a new function into Common to compare two XML files 84/6884/2
authorChristopher O'Shea <christopher.o.shea@ericsson.com>
Mon, 12 May 2014 01:10:25 +0000 (18:10 -0700)
committerChristopher O'Shea <christopher.o.shea@ericsson.com>
Mon, 12 May 2014 18:36:07 +0000 (11:36 -0700)
3 new test case to check the flow are pushed to the switch correctly
Putting back the Variables i deleted last change.

Change-Id: I968ed7050a48595dfcd8a1b7bacee21dc39ebf61
Signed-off-by: Christopher O'Shea <christopher.o.shea@ericsson.com>
test/csit/libraries/Common.py
test/csit/suites/base-of13/300__dst_ip.txt [new file with mode: 0644]
test/csit/suites/base-of13/301__src_ip.txt [new file with mode: 0644]
test/csit/suites/base-of13/302__dst_mac.txt [new file with mode: 0644]
test/csit/variables/Variables.py

index 000b2b868eaea18df04aa299b461f2960e1f0ff6..6b1570907ab34f743d6e65fff80d210a0d206a7a 100644 (file)
@@ -4,6 +4,7 @@ Authors: Baohua Yang@IBM, Denghui Huang@IBM
 Updated: 2013-11-14
 """
 import collections
+import xml.etree.ElementTree as ET
 
 '''
 Common constants and functions for the robot framework.
@@ -35,5 +36,28 @@ def combine_strings(*strings):
     else:
         return result
 
+        
+def compare_xml(xml1, xml2):
+    """
+    compare the two XML files to see if they contain the same data
+    but could be if different order.
+    It just split the xml in to lines and just check the line is in
+    the other file 
+    """
+    for line in xml1.rstrip().split('\n'):
+        if line not in xml2.rstrip().split('\n'):
+            return False
+
+    for line in xml2.rstrip().split('\n'):
+        if line not in xml1.rstrip().split('\n'):
+            return False
+
+    return True
+
+    
+
+
 if __name__ == '__main__':
+    
+
     pass
diff --git a/test/csit/suites/base-of13/300__dst_ip.txt b/test/csit/suites/base-of13/300__dst_ip.txt
new file mode 100644 (file)
index 0000000..17ad0d5
--- /dev/null
@@ -0,0 +1,67 @@
+*** Settings ***
+Documentation     Test suite for pushing/verify/remove a flow through RESTCONF
+Suite Setup       Create Session    session    http://${CONTROLLER}:8080    auth=${AUTH}    headers=${HEADERS_XML}
+Suite Teardown    Delete All Sessions
+Library           SSHLibrary
+Library           Collections
+Library           OperatingSystem
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${REST_CON}       /restconf/config/opendaylight-inventory:nodes
+${REST_OPR}       /restconf/operational/opendaylight-inventory:nodes
+${FILE}           ${CURDIR}/../../variables/xmls/f1.xml
+${FLOW}           124
+${TABLE}          2
+@{FLOWELMENTS}    nw_dst=10.0.1.0    table=2    dec_ttl
+
+*** Test Cases ***
+Add a flow - Output to physical port#
+    [Documentation]    Push a flow through REST-API
+    [Tags]    Push
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Set Suite Variable    ${body}
+    ${resp}    Putxml    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    
+
+Verify after adding flow config - Output to physical port#
+    [Documentation]    Verify the flow
+    [Tags]    Get
+    ${resp}    get    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    compare xml    ${body}    ${resp.content}
+
+Verify flows after adding flow config on OVS
+    [Documentation]    Checking Flows on switch
+    [Tags]    Switch
+    write    dpctl dump-flows -O OpenFlow13
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Sleep    2
+    ${switchouput}    Read
+    : FOR    ${flowElement}    IN    @{FLOWELMENTS}
+    \    should Contain    ${switchouput}    ${flowElement}
+
+Remove a flow - Output to physical port#
+    [Documentation]    Remove a flow
+    [Tags]    remove
+    ${resp}    Delete    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after deleting flow config - Output to physical port#
+    [Documentation]    Verify the flow
+    [Tags]    Get
+    ${resp}    Get    session    ${REST_CON}/node/openflow:1/table/${TABLE}
+    Should Not Contain    ${resp.content}    ${FLOW}
+
+Verify flows after deleting flow config on OVS
+    [Documentation]    Checking Flows on switch
+    [Tags]    Switch
+    write    dpctl dump-flows -O OpenFlow13
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Sleep    2
+    ${switchouput}    Read
+    : FOR    ${flowElement}    IN    @{FLOWELMENTS}
+    \    should Not Contain    ${switchouput}    ${flowElement}
diff --git a/test/csit/suites/base-of13/301__src_ip.txt b/test/csit/suites/base-of13/301__src_ip.txt
new file mode 100644 (file)
index 0000000..b79de25
--- /dev/null
@@ -0,0 +1,66 @@
+*** Settings ***
+Documentation     Test suite for pushing/verify/remove a flow through RESTCONF
+Suite Setup       Create Session    session    http://${CONTROLLER}:8080    auth=${AUTH}    headers=${HEADERS_XML}
+Suite Teardown    Delete All Sessions
+Library           SSHLibrary
+Library           Collections
+Library           OperatingSystem
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${REST_CON}       /restconf/config/opendaylight-inventory:nodes
+${REST_OPR}       /restconf/operational/opendaylight-inventory:nodes
+${FILE}           ${CURDIR}/../../variables/xmls/f2.xml
+${FLOW}           125
+${TABLE}          2
+@{FLOWELMENTS}    nw_src=10.0.0.1    table=2    drop
+
+*** Test Cases ***
+Add a flow - Output to physical port#
+    [Documentation]    Push a flow through REST-API
+    [Tags]    Push
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Set Suite Variable    ${body}
+    ${resp}    Putxml    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after adding flow config - Output to physical port#
+    [Documentation]    Verify the flow
+    [Tags]    Get
+    ${resp}    get    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    compare xml    ${body}    ${resp.content}
+
+Verify flows after adding flow config on OVS
+    [Documentation]    Checking Flows on switch
+    [Tags]    Switch
+    write    dpctl dump-flows -O OpenFlow13
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Sleep    2
+    ${switchouput}    Read
+    : FOR    ${flowElement}    IN    @{FLOWELMENTS}
+    \    should Contain    ${switchouput}    ${flowElement}
+
+Remove a flow - Output to physical port#
+    [Documentation]    Remove a flow
+    [Tags]    remove
+    ${resp}    Delete    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after deleting flow config - Output to physical port#
+    [Documentation]    Verify the flow
+    [Tags]    Get
+    ${resp}    Get    session    ${REST_CON}/node/openflow:1/table/${TABLE}
+    Should Not Contain    ${resp.content}    ${FLOW}
+
+Verify flows after deleting flow config on OVS
+    [Documentation]    Checking Flows on switch
+    [Tags]    Switch
+    write    dpctl dump-flows -O OpenFlow13
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Sleep    2
+    ${switchouput}    Read
+    : FOR    ${flowElement}    IN    @{FLOWELMENTS}
+    \    should Not Contain    ${switchouput}    ${flowElement}
diff --git a/test/csit/suites/base-of13/302__dst_mac.txt b/test/csit/suites/base-of13/302__dst_mac.txt
new file mode 100644 (file)
index 0000000..8f72905
--- /dev/null
@@ -0,0 +1,66 @@
+*** Settings ***
+Documentation     Test suite for pushing/verify/remove a flow through RESTCONF
+Suite Setup       Create Session    session    http://${CONTROLLER}:8080    auth=${AUTH}    headers=${HEADERS_XML}
+Suite Teardown    Delete All Sessions
+Library           SSHLibrary
+Library           Collections
+Library           OperatingSystem
+Library           ../../libraries/RequestsLibrary.py
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+
+*** Variables ***
+${REST_CON}       /restconf/config/opendaylight-inventory:nodes
+${REST_OPR}       /restconf/operational/opendaylight-inventory:nodes
+${FILE}           ${CURDIR}/../../variables/xmls/f3.xml
+${FLOW}           126
+${TABLE}          2
+@{FLOWELMENTS}    dl_src=00:00:00:00:00:01    table=2    drop
+
+*** Test Cases ***
+Add a flow - Output to physical port#
+    [Documentation]    Push a flow through REST-API
+    [Tags]    Push
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Set Suite Variable    ${body}
+    ${resp}    Putxml    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}    data=${body}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after adding flow config - Output to physical port#
+    [Documentation]    Verify the flow
+    [Tags]    Get
+    ${resp}    get    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    compare xml    ${body}    ${resp.content}
+
+Verify flows after adding flow config on OVS
+    [Documentation]    Checking Flows on switch
+    [Tags]    Switch
+    write    dpctl dump-flows -O OpenFlow13
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Sleep    2
+    ${switchouput}    Read
+    : FOR    ${flowElement}    IN    @{FLOWELMENTS}
+    \    should Contain    ${switchouput}    ${flowElement}
+
+Remove a flow - Output to physical port#
+    [Documentation]    Remove a flow
+    [Tags]    remove
+    ${resp}    Delete    session    ${REST_CON}/node/openflow:1/table/${TABLE}/flow/${FLOW}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after deleting flow config - Output to physical port#
+    [Documentation]    Verify the flow
+    [Tags]    Get
+    ${resp}    Get    session    ${REST_CON}/node/openflow:1/table/${TABLE}
+    Should Not Contain    ${resp.content}    ${FLOW}
+
+Verify flows after deleting flow config on OVS
+    [Documentation]    Checking Flows on switch
+    [Tags]    Switch
+    write    dpctl dump-flows -O OpenFlow13
+    ${body}    OperatingSystem.Get File    ${FILE}
+    Sleep    2
+    ${switchouput}    Read
+    : FOR    ${flowElement}    IN    @{FLOWELMENTS}
+    \    should Not Contain    ${switchouput}    ${flowElement}
index 5289435c3703926430024efa72ae6e03bee29065..d1977d6aaa7c031762bbfeead8474ce2f475ce9c 100644 (file)
@@ -15,7 +15,7 @@ PWD = 'admin'
 AUTH = [u'admin',u'admin']
 HEADERS={'Content-Type': 'application/json'}
 HEADERS_XML={'Content-Type': 'application/xml'}
-HEADERS_ACCEPT={'Accept': 'application/xml'}
+ACCEPT_XML={'Accept': 'application/xml'}
 ODL_CONTROLLER_SESSION=None
 TOPO_TREE_LEVEL=2
 
@@ -29,6 +29,7 @@ VTNWEBAPI='/vtn-webapi'
 #controllers URL
 CTRLS_CREATE='controllers.json'
 CTRLS='controllers'
+SW='switches'
 
 #vtn URL
 VTNS_CREATE='vtns.json'
@@ -44,3 +45,9 @@ VBRIFS='interfaces'
 
 #portmap URL
 PORTMAP_CREATE='portmap.json'
+
+#vlanmap URL
+VLANMAP_CREATE='vlanmaps.json'
+
+#ports URL
+PORTS='ports/detail.json'