2 Documentation Test suite for Group Based Policy, sxp-ep-provider component.
4 Library OperatingSystem WITH NAME os
5 Library RequestsLibrary
7 Library ../../../libraries/GbpSxp.py WITH NAME gbpsxp
8 Resource ../../../variables/Variables.robot
9 Resource ../../../libraries/Utils.robot
10 Resource ../../../libraries/TemplatedRequests.robot
11 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
12 Resource ../../../libraries/GbpSxp.robot
14 Suite Setup Suite_Startup
15 Suite Teardown Suite_Cleanup
16 Test Setup GbpSxp.Prepare_Ssh_Tooling
17 Test Teardown Wipe_Clean_Ep_Templates_And_Sxp_Node
21 ${EP_PROVIDER_TEMPLATES_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-ep-provider-templates
22 ${SXP_NODE_CONFIG_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-node.json
23 ${SXP_NODE_ADD_ENTRY_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-node-add-entry.json
24 ${GBP_RPC_UNREGISTER_ENDPOINT_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-rpc-unregister-endpoint.json
25 ${GBP_EXPECTED_ENDPOINTS_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-endpoint
26 ${ISE_MOCK_SERVER_API_FOLDER} mock-server-tc010
27 ${CONFIGURE_ISE_SOURCE_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-ise-source.json
28 ${SXP_NODE_NAME} 1.1.1.1
32 Register_EP_Using_Manual_Inputs
33 [Documentation] Elicit endpoint registration by providing ep-policy-template, ep-forwarding-template and ip-sgt binding
34 Utils.Add_Elements_To_URI_From_File ${SXP_EP_PROVIDER_CONFIG_URI} ${EP_PROVIDER_TEMPLATES_FILE}-2.1.json
35 Create_sxp_node session ${SXP_NODE_CONFIG_FILE} 1.1.1.1
36 Utils.Post_Elements_To_URI_From_File ${SXP_NODE_RPC_ADD_ENTRY_URI} ${SXP_NODE_ADD_ENTRY_FILE}
37 ${expected_endpoints} os.Get_File ${GBP_EXPECTED_ENDPOINTS_FILE}-2.1.json
38 Wait_For_Endpoint_And_Check session ${expected_endpoints}
40 Register_EP_Using_Manual_Inputs_And_Ise
41 [Documentation] Elicit endpoint registration by providing ep-forwarding-template and ip-sgt binding (ep-policy-template will loaded from ise-API)
42 Utils.Add_Elements_To_URI_From_File ${SXP_EP_PROVIDER_CONFIG_URI} ${EP_PROVIDER_TEMPLATES_FILE}-2.2.json
43 gbpsxp.Deploy_Ise_Mock_Server ${ISE_MOCK_SERVER_API_FOLDER} ${ISE_REST_PORT}
44 ${ise_harvest_status_json} gbpsxp.Configure_Ise_Source_And_Gain_Harvest_Status
46 ... ${CONFIGURE_ISE_SOURCE_FILE}
47 ... http://${TOOLS_SYSTEM_IP}:${ISE_REST_PORT}
48 gbpsxp.Check_Ise_Harvest_Status ${ise_harvest_status_json} 5
49 Create_sxp_node session ${SXP_NODE_CONFIG_FILE} ${SXP_NODE_NAME}
50 Utils.Post_Elements_To_URI_From_File ${SXP_NODE_RPC_ADD_ENTRY_URI} ${SXP_NODE_ADD_ENTRY_FILE}
51 ${expected_endpoints} os.Get_File ${GBP_EXPECTED_ENDPOINTS_FILE}-2.2.json
52 Wait_For_Endpoint_And_Check session ${expected_endpoints}
53 gbpsxp.Clean_ise_source_config
54 gbpsxp.Teardown_Ise_Mock_Server ${ISE_MOCK_SERVER_API_FOLDER}
59 [Documentation] Setup session and set karaf log levels
60 RequestsLibrary.Create_Session
62 ... http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
64 ... headers=${HEADERS}
65 KarafKeywords.Setup_Karaf_Keywords
66 ${karaf_debug_enabled} BuiltIn.Get_Variable_Value ${KARAF_DEBUG} ${False}
67 IF ${karaf_debug_enabled}
68 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set DEBUG org.opendaylight.sxp
70 IF ${karaf_debug_enabled}
71 KarafKeywords.Execute_Controller_Karaf_Command_On_Background
72 ... log:set DEBUG org.opendaylight.groupbasedpolicy.renderer
74 IF ${karaf_debug_enabled}
75 KarafKeywords.Execute_Controller_Karaf_Command_On_Background
76 ... log:set DEBUG org.opendaylight.groupbasedpolicy.sxp
78 IF ${karaf_debug_enabled}
79 KarafKeywords.Execute_Controller_Karaf_Command_On_Background
80 ... log:set DEBUG org.opendaylight.groupbasedpolicy.sxp_ep_provider
84 [Documentation] Cleanup session and set karaf log levels to default
85 ${karaf_debug_enabled} BuiltIn.Get_Variable_Value ${KARAF_DEBUG} ${False}
86 IF ${karaf_debug_enabled}
87 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set INFO org.opendaylight.sxp
89 IF ${karaf_debug_enabled}
90 KarafKeywords.Execute_Controller_Karaf_Command_On_Background
91 ... log:set INFO org.opendaylight.groupbasedpolicy.renderer
93 IF ${karaf_debug_enabled}
94 KarafKeywords.Execute_Controller_Karaf_Command_On_Background
95 ... log:set INFO org.opendaylight.groupbasedpolicy.sxp
97 IF ${karaf_debug_enabled}
98 KarafKeywords.Execute_Controller_Karaf_Command_On_Background
99 ... log:set INFO org.opendaylight.groupbasedpolicy.sxp_ep_provider
101 RequestsLibrary.Delete_All_Sessions
103 Wipe_Clean_Ep_Templates_And_Sxp_Node
104 [Documentation] Delete sxp-ep-provider templates and sxp node
105 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${SXP_EP_PROVIDER_CONFIG_URI}
106 BuiltIn.Run_Keyword_And_Ignore_Error
107 ... Utils.Remove_All_Elements_If_Exist
108 ... ${SXP_TOPOLOGY_NODE_CONFIG_URI}/node/${SXP_NODE_NAME}
109 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${GBP_TENANT_CONFIG_URI}
110 Utils.Post_Elements_To_URI_From_File ${GBP_RPC_UNREGISTER_ENDPOINT_URI} ${GBP_RPC_UNREGISTER_ENDPOINT_FILE}
111 BuiltIn.Wait_Until_Keyword_Succeeds 5 1 Check_For_Clean_Endpoints session
112 gbpsxp.Teardown_Ssh_Tooling
114 Check_For_Clean_Endpoints
115 [Documentation] Ensure that there are no endpoints in the system
116 [Arguments] ${session_arg}
117 ${actual_endpoints} Utils.Get_Data_From_URI ${session_arg} ${GBP_ENDPOINTS_URI}
118 ${actual_endpoints_json} Utils.Json_Parse_From_String ${actual_endpoints}
119 BuiltIn.Should_Be_Empty ${actual_endpoints_json['endpoints']['address-endpoints']}
121 Wait_For_Endpoint_And_Check
122 [Documentation] Wait for endpoint to appear in DS/operational and compare to expected endpoint
123 [Arguments] ${session_arg} ${expected_endpoints}
124 ${actual_endpoints_no_timestamp} BuiltIn.Wait_Until_Keyword_Succeeds
127 ... Get_Endpoints_And_Clean_Timestamp
129 TemplatedRequests.Normalize_Jsons_And_Compare ${expected_endpoints} ${actual_endpoints_no_timestamp}
131 Get_Endpoints_And_Clean_Timestamp
132 [Documentation] Read endpoints from DS/operational and clean timestamp for simple comparison
133 [Arguments] ${session_arg}
134 ${actual_endpoints} Utils.Get_Data_From_URI ${session_arg} ${GBP_ENDPOINTS_URI}
135 ${actual_endpoints_json} Utils.Json_Parse_From_String ${actual_endpoints}
136 ${actual_endpoints_no_timestamp} gbpsxp.Remove_Endpoint_Timestamp ${actual_endpoints_json}
137 RETURN ${actual_endpoints_no_timestamp}
140 [Documentation] Create sxp node and wait till it appears in DS/operational
141 [Arguments] ${session_arg} ${sxp_node_config_file} ${sxp_node_id}
142 ${previous_topology_config} BuiltIn.Run_Keyword_And_Ignore_Error
143 ... Utils.Get_Data_From_URI
145 ... ${SXP_TOPOLOGY_NODE_CONFIG_URI}
146 BuiltIn.Log ${previous_topology_config}
147 Utils.Add_Elements_To_URI_From_File_And_Verify
148 ... ${SXP_TOPOLOGY_NODE_CONFIG_URI}/node/${sxp_node_id}
149 ... ${sxp_node_config_file}
150 ${sxp_node_config_readback} Utils.Get_Data_From_URI
152 ... ${SXP_TOPOLOGY_NODE_CONFIG_URI}/node/${sxp_node_id}
153 BuiltIn.Wait_Until_Keyword_Succeeds
156 ... Check_If_Sxp_Node_Is_Enabled
158 ... ${SXP_TOPOLOGY_NODE_OPERATIONAL_URI}/node/${sxp_node_id}
160 Check_If_Sxp_Node_Is_Enabled
161 [Documentation] Read node enabled leaf and check if it is true
162 [Arguments] ${session_arg} ${node_uri}
163 ${sxp_node} Utils.Get_Data_From_URI ${session_arg} ${node_uri}
164 ${sxp_node_json} Utils.Json_Parse_From_String ${sxp_node}
165 ${sxp_node_enabled} gbpsxp.Resolve_sxp_node_is_enabled ${sxp_node_json}
166 BuiltIn.Should_Be_Equal_As_Strings True ${sxp_node_enabled}