2 Documentation Test suite for Group Based Policy, sxp-ep-provider component.
4 Library OperatingSystem WITH NAME os
5 Library RequestsLibrary WITH NAME reqLib
7 Library ../../../libraries/GbpSxp.py WITH NAME gbpsxp
8 Resource ../../../variables/Variables.robot
9 Resource ../../../variables/sfc/Variables.robot
10 Resource ../../../libraries/Utils.robot
11 Resource ../../../libraries/TemplatedRequests.robot
12 Resource ../../../libraries/NetconfKeywords.robot
13 Resource ../../../libraries/GbpSxp.robot
15 Suite Setup Setup_Http_And_Netconf
16 Suite Teardown Teardown_Http_And_Netconf
17 Test Setup Prepare_Renderer_Prerequisities
18 Test Teardown Wipe_Clean_Renderer_Policy_Cohort
22 ${EP_PROVIDER_TEMPLATES_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-ep-policy-templates
23 ${IOS_XE_SCHEMAS_FOLDER} ${CURDIR}/../../../variables/gbp/ios-xe-schemas
24 ${GBP_RENDERER_POLICY_FILE} ${CURDIR}/../../../variables/gbp/gbpsxp-renderer-policy.json
26 @{IOS_XE_IP} ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP}
27 @{IOS_XE_NODE_NAMES} ios-xe-mock-1 ios-xe-mock-2
28 ${NETCONF_CONFIG_IOSXE_NODE_FILE} ${CURDIR}/../../../variables/gbp/ios-xe-netconf-node.json
30 ${SFC_SERVICE_FUNCTIONS_FILE} ${CURDIR}/../../../variables/gbp/sfc/service-functions.json
31 ${SFC_SF_FORWARDERS_FILE} ${CURDIR}/../../../variables/gbp/sfc/service-function-forwarders.json
32 ${SFC_SF_CHAINS_FILE} ${CURDIR}/../../../variables/gbp/sfc/service-function-chains.json
33 ${SFC_SF_PATHS_FILE} ${CURDIR}/../../../variables/gbp/sfc/service-function-paths.json
37 Configure_Sfc_And_Ios_Xe_Renderer_Using_Generated_Sgt
38 [Documentation] Elicit netconf device configuration by providing sfc configurations and ios-xe renderer policy
39 ${renderer_policy} ${next_version} Provision_renderer_policy session ${GBP_RENDERER_POLICY_FILE}
40 Utils.Add_Elements_To_URI_And_Verify ${GBP_RENDERER_CONFIG_URI}/renderer-policy ${renderer_policy}
41 BuiltIn.Wait_Until_Keyword_Succeeds
44 ... Check_Renderer_Policy_Status_Version
47 ${security_group_json} BuiltIn.Wait_Until_Keyword_Succeeds
50 ... Seek_Security_Group
52 ... ${NETCONF_CONFIG_URI}/node/${IOS_XE_NODE_NAMES[1]}/${MOUNTPOINT_IOSXE_SUFFIX}
53 BuiltIn.Log ${security_group_json['source']['tag']} level=DEBUG
54 BuiltIn.Log ${security_group_json['destination']['tag']} level=DEBUG
55 BuiltIn.Should_Be_Equal_As_Integers 100 ${security_group_json['source']['tag']}
56 BuiltIn.Should_Be_Equal_As_Integers 101 ${security_group_json['destination']['tag']}
57 ${expected_templates} os.Get_File ${EP_PROVIDER_TEMPLATES_FILE}-3.1.json
58 ${actual_templates} Utils.Get_Data_From_URI session ${SXP_EP_PROVIDER_CONFIG_URI}
59 TemplatedRequests.Normalize_Jsons_And_Compare ${expected_templates} ${actual_templates}
61 Configure_Sfc_And_Ios_Xe_Renderer_Using_Existing_Sgt
62 [Documentation] Elicit netconf device configuration by providing sfc configurations and ios-xe renderer policy and ep-policy-templates
63 Utils.Add_Elements_To_URI_From_File ${SXP_EP_PROVIDER_CONFIG_URI} ${EP_PROVIDER_TEMPLATES_FILE}-3.2.json
64 ${renderer_policy} ${next_version} Provision_renderer_policy session ${GBP_RENDERER_POLICY_FILE}
65 Utils.Add_Elements_To_URI_And_Verify ${GBP_RENDERER_CONFIG_URI}/renderer-policy ${renderer_policy}
66 BuiltIn.Wait_Until_Keyword_Succeeds
69 ... Check_Renderer_Policy_Status_Version
72 ${security_group_json} BuiltIn.Wait_Until_Keyword_Succeeds
75 ... Seek_Security_Group
77 ... ${NETCONF_CONFIG_URI}/node/${IOS_XE_NODE_NAMES[1]}/${MOUNTPOINT_IOSXE_SUFFIX}
78 BuiltIn.Log ${security_group_json['source']['tag']} level=DEBUG
79 BuiltIn.Log ${security_group_json['destination']['tag']} level=DEBUG
80 BuiltIn.Should_Be_Equal_As_Integers 43 ${security_group_json['source']['tag']}
81 BuiltIn.Should_Be_Equal_As_Integers 42 ${security_group_json['destination']['tag']}
85 Setup_Http_And_Netconf
86 [Documentation] Setup http session, setup ssh session to tools, deploy netconf-testtool (with ios-xe schemas) and start
87 reqLib.Create_Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
88 ${tools_1_session} GbpSxp.Prepare_Ssh_Tooling ${TOOLS_SYSTEM_IP}
89 ${tools_2_session} GbpSxp.Prepare_Ssh_Tooling ${TOOLS_SYSTEM_2_IP}
90 @{tools_sessions} BuiltIn.Create_List ${tools_1_session} ${tools_2_session}
91 BuiltIn.Set_Suite_Variable ${TOOLS_SESSIONS} ${tools_sessions}
92 NetconfKeywords.Setup_NetconfKeywords
93 ${run_netconf_testtool_manually} BuiltIn.Get_Variable_Value ${run_netconf_testtool_manually} ${False}
94 ${logfile} Utils.Get_Log_File_Name testtool
95 IF ${run_netconf_testtool_manually}
96 BuiltIn.Set_Suite_Variable ${testtool_log} ${logfile}
98 FOR ${ssh_session} IN @{TOOLS_SESSIONS}
99 SSHKeywords.Restore_Current_Ssh_Connection_From_Index ${ssh_session}
100 IF not ${run_netconf_testtool_manually}
101 Install_And_Start_Testtool
104 ... schemas=${IOS_XE_SCHEMAS_FOLDER}
109 Teardown_Http_And_Netconf
110 [Documentation] Close http session, close ssh session to tools, stop netconf-testtool
111 FOR ${ssh_session} IN @{TOOLS_SESSIONS}
112 BuiltIn.Log ${ssh_session}
113 SSHKeywords.Restore_Current_Ssh_Connection_From_Index ${ssh_session}
116 gbpsxp.Teardown_Ssh_Tooling ${TOOLS_SESSIONS}
117 RequestsLibrary.Delete_All_Sessions
119 Prepare_Renderer_Prerequisities
120 [Documentation] Prepare sfc configurations, connect netconf device
121 FOR ${INDEX} IN RANGE 0 2
123 ${netconf_node_configuration_json} Utils.Json_Parse_From_File ${NETCONF_CONFIG_IOSXE_NODE_FILE}
124 ${netconf_node_configuration} gbpsxp.Replace_Netconf_Node_Host
125 ... ${netconf_node_configuration_json}
126 ... ${IOS_XE_NODE_NAMES[${INDEX}]}
127 ... ${IOS_XE_IP[${INDEX}]}
128 BuiltIn.Log ${netconf_node_configuration} level=DEBUG
129 Utils.Add_Elements_To_URI_And_Verify
130 ... ${NETCONF_CONFIG_URI}/node/${IOS_XE_NODE_NAMES[${INDEX}]}
131 ... ${netconf_node_configuration}
133 FOR ${INDEX} IN RANGE 0 2
135 BuiltIn.Wait_Until_Keyword_Succeeds
138 ... Check_Netconf_Node_Status
140 ... ${NETCONF_OPERATIONAL_URI}/node/${IOS_XE_NODE_NAMES[${INDEX}]}
141 BuiltIn.Wait_Until_Keyword_Succeeds
144 ... TemplatedRequests.Get_From_Uri
145 ... ${NETCONF_CONFIG_URI}/node/${IOS_XE_NODE_NAMES[${INDEX}]}/yang-ext:mount
148 Utils.Add_Elements_To_URI_From_File ${SERVICE_FUNCTIONS_URI} ${SFC_SERVICE_FUNCTIONS_FILE}
149 &{ip_mgmt_map} BuiltIn.Create_Dictionary SFF1=${TOOLS_SYSTEM_2_IP} SFF2=${TOOLS_SYSTEM_IP}
150 ${sfc_sf_forwarders_json} Utils.Json_Parse_From_File ${SFC_SF_FORWARDERS_FILE}
151 ${sfc_sf_forwarders} gbpsxp.Replace_Ip_Mgmt_Address_In_Forwarder ${sfc_sf_forwarders_json} ${ip_mgmt_map}
152 Utils.Add_Elements_To_URI_And_Verify ${SERVICE_FORWARDERS_URI} ${sfc_sf_forwarders}
153 Utils.Add_Elements_To_URI_From_File ${SERVICE_CHAINS_URI} ${SFC_SF_CHAINS_FILE}
154 Utils.Add_Elements_To_URI_From_File ${SERVICE_FUNCTION_PATHS_URI} ${SFC_SF_PATHS_FILE}
156 Check_Netconf_Node_Status
157 [Documentation] Check if connection status of given node is 'connected'
158 [Arguments] ${session_arg} ${node_operational_uri}
159 ${node_content} Utils.Get_Data_From_URI ${session_arg} ${node_operational_uri}
160 ${node_content_json} Utils.Json_Parse_From_String ${node_content}
161 BuiltIn.Should_Be_Equal_As_Strings
163 ... ${node_content_json['node'][0]['netconf-node-topology:connection-status']}
165 Wipe_Clean_Renderer_Policy_Cohort
166 [Documentation] Delete ep-policy-templates, renderer-policy, sfc configuraions, netconf-device config
167 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${SERVICE_FUNCTIONS_URI}
168 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${SERVICE_FORWARDERS_URI}
169 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${SERVICE_CHAINS_URI}
170 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${SERVICE_FUNCTION_PATHS_URI}
171 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${GBP_RENDERER_CONFIG_URI}
172 # clean netconf-device config (behind mountpoint) and disconnect by removing it from DS/config
173 FOR ${ios_xe_node_name} IN @{IOS_XE_NODE_NAMES}
174 BuiltIn.Run_Keyword_And_Ignore_Error
175 ... Utils.Remove_All_Elements_If_Exist
176 ... ${NETCONF_CONFIG_URI}/node/${ios_xe_node_name}/${MOUNTPOINT_IOSXE_SUFFIX}
177 BuiltIn.Run_Keyword_And_Ignore_Error
178 ... Utils.Remove_All_Elements_If_Exist
179 ... ${NETCONF_CONFIG_URI}/node/${ios_xe_node_name}
181 FOR ${ios_xe_node_name} IN @{IOS_XE_NODE_NAMES}
182 BuiltIn.Wait_Until_Keyword_Succeeds
185 ... Utils.No_Content_From_URI
187 ... ${NETCONF_OPERATIONAL_URI}/node/${ios_xe_node_name}
189 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${SXP_EP_PROVIDER_CONFIG_URI}
190 BuiltIn.Run_Keyword_And_Ignore_Error Utils.Remove_All_Elements_If_Exist ${GBP_TENANT_CONFIG_URI}
193 [Documentation] Read given DS and seek CONFIG['native']['class-map'][0]['match']['security-group']
194 [Arguments] ${session_arg} ${config_uri}
195 ${device_ds_config} Utils.Get_Data_From_URI ${session_arg} ${config_uri}
196 ${device_ds_config_json} Utils.Json_Parse_From_String ${device_ds_config}
197 RETURN ${device_ds_config_json['native']['class-map'][0]['match']['security-group']}
199 Propose_Renderer_Configuration_Next_Version
200 [Documentation] Read current renderer configuration status and compute next version or use 0 if status absents
201 [Arguments] ${session_arg}
202 ${renderer_policy} BuiltIn.Run_Keyword_And_Ignore_Error
203 ... Utils.Get_Data_From_URI
205 ... ${GBP_RENDERER_POLICY_OPERATIONAL_URI}
206 IF '${renderer_policy[0]}' != 'PASS' RETURN 0
207 ${renderer_policy_json} Utils.Json_Parse_From_String ${renderer_policy[1]}
208 ${current_version} BuiltIn.Convert_To_Integer ${renderer_policy_json['renderer-policy']['version']}
209 RETURN ${current_version + 1}
211 Provision_renderer_policy
212 [Documentation] Replace version number in given renderer-policy in order to be the next expected value
213 [Arguments] ${session_arg} ${renderer_policy_file}
214 ${renderer_policy_json} Utils.Json_Parse_From_File ${renderer_policy_file}
215 ${next_version} Propose_Renderer_Configuration_Next_Version ${session_arg}
216 ${renderer_policy_updated} gbpsxp.Replace_Renderer_Policy_Version ${renderer_policy_json} ${next_version}
217 RETURN ${renderer_policy_updated} ${next_version}
219 Check_Renderer_Policy_Status_Version
220 [Documentation] Read current renderer policy version and compare it to expected version
221 [Arguments] ${session_arg} ${expected_version}
222 ${renderer_policy} Utils.Get_Data_From_URI ${session_arg} ${GBP_RENDERER_POLICY_OPERATIONAL_URI}
223 ${renderer_policy_json} Utils.Json_Parse_From_String ${renderer_policy}
224 BuiltIn.Should_Be_Equal_As_Integers ${renderer_policy_json['renderer-policy']['version']} ${expected_version}