Use openstack cli instead of nova console-log cli
[integration/test.git] / csit / suites / netvirt / Netvirt_Vpnservice / ARP_Learning.robot
1 *** Settings ***
2 Documentation     Test suite for ARP Request. More test cases to be added in subsequent patches.
3 Suite Setup       Start Suite
4 Suite Teardown    End Suite
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     Get Test Teardown Debugs
7 Library           RequestsLibrary
8 Resource          ../../../libraries/OpenStackOperations.robot
9 Resource          ../../../libraries/DevstackUtils.robot
10 Resource          ../../../libraries/VpnOperations.robot
11 Resource          ../../../libraries/SetupUtils.robot
12 Resource          ../../../variables/netvirt/Variables.robot
13 Resource          ../../../variables/Variables.robot
14
15 *** Variables ***
16 ${SECURITY_GROUP}    sg-vpnservice-arp
17 @{VPN_INSTANCE_ID}    4ae8cd92-48ca-49b5-94e1-b2921a261111    4ae8cd92-48ca-49b5-94e1-b2921a261112
18 @{VPN_NAME}       vpn1    vpn2
19 ${CREATE_RD}      ["2200:2"]
20 ${CREATE_RD1}     ["2200:3"]
21 ${CREATE_EXPORT_RT}    ["2200:2","2200:3"]
22 ${CREATE_IMPORT_RT}    ["2200:2","2200:3"]
23
24 *** Test Cases ***
25 TC00 Verify Setup
26     [Documentation]    Verify that VMs received ip and ping is happening between different VM
27     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}    @{VM_INSTANCES_NET3}
28     : FOR    ${VM}    IN    @{VM_INSTANCES}
29     \    Poll VM Is ACTIVE    ${VM}
30     ${VM_IP_NET1}    ${DHCP_IP1}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET1}
31     ${VM_IP_NET2}    ${DHCP_IP2}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET2}
32     ${VM_IP_NET3}    ${DHCP_IP3}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET3}
33     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_NET1}    ${VM_INSTANCES_NET2}    ${VM_INSTANCES_NET3}
34     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET1}    ${VM_IP_NET2}    ${VM_IP_NET3}
35     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET1}
36     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
37     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
38     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    openstack console log show @{VM_INSTANCES}[${index}]    30s
39     Set Suite Variable    ${VM_IP_NET1}
40     Set Suite Variable    ${VM_IP_NET2}
41     Set Suite Variable    ${VM_IP_NET3}
42     Should Not Contain    ${VM_IP_NET1}    None
43     Should Not Contain    ${VM_IP_NET2}    None
44     Should Not Contain    ${VM_IP_NET3}    None
45     ${vm_instances} =    Create List    @{VM_IP_NET1}    @{VM_IP_NET2}    @{VM_IP_NET3}
46     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRIES_URL}    ${vm_instances}
47     Verify Ping On Same Networks
48     Verify Ping On Different Networks
49
50 TC01 Verify GARP Requests
51     [Documentation]    Verify that GARP request are sent to controller
52     Set Suite Variable    ${FIB_ENTRY_1}    ${VM_IP_NET1[0]}
53     Set Suite Variable    ${FIB_ENTRY_3}    ${VM_IP_NET1[1]}
54     Wait Until Keyword Succeeds    10s    1s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
55     Wait Until Keyword Succeeds    10s    1s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
56     ${output}=    Get Fib Entries    session
57     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_3}\/32".*"${OS_COMPUTE_2_IP}\\"
58     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_1}\/32".*"${OS_COMPUTE_1_IP}\\"
59     Log    Checking the RX Packets Count on VM1 and VM2 before ARP Broadcast
60     ${rx_packet1_before} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig eth0
61     ${rx_packet0_before} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0
62     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
63     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${CONFIG_EXTRA_ROUTE_IP1}
64     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig
65     Should Contain    ${output}    eth0:1
66     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${RPING_MIP_IP}
67     Should Contain    ${output}    broadcast
68     Should Contain    ${output}    Received 0 reply
69     Log    Checking the RX Packets Count on VM1 and VM2 after ARP Broadcast
70     ${rx_packet1_after} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig eth0
71     ${rx_packet0_after} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0
72     Should Not Be Equal    ${rx_packet0_before}    ${rx_packet0_after}
73     Should Not Be Equal    ${rx_packet1_before}    ${rx_packet1_after}
74     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
75     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
76     Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
77     ${output}=    Get Fib Entries    session
78     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_3}\\/32".*"${OS_COMPUTE_2_IP}\\"
79     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_1}\\/32".*"${OS_COMPUTE_1_IP}\\"
80     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_2_IP}\\"
81     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
82
83 TC02 Verify MIP Migration
84     [Documentation]    Verify that after migration of movable ip across compute nodes, the controller updates the routes
85     Log    Bring down the Sub Interface on DPN2
86     ${UNCONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 down
87     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${UNCONFIG_EXTRA_ROUTE_IP1}
88     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig
89     Should Not Contain    ${output}    eth0:1
90     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
91     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
92     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig
93     Should Contain    ${output}    eth0:1
94     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0:1
95     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${RPING_MIP_IP}
96     Should Contain    ${output}    Received 0 reply
97     Should Contain    ${output}    broadcast
98     Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
99     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${RPING_MIP_IP}
100     ${output}    Get Fib Entries    session
101     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_1_IP}\\"
102     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
103     Log    Removing the created sub-interface
104     ${UNCONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 down
105     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${UNCONFIG_EXTRA_ROUTE_IP1}
106
107 TC03 Verify ping to subnet gateway
108     [Documentation]    Verify pig happens to subnet gateway. To be sobmitted in next patch
109     [Tags]    not-implemented    exclude
110     TODO
111
112 TC04 If anything other than subnet ip then no reply
113     [Documentation]    If anything other than subnet ip then no reply. To be sobmitted in next patch
114     [Tags]    not-implemented    exclude
115     TODO
116
117 TC05 Validate multiple mip migration
118     [Documentation]    Validate multiple mip migration. To be sobmitted in next patch
119     [Tags]    not-implemented    exclude
120     TODO
121
122 TC06 Same DPN MIP Migration
123     [Documentation]    Same DPN MIP Migration. To be sobmitted in next patch
124     [Tags]    not-implemented    exclude
125     TODO
126
127 *** Keywords ***
128 Start Suite
129     [Documentation]    Run at start of the suite
130     DevstackUtils.Devstack Suite Setup
131     SetupUtils.Setup_Utils_For_Setup_And_Teardown
132     Create Setup
133
134 End Suite
135     [Documentation]    Run at end of the suite
136     Delete Setup
137     Close All Connections
138
139 Create Setup
140     [Documentation]    Create networks,subnets,ports and VMs
141     : FOR    ${network}    IN    @{NETWORKS}
142     \    Create Network    ${network}
143     ${NET_LIST}    List Networks
144     : FOR    ${network}    IN    @{NETWORKS}
145     \    Should Contain    ${NET_LIST}    ${network}
146     : FOR    ${i}    IN RANGE    0    3
147     \    Create SubNet    ${NETWORKS[${i}]}    ${SUBNETS[${i}]}    ${SUBNET_CIDR[${i}]}
148     ${SUB_LIST}    List Subnets
149     : FOR    ${subnet}    IN    @{SUBNETS}
150     \    Should Contain    ${SUB_LIST}    ${subnet}
151     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
152     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
153     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
154     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
155     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
156     Create Port    ${NETWORKS[1]}    ${PORT_LIST[4]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
157     Create Port    ${NETWORKS[1]}    ${PORT_LIST[5]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
158     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET1[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
159     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET1[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
160     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET2[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
161     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET2[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
162     Create Vm Instance With Port On Compute Node    ${PORT_LIST[4]}    ${VM_INSTANCES_NET3[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
163     Create Vm Instance With Port On Compute Node    ${PORT_LIST[5]}    ${VM_INSTANCES_NET3[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
164     Create Router    ${ROUTERS}
165     Add Router Interface    ${ROUTERS}    ${SUBNETS[1]}
166     Add Router Interface    ${ROUTERS}    ${SUBNETS[2]}
167     ${net_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
168     Set Suite Variable    ${net_id}
169     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
170     Set Suite Variable    ${tenant_id}
171     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=${CREATE_RD}    exportrt=${CREATE_EXPORT_RT}    importrt=${CREATE_IMPORT_RT}    tenantid=${tenant_id}
172     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
173     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
174     Associate L3VPN To Network    networkid=${net_id}    vpnid=${VPN_INSTANCE_ID[0]}
175     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
176     Should Contain    ${resp}    ${net_id}
177     ${router_id}=    Get Router Id    ${ROUTERS}    ${devstack_conn_id}
178     Set Suite Variable    ${router_id}
179     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
180     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
181     Should Contain    ${resp}    ${router_id}
182
183 Verify Ping On Same Networks
184     [Documentation]    Verify ping among VM of same network
185     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${VM_IP_NET1[1]}
186     Should Contain    ${output}    ${PING_REGEXP}
187     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${VM_IP_NET2[1]}
188     Should Contain    ${output}    ${PING_REGEXP}
189     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ping -c 3 ${VM_IP_NET1[0]}
190     Should Contain    ${output}    ${PING_REGEXP}
191     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[1]}    ping -c 3 ${VM_IP_NET2[0]}
192     Should Contain    ${output}    ${PING_REGEXP}
193     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${VM_IP_NET3[1]}
194     Should Contain    ${output}    ${PING_REGEXP}
195
196 Verify Ping On Different Networks
197     [Documentation]    Verify ping among VMs of different network
198     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${VM_IP_NET2[0]}
199     Should Contain    ${output}    ${PING_REGEXP}
200     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${VM_IP_NET3[0]}
201     Should Contain    ${output}    ${PING_REGEXP}
202     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ping -c 3 ${VM_IP_NET2[1]}
203     Should Contain    ${output}    ${PING_REGEXP}
204     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[1]}    ping -c 3 ${VM_IP_NET3[1]}
205     Should Contain    ${output}    ${PING_REGEXP}
206     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${VM_IP_NET1[1]}
207     Should Contain    ${output}    ${PING_REGEXP}
208
209 Verify Flows Are Present
210     [Arguments]    ${ip}
211     [Documentation]    Verify Flows Are Present
212     ${flow_output}=    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
213     Log    ${flow_output}
214     ${resp}=    Should Contain    ${flow_output}    table=50
215     ${resp}=    Should Contain    ${flow_output}    table=21,
216     @{vm_ip}=    Create List    @{VM_IP_NET1}    @{VM_IP_NET2}    @{VM_IP_NET3}
217     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:36
218     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:17
219     : FOR    ${i}    IN    @{vm_ip}
220     \    ${resp}=    Should Match regexp    ${flow_output}    table=21.*nw_dst=${i}
221
222 Verify Ping To Sub Interface
223     [Arguments]    ${sub_interface_ip}
224     [Documentation]    Verify ping to the sub-interface
225     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${sub_interface_ip}
226     Should Contain    ${output}    ${PING_REGEXP}
227     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${sub_interface_ip}
228     Should Contain    ${output}    ${PING_REGEXP}
229     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${sub_interface_ip}
230     Should Contain    ${output}    ${PING_REGEXP}
231
232 Verify Learnt IP
233     [Arguments]    ${ip}    ${session}
234     [Documentation]    Check that sub interface ip has been learnt after ARP request
235     ${resp}    RequestsLibrary.Get Request    ${session}    /restconf/operational/odl-l3vpn:learnt-vpn-vip-to-port-data/
236     Log    ${resp.content}
237     Should Contain    ${resp.content}    ${ip}
238
239 TODO
240     Fail    "Not implemented"
241
242 Delete Setup
243     [Documentation]    Delete the setup
244     Dissociate L3VPN From Networks    networkid=${net_id}    vpnid=${VPN_INSTANCE_ID[0]}
245     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
246     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
247     Remove Interface    ${ROUTERS}    ${SUBNETS[1]}
248     Remove Interface    ${ROUTERS}    ${SUBNETS[2]}
249     Delete Router    ${ROUTERS}
250     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}    @{VM_INSTANCES_NET3}
251     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
252     \    Delete Vm Instance    ${VmInstance}
253     : FOR    ${Port}    IN    @{PORT_LIST}
254     \    Delete Port    ${Port}
255     : FOR    ${Subnet}    IN    @{SUBNETS}
256     \    Delete SubNet    ${Subnet}
257     : FOR    ${Network}    IN    @{NETWORKS}
258     \    Delete Network    ${Network}
259     Delete SecurityGroup    ${SECURITY_GROUP}