cleanup connections
[integration/test.git] / csit / suites / l2gw / 01_Configure_verify_l2gateway.robot
1 *** Settings ***
2 Documentation     Test Suite for verification of HWVTEP usecases
3 Suite Setup       Basic Suite Setup
4 Suite Teardown    Basic Suite Teardown
5 Test Teardown     Get L2gw Debug Info
6 Resource          ../../libraries/L2GatewayOperations.robot
7
8 *** Test Cases ***
9 TC01 Configure Hwvtep Manager OVS Manager Controller And Verify
10     L2GatewayOperations.Add Vtep Manager And Verify    ${ODL_IP}
11
12 TC02 Create First Set Of Network Subnet And Ports
13     OpenStackOperations.Create Network    ${NET_1}    ${NET_ADDT_ARG} ${NET_1_SEGID}
14     ${output}=    OpenStackOperations.List Networks
15     Should Contain    ${output}    ${NET_1}
16     OpenStackOperations.Create SubNet    ${NET_1}    ${SUBNET_1}    ${SUBNET_RANGE1}    ${SUBNET_ADDT_ARG}
17     ${output}=    OpenStackOperations.List Subnets
18     Should Contain    ${output}    ${SUBNET_1}
19     OpenStackOperations.Create And Configure Security Group    ${SECURITY_GROUP_L2GW}
20     OpenStackOperations.Create Port    ${NET_1}    ${OVS_PORT_1}    sg=${SECURITY_GROUP_L2GW}
21     OpenStackOperations.Create Neutron Port With Additional Params    ${NET_1}    ${HWVTEP_PORT_1}    ${SECURITY_GROUP_L2GW_NONE}
22     ${port_mac}=    Get Port Mac    ${OVS_PORT_1}    #port_mac[0]
23     ${port_ip}=    Get Port Ip    ${OVS_PORT_1}    #port_ip[0]
24     Append To List    ${port_mac_list}    ${port_mac}
25     Append To List    ${port_ip_list}    ${port_ip}
26     ${port_mac}=    Get Port Mac    ${HWVTEP_PORT_1}    #port_mac[1]
27     ${port_ip}=    Get Port Ip    ${HWVTEP_PORT_1}    #port_ip[1]
28     Append To List    ${port_mac_list}    ${port_mac}
29     Append To List    ${port_ip_list}    ${port_ip}
30
31 TC03 Update Port For Hwvtep And Attach Port To Namespace
32     L2GatewayOperations.Update Port For Hwvtep    ${HWVTEP_PORT_1}
33     Wait Until Keyword Succeeds    30s    2s    L2GatewayOperations.Attach Port To Hwvtep Namespace    ${port_mac_list[1]}    ${HWVTEP_NS1}    ${NS_TAP1}
34
35 TC04 Create Vms On Compute Node
36     OpenStackOperations.Create Nano Flavor
37     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${OVS_PORT_1}    ${OVS_VM1_NAME}    ${OVS_IP}
38     ${vm_ip}=    Wait Until Keyword Succeeds    60s    2s    L2GatewayOperations.Verify Nova VM IP    ${OVS_VM1_NAME}
39     Log    ${vm_ip}
40     Should Contain    ${vm_ip}    ${port_ip_list[0]}
41
42 TC05 Create L2Gateway And Connection And Verify
43     ${output}=    L2GatewayOperations.Create Verify L2Gateway    ${HWVTEP_BRIDGE}    ${NS_PORT1}    ${L2GW_NAME1}
44     Log    ${output}
45     ${output}=    Wait Until Keyword Succeeds    30s    2s    L2GatewayOperations.Create Verify L2Gateway Connection    ${L2GW_NAME1}    ${NET_1}
46     Log    ${output}
47     Wait Until Keyword Succeeds    30s    2s    L2GatewayOperations.Verify Ovs Tunnel    ${HWVTEP_IP}    ${OVS_IP}
48     ${output}=    ITM Get Tunnels
49     Log    ${output}
50     Should Contain    ${output}    physicalswitch/${HWVTEP_BRIDGE}
51     Wait Until Keyword Succeeds    30s    1s    L2GatewayOperations.Verify Vtep List    ${hwvtep_conn_id}    ${TUNNEL_TABLE}    enable="true"
52     ${phy_port_out}=    Get Vtep List    ${PHYSICAL_PORT_TABLE}
53     Validate Regexp In String    ${phy_port_out}    ${VLAN_BINDING_REGEX}    1
54     ${list}=    Create List    ${OVS_IP}    ${HWVTEP_IP}
55     Wait Until Keyword Succeeds    30s    1s    L2GatewayOperations.Verify Vtep List    ${hwvtep_conn_id}    ${PHYSICAL_LOCATOR_TABLE}    @{list}
56     Wait Until Keyword Succeeds    30s    1s    L2GatewayOperations.Verify Vtep List    ${hwvtep_conn_id}    ${UCAST_MACS_REMOTE_TABLE}    ${port_mac_list[0]}
57
58 TC06 Dhcp Ip Allocation For Hwvtep Tap Port
59     Wait Until Keyword Succeeds    180s    10s    L2GatewayOperations.Namespace Dhclient Verify    ${HWVTEP_NS1}    ${NS_TAP1}    ${port_ip_list[1]}
60
61 TC07 Verify Ping From Compute Node Vm To Hwvtep
62     ${output}=    Wait Until Keyword Succeeds    60s    10s    Execute Command on VM Instance    ${NET_1}    ${port_ip_list[0]}
63     ...    ping -c 3 ${port_ip_list[1]}
64     Log    ${output}
65     Should Not Contain    ${output}    ${PACKET_LOSS}
66     ${src_mac_list}=    Create List    ${port_mac_list[0]}
67     ${dst_mac_list}=    Create List    ${port_mac_list[1]}
68     Wait Until Keyword Succeeds    30s    5s    L2GatewayOperations.Verify Elan Flow Entries    ${OVS_IP}    ${src_mac_list}    ${dst_mac_list}
69
70 TC08 Ping Verification From Namespace Tap To Ovs Vm
71     Wait Until Keyword Succeeds    30s    5s    L2GatewayOperations.Verify Ping In Namespace Extra Timeout    ${HWVTEP_NS1}    ${port_mac_list[1]}    ${port_ip_list[0]}
72
73 TC09 Additional Network Subnet Port Creation
74     OpenStackOperations.Create Network    ${NET_2}    ${NET_ADDT_ARG} ${NET_2_SEGID}
75     ${output}=    OpenStackOperations.List Networks
76     Should Contain    ${output}    ${NET_2}
77     OpenStackOperations.Create SubNet    ${NET_2}    ${SUBNET_2}    ${SUBNET_RANGE2}    ${SUBNET_ADDT_ARG}
78     ${output}=    OpenStackOperations.List Subnets
79     Should Contain    ${output}    ${SUBNET_2}
80     OpenStackOperations.Create Port    ${NET_2}    ${OVS_PORT_2}    sg=${SECURITY_GROUP_L2GW}
81     OpenStackOperations.Create Neutron Port With Additional Params    ${NET_2}    ${HWVTEP_PORT_2}    ${SECURITY_GROUP_L2GW_NONE}
82     ${port_mac}=    Get Port Mac    ${OVS_PORT_2}    #port_mac[2]
83     ${port_ip}=    Get Port Ip    ${OVS_PORT_2}    #port_ip[2]
84     Append To List    ${port_mac_list}    ${port_mac}
85     Append To List    ${port_ip_list}    ${port_ip}
86     ${port_mac}=    Get Port Mac    ${HWVTEP_PORT_2}    #port_mac[3]
87     ${port_ip}=    Get Port Ip    ${HWVTEP_PORT_2}    #port_ip[3]
88     Append To List    ${port_mac_list}    ${port_mac}
89     Append To List    ${port_ip_list}    ${port_ip}
90
91 TC10 Update And Attach Second Port To Hwvtep Create L2gw Connection
92     L2GatewayOperations.Update Port For Hwvtep    ${HWVTEP_PORT_2}
93     Wait Until Keyword Succeeds    30s    2s    L2GatewayOperations.Attach Port To Hwvtep Namespace    ${port_mac_list[3]}    ${HWVTEP_NS2}    ${NS2_TAP1}
94     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${OVS_PORT_2}    ${OVS_VM2_NAME}    ${OVS_IP}
95     ${vm_ip}=    Wait Until Keyword Succeeds    60s    2s    L2GatewayOperations.Verify Nova VM IP    ${OVS_VM2_NAME}
96     Log    ${vm_ip}
97     Should Contain    ${vm_ip}    ${port_ip_list[2]}
98     ${output}=    L2GatewayOperations.Create Verify L2Gateway    ${HWVTEP_BRIDGE}    ${NS_PORT2}    ${L2GW_NAME2}
99     Log    ${output}
100     ${output}=    L2GatewayOperations.Create Verify L2Gateway Connection    ${L2GW_NAME2}    ${NET_2}
101     Log    ${output}
102     ${phy_port_out}=    Get Vtep List    ${PHYSICAL_PORT_TABLE}
103     Validate Regexp In String    ${phy_port_out}    ${VLAN_BINDING_REGEX}    2
104
105 TC11 Dhcp Ip Allocation And Ping Validation Within Second Network
106     Wait Until Keyword Succeeds    180s    10s    L2GatewayOperations.Namespace Dhclient Verify    ${HWVTEP_NS2}    ${NS2_TAP1}    ${port_ip_list[3]}
107     ${output}=    Wait Until Keyword Succeeds    60s    10s    Execute Command on VM Instance    ${NET_2}    ${port_ip_list[2]}
108     ...    ping -c 3 ${port_ip_list[3]}
109     Log    ${output}
110     Should Not Contain    ${output}    ${PACKET_LOSS}
111     ${src_mac_list}=    Create List    ${port_mac_list[2]}
112     ${dst_mac_list}=    Create List    ${port_mac_list[3]}
113     Wait Until Keyword Succeeds    30s    5s    L2GatewayOperations.Verify Elan Flow Entries    ${OVS_IP}    ${src_mac_list}    ${dst_mac_list}
114     Wait Until Keyword Succeeds    30s    5s    L2GatewayOperations.Verify Ping In Namespace Extra Timeout    ${HWVTEP_NS2}    ${port_mac_list[3]}    ${port_ip_list[2]}
115
116 TC12 Ping Between Vm In Second Network To Namespace In First Network
117     ${output}=    Wait Until Keyword Succeeds    60s    10s    Execute Command on VM Instance    ${NET_2}    ${port_ip_list[2]}
118     ...    ping -c 3 ${port_ip_list[1]}
119     Log    ${output}
120     Should Contain    ${output}    ${PACKET_LOSS}
121
122 TC13 Ping Between Namespace In Second Network To Vm In First Network
123     Wait Until Keyword Succeeds    30s    5s    L2GatewayOperations.Verify Ping Fails In Namespace    ${HWVTEP_NS2}    ${port_mac_list[3]}    ${port_ip_list[0]}
124
125 TC99 Cleanup L2Gateway Connection Itm Tunnel Port Subnet And Network
126     L2GatewayOperations.Delete L2Gateway Connection    ${L2GW_NAME1}
127     L2GatewayOperations.Delete L2Gateway Connection    ${L2GW_NAME2}
128     L2GatewayOperations.Delete L2Gateway    ${L2GW_NAME1}
129     L2GatewayOperations.Delete L2Gateway    ${L2GW_NAME2}
130     OpenStackOperations.Delete Vm Instance    ${OVS_VM1_NAME}
131     OpenStackOperations.Delete Vm Instance    ${OVS_VM2_NAME}
132     OpenStackOperations.Delete Port    ${OVS_PORT_1}
133     OpenStackOperations.Delete Port    ${OVS_PORT_2}
134     OpenStackOperations.Delete Port    ${HWVTEP_PORT_1}
135     OpenStackOperations.Delete Port    ${HWVTEP_PORT_2}
136     OpenStackOperations.Delete SubNet    ${SUBNET_1}
137     OpenStackOperations.Delete SubNet    ${SUBNET_2}
138     OpenStackOperations.Delete Network    ${NET_1}
139     OpenStackOperations.Delete Network    ${NET_2}
140
141 *** Keywords ***
142 Basic Suite Setup
143     [Documentation]    Basic Suite Setup required for the HWVTEP Test Suite
144     OpenStackOperations.OpenStack Suite Setup
145     OpenStackOperations.Get ControlNode Connection
146     Write Commands Until Prompt    cd ${DEVSTACK_DEPLOY_PATH}; source openrc admin admin    30s
147     ${port_mac_list}=    Create List
148     Set Suite Variable    ${port_mac_list}
149     ${port_ip_list}=    Create List
150     Set Suite Variable    ${port_ip_list}
151     Start Suite
152
153 Basic Suite Teardown
154     Stop Suite
155     OpenStackOperations.OpenStack Suite Teardown
156
157 Start Suite
158     [Documentation]    Suite Setup to configure HWVTEP Emulator for L2 Gateway Testcase Verification.
159     ${hwvtep_conn_id}=    Create And Set Hwvtep Connection Id    ${HWVTEP_IP}
160     Set Suite Variable    ${hwvtep_conn_id}
161     Hwvtep Cleanup    ${hwvtep_conn_id}    ${HWVTEP_BRIDGE}
162     Namespace Cleanup
163     Hwvtep Initiate    ${hwvtep_conn_id}    ${HWVTEP_IP}    ${HWVTEP_BRIDGE}
164     Namespace Intiate Hwvtep1
165     Wait Until Keyword Succeeds    30s    1s    Hwvtep Validation
166
167 Stop Suite
168     [Documentation]    Stop Suite to cleanup Hwvtep configuration
169     Hwvtep Cleanup    ${hwvtep_conn_id}    ${HWVTEP_BRIDGE}
170     Namespace Cleanup
171
172 Hwvtep Cleanup
173     [Arguments]    ${conn_id}    ${hwvtep_bridge}
174     [Documentation]    Cleanup any existing VTEP, VSWITCHD or OVSDB processes.
175     Switch Connection    ${conn_id}
176     Write Commands Until Prompt    ${DEL_OVS_BRIDGE} ${hwvtep_bridge}    30s
177     Write Commands Until Prompt    ${KILL_VTEP_PROC}    30s
178     Write Commands Until Prompt    ${KILL_VSWITCHD_PROC}    30s
179     Write Commands Until Prompt    ${KILL_OVSDB_PROC}    30s
180     ${stdout}=    Write Commands Until Prompt    ${GREP_OVS}    30s
181     Log    ${stdout}
182     Write Commands Until Prompt    ${REM_OVSDB}    30s
183     Write Commands Until Prompt    ${REM_VTEPDB}    30s
184
185 Namespace Cleanup
186     [Documentation]    Cleanup the existing namespaces and ports.
187     Switch Connection    ${hwvtep_conn_id}
188     ${stdout}=    Write Commands Until Prompt    ${IP_LINK}    30s
189     Log    ${stdout}
190     Write Commands Until Prompt    ${IP_LINK_DEL} ${NS_PORT1}    30s
191     Write Commands Until Prompt    ${IP_LINK_DEL} ${NS_PORT2}    30s
192     ${stdout}=    Write Commands Until Prompt    ${NETNS}    30s
193     Log    ${stdout}
194     Write Commands Until Prompt    ${NETNS_DEL} ${HWVTEP_NS1}    30s
195     Write Commands Until Prompt    ${NETNS_DEL} ${HWVTEP_NS2}    30s
196     ${stdout}=    Write Commands Until Prompt    ${IP_LINK}    30s
197     Log    ${stdout}
198
199 Hwvtep Initiate
200     [Arguments]    ${conn_id}    ${hwvtep_ip}    ${hwvtep_bridge}
201     [Documentation]    Configure the Hwvtep Emulation
202     Switch Connection    ${conn_id}
203     Write Commands Until Prompt    ${CREATE_OVSDB}    30s
204     Write Commands Until Prompt    ${CREATE VTEP}    30s
205     Write Commands Until Prompt    ${START_OVSDB_SERVER}    30s
206     ${stdout}=    Write Commands Until Prompt    ${GREP_OVS}    30s
207     Log    ${stdout}
208     Write Commands Until Prompt    ${INIT_VSCTL}    30s
209     Write Commands Until Prompt    ${DETACH_VSWITCHD}    30s
210     Write Commands Until Prompt    ${CREATE_OVS_BRIDGE} ${hwvtep_bridge}    30s
211     ${stdout}=    Write Commands Until Prompt    ${OVS_SHOW}    30s
212     Log    ${stdout}
213     Write Commands Until Prompt    ${ADD_VTEP_PS} ${hwvtep_bridge}    30s
214     Write Commands Until Prompt    ${SET_VTEP_PS} ${hwvtep_bridge} tunnel_ips=${hwvtep_ip}    30s
215     Write Commands Until Prompt    ${START_OVSVTEP} ${hwvtep_bridge}    30s
216     ${stdout}=    Write Commands Until Prompt    ${GREP_OVS}    30s
217     Log    ${stdout}
218
219 Namespace Intiate Hwvtep1
220     [Documentation]    Create and configure the namespace, bridges and ports.
221     Switch Connection    ${hwvtep_conn_id}
222     Create Configure Namespace    ${HWVTEP_NS1}    ${NS_PORT1}    ${NS_TAP1}    ${HWVTEP_BRIDGE}
223     Create Configure Namespace    ${HWVTEP_NS2}    ${NS_PORT2}    ${NS2_TAP1}    ${HWVTEP_BRIDGE}
224
225 Create Configure Namespace
226     [Arguments]    ${ns_name}    ${ns_port_name}    ${tap_port_name}    ${hwvtep_bridge}
227     Write Commands Until Prompt    ${NETNS_ADD} ${ns_name}    30s
228     Write Commands Until Prompt    ${IP_LINK_ADD} ${tap_port_name} type veth peer name ${ns_port_name}    30s
229     Write Commands Until Prompt    ${CREATE_OVS_PORT} ${hwvtep_bridge} ${ns_port_name}    30s
230     Write Commands Until Prompt    ${IP_LINK_SET} ${tap_port_name} netns ${ns_name}    30s
231     Write Commands Until Prompt    ${NETNS_EXEC} ${ns_name} ${IPLINK_SET} ${tap_port_name} up    30s
232     Write Commands Until Prompt    sudo ${IPLINK_SET} ${ns_port_name} up    30s
233     ${stdout}=    Write Commands Until Prompt    ${NETNS_EXEC} ${ns_name} ${IFCONF}    30s
234     Log    ${stdout}
235
236 Hwvtep Validation
237     [Documentation]    Initial validation of the Hwvtep Configuration to confirm Phyisical_Switch table entries
238     Switch Connection    ${hwvtep_conn_id}
239     ${stdout}=    Write Commands Until Prompt    ${VTEP LIST} ${PHYSICAL_SWITCH_TABLE}    30s
240     Should Contain    ${stdout}    ${HWVTEP_BRIDGE}
241     Should Contain    ${stdout}    ${HWVTEP_IP}
242     ${stdout}=    Write Commands Until Prompt    ${VTEP LIST} ${PHYSICAL_PORT_TABLE}    30s
243     Should Contain    ${stdout}    ${NS_PORT1}
244     Should Contain    ${stdout}    ${NS_PORT2}
245
246 Create And Set Hwvtep Connection Id
247     [Arguments]    ${hwvtep_ip}
248     [Documentation]    To create connection and return connection id for hwvtep_ip received
249     ${conn_id}=    SSHLibrary.Open Connection    ${hwvtep_ip}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
250     Log    ${conn_id}
251     Flexible SSH Login    ${DEFAULT_USER}    ${DEFAULT_PASSWORD}
252     [Return]    ${conn_id}