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