2 Documentation Cluster OpenFlow library. So far this library is only to be used by OpenFlow cluster test as it is very specific for this test.
3 Library RequestsLibrary
4 Library ${CURDIR}/ScaleClient.py
5 Resource ClusterManagement.robot
6 Resource MininetKeywords.robot
8 Variables ../variables/Variables.py
11 @{SHARD_OPER_LIST} inventory topology default entity-ownership
12 @{SHARD_CONF_LIST} inventory topology default
13 ${config_table_0} ${CONFIG_NODES_API}/node/openflow:1/table/0
14 ${operational_table_0} ${OPERATIONAL_NODES_API}/node/openflow:1/table/0
15 ${operational_port_1} ${OPERATIONAL_NODES_API}/node/openflow:1/node-connector/openflow:1:1
18 Get InventoryConfig Shard Status
19 [Arguments] ${controller_index_list}=${EMPTY}
20 [Documentation] Check Status for Inventory Config shard in OpenFlow application.
21 ${inv_conf_leader} ${inv_conf_followers_list} Wait Until Keyword Succeeds 10s 1s ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=inventory
22 ... shard_type=config member_index_list=${controller_index_list}
23 Log config inventory Leader is ${inv_conf_leader} and followers are ${inv_conf_followers_list}
24 [Return] ${inv_conf_leader} ${inv_conf_followers_list}
26 Check OpenFlow Shards Status
27 [Arguments] ${controller_index_list}=${EMPTY}
28 [Documentation] Check Status for all shards in OpenFlow application.
29 ClusterManagement.Verify_Leader_Exists_For_Each_Shard shard_name_list=${SHARD_OPER_LIST} shard_type=operational member_index_list=${controller_index_list}
30 ClusterManagement.Verify_Leader_Exists_For_Each_Shard shard_name_list=${SHARD_CONF_LIST} shard_type=config member_index_list=${controller_index_list}
32 Check OpenFlow Shards Status After Cluster Event
33 [Arguments] ${controller_index_list}=${EMPTY}
34 [Documentation] Check Shards Status after some cluster event.
35 Wait Until Keyword Succeeds 90s 1s ClusterOpenFlow.Check OpenFlow Shards Status ${controller_index_list}
37 Get OpenFlow Entity Owner Status For One Device
38 [Arguments] ${device} ${controller_index} ${controller_index_list}=${EMPTY}
39 [Documentation] Check Entity Owner Status and identify owner and successors for the device ${device}. Request is sent to controller ${controller_index}.
40 ${owner} ${successor_list} Wait Until Keyword Succeeds 10s 1s ClusterManagement.Verify_Owner_And_Successors_For_Device device_name=${device}
41 ... device_type=openflow member_index=${controller_index} candidate_list=${controller_index_list}
42 [Return] ${owner} ${successor_list}
44 Check OpenFlow Network Operational Information For Sample Topology
45 [Arguments] ${controller_index_list}=${EMPTY}
46 [Documentation] Check devices in tree,2 are in operational inventory and topology in all instances in ${controller_index_list}.
47 ... Inventory should show 1x node_id per device 1x node_id per connector. Topology should show 2x node_id per device + 3x node_id per connector
48 ... + 5x node_id per link termination. TODO: A Keyword that can calculate this based on mininet topology.
49 ${dictionary} Create Dictionary openflow:1=4 openflow:2=5 openflow:3=5
50 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_NODES_API} dictionary=${dictionary} member_index_list=${controller_index_list}
51 ${dictionary} Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
52 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}
54 Check No OpenFlow Network Operational Information
55 [Arguments] ${controller_index_list}=${EMPTY}
56 [Documentation] Check device is not in operational inventory or topology in all cluster instances in ${controller_index_list}.
57 ${dictionary} Create Dictionary openflow=0
58 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_NODES_API} dictionary=${dictionary} member_index_list=${controller_index_list}
59 ${dictionary} Create Dictionary openflow=0
60 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}
62 Add Sample Flow And Verify
63 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
64 [Documentation] Add sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
65 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_1.json
66 # There are slight differences on the way He and Li plugin display table information. He plugin has an additional Hashmap field
67 # replicating some of the matches in the flows section. Same comment applies for further keywords.
68 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"1"=1
69 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"1"=1
70 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${body} ${controller_index} ${controller_index_list}
71 Wait Until Keyword Succeeds 15s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
73 Modify Sample Flow And Verify
74 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
75 [Documentation] Modify sample flow in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
76 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/sample_flow_2.json
77 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2 "output-node-connector":"2"=1
78 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1 "output-node-connector":"2"=1
79 ClusterManagement.Put_As_Json_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${body} ${controller_index} ${controller_index_list}
80 Wait Until Keyword Succeeds 15s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
82 Delete Sample Flow And Verify
83 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
84 [Documentation] Delete sample flow in Owner and verify it gets removed from all instances.
85 ${dictionary}= Create Dictionary 10.0.2.0/24=0
86 ClusterManagement.Delete_And_Check_Member_List_Or_All ${config_table_0}/flow/1 ${controller_index} ${controller_index_list}
87 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
89 Send RPC Add Sample Flow And Verify
90 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
91 [Documentation] Add sample flow in ${controller_index} and verify it gets applied from all instances in ${controller_index_list}.
92 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/add_flow_rpc.json
93 Run Keyword If '${ODL_OF_PLUGIN}' == 'helium' Set Test Variable &{dictionary} 10.0.1.0/24=2
94 Run Keyword If '${ODL_OF_PLUGIN}' == 'lithium' Set Test Variable &{dictionary} 10.0.1.0/24=1
95 ClusterManagement.Post_As_Json_To_Member uri=/restconf/operations/sal-flow:add-flow data=${body} member_index=${controller_index}
96 Wait Until Keyword Succeeds 15s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
98 Send RPC Delete Sample Flow And Verify
99 [Arguments] ${controller_index} ${controller_index_list}=${EMPTY}
100 [Documentation] Delete sample flow in ${controller_index} and verify it gets removed from all instances in ${controller_index_list}.
101 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/openflowplugin/delete_flow_rpc.json
102 ${dictionary}= Create Dictionary 10.0.1.0/24=0
103 ClusterManagement.Post_As_Json_To_Member uri=/restconf/operations/sal-flow:remove-flow data=${body} member_index=${controller_index}
104 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_table_0} dictionary=${dictionary} member_index_list=${controller_index_list}
106 Take OpenFlow Device Link Down and Verify
107 [Arguments] ${controller_index_list}=${EMPTY}
108 [Documentation] Take a link down and verify port status in all instances in ${controller_index_list}.
109 ${dictionary}= Create Dictionary "link-down":true=1
110 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 down
111 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_port_1} dictionary=${dictionary} member_index_list=${controller_index_list}
112 ${dictionary} Create Dictionary openflow:1=16 openflow:2=14 openflow:3=19
113 Wait Until Keyword Succeeds 20s 2s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${OPERATIONAL_TOPO_API} dictionary=${dictionary} member_index_list=${controller_index_list}
115 Take OpenFlow Device Link Up and Verify
116 [Arguments] ${controller_index_list}=${EMPTY}
117 [Documentation] Take the link up and verify port status in all instances in ${controller_index_list}.
118 ${dictionary}= Create Dictionary "link-down":true=0
119 ${ouput}= MininetKeywords.Send Mininet Command ${mininet_conn_id} link s1 s2 up
120 Wait Until Keyword Succeeds 5s 1s ClusterManagement.Check_Item_Occurrence_Member_List_Or_All uri=${operational_port_1} dictionary=${dictionary} member_index_list=${controller_index_list}
121 ${dictionary} Create Dictionary openflow:1=21 openflow:2=19 openflow:3=19
122 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}
124 Verify_Switch_Connections_Running_On_Member
125 [Arguments] ${switch_count} ${member_index}
126 [Documentation] Check if number of Switch connections on member of given index is equal to ${switch_count}.
127 ${count} = ScaleClient.Get_Switches_Count controller=${ODL_SYSTEM_${member_index}_IP}
128 BuiltIn.Should_Be_Equal_As_Numbers ${switch_count} ${count}
130 Check_Flows_Operational_Datastore_On_Member
131 [Arguments] ${flow_count} ${member_index}
132 [Documentation] Check if number of Operational Flows on member of given index is equal to ${flow_count}.
133 ${sw} ${repf} ${found_flow}= ScaleClient.Flow Stats Collected controller=${ODL_SYSTEM_${member_index}_IP}
134 BuiltIn.Should_Be_Equal_As_Numbers ${flow_count} ${found_flow}