07d07fae5102edc79d1c77321cce7a34f2bdc7c7
[integration/test.git] / 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.robot
21 Resource          ../../../libraries/FlowLib.robot
22 Resource          ../../../libraries/SwitchUtils.robot
23 Resource          ../../../libraries/OVSDB.robot
24 Library           RequestsLibrary
25 Library           ../../../libraries/Common.py
26 Variables         ../../../variables/Variables.py
27 Library           ../../../libraries/SwitchClasses/${SWITCH_CLASS}.py
28
29 *** Variables ***
30 ${SWITCH_CLASS}    Ovs
31 ${SWITCH_IP}      ${TOOLS_SYSTEM_IP}
32 ${SWITCH_PROMPT}    ${TOOLS_SYSTEM_PROMPT}
33 ${ODL_SYSTEM_IP}    null
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
48 *** Test Cases ***    output port        tableID              flowID    priority
49 INPORT                [Documentation]    ${INPORT_doc}
50                       [Tags]             inport
51                       ${TEST_NAME}       200                  161       1
52
53 TABLE                 [Documentation]    ${TABLE_doc}
54                       [Tags]             table
55                       ${TEST_NAME}       200                  261       65535
56
57 NORMAL                [Documentation]    ${NORMAL_doc}
58                       [Tags]             normal
59                       ${TEST_NAME}       200                  361       9
60
61 FLOOD                 [Documentation]    ${FLOOD_doc}
62                       [Tags]             flood
63                       ${TEST_NAME}       200                  81        255
64
65 ALL                   [Documentation]    ${ALL_doc}
66                       [Tags]             all
67                       ${TEST_NAME}       200                  88        42
68
69 CONTROLLER            [Documentation]    ${CONTROLLER_doc}
70                       [Tags]             controller
71                       ${TEST_NAME}       200                  21        21
72
73 LOCAL                 [Documentation]    ${LOCAL_doc}
74                       [Tags]             local
75                       ${TEST_NAME}       200                  32        12345
76
77 *** Keywords ***
78 Create And Remove Flow
79     [Arguments]    ${output_port}    ${table_id}    ${flow_id}    ${priority}
80     ##The dictionaries here will be used to populate the match and action elements of the flow mod
81     ${ethernet_match_dict}=    Create Dictionary    type=${eth_type}    destination=${eth_dst}    source=${eth_src}
82     ${ipv4_match_dict}=    Create Dictionary    source=${ipv4_src}    destination=${ipv4_dst}
83     ##flow is a python Object to build flow details, including the xml format to send to controller
84     ${flow}=    Create Inventory Flow
85     Set "${flow}" "table_id" With "${table_id}"
86     Set "${flow}" "id" With "${flow_id}"
87     Set "${flow}" "priority" With "${priority}"
88     Clear Flow Actions    ${flow}
89     Set Flow Output Action    ${flow}    0    0    ${output_port}
90     Set Flow Ethernet Match    ${flow}    ${ethernet_match_dict}
91     Set Flow IPv4 Match    ${flow}    ${ipv4_match_dict}
92     Log    Flow XML is ${flow.xml}
93     Call Method    ${test_switch}    create_flow_match_elements    ${flow.xml}
94     Log    ${test_switch.flow_validations}
95     ${dpid_id}=    Get Switch Datapath ID    ${test_switch}
96     Wait Until Keyword Succeeds    3s    1s    Add Flow To Controller And Verify    ${flow.xml}    openflow:${dpid_id}    ${flow.table_id}
97     ...    ${flow.id}
98     Wait Until Keyword Succeeds    3s    1s    Validate Switch Output    ${test_switch}    ${test_switch.dump_all_flows}    ${test_switch.flow_validations}
99     Wait Until Keyword Succeeds    3s    1s    Remove Flow From Controller And Verify    openflow:${dpid_id}    ${flow.table_id}    ${flow.id}
100     Wait Until Keyword Succeeds    3s    1s    Validate Switch Output    ${test_switch}    ${test_switch.dump_all_flows}    ${test_switch.flow_validations}
101     ...    false
102
103 OpenFlow Actions Suite Setup
104     ${test_switch}=    Get Switch    ${SWITCH_CLASS}
105     Set Suite Variable    ${test_switch}
106     Call Method    ${test_switch}    set_mgmt_ip    ${SWITCH_IP}
107     Call Method    ${test_switch}    set_controller_ip    ${ODL_SYSTEM_IP}
108     Call Method    ${test_switch}    set_mgmt_prompt    ${SWITCH_PROMPT}
109     Run Command On Controller    ${ODL_SYSTEM_IP}    ps -elf | grep java
110     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}
111     Ping    ${test_switch.mgmt_ip}
112     Initialize Switch    ${test_switch}
113     Configure OpenFlow    ${test_switch}
114     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
115
116 OpenFlow Actions Suite Teardown
117     Clean OVSDB Test Environment
118     Cleanup Switch    ${test_switch}
119     SSHLibrary.Close All Connections
120     Telnet.Close All Connections