Update Robot Framework format - step 11
[integration/test.git] / csit / suites / netvirt / elan / elan_service_recovery.robot
1 *** Settings ***
2 Documentation       Test Suite for elan interface and service recovery
3
4 Library             Collections
5 Library             String
6 Resource            ../../../libraries/DevstackUtils.robot
7 Resource            ../../../libraries/FlowLib.robot
8 Resource            ../../../libraries/KarafKeywords.robot
9 Resource            ../../../libraries/OpenStackOperations.robot
10 Resource            ../../../libraries/OVSDB.robot
11 Resource            ../../../libraries/SetupUtils.robot
12 Resource            ../../../libraries/Utils.robot
13 Resource            ../../../libraries/VpnOperations.robot
14 Resource            ../../../variables/netvirt/Variables.robot
15 Resource            ../../../variables/Variables.robot
16
17 Suite Setup         Suite Setup
18 Suite Teardown      OpenStackOperations.OpenStack Suite Teardown
19 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
20 Test Teardown       OpenStackOperations.Get Test Teardown Debugs
21
22
23 *** Variables ***
24 ${REQ_NETWORK}              elansr_net_1
25 ${REQ_SUBNET}               elansr_sub_1
26 ${REQ_SUBNET_CIDR}          85.1.0.0/16
27 ${SECURITY_GROUP}           elansr_sg
28 ${SERVICE-STATUS-CLI}       srm:recover service elan
29 ${INTERFACE-STATUS-CLI}     srm:recover instance elan-interface
30 ${NUM_OF_PORTS_PER_HOST}    2
31 @{NET_1_VMS}                elansr_net_1_vm_1    elansr_net_1_vm_2
32 @{NET_2_VMS}                elansr_net_2_vm_3    elansr_net_2_vm_4
33 @{PORT_LIST}                elansr_net_1_port_1    elansr_net_1_port_2    elansr_net_1_port_3    elansr_net_1_port_4
34
35
36 *** Test Cases ***
37 To Verify ELAN Service Recovery
38     [Documentation]    To Verify Elan Service recovery by deleting and recovering multiple flows
39     OVSDB.Verify Dump Flows For Specific Table
40     ...    ${OS_CMP1_IP}
41     ...    ${ELAN_SMAC_TABLE}
42     ...    True
43     ...    ${EMPTY}
44     ...    dl_src=${PORT_MAC_ADDR}[0]
45     ...    actions=goto_table:${ELAN_DMACTABLE}
46     OVSDB.Verify Dump Flows For Specific Table
47     ...    ${OS_CMP2_IP}
48     ...    ${ELAN_SMAC_TABLE}
49     ...    True
50     ...    ${EMPTY}
51     ...    dl_src=${PORT_MAC_ADDR}[2]
52     ...    actions=goto_table:${ELAN_DMACTABLE}
53     ${flow_id} =    FlowLib.Get Flow Id    ${DPNID_1}    ${ELAN_SMAC_TABLE}    ${PORT_MAC_ADDR}[0]
54     FlowLib.Delete Flow Via Restconf    ${DPNID_1}    ${ELAN_SMAC_TABLE}    ${flow_id}
55     ${flow_id} =    FlowLib.Get Flow Id    ${DPNID_2}    ${ELAN_SMAC_TABLE}    ${PORT_MAC_ADDR}[2]
56     FlowLib.Delete Flow Via Restconf    ${DPNID_2}    ${ELAN_SMAC_TABLE}    ${flow_id}
57     ${mac_elements} =    BuiltIn.Create List    ${PORT_MAC_ADDR}[0]
58     Utils.Check For Elements Not At URI
59     ...    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}
60     ...    ${mac_elements}
61     ${mac_elements} =    BuiltIn.Create List    ${PORT_MAC_ADDR}[2]
62     Utils.Check For Elements Not At URI
63     ...    ${CONFIG_NODES_API}/node/openflow:${DPNID_2}/table/${ELAN_SMAC_TABLE}
64     ...    ${mac_elements}
65     BuiltIn.Wait Until Keyword Succeeds
66     ...    10s
67     ...    5s
68     ...    OVSDB.Verify Dump Flows For Specific Table
69     ...    ${OS_CMP1_IP}
70     ...    ${ELAN_SMAC_TABLE}
71     ...    False
72     ...    ${EMPTY}
73     ...    dl_src=${PORT_MAC_ADDR}[0]
74     BuiltIn.Wait Until Keyword Succeeds
75     ...    10s
76     ...    5s
77     ...    OVSDB.Verify Dump Flows For Specific Table
78     ...    ${OS_CMP2_IP}
79     ...    ${ELAN_SMAC_TABLE}
80     ...    False
81     ...    ${EMPTY}
82     ...    dl_src=${PORT_MAC_ADDR}[2]
83     KarafKeywords.Issue Command On Karaf Console    ${SERVICE-STATUS-CLI}
84     OVSDB.Verify Dump Flows For Specific Table
85     ...    ${OS_CMP1_IP}
86     ...    ${ELAN_SMAC_TABLE}
87     ...    True
88     ...    ${EMPTY}
89     ...    dl_src=${PORT_MAC_ADDR}[0]
90     ...    actions=goto_table:${ELAN_DMACTABLE}
91     OVSDB.Verify Dump Flows For Specific Table
92     ...    ${OS_CMP2_IP}
93     ...    ${ELAN_SMAC_TABLE}
94     ...    True
95     ...    ${EMPTY}
96     ...    dl_src=${PORT_MAC_ADDR}[2]
97     ...    actions=goto_table:${ELAN_DMACTABLE}
98     ${mac_elements} =    BuiltIn.Create List    ${PORT_MAC_ADDR}[0]
99     Utils.Check For Elements At URI
100     ...    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}
101     ...    ${mac_elements}
102     ${mac_elements} =    BuiltIn.Create List    ${PORT_MAC_ADDR}[2]
103     Utils.Check For Elements At URI
104     ...    ${CONFIG_NODES_API}/node/openflow:${DPNID_2}/table/${ELAN_SMAC_TABLE}
105     ...    ${mac_elements}
106
107 To Verify Elan Interface recovery
108     [Documentation]    To Verify the Elan Interface recovery by deleting single Flow
109     BuiltIn.Wait Until Keyword Succeeds
110     ...    60s
111     ...    15s
112     ...    OVSDB.Verify Dump Flows For Specific Table
113     ...    ${OS_CMP1_IP}
114     ...    ${ELAN_SMAC_TABLE}
115     ...    True
116     ...    ${EMPTY}
117     ...    dl_src=${PORT_MAC_ADDR}[0]
118     ...    actions=goto_table:${ELAN_DMACTABLE}
119     ${flow_id} =    FlowLib.Get Flow Id    ${DPNID_1}    ${ELAN_SMAC_TABLE}    ${PORT_MAC_ADDR}[0]
120     FlowLib.Delete Flow Via Restconf    ${DPNID_1}    ${ELAN_SMAC_TABLE}    ${flow_id}
121     ${mac_elements} =    BuiltIn.Create List    ${PORT_MAC_ADDR}[0]
122     Utils.Check For Elements Not At URI
123     ...    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}
124     ...    ${mac_elements}
125     BuiltIn.Wait Until Keyword Succeeds
126     ...    60s
127     ...    15s
128     ...    OVSDB.Verify Dump Flows For Specific Table
129     ...    ${OS_CMP1_IP}
130     ...    ${ELAN_SMAC_TABLE}
131     ...    False
132     ...    ${EMPTY}
133     ...    dl_src=${PORT_MAC_ADDR}[0]
134     ${elan_instance_id} =    Get Elan Instance ID
135     ${elan_interface_id} =    Get Elan Interfaces ID    ${elan_instance_id}    ${PORT_MAC_ADDR}[0]
136     Recover Elan Flows    ${elan_interface_id}
137     ${mac_elements} =    BuiltIn.Create List    ${PORT_MAC_ADDR}[0]
138     BuiltIn.Wait Until Keyword Succeeds
139     ...    10s
140     ...    5s
141     ...    Utils.Check For Elements At URI
142     ...    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}
143     ...    ${mac_elements}
144     OVSDB.Verify Dump Flows For Specific Table
145     ...    ${OS_CMP1_IP}
146     ...    ${ELAN_SMAC_TABLE}
147     ...    True
148     ...    ${EMPTY}
149     ...    dl_src=${PORT_MAC_ADDR}[0]
150     ...    actions=goto_table:${ELAN_DMACTABLE}
151
152
153 *** Keywords ***
154 Suite Setup
155     [Documentation]    Test Suite for Elan interface and service recovery
156     OpenStackOperations.OpenStack Suite Setup
157     Create Setup
158     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}
159     OpenStackOperations.Get Suite Debugs
160
161 Create Neutron Ports
162     [Documentation]    Create required number of ports under previously created subnets
163     FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_HOST}
164         OpenStackOperations.Create Port    ${REQ_NETWORK}    ${PORT_LIST}[${index}]    sg=${SECURITY_GROUP}
165         OpenStackOperations.Create Port    ${REQ_NETWORK}    ${PORT_LIST}[${index + 2}]    sg=${SECURITY_GROUP}
166     END
167     @{PORT_MAC_ADDR} =    OpenStackOperations.Get Ports MacAddr    ${PORT_LIST}
168     BuiltIn.Set Suite Variable    @{PORT_MAC_ADDR}
169
170 Create Nova VMs
171     [Documentation]    Create Vm instances on compute nodes
172     [Arguments]    ${num_of_vms_per_dpn}
173     FOR    ${index}    IN RANGE    0    ${num_of_vms_per_dpn}
174         OpenStackOperations.Create Vm Instance With Port On Compute Node
175         ...    ${PORT_LIST}[${index}]
176         ...    ${NET_1_VMS}[${index}]
177         ...    ${OS_CMP1_HOSTNAME}
178         ...    sg=${SECURITY_GROUP}
179         OpenStackOperations.Create Vm Instance With Port On Compute Node
180         ...    ${PORT_LIST}[${index + 2}]
181         ...    ${NET_2_VMS}[${index}]
182         ...    ${OS_CMP2_HOSTNAME}
183         ...    sg=${SECURITY_GROUP}
184     END
185     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
186     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
187     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
188     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
189     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
190     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
191
192 Create Setup
193     [Documentation]    Create basic topology
194     BuiltIn.Wait Until Keyword Succeeds    60s    10s    VpnOperations.Verify Tunnel Status as UP
195     OpenStackOperations.Create Network    ${REQ_NETWORK}
196     OpenStackOperations.Create SubNet    ${REQ_NETWORK}    ${REQ_SUBNET}    ${REQ_SUBNET_CIDR}
197     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
198     Create Neutron Ports
199     Create Nova VMs    ${2}
200     ${DPNID_1} =    OVSDB.Get DPID    ${OS_CMP1_IP}
201     ${DPNID_2} =    OVSDB.Get DPID    ${OS_CMP2_IP}
202     BuiltIn.Set Suite Variable    ${DPNID_1}
203     BuiltIn.Set Suite Variable    ${DPNID_2}
204
205 Get Elan Instance ID
206     [Documentation]    Retrieving ELAN instance ID
207     ${output} =    KarafKeywords.Issue Command On Karaf Console    elaninterface:show
208     ${elan_instance} =    String.Split String    ${output}
209     ${elan_instance_with_tag} =    BuiltIn.Set Variable    ${elan_instance[5]}
210     ${elan_instance_id} =    String.Split String    ${elan_instance_with_tag}    /
211     RETURN    ${elan_instance_id}[0]
212
213 Get Elan Interfaces ID
214     [Documentation]    Getting the ELAN interface ID with corresponding mac address and returning interface ID list
215     [Arguments]    ${elan_id}    ${mac}
216     ${elan_output} =    KarafKeywords.Issue Command On Karaf Console    elanmactable:show ${elan_id}
217     ${interface_id} =    String.Get Regexp Matches    ${elan_output}    (${REGEX_UUID})\\s*${mac}    1
218     RETURN    ${interface_id}[0]
219
220 Recover Elan Flows
221     [Documentation]    Recover ELAN flows for the given interfaces
222     [Arguments]    ${interface}
223     ${recover_msg} =    KarafKeywords.Issue Command On Karaf Console    ${INTERFACE-STATUS-CLI} ${interface}
224     BuiltIn.Should Contain    ${recover_msg}    RPC call to recover was successful