Stabilize ovsdb-csit-3node-clustering-only-<stream> job
[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          ClusterKeywords.robot
5 Resource          MininetKeywords.robot
6 Resource          Utils.robot
7 Resource          OVSDB.robot
8 Variables         ../variables/Variables.py
9
10 *** Variables ***
11 ${BRIDGE}         br01
12 ${OVSDB_CONFIG_DIR}    ${CURDIR}/../variables/ovsdb
13
14 *** Keywords ***
15 Check Ovsdb Shards Status
16     [Arguments]    ${controller_index_list}
17     [Documentation]    Check Status for all shards in Ovsdb application.
18     ${topo_conf_leader}    ${topo_conf_followers_list}    ClusterKeywords.Get Cluster Shard Status    ${controller_index_list}    config    topology
19     ${topo_oper_leader}    ${topo_oper_followers_list}    ClusterKeywords.Get Cluster Shard Status    ${controller_index_list}    operational    topology
20     ${owner_oper_leader}    ${owner_oper_followers_list}    ClusterKeywords.Get Cluster Shard Status    ${controller_index_list}    operational    entity-ownership
21     Log    config topology Leader is ${topo_conf_leader} and followers are ${topo_conf_followers_list}
22     Log    operational topology Leader is ${topo_oper_leader} and followers are ${topo_oper_followers_list}
23     Log    operational entity-ownership Leader is ${owner_oper_leader} and followers are ${owner_oper_followers_list}
24
25 Check Ovsdb Shards Status After Cluster Event
26     [Arguments]    ${controller_index_list}
27     [Documentation]    Check Shard Status after some cluster event.
28     Wait Until Keyword Succeeds    90s    1s    Check Ovsdb Shards Status    ${controller_index_list}
29
30 Get Ovsdb Entity Owner Status For One Device
31     [Arguments]    ${controller_index_list}    ${device}
32     [Documentation]    Check Entity Owner Status and identify owner and candidate for an ovs device ${device}.
33     ${owner}    ${candidates_list}    Wait Until Keyword Succeeds    20s    1s    ClusterKeywords.Get Cluster Entity Owner    ${controller_index_list}
34     ...    ovsdb    ${device}
35     [Return]    ${owner}    ${candidates_list}
36
37 Create Sample Bridge Manually And Verify
38     [Arguments]    ${controller_index_list}
39     [Documentation]    Create bridge br-s1 using OVS command and verify it gets created in all instances in ${controller_index_list}.
40     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-br br-s1
41     ${dictionary_operational}=    Create Dictionary    br-s1=5
42     ${dictionary_config}=    Create Dictionary    br-s1=0
43     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary_config}    ${CONFIG_TOPO_API}
44     Wait Until Keyword Succeeds    10s    2s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary_operational}    ${OPERATIONAL_TOPO_API}
45
46 Add Sample Port To The Manual Bridge And Verify
47     [Arguments]    ${controller_index_list}
48     [Documentation]    Add Port vx1 to br-s1 using OVS command and verify it gets added in all instances in ${controller_index_list}.
49     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl add-port br-s1 vx1 -- set Interface vx1 type=vxlan
50     ${dictionary_operational}=    Create Dictionary    vx1=2
51     ${dictionary_config}=    Create Dictionary    vx1=0
52     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary_config}    ${CONFIG_TOPO_API}
53     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary_operational}    ${OPERATIONAL_TOPO_API}
54
55 Delete Sample Bridge Manually And Verify
56     [Arguments]    ${controller_index_list}
57     [Documentation]    Delete bridge br-s1 using OVS command and verify it gets applied in all instances in ${controller_index_list}.
58     Utils.Run Command On Mininet    ${TOOLS_SYSTEM_IP}    sudo ovs-vsctl del-br br-s1
59     ${dictionary}=    Create Dictionary    br-s1=0
60     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary}    ${OPERATIONAL_TOPO_API}
61
62 Create Sample Bridge And Verify
63     [Arguments]    ${controller_index_list}    ${controller_index}
64     [Documentation]    Create bridge ${BRIDGE} in controller ${controller_index} and verify it gets created in all instances in ${controller_index_list}.
65     ${body}=    OperatingSystem.Get File    ${CURDIR}/../variables/ovsdb/create_bridge_3node.json
66     ${body}    Replace String    ${body}    ovsdb://127.0.0.1:61644    ovsdb://uuid/${ovsdb_uuid}
67     ${body}    Replace String    ${body}    tcp:controller1:6633    tcp:${ODL_SYSTEM_1_IP}:6633
68     ${body}    Replace String    ${body}    tcp:controller2:6633    tcp:${ODL_SYSTEM_2_IP}:6633
69     ${body}    Replace String    ${body}    tcp:controller3:6633    tcp:${ODL_SYSTEM_3_IP}:6633
70     ${body}    Replace String    ${body}    127.0.0.1    ${TOOLS_SYSTEM_IP}
71     ${body}    Replace String    ${body}    br01    ${BRIDGE}
72     ${body}    Replace String    ${body}    61644    ${OVSDB_PORT}
73     Log    ${body}
74     ${TOOLS_SYSTEM_IP1}    Replace String    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_IP}    "${TOOLS_SYSTEM_IP}"
75     ${dictionary}=    Create Dictionary    ${TOOLS_SYSTEM_IP1}=1    ${OVSDBPORT}=4    ${BRIDGE}=1
76     Wait Until Keyword Succeeds    20s    1s    ClusterKeywords.Put And Check At URI In Cluster    ${controller_index_list}    ${controller_index}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
77     ...    ${body}
78     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary}    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
79
80 Create Sample Port And Verify
81     [Arguments]    ${controller_index_list}    ${controller_index}
82     [Documentation]    Add Port vx2 to bridge ${BRIDGE} in controller ${controller_index} and verify it gets added in all instances in ${controller_index_list}.
83     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_port_3node.json
84     ${body}    Replace String    ${sample}    192.168.1.10    ${TOOLS_SYSTEM_IP}
85     Log    ${body}
86     Log    URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
87     ${port_dictionary}=    Create Dictionary    ${BRIDGE}=6    vx2=3
88     ClusterKeywords.Put And Check At URI In Cluster    ${controller_index_list}    ${controller_index}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/    ${body}
89     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${port_dictionary}    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
90
91 Modify the destination IP of Sample Port
92     [Arguments]    ${controller_index_list}    ${controller_index}
93     [Documentation]    Modify the dst ip of port vx2 in bridge ${BRIDGE} in controller ${controller_index}.
94     ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_port_3node.json
95     ${body}    Replace String    ${sample}    192.168.1.10    10.0.0.19
96     Log    URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
97     Log    ${body}
98     ClusterKeywords.Put And Check At URI In Cluster    ${controller_index_list}    ${controller_index}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/    ${body}
99
100 Verify Sample Port Is Modified
101     [Arguments]    ${controller_index_list}
102     [Documentation]    Verify dst ip of port vx2 in bridge ${BRIDGE} gets modified in all instances in ${controller_index_list}.
103     ${port_dictionary}    Create Dictionary    br01=6    vx2=3    10.0.0.19=1
104     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${port_dictionary}    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
105
106 Delete Sample Port And Verify
107     [Arguments]    ${controller_index_list}    ${controller_index}
108     [Documentation]    Delete port vx2 from bridge ${BRIDGE} in controller ${controller_index} and verify it gets deleted in all instances in ${controller_index_list}.
109     ${dictionary}=    Create Dictionary    vx2=0
110     ClusterKeywords.Delete And Check At URI In Cluster    ${controller_index_list}    ${controller_index}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
111     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary}    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
112
113 Delete Sample Bridge And Verify
114     [Arguments]    ${controller_index_list}    ${controller_index}
115     [Documentation]    Delete bridge ${BRIDGE} in ${controller_index} and verify it gets deleted in all instances in ${controller_index_list}.
116     ${dictionary}=    Create Dictionary    ${BRIDGE}=0
117     Wait Until Keyword Succeeds    20s    1s    ClusterKeywords.Delete And Check At URI In Cluster    ${controller_index_list}    ${controller_index}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
118     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary}    ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
119
120 Configure Exit OVSDB Connection
121     [Arguments]    ${controller_index_list}
122     [Documentation]    Cleans up test environment, close existing sessions.
123     OVSDB.Clean OVSDB Test Environment    ${TOOLS_SYSTEM_IP}
124     ${dictionary}=    Create Dictionary    ovsdb://uuid=0
125     Wait Until Keyword Succeeds    5s    1s    ClusterKeywords.Check Item Occurrence At URI In Cluster    ${controller_index_list}    ${dictionary}    ${OPERATIONAL_TOPO_API}