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