Use $ for list arg passed in to builtIn kw
[integration/test.git] / csit / suites / netvirt / elan / elan_service_recovery.robot
1 *** Settings ***
2 Documentation     Test Suite for elan interface and service recovery
3 Suite Setup       Start Suite
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 Library           Collections
8 Library           String
9 Resource          ../../../libraries/DevstackUtils.robot
10 Resource          ../../../libraries/FlowLib.robot
11 Resource          ../../../libraries/KarafKeywords.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/OVSDB.robot
14 Resource          ../../../libraries/SetupUtils.robot
15 Resource          ../../../libraries/Utils.robot
16 Resource          ../../../libraries/VpnOperations.robot
17 Resource          ../../../variables/netvirt/Variables.robot
18 Resource          ../../../variables/Variables.robot
19
20 *** Variables ***
21 ${REQ_NETWORK}    elansr_net_1
22 ${REQ_SUBNET}     elansr_sub_1
23 ${REQ_SUBNET_CIDR}    85.1.0.0/16
24 ${SECURITY_GROUP}    elansr_sg
25 ${SERVICE-STATUS-CLI}    srm:recover service elan
26 ${INTERFACE-STATUS-CLI}    srm:recover instance elan-interface
27 ${NUM_OF_PORTS_PER_HOST}    2
28 @{NET_1_VMS}      elansr_net_1_vm_1    elansr_net_1_vm_2
29 @{NET_2_VMS}      elansr_net_2_vm_3    elansr_net_2_vm_4
30 @{PORT_LIST}      elansr_net_1_port_1    elansr_net_1_port_2    elansr_net_1_port_3    elansr_net_1_port_4
31
32 *** Test Cases ***
33 To Verify ELAN Service Recovery
34     [Documentation]    To Verify Elan Service recovery by deleting and recovering multiple flows
35     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ELAN_SMAC_TABLE}    True    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[0]    actions=goto_table:${ELAN_DMACTABLE}
36     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ELAN_SMAC_TABLE}    True    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[2]    actions=goto_table:${ELAN_DMACTABLE}
37     ${flow_id} =    FlowLib.Get Flow Id    ${DPNID_1}    ${ELAN_SMAC_TABLE}    @{PORT_MAC_ADDR}[0]
38     FlowLib.Delete Flow Via Restconf    ${DPNID_1}    ${ELAN_SMAC_TABLE}    ${flow_id}
39     ${flow_id} =    FlowLib.Get Flow Id    ${DPNID_2}    ${ELAN_SMAC_TABLE}    @{PORT_MAC_ADDR}[2]
40     FlowLib.Delete Flow Via Restconf    ${DPNID_2}    ${ELAN_SMAC_TABLE}    ${flow_id}
41     ${mac_elements} =    BuiltIn.Create List    @{PORT_MAC_ADDR}[0]
42     Utils.Check For Elements Not At URI    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}    ${mac_elements}
43     ${mac_elements} =    BuiltIn.Create List    @{PORT_MAC_ADDR}[2]
44     Utils.Check For Elements Not At URI    ${CONFIG_NODES_API}/node/openflow:${DPNID_2}/table/${ELAN_SMAC_TABLE}    ${mac_elements}
45     BuiltIn.Wait Until Keyword Succeeds    10s    5s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ELAN_SMAC_TABLE}    False
46     ...    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[0]
47     BuiltIn.Wait Until Keyword Succeeds    10s    5s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ELAN_SMAC_TABLE}    False
48     ...    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[2]
49     KarafKeywords.Issue Command On Karaf Console    ${SERVICE-STATUS-CLI}
50     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ELAN_SMAC_TABLE}    True    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[0]    actions=goto_table:${ELAN_DMACTABLE}
51     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP2_IP}    ${ELAN_SMAC_TABLE}    True    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[2]    actions=goto_table:${ELAN_DMACTABLE}
52     ${mac_elements} =    BuiltIn.Create List    @{PORT_MAC_ADDR}[0]
53     Utils.Check For Elements At URI    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}    ${mac_elements}
54     ${mac_elements} =    BuiltIn.Create List    @{PORT_MAC_ADDR}[2]
55     Utils.Check For Elements At URI    ${CONFIG_NODES_API}/node/openflow:${DPNID_2}/table/${ELAN_SMAC_TABLE}    ${mac_elements}
56
57 To Verify Elan Interface recovery
58     [Documentation]    To Verify the Elan Interface recovery by deleting single Flow
59     BuiltIn.Wait Until Keyword Succeeds    60s    15s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ELAN_SMAC_TABLE}    True
60     ...    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[0]    actions=goto_table:${ELAN_DMACTABLE}
61     ${flow_id} =    FlowLib.Get Flow Id    ${DPNID_1}    ${ELAN_SMAC_TABLE}    @{PORT_MAC_ADDR}[0]
62     FlowLib.Delete Flow Via Restconf    ${DPNID_1}    ${ELAN_SMAC_TABLE}    ${flow_id}
63     ${mac_elements} =    BuiltIn.Create List    @{PORT_MAC_ADDR}[0]
64     Utils.Check For Elements Not At URI    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}    ${mac_elements}
65     BuiltIn.Wait Until Keyword Succeeds    60s    15s    OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ELAN_SMAC_TABLE}    False
66     ...    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[0]
67     ${elan_instance_id} =    Get Elan Instance ID
68     ${elan_interface_id} =    Get Elan Interfaces ID    ${elan_instance_id}    @{PORT_MAC_ADDR}[0]
69     Recover Elan Flows    ${elan_interface_id}
70     ${mac_elements} =    BuiltIn.Create List    @{PORT_MAC_ADDR}[0]
71     BuiltIn.Wait Until Keyword Succeeds    10s    5s    Utils.Check For Elements At URI    ${CONFIG_NODES_API}/node/openflow:${DPNID_1}/table/${ELAN_SMAC_TABLE}    ${mac_elements}
72     OVSDB.Verify Dump Flows For Specific Table    ${OS_CMP1_IP}    ${ELAN_SMAC_TABLE}    True    ${EMPTY}    dl_src=@{PORT_MAC_ADDR}[0]    actions=goto_table:${ELAN_DMACTABLE}
73
74 *** Keywords ***
75 Start Suite
76     [Documentation]    Test Suite for Elan interface and service recovery
77     OpenStackOperations.OpenStack Suite Setup
78     Create Setup
79     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}
80     OpenStackOperations.Get Suite Debugs
81
82 Create Neutron Ports
83     [Documentation]    Create required number of ports under previously created subnets
84     : FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_HOST}
85     \    OpenStackOperations.Create Port    ${REQ_NETWORK}    @{PORT_LIST}[${index}]    sg=${SECURITY_GROUP}
86     \    OpenStackOperations.Create Port    ${REQ_NETWORK}    @{PORT_LIST}[${index + 2}]    sg=${SECURITY_GROUP}
87     @{PORT_MAC_ADDR} =    OpenStackOperations.Get Ports MacAddr    ${PORT_LIST}
88     BuiltIn.Set Suite Variable    @{PORT_MAC_ADDR}
89
90 Create Nova VMs
91     [Arguments]    ${num_of_vms_per_dpn}
92     [Documentation]    Create Vm instances on compute nodes
93     : FOR    ${index}    IN RANGE    0    ${num_of_vms_per_dpn}
94     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORT_LIST}[${index}]    @{NET_1_VMS}[${index}]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
95     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{PORT_LIST}[${index + 2}]    @{NET_2_VMS}[${index}]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
96     @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
97     @{NET_2_VM_IPS}    ${NET_2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
98     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
99     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
100     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
101     BuiltIn.Should Not Contain    ${NET_2_DHCP_IP}    None
102
103 Create Setup
104     [Documentation]    Create basic topology
105     BuiltIn.Wait Until Keyword Succeeds    60s    10s    VpnOperations.Verify Tunnel Status as UP
106     OpenStackOperations.Create Network    ${REQ_NETWORK}
107     OpenStackOperations.Create SubNet    ${REQ_NETWORK}    ${REQ_SUBNET}    ${REQ_SUBNET_CIDR}
108     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
109     Create Neutron Ports
110     Create Nova VMs    ${2}
111     ${DPNID_1} =    OVSDB.Get DPID    ${OS_CMP1_IP}
112     ${DPNID_2} =    OVSDB.Get DPID    ${OS_CMP2_IP}
113     BuiltIn.Set Suite Variable    ${DPNID_1}
114     BuiltIn.Set Suite Variable    ${DPNID_2}
115
116 Get Elan Instance ID
117     [Documentation]    Retrieving ELAN instance ID
118     ${output} =    KarafKeywords.Issue Command On Karaf Console    elaninterface:show
119     ${elan_instance} =    String.Split String    ${output}
120     ${elan_instance_with_tag} =    BuiltIn.Set Variable    ${elan_instance[5]}
121     ${elan_instance_id} =    String.Split String    ${elan_instance_with_tag}    /
122     [Return]    @{elan_instance_id}[0]
123
124 Get Elan Interfaces ID
125     [Arguments]    ${elan_id}    ${mac}
126     [Documentation]    Getting the ELAN interface ID with corresponding mac address and returning interface ID list
127     ${elan_output} =    KarafKeywords.Issue Command On Karaf Console    elanmactable:show ${elan_id}
128     ${interface_id} =    String.Get Regexp Matches    ${elan_output}    (${REGEX_UUID})\\s*${mac}    1
129     [Return]    @{interface_id}[0]
130
131 Recover Elan Flows
132     [Arguments]    ${interface}
133     [Documentation]    Recover ELAN flows for the given interfaces
134     ${recover_msg} =    KarafKeywords.Issue Command On Karaf Console    ${INTERFACE-STATUS-CLI} ${interface}
135     BuiltIn.Should Contain    ${recover_msg}    RPC call to recover was successful