Priority is required in flow config
[integration/test.git] / test / csit / suites / openflowplugin / Switch_Qualification / 020_OpenFlow_Actions.robot
1 *** Settings ***
2 Documentation     OF1.3 Suite for flow actions
3 ...               - output ALL
4 ...               - output CONTROLLER
5 ...               - output TABLE
6 ...               - output INPORT
7 ...               - output LOCAL
8 ...               - output NORMAL
9 ...               - output FLOOD
10 ...               - output ANY
11 ...
12 ...               NOTE: for OVS, INPORT does not appear to be supported
13 Suite Setup       OpenFlow Actions Suite Setup
14 Suite Teardown    OpenFlow Actions Suite Teardown
15 Test Template     Create And Remove Flow
16 Library           Collections
17 Library           OperatingSystem
18 Library           String
19 Library           XML
20 Resource          ../../../libraries/Utils.txt
21 Resource          ../../../libraries/FlowLib.txt
22 Resource          ../../../libraries/SwitchUtils.txt
23 Library           ../../../libraries/RequestsLibrary.py
24 Library           ../../../libraries/Common.py
25 Variables         ../../../variables/Variables.py
26 Library           ../../../libraries/SwitchClasses/${SWITCH_CLASS}.py
27
28 *** Variables ***
29 ${SWITCH_CLASS}    Ovs
30 ${SWITCH_IP}      ${MININET}
31 ${CONTROLLER}     null
32 ${REST_CON}       /restconf/config/opendaylight-inventory:nodes
33 ${REST_OPR}       /restconf/operational/opendaylight-inventory:nodes
34 ${ipv4_src}       11.3.0.0/16
35 ${ipv4_dst}       99.0.0.0/8
36 ${eth_type}       0x800
37 ${eth_src}        00:ab:cd:ef:01:23
38 ${eth_dst}        ff:ff:ff:ff:ff:ff
39 ##documentation strings
40 ${INPORT_doc}     OF1.3: OFPP_INPORT = 0xfffffff8, /* Send the packet out the input port. This\nreserved port must be explicitly used\nin order to send back out of the input\nport. */\n
41 ${TABLE_doc}      OF1.3: OFPP_TABLE = 0xfffffff9, /* Submit the packet to the first flow table NB: This destination port can only be used in packet-out messages. */
42 ${NORMAL_doc}     OF1.3 OFPP_NORMAL = 0xfffffffa, /* Process with normal L2/L3 switching. */
43 ${FLOOD_doc}      OF1.3 OFPP_FLOOD = 0xfffffffb, /* All physical ports in VLAN, except input port and those blocked or link down. */
44 ${ALL_doc}        OF1.3: OFPP_ALL = 0xfffffffc, /* All physical ports except input port. */
45 ${CONTROLLER_doc}    OF1.3 OFPP_CONTROLLER = 0xfffffffd, /* Send to controller. */
46 ${LOCAL_doc}      OF1.3 OFPP_LOCAL = 0xfffffffe, /* Local openflow "port". */
47 ${ANY_doc}        OF1.3 OFPP_ANY = 0xffffffff /* Wildcard port used only for flow mod (delete) and flow stats requests. Selects all flows regardless of output port (including flows with no output port). */
48
49 *** Test Cases ***    output port        tableID              flowID      priority
50 INPORT                [Documentation]    ${INPORT_doc}
51                       [Tags]             inport
52                       ${TEST_NAME}       200                  161         1
53
54 TABLE                 [Documentation]    ${TABLE_doc}
55                       [Tags]             table
56                       ${TEST_NAME}       200                  261         65535
57
58 NORMAL                [Documentation]    ${NORMAL_doc}
59                       [Tags]             normal
60                       ${TEST_NAME}       200                  361         9
61
62 FLOOD                 [Documentation]    ${FLOOD_doc}
63                       [Tags]             flood
64                       ${TEST_NAME}       200                  81         255
65
66 ALL                   [Documentation]    ${ALL_doc}
67                       [Tags]             all
68                       ${TEST_NAME}       200                  88         42
69
70 CONTROLLER            [Documentation]    ${CONTROLLER_doc}
71                       [Tags]             controller
72                       ${TEST_NAME}       200                  21         21
73
74 LOCAL                 [Documentation]    ${LOCAL_doc}
75                       [Tags]             local
76                       ${TEST_NAME}       200                  32         12345
77
78 ANY                   [Documentation]    ${ANY_doc}
79                       [Tags]             any
80                       ${TEST_NAME}       200                  111         54321
81
82 *** Keywords ***
83 Create And Remove Flow
84     [Arguments]    ${output_port}    ${table_id}    ${flow_id}    ${priority}
85     ##The dictionaries here will be used to populate the match and action elements of the flow mod
86     ${ethernet_match_dict}=    Create Dictionary    type=${eth_type}    destination=${eth_dst}    source=${eth_src}
87     ${ipv4_match_dict}=    Create Dictionary    source=${ipv4_src}    destination=${ipv4_dst}
88     ##flow is a python Object to build flow details, including the xml format to send to controller
89     ${flow}=    Create Inventory Flow
90     Set "${flow}" "table_id" With "${table_id}"
91     Set "${flow}" "id" With "${flow_id}"
92     Set "${flow}" "priority" With "${priority}"
93     Clear Flow Actions    ${flow}
94     Set Flow Output Action    ${flow}    0    0    ${output_port}
95     Set Flow Ethernet Match    ${flow}    ${ethernet_match_dict}
96     Set Flow IPv4 Match    ${flow}    ${ipv4_match_dict}
97     Log    Flow XML is ${flow.xml}
98     Call Method    ${test_switch}    create_flow_match_elements    ${flow.xml}
99     Log    ${test_switch.flow_validations}
100     ${dpid_id}=    Get Switch Datapath ID    ${test_switch}
101     Add Flow To Controller And Verify    ${flow.xml}    openflow:${dpid_id}    ${flow.table_id}    ${flow.id}
102     Validate Switch Output    ${test_switch}    ${test_switch.dump_all_flows}    ${test_switch.flow_validations}
103     Remove Flow From Controller And Verify    ${flow.xml}    openflow:${dpid_id}    ${flow.table_id}    ${flow.id}
104     Validate Switch Output    ${test_switch}    ${test_switch.dump_all_flows}    ${test_switch.flow_validations}    false
105
106 OpenFlow Actions Suite Setup
107     ${test_switch}=    Get Switch    ${SWITCH_CLASS}
108     Set Suite Variable    ${test_switch}
109     Call Method    ${test_switch}    set_mgmt_ip    ${SWITCH_IP}
110     Call Method    ${test_switch}    set_controller_ip    ${CONTROLLER}
111     Run Command On Remote System    ${CONTROLLER}   ps -elf | grep java
112     Log    MAKE: ${test_switch.make}\n MODEL: ${test_switch.model}\n IP: ${test_switch.mgmt_ip}\n PROMPT: ${test_switch.mgmt_prompt}\n CONTROLLER_IP: ${test_switch.of_controller_ip}\n MGMT_PROTOCOL: ${test_switch.mgmt_protocol}
113     Ping    ${test_switch.mgmt_ip}
114     Initialize Switch    ${test_switch}
115     Configure OpenFlow    ${test_switch}
116     Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
117
118 OpenFlow Actions Suite Teardown
119     Cleanup Switch    ${test_switch}
120     SSHLibrary.Close All Connections
121     Telnet.Close All Connections