1ffafa3c1c8592e54659a6d1d99dc2fdb87336b2
[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 Suite Setup       Suite Setup
8 Suite Teardown    Run Keywords    OpenStackOperations.OpenStack Suite Teardown
9 ...               AND    SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    INFO    ${TEST_LOG_COMPONENTS}
10 Test Setup        Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
11 ...               AND    OpenStackOperations.Get DumpFlows And Ovsconfig    ${OS_CMP1_CONN_ID}
12 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
13 Library           OperatingSystem
14 Library           RequestsLibrary
15 Library           String
16 Resource          ../../../libraries/DevstackUtils.robot
17 Resource          ../../../libraries/Genius.robot
18 Resource          ../../../libraries/KarafKeywords.robot
19 Resource          ../../../variables/netvirt/Variables.robot
20 Resource          ../../../libraries/OVSDB.robot
21 Resource          ../../../libraries/OvsManager.robot
22 Resource          ../../../libraries/OpenStackOperations.robot
23 Resource          ../../../libraries/SetupUtils.robot
24 Resource          ../../../libraries/Utils.robot
25 Resource          ../../../variables/netvirt/Variables.robot
26 Resource          ../../../variables/Variables.robot
27
28 *** Variables ***
29 ${acl_sr_security_group}    acl_sr_sg
30 @{acl_sr_networks}    acl_sr_net_1    acl_sr_net_2    acl_sr_net_3
31 @{acl_sr_subnets}    acl_sr_sub_1    acl_sr_sub_2    acl_sr_sub_3
32 @{acl_sr_subnet_cidrs}    81.1.1.0/24    82.1.1.0/24    83.1.1.0/24
33 @{acl_sr_net_1_ports}    acl_sr_net_1_port_1    acl_sr_net_1_port_2
34 @{acl_sr_net_1_vms}    acl_sr_net_1_vm_1    acl_sr_net_1_vm_2
35 ${TEST_LOG_LEVEL}    trace
36 @{TEST_LOG_COMPONENTS}    org.opendaylight.netvirt.aclservice    org.opendaylight.genius.interfacemanager    org.opendaylight.genius.srm
37
38 *** Test Cases ***
39 ACL Service Recovery CLI
40     [Documentation]    This test case covers ACL service recovery.
41     ${count_before} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${INGRESS_ACL_REMOTE_ACL_TABLE}
42     ${node_id} =    OVSDB.Get DPID    ${OS_CMP1_IP}
43     ${resp} =    RequestsLibrary.Delete Request    session    ${CONFIG_NODES_API}/node/openflow:${node_id}/flow-node-inventory:table/${INGRESS_ACL_REMOTE_ACL_TABLE}
44     Should Be Equal As Strings    ${resp.status_code}    200
45     Wait Until Keyword Succeeds    30s    5s    Verify ACL Flows Should Not Contain    ${OS_CMP1_CONN_ID}    ${INGRESS_ACL_REMOTE_ACL_TABLE}
46     ${output} =    Issue_Command_On_Karaf_Console    srm:recover service acl
47     Should Contain    ${output}    RPC call to recover was successful
48     Wait Until Keyword Succeeds    30s    5s    Verify Flow Counts Are Same    ${count_before}    ${INGRESS_ACL_REMOTE_ACL_TABLE}
49
50 ACL Instance Recovery CLI
51     [Documentation]    This test case covers ACL instance recovery.
52     ${count_before} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${EGRESS_LEARN_ACL_FILTER_TABLE}
53     ${node_id} =    OVSDB.Get DPID    ${OS_CMP1_IP}
54     Write Commands Until Expected Prompt    sudo ovs-ofctl del-flows br-int -OOpenflow13 "table=${EGRESS_LEARN_ACL_FILTER_TABLE},icmp"    ${DEFAULT_LINUX_PROMPT_STRICT}
55     Wait Until Keyword Succeeds    30s    5s    Verify ACL Flows Should Not Contain    ${OS_CMP1_CONN_ID}    ${EGRESS_LEARN_ACL_FILTER_TABLE}    icmp
56     ${output} =    OpenStack CLI    openstack security group show ${acl_sr_security_group} | awk '/ id / {print $4}'
57     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
58     ${instance_id} =    Collections.Get from List    ${splitted_output}    0
59     ${output} =    Issue_Command_On_Karaf_Console    srm:recover instance acl-instance ${instance_id}
60     Should Contain    ${output}    RPC call to recover was successful
61     Wait Until Keyword Succeeds    30s    5s    Verify ACL Flows Should Contain    ${OS_CMP1_CONN_ID}    ${EGRESS_LEARN_ACL_FILTER_TABLE}    icmp
62     Wait Until Keyword Succeeds    30s    5s    Verify Flow Counts Are Same    ${count_before}    ${EGRESS_LEARN_ACL_FILTER_TABLE}
63
64 ACL Interface Recovery CLI
65     [Documentation]    This test case covers ACL interface recovery.
66     ${output} =    OpenStack CLI    openstack port show ${acl_sr_net_1_ports[0]} |awk '/ mac_address / {print$4}'
67     @{list} =    Split String    ${output}
68     ${port_mac}    Set Variable    ${list[0]}
69     ${count_before} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${EGRESS_ACL_TABLE}    port_mac=${port_mac}
70     ${node_id}    OVSDB.Get DPID    ${OS_CMP1_IP}
71     Write Commands Until Expected Prompt    sudo ovs-ofctl del-flows br-int -OOpenflow13 "table=${EGRESS_ACL_TABLE},dl_dst=${port_mac}"    ${DEFAULT_LINUX_PROMPT_STRICT}
72     Wait Until Keyword Succeeds    30s    5s    Verify ACL Flows Should Not Contain    ${OS_CMP1_CONN_ID}    ${EGRESS_ACL_TABLE}    ${port_mac}
73     ${output} =    OpenStack CLI    openstack port show ${acl_sr_net_1_ports[0]} |awk '/ id / {print$4}'
74     ${splitted_output} =    String.Split String    ${output}    ${EMPTY}
75     ${interface_id} =    Collections.Get from List    ${splitted_output}    0
76     ${output} =    Issue_Command_On_Karaf_Console    srm:recover instance acl-interface ${interface_id}
77     Should Contain    ${output}    RPC call to recover was successful
78     Wait Until Keyword Succeeds    30s    5s    Verify ACL Flows Should Contain    ${OS_CMP1_CONN_ID}    ${EGRESS_ACL_TABLE}    ${port_mac}
79     Wait Until Keyword Succeeds    30s    5s    Verify Flow Counts Are Same    ${count_before}    ${EGRESS_ACL_TABLE}    port_mac=${port_mac}
80
81 *** Keywords ***
82 Verify Flow Counts Are Same
83     [Arguments]    ${count_before}    ${table_id}    ${port_mac}=""
84     [Documentation]    Verify flows count should be same as before and after for a table id with a given port mac.
85     ${count_after} =    OvsManager.Get Dump Flows Count    ${OS_CMP1_CONN_ID}    ${table_id}    port_mac=${port_mac}
86     Should Be Equal As Numbers    ${count_before}    ${count_after}
87
88 Verify ACL Flows Should Not Contain
89     [Arguments]    ${conn_id}    ${table_id}    ${acl_var}=${None}
90     [Documentation]    Verify dump flows should not be having the table id.
91     SSHLibrary.Switch Connection    ${conn_id}
92     ${output} =    Write Commands Until Expected Prompt    sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id}    ${DEFAULT_LINUX_PROMPT_STRICT}
93     BuiltIn.Run Keyword If    '${acl_var}'=='None'    Should Not Contain    ${output}    table=${table_id}
94     ...    ELSE    Should Not Contain    ${output}    ${acl_var}
95
96 Verify ACL Flows Should Contain
97     [Arguments]    ${conn_id}    ${table_id}    ${acl_var}=${None}
98     [Documentation]    Verify dump flows should be having the table id.
99     SSHLibrary.Switch Connection    ${conn_id}
100     ${output} =    Write Commands Until Expected Prompt    sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id}    ${DEFAULT_LINUX_PROMPT_STRICT}
101     BuiltIn.Run Keyword If    '${acl_var}'=='None'    Should Contain    ${output}    table=${table_id}
102     ...    ELSE    Should Contain    ${output}    ${acl_var}
103
104 Suite Setup
105     [Documentation]    Create Basic setup for the feature. Creates single network, subnet, two ports and two VMs.
106     OpenStackOperations.OpenStack Suite Setup
107     SetupUtils.Setup_Logging_For_Debug_Purposes_On_List_Or_All    ${TEST_LOG_LEVEL}    ${TEST_LOG_COMPONENTS}
108     OpenStackOperations.Create Allow All SecurityGroup    ${acl_sr_security_group}
109     OpenStackOperations.Create Network    @{acl_sr_networks}[0]
110     OpenStackOperations.Create SubNet    @{acl_sr_networks}[0]    @{acl_sr_subnets}[0]    ${acl_sr_subnet_cidrs[0]}
111     OpenStackOperations.Create Port    @{acl_sr_networks}[0]    ${acl_sr_net_1_ports[0]}    sg=${acl_sr_security_group}
112     OpenStackOperations.Create Port    @{acl_sr_networks}[0]    ${acl_sr_net_1_ports[1]}    sg=${acl_sr_security_group}
113     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${PORT_URL}    ${acl_sr_net_1_ports}
114     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${acl_sr_net_1_ports[0]}    ${acl_sr_net_1_vms[0]}    ${OS_CMP1_HOSTNAME}    sg=${acl_sr_security_group}
115     OpenStackOperations.Create Vm Instance With Port On Compute Node    ${acl_sr_net_1_ports[1]}    ${acl_sr_net_1_vms[1]}    ${OS_CMP2_HOSTNAME}    sg=${acl_sr_security_group}