Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / netvirt / ofpunt_path / openflow_punt_path_protection.robot
1 *** Settings ***
2 Documentation     Test suite for OpenFlow punt path protection for subnet route, SNAT, ARP and GARP
3 Suite Setup       Suite Setup
4 Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
7 Resource          ../../../libraries/ClusterManagement.robot
8 Resource          ../../../libraries/OpenStackOperations.robot
9 Resource          ../../../libraries/OvsManager.robot
10 Resource          ../../../libraries/OVSDB.robot
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/VpnOperations.robot
13 Resource          ../../../variables/Variables.robot
14 Resource          ../../../variables/netvirt/Variables.robot
15
16 *** Variables ***
17 @{NETWORKS}       of_punt_net_1    of_punt_net_2    of_punt_net_3
18 ${EXT_NETWORKS}    of_punt_ext_net_1
19 @{PORT_LIST}      of_punt_net1_port_1    of_punt_net1_port_2    of_punt_net2_port_1    of_punt_net2_port_2    of_punt_net3_port_1    of_punt_net3_port_2
20 @{EXTRA_PORTS}    of_punt_net_1_port_3    of_punt_net_2_port_3
21 @{EXTRA_VMS}      of_punt_net_1_vm_3    of_punt_net_2_vm_3
22 @{EXTRA_NW_IP}    11.1.1.100    22.1.1.100    12.1.1.12    13.1.1.13
23 @{VM_LIST}        of_punt_net1_vm_1    of_punt_net1_vm_2    of_punt_net2_vm_1    of_punt_net2_vm_2    of_punt_net3_vm_1    of_punt_net3_vm_2
24 @{SUBNETS}        of_punt_sub_1    of_punt_sub_2    of_punt_sub_3
25 ${EXT_SUBNETS}    of_punt_ext_sub_1
26 @{SUBNETS_CIDR}    11.1.1.0/24    22.1.1.0/24    33.1.1.0/24
27 ${EXT_SUBNETS_CIDR}    55.1.1.0/24
28 ${EXT_SUBNETS_FIXED_IP}    55.1.1.100
29 @{VPN_ID}         4ae8cd92-48ca-49b5-94e1-b2921a261111    4ae8cd92-48ca-49b5-94e1-b2921a262222
30 @{VPN_NAME}       of_punt_vpn_1    of_punt_vpn_2
31 @{ROUTERS}        of_punt_router_1    of_punt_router_2
32 @{ROUTERS_ID}     @{EMPTY}
33 @{DPN_IDS}        @{EMPTY}
34 ${SECURITY_GROUP}    of_punt_sg
35 @{DCGW_RD_IRT_ERT}    11:1    22:1
36 @{L3VPN_RD_IRT_ERT}    ["@{DCGW_RD_IRT_ERT}[0]"]    ["@{DCGW_RD_IRT_ERT}[1]"]
37 @{FILES_PATH}     ${KARAF_HOME}/etc/opendaylight/datastore/initial/config/netvirt-vpnmanager-config.xml    ${KARAF_HOME}/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml    ${KARAF_HOME}/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml
38 ${SNAT_ORIGINAL_TIMEOUT}    5
39 ${L3_ORIGINAL_TIMEOUT}    10
40 ${ARP_ORIGINAL_TIMEOUT}    5
41 @{ORIGINAL_TIMEOUTS}    ${L3_ORIGINAL_TIMEOUT}    ${SNAT_ORIGINAL_TIMEOUT}    ${ARP_ORIGINAL_TIMEOUT}
42 @{OF_PUNT_TABLES}    ${L3_PUNT_TABLE}    ${SNAT_PUNT_TABLE}    ${ARP_PUNT_TABLE}    ${ARP_LEARN_TABLE}
43 @{VALID_TIMEOUTS}    20    30    100    1000    10000
44 ${TCP_PORT}       80
45 ${UDP_PORT}       33435
46 ${TELNET_PORT}    23
47 ${ARP_REG}        0x1
48 ${GARP_REG}       0x101
49
50 *** Test Cases ***
51 Verify default punt timeout values and flows
52     [Documentation]    Verify default time out for subnet route, SNAT and ARP in respective defualt openflow tables
53     ${snat_napt_switch_ip} =    Get NAPT Switch IP From DPID    @{ROUTERS}[1]
54     FOR    ${index}    IN RANGE    0    3
55         BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    @{OF_PUNT_TABLES}[${index}]
56         ...    True    ${EMPTY}    learn(table=@{OF_PUNT_TABLES}[${index}],hard_timeout=@{ORIGINAL_TIMEOUTS}[${index}]
57     END
58
59 Set punt timeout to zero and verify flows
60     [Documentation]    Verify default flows in OVS for subnet route, SNAT and ARP after the changing the default punt timeout value to zero.
61     ...    Default subnet route, SNAT and ARP should get deleted after changing default timeout value to zero
62     FOR    ${index}    IN RANGE    0    3
63         Change Hard Timeout Value In XML File    @{FILES_PATH}[${index}]    @{ORIGINAL_TIMEOUTS}[${index}]    ${0}
64         Verify Punt Values In XML File    @{FILES_PATH}[${index}]    ${0}
65     END
66     ClusterManagement.Stop_Members_From_List_Or_All
67     ClusterManagement.Start_Members_From_List_Or_All
68     ${snat_napt_switch_ip} =    Get NAPT Switch IP From DPID    @{ROUTERS}[1]
69     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Check OVS OpenFlow Connections    ${OS_CMP1_IP}    2
70     FOR    ${index}    IN RANGE    0    3
71         OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    @{OF_PUNT_TABLES}[${index}]    False    ${EMPTY}    learn(table=@{OF_PUNT_TABLES}[${index}],hard_timeout=@{ORIGINAL_TIMEOUTS}[${index}]
72     END
73
74 Set punt timeout to combination of valid ranges and verfiy flows
75     [Documentation]    Verify the default flow in OVS for subnet route, SNAT and ARP after the changing the default value to different set of values.
76     ...    Default subnet route, SNAT and ARP flows should get changed after changing default timeout value to different set of values
77     Set Original TimeOut In Xml    ${0}
78     FOR    ${index}    IN RANGE    0    3
79         Change Hard Timeout Value In XML File    @{FILES_PATH}[${index}]    @{ORIGINAL_TIMEOUTS}[${index}]    @{VALID_TIMEOUTS}[0]
80         Verify Punt Values In XML File    @{FILES_PATH}[${index}]    @{VALID_TIMEOUTS}[0]
81     END
82     ${count} =    BuiltIn.Get length    ${VALID_TIMEOUTS}
83     FOR    ${index}    IN RANGE    1    ${count}
84         Change Hard Timeout Value In XML File    @{FILES_PATH}[0]    @{VALID_TIMEOUTS}[${index - 1}]    @{VALID_TIMEOUTS}[${index}]
85         Verify Punt Values In XML File    @{FILES_PATH}[0]    @{VALID_TIMEOUTS}[${index}]
86         Change Hard Timeout Value In XML File    @{FILES_PATH}[1]    @{VALID_TIMEOUTS}[${index - 1}]    @{VALID_TIMEOUTS}[${index}]
87         Verify Punt Values In XML File    @{FILES_PATH}[1]    @{VALID_TIMEOUTS}[${index}]
88         Change Hard Timeout Value In XML File    @{FILES_PATH}[2]    @{VALID_TIMEOUTS}[${index - 1}]    @{VALID_TIMEOUTS}[${index}]
89         Verify Punt Values In XML File    @{FILES_PATH}[2]    @{VALID_TIMEOUTS}[${index}]
90         ClusterManagement.Stop_Members_From_List_Or_All
91         ClusterManagement.Start_Members_From_List_Or_All
92         BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Check OVS OpenFlow Connections    ${OS_CMP1_IP}    2
93         ${snat_napt_switch_ip} =    Get NAPT Switch IP From DPID    @{ROUTERS}[1]
94         BuiltIn.Wait Until Keyword Succeeds    120s    5s    OVSDB.Verify Dump Flows For Specific Table    ${OS_COMPUTE_1_IP}    ${L3_PUNT_TABLE}
95         ...    True    ${EMPTY}    learn(table=${L3_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[${index}]
96         BuiltIn.Wait Until Keyword Succeeds    120s    5s    OVSDB.Verify Dump Flows For Specific Table    ${OS_COMPUTE_1_IP}    ${ARP_PUNT_TABLE}
97         ...    True    ${EMPTY}    learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[${index}]
98         BuiltIn.Wait Until Keyword Succeeds    180s    5s    OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}
99         ...    True    ${EMPTY}    learn(table=${SNAT_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[${index}]
100     END
101     Set Original TimeOut In Xml    @{VALID_TIMEOUTS}[4]
102
103 Verify learnt flow for subnet route flow table
104     [Documentation]    Get default subnet table packet count before sending traffic to unkwon destination.
105     ...    Send subnet route traffic using Ping with packet count 5.
106     ...    Punt the first packet to controller and add new rule to stop pipeline processing.
107     ...    Check packet count before and after traffic for both(defualt and learnt tables).
108     FOR    ${index}    IN RANGE    0    3
109         Change Hard Timeout Value In XML File    @{FILES_PATH}[${index}]    @{ORIGINAL_TIMEOUTS}[${index}]    @{VALID_TIMEOUTS}[0]
110         Verify Punt Values In XML File    @{FILES_PATH}[${index}]    @{VALID_TIMEOUTS}[0]
111     END
112     ClusterManagement.Stop_Members_From_List_Or_All
113     ClusterManagement.Start_Members_From_List_Or_All
114     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Check OVS OpenFlow Connections    ${OS_CMP1_IP}    2
115     ${count_before_traffic} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${L3_PUNT_TABLE},    |grep "ip actions=CONTROLLER:65535,learn(table=${L3_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
116     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{VM_IPS}[0]    sudo ping -c 5 @{EXTRA_NW_IP}[1]
117     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${L3_PUNT_TABLE}    True    ${EMPTY}    nw_dst=@{EXTRA_NW_IP}[1] actions=drop
118     ${learnt_packet_count}    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${L3_PUNT_TABLE},    |grep "nw_dst=@{EXTRA_NW_IP}[1] actions=drop"
119     BuiltIn.Should be true    ${learnt_packet_count} > 1
120     ${count_after_traffic}    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${L3_PUNT_TABLE},    |grep "ip actions=CONTROLLER:65535,learn(table=${L3_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
121     ${count_before_traffic} =    BuiltIn.Evaluate    ${count_before_traffic} + 1
122     BuiltIn.Should be true    ${count_after_traffic} == ${count_before_traffic}
123
124 Verify learnt flow for UDP in SNAT flow table
125     [Documentation]    Get default SNAT table packet count before sending traffic to unkwon destination.
126     ...    Send UDP traffic using traceroute with packet count 4.
127     ...    Punt the first packet to controller and add new rule to stop pipeline processing.
128     ...    Check packet count before and after traffic for both(defualt and learnt tables).
129     ${compute_ip}    Get NAPT Switch IP From DPID    @{ROUTERS}[1]
130     OVSDB.Verify Dump Flows For Specific Table    ${compute_ip}    ${SNAT_PUNT_TABLE}    @{VALID_TIMEOUTS}[0]
131     ${count_before_traffic} =    OvsManager.Get Packet Count From Table    ${compute_ip}    ${INTEGRATION_BRIDGE}    table=${SNAT_PUNT_TABLE}    |grep "table=46.*n_packets=[\0-9+].*udp.*learn(table=46"
132     BuiltIn.Should be true    ${count_before_traffic} == 0
133     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{VM_IPS}[4]    traceroute @{EXTRA_NW_IP}[2] -w 1 -q 1 -m 4
134     OVSDB.Verify Dump Flows For Specific Table    ${compute_ip}    ${SNAT_PUNT_TABLE}    True    ${EMPTY}    tp_dst=${UDP_PORT} actions=drop
135     ${count_after_traffic} =    OvsManager.Get Packet Count From Table    ${compute_ip}    ${INTEGRATION_BRIDGE}    table=${SNAT_PUNT_TABLE}    |grep "table=46.*n_packets=[\0-9+].*udp.*learn(table=46"
136     ${count_before_traffic} =    BuiltIn.Evaluate    ${count_before_traffic} + 1
137     BuiltIn.Should be true    ${count_after_traffic} == ${count_before_traffic}
138     OVSDB.Verify Dump Flows For Specific Table    ${compute_ip}    ${SNAT_PUNT_TABLE}    True    ${EMPTY}    actions=set_field:${EXT_SUBNETS_FIXED_IP}->ip_src
139     ${controller_packet_count} =    OvsManager.Get Packet Count From Table    ${compute_ip}    ${INTEGRATION_BRIDGE}    table=${SNAT_PUNT_TABLE}    |grep "table=46.*n_packets=[\0-9+].*udp.*nw_src=@{VM_IPS}[4].*actions=set_field:${EXT_SUBNETS_FIXED_IP}.*goto_table:47"
140     BuiltIn.Should be true    ${controller_packet_count} > 1
141
142 Verify learnt flow for TCP in SNAT flow table
143     [Documentation]    Get default SNAT table packet count before sending traffic to unkwon destination.
144     ...    Send TCP traffic using wget.
145     ...    Punt the first packet to controller and add new rule to stop pipeline processing.
146     ...    Check packet count before and after traffic for both(defualt and learnt tables).
147     ${compute_ip}    Get NAPT Switch IP From DPID    @{ROUTERS}[1]
148     OVSDB.Verify Dump Flows For Specific Table    ${compute_ip}    ${SNAT_PUNT_TABLE}    @{VALID_TIMEOUTS}[0]
149     ${count_before_traffic} =    OvsManager.Get Packet Count From Table    ${compute_ip}    ${INTEGRATION_BRIDGE}    table=${SNAT_PUNT_TABLE}    |grep "table=46.*n_packets=[\0-9+].*tcp.*learn(table=46"
150     BuiltIn.Should be true    ${count_before_traffic} == 0
151     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{VM_IPS}[4]    wget -qc http://@{EXTRA_NW_IP}[2]/ &
152     OVSDB.Verify Dump Flows For Specific Table    ${compute_ip}    ${SNAT_PUNT_TABLE}    True    ${EMPTY}    tp_dst=${TCP_PORT} actions=drop
153     ${count_after_traffic} =    OvsManager.Get Packet Count From Table    ${compute_ip}    ${INTEGRATION_BRIDGE}    table=${SNAT_PUNT_TABLE}    |grep "table=46.*n_packets=[\0-9+].*tcp.*learn(table=46"
154     ${count_before_traffic} =    BuiltIn.Evaluate    ${count_before_traffic} + 1
155     BuiltIn.Should be true    ${count_after_traffic} == ${count_before_traffic}
156     OVSDB.Verify Dump Flows For Specific Table    ${compute_ip}    ${SNAT_PUNT_TABLE}    True    ${EMPTY}    actions=set_field:${EXT_SUBNETS_FIXED_IP}->ip_src
157     ${controller_packet_count} =    OvsManager.Get Packet Count From Table    ${compute_ip}    ${INTEGRATION_BRIDGE}    table=${SNAT_PUNT_TABLE}    |grep "table=46.*n_packets=[\0-9+].*tcp.*nw_src=@{VM_IPS}[4].*actions=set_field:${EXT_SUBNETS_FIXED_IP}.*goto_table:47"
158     BuiltIn.Should be true    ${controller_packet_count} > 1
159
160 Verify learnt flow for ARP request in ARP tables
161     [Documentation]    Get default ARP table packet count before sending traffic to unkwon destination.
162     ...    Send ARP request traffic using arping.
163     ...    Punt the first packet to controller and add new rule to stop pipeline processing.
164     ...    Check packet count before and after traffic for both(defualt and learnt tables).
165     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ARP_PUNT_TABLE}    @{VALID_TIMEOUTS}[0]
166     ${count_before_traffic} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "arp actions=CONTROLLER:65535,learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
167     ${count_before_traffic_arp} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ELAN_BASETABLE}    |grep "n_packets=[\0-9+].*reg4=${ARP_REG}.0xffff"
168     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{VM_IPS}[3]    sudo arping -c 5 -I eth0 22.1.1.101
169     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ARP_PUNT_TABLE}    True    ${EMPTY}    arp_tpa=22.1.1.101,arp_op=1
170     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ARP_LEARN_TABLE}    True    ${EMPTY}    arp_spa=22.1.1.101,arp_op=1
171     ${count_after_traffic} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "arp actions=CONTROLLER:65535,learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
172     BuiltIn.Should be true    ${count_after_traffic} > ${count_before_traffic}
173     ${learnt_packet_count} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "n_packets=[\0-9+].*arp_tpa=22.1.1.101,arp_op=1.*actions=load:0x1"
174     BuiltIn.Should be true    ${learnt_packet_count} > 0
175     ${count_after_traffic_arp} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ELAN_BASETABLE}    |grep "n_packets=[\0-9+].*reg4=${ARP_REG}.0xffff"
176     BuiltIn.Should be true    ${count_after_traffic_arp} > ${count_before_traffic_arp}
177
178 Verify learnt flow for ARP reply in ARP tables
179     [Documentation]    Get default ARP table packet count before sending traffic to unkwon destination.
180     ...    Send ARP reply traffic using arping.
181     ...    Punt the first packet to controller and add new rule to stop pipeline processing.
182     ...    Check packet count before and after traffic for both(defualt and learnt tables).
183     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ARP_PUNT_TABLE}    @{VALID_TIMEOUTS}[0]
184     ${count_before_traffic} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "arp actions=CONTROLLER:65535,learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
185     ${count_before_traffic_arp} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ELAN_BASETABLE}    |grep "n_packets=[\0-9+].*reg4=${ARP_REG}.0xffff"
186     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{VM_IPS}[1]    sudo arping -A -c 5 -I eth0 -s @{VM_IPS}[1] 11.1.1.101
187     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ARP_PUNT_TABLE}    True    ${EMPTY}    arp_tpa=11.1.1.101,arp_op=2
188     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ARP_LEARN_TABLE}    True    ${EMPTY}    arp_spa=11.1.1.101,arp_op=2
189     ${count_after_traffic} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "arp actions=CONTROLLER:65535,learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
190     BuiltIn.Should be true    ${count_after_traffic} > ${count_before_traffic}
191     ${learnt_packet_count} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "n_packets=[\0-9+].*arp_tpa=11.1.1.101,arp_op=2.*actions=load:0x1"
192     BuiltIn.Should be true    ${learnt_packet_count} > 0
193     ${count_after_traffic_arp} =    OvsManager.Get Packet Count From Table    ${OS_CMP2_IP}    ${INTEGRATION_BRIDGE}    table=${ELAN_BASETABLE}    |grep "n_packets=[\0-9+].*reg4=${ARP_REG}.0xffff"
194     BuiltIn.Should be true    ${count_after_traffic_arp} > ${count_before_traffic_arp}
195
196 Verify learnt flow for GARP (Gratuitous ARP) in ARP tables
197     [Documentation]    Get default ARP table packet count before sending traffic to unkwon destination.
198     ...    Send GARP traffic using arping.
199     ...    Punt the first packet to controller and add new rule to stop pipeline processing.
200     ...    Check packet count before and after traffic for both(defualt and learnt tables).
201     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_PUNT_TABLE}    @{VALID_TIMEOUTS}[0]
202     ${count_before_traffic} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "arp actions=CONTROLLER:65535,learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
203     ${count_before_traffic_arp} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${ELAN_BASETABLE}    |grep "n_packets=[\0-9+].*reg4=${GARP_REG}.0xffff"
204     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{VM_IPS}[0]    sudo arping -U -c 5 -I eth0 @{VM_IPS}[0] &
205     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_PUNT_TABLE}    True    ${EMPTY}    arp_tpa=@{VM_IPS}[0],arp_op=1
206     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_LEARN_TABLE}    True    ${EMPTY}    arp_spa=@{VM_IPS}[0],arp_op=1
207     ${count_after_traffic} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "arp actions=CONTROLLER:65535,learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]"
208     BuiltIn.Should be true    ${count_after_traffic} > ${count_before_traffic}
209     ${learnt_packet_count} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${ARP_PUNT_TABLE}    |grep "arp_tpa=@{VM_IPS}[0],arp_op=1"
210     BuiltIn.Should be true    ${learnt_packet_count} > 0
211     ${count_after_traffic_arp} =    OvsManager.Get Packet Count From Table    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    table=${ELAN_BASETABLE}    |grep "n_packets=[\0-9+].*reg4=${GARP_REG}.0xffff"
212     BuiltIn.Should be true    ${count_after_traffic_arp} > ${count_before_traffic_arp}
213
214 Verify resync subnet route, SNAT and ARP route flow tables after disconnect and reconnecting OVS control path
215     [Documentation]    Verify learnt subnet route, SNAT and ARP flows.
216     ...    Delete OVS manager and controller and verify learnt flows for subnet, SNAT and ARP.
217     ...    Set OVS manager and controoler again and verify learnt flows for subnet, SNAT and ARP.
218     ...    Verify subnet, SNAT and ARP default flows
219     ${snat_napt_switch_ip} =    Get NAPT Switch IP From DPID    @{ROUTERS}[1]
220     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Check OVS OpenFlow Connections    ${OS_CMP1_IP}    2
221     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{VM_IPS}[0]    sudo ping -c 5 @{EXTRA_NW_IP}[1]
222     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${L3_PUNT_TABLE}    True    ${EMPTY}    nw_dst=11.1.1.255 actions=drop
223     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${L3_PUNT_TABLE}    True    ${EMPTY}    nw_dst=@{EXTRA_NW_IP}[1] actions=drop
224     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{VM_IPS}[4]    traceroute @{EXTRA_NW_IP}[2] -w 1 -q 1 -m 4
225     OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}    True    ${EMPTY}    tp_dst=${UDP_PORT} actions=drop
226     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{VM_IPS}[4]    wget -qc http://@{EXTRA_NW_IP}[2]/ &
227     OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}    True    ${EMPTY}    tp_dst=${TCP_PORT} actions=drop
228     OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{VM_IPS}[0]    sudo arping -c 2 @{VM_IPS}[1]
229     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_PUNT_TABLE}    True    ${EMPTY}    arp_tpa=@{VM_IPS}[1],arp_op=1
230     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_LEARN_TABLE}    True    ${EMPTY}    arp_spa=@{VM_IPS}[1],arp_op=1
231     OVSDB.Delete OVS Manager    ${OS_CMP1_IP}
232     OVSDB.Delete OVS Controller    ${OS_CMP1_IP}
233     OVSDB.Delete OVS Manager    ${snat_napt_switch_ip}
234     OVSDB.Delete OVS Controller    ${snat_napt_switch_ip}
235     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${L3_PUNT_TABLE}    False    ${EMPTY}    nw_dst=11.1.1.255 actions=drop
236     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${L3_PUNT_TABLE}    False    ${EMPTY}    nw_dst=@{EXTRA_NW_IP}[1] actions=drop
237     OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}    False    ${EMPTY}    nw_dst=11.1.1.255 actions=drop
238     OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}    False    ${EMPTY}    tp_dst=${TCP_PORT} actions=drop
239     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_PUNT_TABLE}    False    ${EMPTY}    arp_tpa=@{VM_IPS}[1],arp_op=1
240     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_LEARN_TABLE}    False    ${EMPTY}    arp_spa=@{VM_IPS}[1],arp_op=1
241     OVSDB.Set Controller In OVS Bridge    ${OS_CMP1_IP}    ${INTEGRATION_BRIDGE}    tcp:${ODL_SYSTEM_IP}:6653
242     OVSDB.Set Controller In OVS Bridge    ${snat_napt_switch_ip}    ${INTEGRATION_BRIDGE}    tcp:${ODL_SYSTEM_IP}:6653
243     OVSDB.Add Multiple Managers to OVS    ${OS_CMP1_IP}
244     OVSDB.Add Multiple Managers to OVS    ${snat_napt_switch_ip}
245     ${snat_napt_switch_ip} =    Get NAPT Switch IP From DPID    @{ROUTERS}[1]
246     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Check OVS OpenFlow Connections    ${OS_CMP1_IP}    2
247     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${L3_PUNT_TABLE}    True
248     ...    ${EMPTY}    nw_dst=11.1.1.255 actions=drop
249     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}    False
250     ...    ${EMPTY}    tp_dst=${UDP_PORT} actions=drop
251     BuiltIn.Wait Until Keyword Succeeds    190s    40s    OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}    False
252     ...    ${EMPTY}    tp_dst=${TCP_PORT} actions=drop
253     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_PUNT_TABLE}    False
254     ...    ${EMPTY}    arp_tpa=@{EXTRA_NW_IP}[1],arp_op=1
255     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_LEARN_TABLE}    False
256     ...    ${EMPTY}    arp_spa=@{EXTRA_NW_IP}[1],arp_op=1
257     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${L3_PUNT_TABLE}    True    ${EMPTY}    learn(table=${L3_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]
258     OVSDB.Verify Dump Flows For Specific Table    ${snat_napt_switch_ip}    ${SNAT_PUNT_TABLE}    True    ${EMPTY}    learn(table=${SNAT_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]
259     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ARP_PUNT_TABLE}    True    ${EMPTY}    learn(table=${ARP_PUNT_TABLE},hard_timeout=@{VALID_TIMEOUTS}[0]
260
261 *** Keywords ***
262 Suite Setup
263     [Documentation]    Create common setup related to openflow punt path protection
264     VpnOperations.Basic Suite Setup
265     FOR    ${network}    IN    @{NETWORKS}
266         OpenStackOperations.Create Network    ${network}
267     END
268     OpenStackOperations.Create Network    ${EXT_NETWORKS}    additional_args=--external --provider-network-type gre
269     ${elements} =    BuiltIn.Create List    ${EXT_NETWORKS}
270     ${count} =    BuiltIn.Get length    ${SUBNETS}
271     FOR    ${index}    IN RANGE    0    ${count}
272         OpenStackOperations.Create SubNet    @{NETWORKS}[${index}]    @{SUBNETS}[${index}]    @{SUBNETS_CIDR}[${index}]
273     END
274     OpenStackOperations.Create SubNet    ${EXT_NETWORKS}    ${EXT_SUBNETS}    ${EXT_SUBNETS_CIDR}    additional_args=--no-dhcp
275     FOR    ${router}    IN    @{ROUTERS}
276         OpenStackOperations.Create Router    ${router}
277         ${router_id} =    OpenStackOperations.Get Router Id    ${router}
278         Collections.Append To List    ${ROUTERS_ID}    ${router_id}
279     END
280     BuiltIn.Set Suite Variable    @{ROUTERS_ID}
281     FOR    ${index}    IN RANGE    0    2
282         OpenStackOperations.Add Router Interface    @{ROUTERS}[0]    @{SUBNETS}[${index}]
283     END
284     OpenStackOperations.Add Router Interface    @{ROUTERS}[1]    @{SUBNETS}[2]
285     OpenStackOperations.Create And Configure Security Group    ${SECURITY_GROUP}
286     ${ext_net} =    BuiltIn.Create List    ${EXT_NETWORKS}
287     ${NETWORKS_ALL} =    Collections.Combine Lists    ${NETWORKS}    ${ext_net}
288     FOR    ${index}    IN RANGE    0    3
289         OpenStackOperations.Create Port    @{NETWORKS_ALL}[${index}]    @{PORT_LIST}[${index + ${index}}]    sg=${SECURITY_GROUP}
290         OpenStackOperations.Create Port    @{NETWORKS_ALL}[${index}]    @{PORT_LIST}[${index + ${index + 1}}]    sg=${SECURITY_GROUP}
291     END
292     OpenStackOperations.Create Port    @{NETWORKS}[0]    @{EXTRA_PORTS}[0]    sg=${SECURITY_GROUP}    additional_args=--allowed-address ip-address=0.0.0.0 --fixed-ip subnet=@{SUBNETS}[0],ip-address=@{EXTRA_NW_IP}[0]
293     OpenStackOperations.Create Port    @{NETWORKS}[1]    @{EXTRA_PORTS}[1]    sg=${SECURITY_GROUP}    additional_args=--allowed-address ip-address=0.0.0.0 --fixed-ip subnet=@{SUBNETS}[1],ip-address=@{EXTRA_NW_IP}[1]
294     FOR    ${index}    IN RANGE    0    3
295         OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORT_LIST}[${index + ${index}}]    @{VM_LIST}[${index + ${index}}]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
296         OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORT_LIST}[${index + ${index + 1}}]    @{VM_LIST}[${index + ${index + 1}}]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
297     END
298     @{VM_IPS}    ${dhcp_ip} =    OpenStackOperations.Get VM IPs    @{VM_LIST}
299     BuiltIn.Set Suite Variable    ${VM_IPS}
300     OpenStackOperations.Show Debugs    @{VM_LIST}
301     BuiltIn.Should Not Contain    ${VM_IPS}    None
302     BuiltIn.Should Not Contain    ${dhcp_ip}    None
303     FOR    ${index}    IN RANGE    0    2
304         VpnOperations.VPN Create L3VPN    name=@{VPN_NAME}[${index}]    vpnid=@{VPN_ID}[${index}]    rd=@{L3VPN_RD_IRT_ERT}[${index}]    exportrt=@{L3VPN_RD_IRT_ERT}[${index}]    importrt=@{L3VPN_RD_IRT_ERT}[${index}]
305     END
306     VpnOperations.Associate VPN to Router    routerid=@{ROUTERS_ID}[0]    vpnid=@{VPN_ID}[0]
307     ${network_id} =    OpenStackOperations.Get Net Id    ${EXT_NETWORKS}
308     VpnOperations.Associate L3VPN To Network    networkid=${network_id}    vpnid=@{VPN_ID}[1]
309     OpenStackOperations.Add Router Gateway    @{ROUTERS}[1]    ${EXT_NETWORKS}    additional_args=--fixed-ip subnet=${EXT_SUBNETS},ip-address=${EXT_SUBNETS_FIXED_IP} --enable-snat
310     Create Dictionary For DPN ID And Compute IP Mapping For All DPNS
311     OpenStackOperations.Get Suite Debugs
312
313 Set Original TimeOut In Xml
314     [Arguments]    ${hard_timeout}
315     [Documentation]    Set default timeout in XML for all the punt files
316     FOR    ${index}    IN RANGE    0    3
317         Change Hard Timeout Value In XML File    @{FILES_PATH}[${index}]    ${hard_timeout}    @{ORIGINAL_TIMEOUTS}[${index}]
318         Verify Punt Values In XML File    @{FILES_PATH}[${index}]    @{ORIGINAL_TIMEOUTS}[${index}]
319     END
320     ClusterManagement.Stop_Members_From_List_Or_All
321     ClusterManagement.Start_Members_From_List_Or_All
322     BuiltIn.Wait Until Keyword Succeeds    120s    20s    OVSDB.Check OVS OpenFlow Connections    ${OS_CMP1_IP}    2
323
324 Verify Punt Values In XML File
325     [Arguments]    ${file_path}    ${value}
326     [Documentation]    Verify the default value for SNAT, ARP in ELAN, Subnet Routing in the xml file in ODL Controller
327     ${output} =    Utils.Run Command On Remote System And Log    ${ODL_SYSTEM_IP}    cat ${file_path} | grep punt-timeout
328     @{matches} =    BuiltIn.Should Match Regexp    ${output}    punt.timeout.*?([0-9]+)
329     BuiltIn.Should be true    @{matches}[1] == ${value}
330
331 Change Hard Timeout Value In XML File
332     [Arguments]    ${file_path}    ${value_1}    ${value_2}
333     [Documentation]    Change the default value in xml in the ODL controller for subnet route, SNAT and ARP
334     Utils.Run Command On Remote System And Log    ${ODL_SYSTEM_IP}    sed -i -e 's/punt-timeout\>${value_1}/punt-timeout\>${value_2}/' ${file_path}
335
336 Create Dictionary For DPN ID And Compute IP Mapping For All DPNS
337     [Documentation]    Creating dictionary for DPN ID and compute IP mapping
338     FOR    ${ip}    IN    @{OS_ALL_IPS}
339         ${dpnid}    OVSDB.Get DPID    ${ip}
340         Collections.Append To List    ${DPN_IDS}    ${dpnid}
341     END
342     ${DPN_TO_COMPUTE_IP} =    BuiltIn.Create Dictionary
343     ${count} =    BuiltIn.Get length    ${OS_ALL_IPS}
344     FOR    ${index}    IN RANGE    0    ${count}
345         Collections.Set To Dictionary    ${DPN_TO_COMPUTE_IP}    @{DPN_IDS}[${index}]    @{OS_ALL_IPS}[${index}]
346     END
347     FOR    ${dp_id}    IN    @{DPN_IDS}
348         Collections.Dictionary Should Contain Key    ${DPN_TO_COMPUTE_IP}    ${dp_id}
349     END
350     BuiltIn.Set Suite Variable    ${DPN_TO_COMPUTE_IP}
351
352 Get SNAT NAPT Switch DPID
353     [Arguments]    ${router_name}
354     [Documentation]    Returns the SNAT NAPT switch dpnid from odl rest call.
355     ${router_id} =    OpenStackOperations.Get Router Id    ${router_name}
356     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/odl-nat:napt-switches/router-to-napt-switch/${router_id}
357     Log    ${resp.content}
358     @{matches} =    BuiltIn.Should Match Regexp    ${resp.content}    switch.id.*?([0-9]+)
359     ${dpnid} =    BuiltIn.Convert To Integer    @{matches}[1]
360     [Return]    ${dpnid}
361
362 Get NAPT Switch IP From DPID
363     [Arguments]    ${router_name}
364     [Documentation]    Return SNAT NAPT switch ip for the given router name
365     ${dpnid} =    BuiltIn.Wait Until Keyword Succeeds    60s    15s    Get SNAT NAPT Switch DPID    ${router_name}
366     ${compute_ip} =    Collections.Get From Dictionary    ${DPN_TO_COMPUTE_IP}    ${dpnid}
367     [Return]    ${compute_ip}