Merge "o introducing FlowLib robot/python library. Gives ability to dynamically...
[integration/test.git] / test / csit / suites / base-of13 / 070__Flows_OF13 / 305__ttl.txt
index cd9ba04ce90813aa5ea519634e1e2b7f7da5baf8..5b05b6c5470d0642e45df7e0ae1d792af77df344 100644 (file)
@@ -8,7 +8,7 @@ Documentation     OF1.3 Suite to cover TTL Actions
 ...               - Decrement MPLS TTL
 ...
 ...               NOTE: for OVS, it appears that set_ttl, and both copy in/out are not supported, so need to skip those checks for now.
-Suite Setup       Create Session    session    http://${CONTROLLER}:8080    auth=${AUTH}    headers=${HEADERS_XML}
+Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
 Suite Teardown    Delete All Sessions
 Test Template     Create And Remove Flow
 Library           SSHLibrary
@@ -16,6 +16,7 @@ Library           Collections
 Library           OperatingSystem
 Library           String
 Library           XML
+Resource          ../../../libraries/FlowLib.txt
 Library           ../../../libraries/RequestsLibrary.py
 Library           ../../../libraries/Common.py
 Variables         ../../../variables/Variables.py
@@ -25,41 +26,60 @@ ${REST_CON}       /restconf/config/opendaylight-inventory:nodes
 ${REST_OPR}       /restconf/operational/opendaylight-inventory:nodes
 ${GENERIC_ACTION_FLOW_FILE}    ${CURDIR}/../../../variables/xmls/genericActionFlow.xml
 ${MININET_CMD}    sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,1 --switch ovsk,protocols=OpenFlow13
+${ipv4_src}       10.1.2.0/24
+${ipv4_dst}       40.4.0.0/16
+${eth_type}       0x800
+${eth_src}        00:00:00:01:23:ae
+${eth_dst}        ff:ff:ff:ff:ff:ff
 
-*** Test Cases ***    ODL flow action        action XML                tableID    flowID    verify OVS?    OVS specific string?
-Set_IP_TTL            set-nw-ttl-action      <nw-ttl>1</nw-ttl>        2          101       no             set_ttl
+*** Test Cases ***    ODL flow action        action key                                                                                                                      action value    tableID    flowID    verify OVS?    OVS specific string?
+Set_IP_TTL            [Documentation]        OF1.3: \ OFPAT_SET_NW_TTL = 23, /* IP TTL. */\n(currently not supported on OVS)\n
+                      [Tags]                 ttl                                                                                                                             set
+                      set-nw-ttl-action      nw-ttl                                                                                                                          1               2          101       no             set_ttl
 
-Dec_TTL               dec-nw-ttl             none                      3          305       yes            dec_ttl
+Dec_TTL               [Documentation]        OF1.3: \ OFPAT_DEC_NW_TTL = 24, /* Decrement IP TTL. */\n
+                      [Tags]                 ttl                                                                                                                             dec
+                      dec-nw-ttl             none                                                                                                                            none            3          305       yes            dec_ttl
 
-Copy_TTL_In           copy-ttl-in            none                      9          202       no             copy_ttl_in
+Copy_TTL_In           [Documentation]        OFPAT_COPY_TTL_IN = 12, /* Copy TTL "inwards" -- from outermost to\nnext-to-outermost */\n(currently NOT supported in OVS)\n
+                      [Tags]                 ttl                                                                                                                             copyin
+                      copy-ttl-in            none                                                                                                                            none            9          202       no             copy_ttl_in
 
-Copy_TTL_Out          copy-ttl-out           none                      8          909       no             copy_ttl_out
+Copy_TTL_Out          [Documentation]        OFPAT_COPY_TTL_OUT = 11, /* Copy TTL "outwards" -- from next-to-outermost\nto outermost */\n(currently NOT suported in OVS)
+                      [Tags]                 ttl                                                                                                                             copyout
+                      copy-ttl-out           none                                                                                                                            none            8          909       no             copy_ttl_out
 
-Set_MPLS_TTL          set-mpls-ttl-action    <mpls-ttl>1</mpls-ttl>    4          505       yes            set_mpls_ttl
+Set_MPLS_TTL          [Documentation]        OFPAT_SET_MPLS_TTL = 15, /* MPLS TTL */
+                      [Tags]                 ttl                                                                                                                             setmpls
+                      set-mpls-ttl-action    mpls-ttl                                                                                                                        1               4          505       yes            set_mpls_ttl
 
