Migrate Get Requests invocations(libraries)
[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
14 Library             Collections
15 Library             OperatingSystem
16 Library             String
17 Library             XML
18 Resource            ../../../libraries/Utils.robot
19 Resource            ../../../libraries/FlowLib.robot
20 Resource            ../../../libraries/SwitchUtils.robot
21 Resource            ../../../libraries/OVSDB.robot
22 Library             RequestsLibrary
23 Library             ../../../libraries/Common.py
24 Variables           ../../../variables/Variables.py
25 Library             ../../../libraries/SwitchClasses/${SWITCH_CLASS}.py
26
27 Suite Setup         OpenFlow Actions Suite Setup
28 Suite Teardown      OpenFlow Actions Suite Teardown
29 Test Template       Create And Remove Flow
30
31
32 *** Variables ***
33 ${SWITCH_CLASS}         Ovs
34 ${SWITCH_IP}            ${TOOLS_SYSTEM_IP}
35 ${SWITCH_PROMPT}        ${TOOLS_SYSTEM_PROMPT}
36 ${ODL_SYSTEM_IP}        null
37 ${ipv4_src}             11.3.0.0/16
38 ${ipv4_dst}             99.0.0.0/8
39 ${eth_type}             0x800
40 ${eth_src}              00:ab:cd:ef:01:23
41 ${eth_dst}              ff:ff:ff:ff:ff:ff
42 ##documentation strings
43 ${INPORT_doc}
44 ...                     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
45 ${TABLE_doc}
46 ...                     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. */
47 ${NORMAL_doc}           OF1.3 OFPP_NORMAL = 0xfffffffa, /* Process with normal L2/L3 switching. */
48 ${FLOOD_doc}
49 ...                     OF1.3 OFPP_FLOOD = 0xfffffffb, /* All physical ports in VLAN, except input port and those blocked or link down. */
50 ${ALL_doc}              OF1.3: OFPP_ALL = 0xfffffffc, /* All physical ports except input port. */
51 ${CONTROLLER_doc}       OF1.3 OFPP_CONTROLLER = 0xfffffffd, /* Send to controller. */
52 ${LOCAL_doc}            OF1.3 OFPP_LOCAL = 0xfffffffe, /* Local openflow "port". */
53
54
55 *** Test Cases ***    output port    tableID    flowID    priority
56 INPORT    [Documentation]    ${INPORT_doc}
57     [Tags]    inport
58     ${TEST_NAME}    200    161    1
59 TABLE    [Documentation]    ${TABLE_doc}
60     [Tags]    table
61     ${TEST_NAME}    200    261    65535
62 NORMAL    [Documentation]    ${NORMAL_doc}
63     [Tags]    normal
64     ${TEST_NAME}    200    361    9
65 FLOOD    [Documentation]    ${FLOOD_doc}
66     [Tags]    flood
67     ${TEST_NAME}    200    81    255
68 ALL    [Documentation]    ${ALL_doc}
69     [Tags]    all
70     ${TEST_NAME}    200    88    42
71 CONTROLLER    [Documentation]    ${CONTROLLER_doc}
72     [Tags]    controller
73     ${TEST_NAME}    200    21    21
74 LOCAL    [Documentation]    ${LOCAL_doc}
75     [Tags]    local
76     ${TEST_NAME}    200    32    12345
77
78
79 *** Keywords ***
80 Create And Remove Flow
81     [Arguments]    ${output_port}    ${table_id}    ${flow_id}    ${priority}
82     ##The dictionaries here will be used to populate the match and action elements of the flow mod
83     ${ethernet_match_dict}=    Create Dictionary    type=${eth_type}    destination=${eth_dst}    source=${eth_src}
84     ${ipv4_match_dict}=    Create Dictionary    source=${ipv4_src}    destination=${ipv4_dst}
85     ##flow is a python Object to build flow details, including the xml format to send to controller
86     ${flow}=    Create Inventory Flow
87     Set "${flow}" "table_id" With "${table_id}"
88     Set "${flow}" "id" With "${flow_id}"
89     Set "${flow}" "priority" With "${priority}"
90     Clear Flow Actions    ${flow}
91     Set Flow Output Action    ${flow}    0    0    ${output_port}
92     Set Flow Ethernet Match    ${flow}    ${ethernet_match_dict}
93     Set Flow IPv4 Match    ${flow}    ${ipv4_match_dict}
94     Log    Flow XML is ${flow.xml}
95     Call Method    ${test_switch}    create_flow_match_elements    ${flow.xml}
96     Log    ${test_switch.flow_validations}
97     ${dpid_id}=    Get Switch Datapath ID    ${test_switch}
98     Wait Until Keyword Succeeds
99     ...    3s
100     ...    1s
101     ...    Add Flow To Controller And Verify
102     ...    ${flow.xml}
103     ...    openflow%3A${dpid_id}
104     ...    ${flow.table_id}
105     ...    ${flow.id}
106     Wait Until Keyword Succeeds
107     ...    3s
108     ...    1s
109     ...    Validate Switch Output
110     ...    ${test_switch}
111     ...    ${test_switch.dump_all_flows}
112     ...    ${test_switch.flow_validations}
113     Wait Until Keyword Succeeds
114     ...    3s
115     ...    1s
116     ...    Remove Flow From Controller And Verify
117     ...    openflow%3A${dpid_id}
118     ...    ${flow.table_id}
119     ...    ${flow.id}
120     Wait Until Keyword Succeeds
121     ...    3s
122     ...    1s
123     ...    Validate Switch Output
124     ...    ${test_switch}
125     ...    ${test_switch.dump_all_flows}
126     ...    ${test_switch.flow_validations}
127     ...    false
128
129 OpenFlow Actions Suite Setup
130     ${test_switch}=    Get Switch    ${SWITCH_CLASS}
131     Set Suite Variable    ${test_switch}
132     Call Method    ${test_switch}    set_mgmt_ip    ${SWITCH_IP}
133     Call Method    ${test_switch}    set_controller_ip    ${ODL_SYSTEM_IP}
134     Call Method    ${test_switch}    set_mgmt_prompt    ${SWITCH_PROMPT}
135     Run Command On Controller    ${ODL_SYSTEM_IP}    ps -elf | grep java
136     Log
137     ...    MAKE: ${test_switch.make}\nMODEL: ${test_switch.model}\nIP: ${test_switch.mgmt_ip}\nPROMPT: ${test_switch.mgmt_prompt}\nCONTROLLER_IP: ${test_switch.of_controller_ip}\nMGMT_PROTOCOL: ${test_switch.mgmt_protocol}
138     Ping    ${test_switch.mgmt_ip}
139     Initialize Switch    ${test_switch}
140     Configure OpenFlow    ${test_switch}
141     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
142
143 OpenFlow Actions Suite Teardown
144     Clean OVSDB Test Environment
145     Cleanup Switch    ${test_switch}
146     SSHLibrary.Close All Connections
147     Telnet.Close All Connections