Move bgp global api to BgpOperations library
[integration/test.git] / csit / libraries / ClusterOvsdb.robot
1 *** Settings ***
2 Documentation     Cluster Ovsdb library. So far this library is only to be used by Ovsdb cluster test as it is very specific for this test.
3 Library           RequestsLibrary
4 Resource          ClusterManagement.robot
5 Resource          MininetKeywords.robot
6 Resource          Utils.robot
7 Resource          OVSDB.robot
8 Variables         ../variables/Variables.py
9
10 *** Variables ***
11 @{SHARD_OPER_LIST}    topology    default    entity-ownership
12 @{SHARD_CONF_LIST}    topology    default
13 ${BRIDGE}         br01
14 ${OVSDB_CONFIG_DIR}    ${CURDIR}/../variables/ovsdb
15
16 *** Keywords ***
17 Check Ovsdb Shards Status
18     [Arguments]    ${controller_index_list}=${EMPTY}
19     [Documentation]    Check Status for all shards in Ovsdb application.
20     ClusterManagement.Verify_Leader_Exists_For_Each_Shard    shard_name_list=${SHARD_OPER_LIST}    shard_type=operational    member_index_list=${controller_index_list}
21     ClusterManagement.Verify_Leader_Exists_For_Each_Shard    shard_name_list=${SHARD_CONF_LIST}    shard_type=config    member_index_list=${controller_index_list}
22
23 Check Ovsdb Shards Status After Cluster Event
24     [Arguments]    ${controller_index_list}=${EMPTY}
25     [Documentation]    Check Shard Status after some cluster event.
26     Wait Until Keyword Succeeds    90s    1s    Check Ovsdb Shards Status    ${controller_index_list}
27
28 Get Ovsdb Entity Owner Status For One Device
29     [Arguments]    ${device}    ${controller_index}    ${controller_index_list}=${EMPTY}
30     [Documentation]    Check Entity Owner Status and identify owner and successors for an ovs device ${device}. Request is sent to controller ${controller_index}.
31     ${owner}    ${successor_list}    Wait Until Keyword Succeeds    20s    1s    ClusterManagement.Verify_Owner_And_Successors_For_Device    device_name=${device}
32     ...    device_type=ovsdb    member_index=${controller_index}    candidate_list=${controller_index_list}
33     [Return]    ${owner}    ${successor_list}
34
35 Create Sample Bridge Manually And Verify
36     [Arguments]    ${ovs_system_ip}=${TOOLS_SYSTEM_IP}    ${controller_index_list}=${EMPTY}
37     [Documentation]    Create bridge br-s1 using OVS command and verify it gets created in all instances in ${controller_index_list}.
38     Utils.Run Command On Mininet    ${ovs_system_ip}    sudo ovs-vsctl add-br br-s1
39     ${dictionary_operational}=    Create Dictionary    br-s1=5
40     ${dictionary_config}=    Create Dictionary    br-s1=0
41     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${CONFIG_TOPO_API}    dictionary=${dictionary_config}    member_index_list=${controller_index_list}
42     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}    dictionary=${dictionary_operational}    member_index_list=${controller_index_list}
43
44 Add Sample Port To The Manual Bridge And Verify
45     [Arguments]    ${ovs_system_ip}=${TOOLS_SYSTEM_IP}    ${controller_index_list}=${EMPTY}
46     [Documentation]    Add Port vx1 to br-s1 using OVS command and verify it gets added in all instances in ${controller_index_list}.
47     Utils.Run Command On Mininet    ${ovs_system_ip}    sudo ovs-vsctl add-port br-s1 vx1 -- set Interface vx1 type=vxlan
48     ${dictionary_operational}=    Create Dictionary    vx1=2
49     ${dictionary_config}=    Create Dictionary    vx1=0
50     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${CONFIG_TOPO_API}    dictionary=${dictionary_config}    member_index_list=${controller_index_list}
51     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}    dictionary=${dictionary_operational}    member_index_list=${controller_index_list}
52
53 Create Sample Tap Device
54     [Arguments]    ${ovs_system_ip}=${TOOLS_SYSTEM_IP}
55     [Documentation]    Create Tap Device vport1 and vport2 to add to the bridge br-s1 using OVS command.
56     Utils.Run Command On Mininet    ${ovs_system_ip}    ip tuntap add mode tap vport1
57     Utils.Run Command On Mininet    ${ovs_system_ip}    ip tuntap add mode tap vport2
58     Utils.Run Command On Mininet    ${ovs_system_ip}    ifconfig vport1 up
59     Utils.Run Command On Mininet    ${ovs_system_ip}    ifconfig vport2 up
60
61 Add Sample Tap Device To The Manual Bridge And Verify
62     [Arguments]    ${ovs_system_ip}=${TOOLS_SYSTEM_IP}    ${controller_index_list}=${EMPTY}
63     [Documentation]    Add Tap Device vport1 and vport2 to br-s1 using OVS command and verify it gets added in all instances in ${controller_index_list}.
64     Utils.Run Command On Mininet    ${ovs_system_ip}    sudo ovs-vsctl add-port br-s1 vport1 -- add-port br-s1 vport2
65     ${dictionary_operational}=    Create Dictionary    vport1=2    vport2=2
66     ${dictionary_config}=    Create Dictionary    vport1=0    vport2=0
67     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${CONFIG_TOPO_API}    dictionary=${dictionary_config}    member_index_list=${controller_index_list}
68     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}    dictionary=${dictionary_operational}    member_index_list=${controller_index_list}
69
70 Delete Sample Bridge Manually And Verify
71     [Arguments]    ${ovs_system_ip}=${TOOLS_SYSTEM_IP}    ${controller_index_list}=${EMPTY}
72     [Documentation]    Delete bridge br-s1 using OVS command and verify it gets applied in all instances in ${controller_index_list}.
73     Utils.Run Command On Mininet    ${ovs_system_ip}    sudo ovs-vsctl del-br br-s1
74     ${dictionary}=    Create Dictionary    br-s1=0
75     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}    dictionary=${dictionary}    member_index_list=${controller_index_list}
76
77 Create Sample Bridge And Verify
78     [Arguments]    ${controller_index}    ${controller_index_list}=${EMPTY}
79     [Documentation]    Create bridge ${BRIDGE} in controller ${controller_index} and verify it gets created in all instances in ${controller_index_list}.
80     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/ovsdb/create_bridge_3node.json
81     ${body}    Replace String    ${body}    ovsdb://127.0.0.1:61644    ovsdb://uuid/${ovsdb_uuid}
82     ${body}    Replace String    ${body}    tcp:controller1:6633    tcp:${ODL_SYSTEM_1_IP}:6633
83     ${body}    Replace String    ${body}    tcp:controller2:6633    tcp:${ODL_SYSTEM_2_IP}:6633
84     ${body}    Replace String    ${body}    tcp:controller3:6633    tcp:${ODL_SYSTEM_3_IP}:6633
85     ${body}    Replace String    ${body}    127.0.0.1    ${TOOLS_SYSTEM_IP}
86     ${body}    Replace String    ${body}    br01    ${BRIDGE}
87     ${body}    Replace String    ${body}    61644    ${OVSDB_PORT}
88     Log    ${body}
89     ${TOOLS_SYSTEM_IP1}    Replace String    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_IP}    "${TOOLS_SYSTEM_IP}"
90     ${dictionary}=    Create Dictionary    ${TOOLS_SYSTEM_IP1}=1    ${OVSDBPORT}=4    ${BRIDGE}=1
91     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}    ${body}    ${controller_index}
92     ...    ${controller_index_list}
93     Wait Until Keyword Succeeds    10s    2s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}    dictionary=${dictionary}    member_index_list=${controller_index_list}
94
95 Create Sample Port And Verify
96     [Arguments]    ${controller_index}    ${controller_index_list}=${EMPTY}
97     [Documentation]    Add Port vx2 to bridge ${BRIDGE} in controller ${controller_index} and verify it gets added in all instances in ${controller_index_list}.
98     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_port_3node.json
99     ${body}    Replace String    ${sample}    192.168.1.10    ${TOOLS_SYSTEM_IP}
100     Log    ${body}
101     Log    URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
102     ${port_dictionary}=    Create Dictionary    ${BRIDGE}=1    vx2=3
103     ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/    ${body}    ${controller_index}    ${controller_index_list}
104     Wait Until Keyword Succeeds    10s    2s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/    dictionary=${port_dictionary}    member_index_list=${controller_index_list}
105
106 Modify the destination IP of Sample Port
107     [Arguments]    ${controller_index}    ${controller_index_list}=${EMPTY}
108     [Documentation]    Modify the dst ip of port vx2 in bridge ${BRIDGE} in controller ${controller_index}.
109     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_port_3node.json
110     ${body}    Replace String    ${sample}    192.168.1.10    10.0.0.19
111     Log    URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
112     Log    ${body}
113     ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/    ${body}    ${controller_index}    ${controller_index_list}
114
115 Verify Sample Port Is Modified
116     [Arguments]    ${controller_index_list}=${EMPTY}
117     [Documentation]    Verify dst ip of port vx2 in bridge ${BRIDGE} gets modified in all instances in ${controller_index_list}.
118     ${port_dictionary}    Create Dictionary    br01=6    vx2=3    10.0.0.19=1
119     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}    dictionary=${port_dictionary}    member_index_list=${controller_index_list}
120
121 Delete Sample Port And Verify
122     [Arguments]    ${controller_index}    ${controller_index_list}=${EMPTY}
123     [Documentation]    Delete port vx2 from bridge ${BRIDGE} in controller ${controller_index} and verify it gets deleted in all instances in ${controller_index_list}.
124     ${dictionary}=    Create Dictionary    vx2=0
125     ClusterManagement.Delete_And_Check_Member_List_Or_All    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/    ${controller_index}    ${controller_index_list}
126     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}    dictionary=${dictionary}    member_index_list=${controller_index_list}
127
128 Delete Sample Bridge And Verify
129     [Arguments]    ${controller_index}    ${controller_index_list}=${EMPTY}
130     [Documentation]    Delete bridge ${BRIDGE} in ${controller_index} and verify it gets deleted in all instances in ${controller_index_list}.
131     ${dictionary}=    Create Dictionary    ${BRIDGE}=0
132     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Delete_And_Check_Member_List_Or_All    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}    ${controller_index}    ${controller_index_list}
133     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}    dictionary=${dictionary}    member_index_list=${controller_index_list}
134
135 Configure Exit OVSDB Connection
136     [Arguments]    ${controller_index_list}=${EMPTY}
137     [Documentation]    Cleans up test environment, close existing sessions.
138     OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
139     ${dictionary}=    Create Dictionary    ovsdb://uuid=0
140     Wait Until Keyword Succeeds    5s    1s    ClusterManagement.Check_Item_Occurrence_Member_List_Or_All    uri=${OPERATIONAL_TOPO_API}    dictionary=${dictionary}    member_index_list=${controller_index_list}