1e8197e74bc0f16a9373565ddbe604cba8d84442
[integration/test.git] / csit / suites / netvirt / aclservicerecovery / aclservicerecovery.robot
1 *** Settings ***
2 Documentation       Test Suite for ACL Service Recovery:
3 ...                 The Service Recovery Manager provides
4 ...                 common interface to recover services in ODL.
5 ...                 This feature will register ACL service for recovery
6 ...                 and implement the mechanism to recover ACL service.
7
8 Library             OperatingSystem
9 Library             RequestsLibrary
10 Library             String
11 Resource            ../../../libraries/DevstackUtils.robot
12 Resource            ../../../libraries/KarafKeywords.robot
13 Resource            ../../../libraries/OVSDB.robot
14 Resource            ../../../libraries/OvsManager.robot
15 Resource            ../../../libraries/OpenStackOperations.robot
16 Resource            ../../../libraries/SetupUtils.robot
17 Resource            ../../../libraries/Utils.robot
18 Resource            ../../../variables/netvirt/Variables.robot
19 Resource            ../../../variables/Variables.robot
20
21 Suite Setup         Suite Setup
22 Suite Teardown      Run Keywords    OpenStackOperations.OpenStack Suite Teardown
23 ...                     AND    SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    INFO    ${TEST_LOG_COMPONENTS}
24 Test Setup          Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
25 ...                     AND    OpenStackOperations.Get DumpFlows And Ovsconfig    ${OS_CMP1_CONN_ID}
26 Test Teardown       OpenStackOperations.Get Test Teardown Debugs
27
28
29 *** Variables ***
30 ${acl_sr_security_group}    acl_sr_sg
31 @{acl_sr_networks}          acl_sr_net_1    acl_sr_net_2    acl_sr_net_3
32 @{acl_sr_subnets}           acl_sr_sub_1    acl_sr_sub_2    acl_sr_sub_3
33 @{acl_sr_subnet_cidrs}      81.1.1.0/24    82.1.1.0/24    83.1.1.0/24
34 @{acl_sr_net_1_ports}       acl_sr_net_1_port_1    acl_sr_net_1_port_2
35 @{acl_sr_net_1_vms}         acl_sr_net_1_vm_1    acl_sr_net_1_vm_2
36 ${TEST_LOG_LEVEL}           trace
37 @{TEST_LOG_COMPONENTS}
38 ...                         org.opendaylight.netvirt.aclservice
39
40
41 *** Test Cases ***
42 ACL Service Recovery CLI
43     [Documentation]    This test case covers ACL service recovery.
44     ${count_before} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${INGRESS_ACL_REMOTE_ACL_TABLE}
45     ${node_id} =    OVSDB.Get DPID    ${OS_CMP1_IP}
46     ${resp} =    RequestsLibrary.Delete Request
47     ...    session
48     ...    ${CONFIG_NODES_API}/node/openflow:${node_id}/flow-node-inventory:table/${INGRESS_ACL_REMOTE_ACL_TABLE}
49     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
50     OpenStackOperations.Ping From DHCP Should Not Succeed    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[0]
51     ${flow_after_delete} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${INGRESS_ACL_REMOTE_ACL_TABLE}
52     BuiltIn.Should Be Equal As Strings    ${flow_after_delete}    0
53     ${output} =    Issue_Command_On_Karaf_Console    srm:recover service acl
54     BuiltIn.Should Contain    ${output}    RPC call to recover was successful
55     OpenStackOperations.Ping Vm From DHCP Namespace    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[0]
56     BuiltIn.Wait Until Keyword Succeeds
57     ...    30s
58     ...    5s
59     ...    Verify Flow Counts Are Same
60     ...    ${count_before}
61     ...    ${INGRESS_ACL_REMOTE_ACL_TABLE}
62
63 ACL Instance Recovery CLI
64     [Documentation]    This test case covers ACL instance recovery.
65     ${count_before} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${EGRESS_LEARN_ACL_FILTER_TABLE}
66     ${node_id} =    OVSDB.Get DPID    ${OS_CMP1_IP}
67     Write Commands Until Expected Prompt
68     ...    sudo ovs-ofctl del-flows br-int -OOpenflow13 "table=${EGRESS_LEARN_ACL_FILTER_TABLE},icmp"
69     ...    ${DEFAULT_LINUX_PROMPT_STRICT}
70     Wait Until Keyword Succeeds
71     ...    30s
72     ...    5s
73     ...    OVSDB.Verify Dump Flows For Specific Table
74     ...    ${OS_CMP1_IP}
75     ...    ${EGRESS_LEARN_ACL_FILTER_TABLE}
76     ...    False
77     ...    |grep icmp
78     OpenStackOperations.Ping From DHCP Should Not Succeed    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[0]
79     ${output} =    OpenStack CLI    openstack security group show ${acl_sr_security_group} | awk '/ id / {print $4}'
80     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
81     ${instance_id} =    Collections.Get from List    ${splitted_output}    0
82     ${output} =    Issue_Command_On_Karaf_Console    srm:recover instance acl-instance ${instance_id}
83     BuiltIn.Should Contain    ${output}    RPC call to recover was successful
84     OpenStackOperations.Ping Vm From DHCP Namespace    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[0]
85     Wait Until Keyword Succeeds
86     ...    30s
87     ...    5s
88     ...    OVSDB.Verify Dump Flows For Specific Table
89     ...    ${OS_CMP1_IP}
90     ...    ${EGRESS_LEARN_ACL_FILTER_TABLE}
91     ...    True
92     ...    ${EMPTY}
93     ...    icmp
94     Wait Until Keyword Succeeds
95     ...    30s
96     ...    5s
97     ...    Verify Flow Counts Are Same
98     ...    ${count_before}
99     ...    ${EGRESS_LEARN_ACL_FILTER_TABLE}
100
101 ACL Interface Recovery CLI
102     [Documentation]    This test case covers ACL interface recovery.
103     ${output} =    OpenStack CLI    openstack port show ${acl_sr_net_1_ports[0]} |awk '/ mac_address / {print$4}'
104     @{list} =    Split String    ${output}
105     ${port_mac} =    Set Variable    ${list[0]}
106     ${count_before} =    OvsManager.Get Dump Flows Count
107     ...    ${OS_CMP1_CONN_ID}
108     ...    ${EGRESS_ACL_TABLE}
109     ...    port_mac=${port_mac}
110     ${node_id} =    OVSDB.Get DPID    ${OS_CMP1_IP}
111     Write Commands Until Expected Prompt
112     ...    sudo ovs-ofctl del-flows br-int -OOpenflow13 "table=${EGRESS_ACL_TABLE},dl_dst=${port_mac}"
113     ...    ${DEFAULT_LINUX_PROMPT_STRICT}
114     OpenStackOperations.Ping From DHCP Should Not Succeed    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[0]
115     Wait Until Keyword Succeeds
116     ...    30s
117     ...    5s
118     ...    OVSDB.Verify Dump Flows For Specific Table
119     ...    ${OS_CMP1_IP}
120     ...    ${EGRESS_LEARN_ACL_FILTER_TABLE}
121     ...    False
122     ...    |grep ${port_mac}
123     ${output} =    OpenStack CLI    openstack port show ${acl_sr_net_1_ports[0]} |awk '/ id / {print$4}'
124     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
125     ${interface_id} =    Collections.Get from List    ${splitted_output}    0
126     ${output} =    Issue_Command_On_Karaf_Console    srm:recover instance acl-interface ${interface_id}
127     BuiltIn.Should Contain    ${output}    RPC call to recover was successful
128     OpenStackOperations.Ping Vm From DHCP Namespace    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[0]
129     Wait Until Keyword Succeeds
130     ...    30s
131     ...    5s
132     ...    OVSDB.Verify Dump Flows For Specific Table
133     ...    ${OS_CMP1_IP}
134     ...    ${EGRESS_ACL_TABLE}
135     ...    True
136     ...    ${EMPTY}
137     ...    ${port_mac}
138     Wait Until Keyword Succeeds
139     ...    30s
140     ...    5s
141     ...    Verify Flow Counts Are Same
142     ...    ${count_before}
143     ...    ${EGRESS_ACL_TABLE}
144     ...    port_mac=${port_mac}
145
146
147 *** Keywords ***
148 Verify Flow Counts Are Same
149     [Documentation]    Verify flows count should be same as before and after for a table id with a given port mac.
150     [Arguments]    ${count_before}    ${table_id}    ${port_mac}=""
151     ${count_after} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${table_id}    port_mac=${port_mac}
152     BuiltIn.Should Be Equal As Numbers    ${count_before}    ${count_after}
153
154 Suite Setup
155     [Documentation]    Create Basic setup for the feature. Creates single network, subnet, two ports and two VMs.
156     OpenStackOperations.OpenStack Suite Setup
157     SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    ${TEST_LOG_LEVEL}    ${TEST_LOG_COMPONENTS}
158     OpenStackOperations.Create Allow All SecurityGroup    ${acl_sr_security_group}
159     OpenStackOperations.Create Network    ${acl_sr_networks}[0]
160     OpenStackOperations.Create SubNet    ${acl_sr_networks}[0]    ${acl_sr_subnets}[0]    ${acl_sr_subnet_cidrs[0]}
161     OpenStackOperations.Create Port    ${acl_sr_networks}[0]    ${acl_sr_net_1_ports[0]}    sg=${acl_sr_security_group}
162     OpenStackOperations.Create Port    ${acl_sr_networks}[0]    ${acl_sr_net_1_ports[1]}    sg=${acl_sr_security_group}
163     BuiltIn.Wait Until Keyword Succeeds
164     ...    3s
165     ...    1s
166     ...    Utils.Check For Elements At URI
167     ...    ${PORT_URL}
168     ...    ${acl_sr_net_1_ports}
169     OpenStackOperations.Create Vm Instance With Port On Compute Node
170     ...    ${acl_sr_net_1_ports[0]}
171     ...    ${acl_sr_net_1_vms[0]}
172     ...    ${OS_CMP1_HOSTNAME}
173     ...    sg=${acl_sr_security_group}
174     OpenStackOperations.Create Vm Instance With Port On Compute Node
175     ...    ${acl_sr_net_1_ports[1]}
176     ...    ${acl_sr_net_1_vms[1]}
177     ...    ${OS_CMP2_HOSTNAME}
178     ...    sg=${acl_sr_security_group}
179     @{ACL_SR_NET_1_VM_IPS}    ${net1_dhcp_ip} =    OpenStackOperations.Get VM IPs    @{acl_sr_net_1_vms}
180     BuiltIn.Set Suite Variable    @{ACL_SR_NET_1_VM_IPS}
181     BuiltIn.Should Not Contain    ${ACL_SR_NET_1_VM_IPS}    None
182     BuiltIn.Should Not Contain    ${net1_dhcp_ip}    None
183     OpenStackOperations.Ping Vm From DHCP Namespace    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[0]
184     OpenStackOperations.Ping Vm From DHCP Namespace    ${acl_sr_networks}[0]    ${ACL_SR_NET_1_VM_IPS}[1]