Reduce logging in vpnservice
[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     ${rx_packet1_before} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig eth0
60     ${rx_packet0_before} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0
61     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
62     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${CONFIG_EXTRA_ROUTE_IP1}
63     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig
64     Should Contain    ${output}    eth0:1
65     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${RPING_MIP_IP}
66     Should Contain    ${output}    broadcast
67     Should Contain    ${output}    Received 0 reply
68     ${rx_packet1_after} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig eth0
69     ${rx_packet0_after} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0
70     Should Not Be Equal    ${rx_packet0_before}    ${rx_packet0_after}
71     Should Not Be Equal    ${rx_packet1_before}    ${rx_packet1_after}
72     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
73     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
74     Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
75     ${output}=    Get Fib Entries    session
76     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_3}\\/32".*"${OS_COMPUTE_2_IP}\\"
77     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_1}\\/32".*"${OS_COMPUTE_1_IP}\\"
78     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_2_IP}\\"
79     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
80
81 TC02 Verify MIP Migration
82     [Documentation]    Verify that after migration of movable ip across compute nodes, the controller updates the routes
83     ${UNCONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 down
84     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ${UNCONFIG_EXTRA_ROUTE_IP1}
85     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ifconfig
86     Should Not Contain    ${output}    eth0:1
87     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
88     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
89     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig
90     Should Contain    ${output}    eth0:1
91     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ifconfig eth0:1
92     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${RPING_MIP_IP}
93     Should Contain    ${output}    Received 0 reply
94     Should Contain    ${output}    broadcast
95     Wait Until Keyword Succeeds    5s    1s    Verify Learnt IP    ${FIB_ENTRY_2}    session
96     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${RPING_MIP_IP}
97     ${output}    Get Fib Entries    session
98     ${resp}=    Should Match Regexp    ${output}    destPrefix\\":\\"${FIB_ENTRY_2}\\/32".*"${OS_COMPUTE_1_IP}\\"
99     Verify Ping To Sub Interface    ${FIB_ENTRY_2}
100     ${UNCONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 down
101     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ${UNCONFIG_EXTRA_ROUTE_IP1}
102
103 TC03 Verify ping to subnet gateway
104     [Documentation]    Verify pig happens to subnet gateway. To be sobmitted in next patch
105     [Tags]    not-implemented    exclude
106     TODO
107
108 TC04 If anything other than subnet ip then no reply
109     [Documentation]    If anything other than subnet ip then no reply. To be sobmitted in next patch
110     [Tags]    not-implemented    exclude
111     TODO
112
113 TC05 Validate multiple mip migration
114     [Documentation]    Validate multiple mip migration. To be sobmitted in next patch
115     [Tags]    not-implemented    exclude
116     TODO
117
118 TC06 Same DPN MIP Migration
119     [Documentation]    Same DPN MIP Migration. To be sobmitted in next patch
120     [Tags]    not-implemented    exclude
121     TODO
122
123 *** Keywords ***
124 Start Suite
125     [Documentation]    Run at start of the suite
126     DevstackUtils.Devstack Suite Setup
127     SetupUtils.Setup_Utils_For_Setup_And_Teardown
128     Create Setup
129
130 End Suite
131     [Documentation]    Run at end of the suite
132     Delete Setup
133     Close All Connections
134
135 Create Setup
136     [Documentation]    Create networks,subnets,ports and VMs
137     : FOR    ${network}    IN    @{NETWORKS}
138     \    Create Network    ${network}
139     ${NET_LIST}    List Networks
140     : FOR    ${network}    IN    @{NETWORKS}
141     \    Should Contain    ${NET_LIST}    ${network}
142     : FOR    ${i}    IN RANGE    0    3
143     \    Create SubNet    ${NETWORKS[${i}]}    ${SUBNETS[${i}]}    ${SUBNET_CIDR[${i}]}
144     ${SUB_LIST}    List Subnets
145     : FOR    ${subnet}    IN    @{SUBNETS}
146     \    Should Contain    ${SUB_LIST}    ${subnet}
147     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
148     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
149     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
150     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
151     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
152     Create Port    ${NETWORKS[1]}    ${PORT_LIST[4]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
153     Create Port    ${NETWORKS[1]}    ${PORT_LIST[5]}    sg=${SECURITY_GROUP}    allowed_address_pairs=@{EXTRA_NW_IP}
154     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET1[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
155     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET1[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
156     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET2[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
157     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET2[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
158     Create Vm Instance With Port On Compute Node    ${PORT_LIST[4]}    ${VM_INSTANCES_NET3[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
159     Create Vm Instance With Port On Compute Node    ${PORT_LIST[5]}    ${VM_INSTANCES_NET3[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
160     Create Router    ${ROUTERS}
161     Add Router Interface    ${ROUTERS}    ${SUBNETS[1]}
162     Add Router Interface    ${ROUTERS}    ${SUBNETS[2]}
163     ${net_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
164     Set Suite Variable    ${net_id}
165     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
166     Set Suite Variable    ${tenant_id}
167     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}
168     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
169     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
170     Associate L3VPN To Network    networkid=${net_id}    vpnid=${VPN_INSTANCE_ID[0]}
171     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
172     Should Contain    ${resp}    ${net_id}
173     ${router_id}=    Get Router Id    ${ROUTERS}    ${devstack_conn_id}
174     Set Suite Variable    ${router_id}
175     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
176     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
177     Should Contain    ${resp}    ${router_id}
178
179 Verify Ping On Same Networks
180     [Documentation]    Verify ping among VM of same network
181     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${VM_IP_NET1[1]}
182     Should Contain    ${output}    ${PING_REGEXP}
183     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${VM_IP_NET2[1]}
184     Should Contain    ${output}    ${PING_REGEXP}
185     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ping -c 3 ${VM_IP_NET1[0]}
186     Should Contain    ${output}    ${PING_REGEXP}
187     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[1]}    ping -c 3 ${VM_IP_NET2[0]}
188     Should Contain    ${output}    ${PING_REGEXP}
189     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${VM_IP_NET3[1]}
190     Should Contain    ${output}    ${PING_REGEXP}
191
192 Verify Ping On Different Networks
193     [Documentation]    Verify ping among VMs of different network
194     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${VM_IP_NET2[0]}
195     Should Contain    ${output}    ${PING_REGEXP}
196     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${VM_IP_NET3[0]}
197     Should Contain    ${output}    ${PING_REGEXP}
198     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ping -c 3 ${VM_IP_NET2[1]}
199     Should Contain    ${output}    ${PING_REGEXP}
200     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[1]}    ping -c 3 ${VM_IP_NET3[1]}
201     Should Contain    ${output}    ${PING_REGEXP}
202     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${VM_IP_NET1[1]}
203     Should Contain    ${output}    ${PING_REGEXP}
204
205 Verify Flows Are Present
206     [Arguments]    ${ip}
207     [Documentation]    Verify Flows Are Present
208     ${flow_output}=    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
209     Log    ${flow_output}
210     ${resp}=    Should Contain    ${flow_output}    table=50
211     ${resp}=    Should Contain    ${flow_output}    table=21,
212     @{vm_ip}=    Create List    @{VM_IP_NET1}    @{VM_IP_NET2}    @{VM_IP_NET3}
213     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:36
214     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:17
215     : FOR    ${i}    IN    @{vm_ip}
216     \    ${resp}=    Should Match regexp    ${flow_output}    table=21.*nw_dst=${i}
217
218 Verify Ping To Sub Interface
219     [Arguments]    ${sub_interface_ip}
220     [Documentation]    Verify ping to the sub-interface
221     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${sub_interface_ip}
222     Should Contain    ${output}    ${PING_REGEXP}
223     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${sub_interface_ip}
224     Should Contain    ${output}    ${PING_REGEXP}
225     ${output}=    Execute Command on VM Instance    @{NETWORKS}[2]    ${VM_IP_NET3[0]}    ping -c 3 ${sub_interface_ip}
226     Should Contain    ${output}    ${PING_REGEXP}
227
228 Verify Learnt IP
229     [Arguments]    ${ip}    ${session}
230     [Documentation]    Check that sub interface ip has been learnt after ARP request
231     ${resp}    RequestsLibrary.Get Request    ${session}    /restconf/operational/odl-l3vpn:learnt-vpn-vip-to-port-data/
232     Log    ${resp.content}
233     Should Contain    ${resp.content}    ${ip}
234
235 TODO
236     Fail    "Not implemented"
237
238 Delete Setup
239     [Documentation]    Delete the setup
240     Dissociate L3VPN From Networks    networkid=${net_id}    vpnid=${VPN_INSTANCE_ID[0]}
241     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
242     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
243     Remove Interface    ${ROUTERS}    ${SUBNETS[1]}
244     Remove Interface    ${ROUTERS}    ${SUBNETS[2]}
245     Delete Router    ${ROUTERS}
246     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}    @{VM_INSTANCES_NET3}
247     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
248     \    Delete Vm Instance    ${VmInstance}
249     : FOR    ${Port}    IN    @{PORT_LIST}
250     \    Delete Port    ${Port}
251     : FOR    ${Subnet}    IN    @{SUBNETS}
252     \    Delete SubNet    ${Subnet}
253     : FOR    ${Network}    IN    @{NETWORKS}
254     \    Delete Network    ${Network}
255     Delete SecurityGroup    ${SECURITY_GROUP}