-Dec_MPLS_TTL          dec-mpls-ttl           none                      2          1001      yes            dec_mpls_ttl
+Dec_MPLS_TTL          [Documentation]        OFPAT_DEC_MPLS_TTL = 16, /* Decrement MPLS TTL */
+                      [Tags]                 ttl                                                                                                                             decmpls
+                      dec-mpls-ttl           none                                                                                                                            none            2          1001      yes            dec_mpls_ttl
 
 *** Keywords ***
 Create And Remove Flow
-    [Arguments]    ${flow_action}    ${action_xml}    ${table_id}    ${flow_id}    ${verify_switch_flag}    ${additional_ovs_flowelements}
-    ${flow_body}=    OperatingSystem.Get File    ${GENERIC_ACTION_FLOW_FILE}
-    ${flow_body}=    Replace String    ${flow_body}    FLOW_ACTION    ${flow_action}
-    ${flow_body}=    Replace String    ${flow_body}    FLOW_ID    ${flow_id}
-    ${flow_body}=    Replace String    ${flow_body}    TABLE_ID    ${table_id}
-    Log    ${flow_body}
-    ${flow_root}=    Parse XML    ${flow_body}
-    Run Keyword If    "set" in "${flow_action}"    Add Element    ${flow_root}    ${action_xml}    xpath=instructions/instruction/apply-actions/action/${flow_action}
-    ${nw_src}=    Get Element    ${flow_root}    match/ipv4-source
-    ${nw_dst}=    Get Element    ${flow_root}    match/ipv4-destination
-    ${eth_src}=    Get Element    ${flow_root}    match/ethernet-match/ethernet-source/address
-    ${eth_dst}=    Get Element    ${flow_root}    match/ethernet-match/ethernet-destination/address
-    @{OVS_FLOWELEMENTS}    Create List    dl_dst=${eth_dst.text}    table=${table_id}    dl_src=${eth_src.text}    nw_src=${nw_src.text}    nw_dst=${nw_dst.text}
+    [Arguments]    ${flow_action}    ${action_key}    ${action_value}    ${table_id}    ${flow_id}    ${verify_switch_flag}
     ...    ${additional_ovs_flowelements}
-    ${flow_data}=    Element To String    ${flow_root}
-    Log    ${flow_data}
-    Add Flow To Controller And Verify    ${flow_data}    ${table_id}    ${flow_id}
+    @{OVS_FLOWELEMENTS}    Create List    dl_dst=${eth_dst}    table=${table_id}    dl_src=${eth_src}    nw_src=${ipv4_src}    nw_dst=${ipv4_dst}
+    ...    ${additional_ovs_flowelements}
+    ##The dictionaries here will be used to populate the match and action elements of the flow mod
+    ${ethernet_match_dict}=    Create Dictionary    type=${eth_type}    destination=${eth_dst}    source=${eth_src}
+    ${ipv4_match_dict}=    Create Dictionary    source=${ipv4_src}    destination=${ipv4_dst}
+    ##flow is a python Object to build flow details, including the xml format to send to controller
+    ${flow}=    Create Flow
+    Set "${flow}" "table_id" With "${table_id}"
+    Set "${flow}" "id" With "${flow_id}"
+    Clear Flow Actions    ${flow}
+    Set Flow Action    ${flow}    0    0    ${flow_action}
+    Set Flow Ethernet Match    ${flow}    ${ethernet_match_dict}
+    Set Flow IPv4 Match    ${flow}    ${ipv4_match_dict}
+    ##If the ${flow_action} contains the string "set" we need to include a deeper action detail (e.g. set-ttl needs a element to indicate the value to set it to)
+    Run Keyword If    "set" in "${flow_action}"    Add Flow XML Element    ${flow}    ${action_key}    ${action_value}    instructions/instruction/apply-actions/action/${flow_action}
+    Log    Flow XML is ${flow.xml}
+    Add Flow To Controller And Verify    ${flow.xml}    ${flow.table_id}    ${flow.id}
     Run Keyword If    "${verify_switch_flag}" == "yes"    Verify Flow On Switch    ${OVS_FLOWELEMENTS}
-    Remove Flow From Controller And Verify    ${flow_body}    ${table_id}    ${flow_id}
+    Remove Flow From Controller And Verify    ${flow.xml}    ${flow.table_id}    ${flow.id}
     Run Keyword If    "${verify_switch_flag}" == "yes"    Verify Flow Does Not Exist On Switch    ${OVS_FLOWELEMENTS}
 
 Add Flow To Controller And Verify