2 Documentation TCPMD5 user-facing feature system tests, using PCEP.
4 ... Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
10 ... Test suite performs basic pcep md5 password authorization test cases:
11 ... (Run entire basic PCEP suite without passwords.)
12 ... Start pcc-mock (reconnecting mode): 1 pcc, 1 lsp, password set, check pcep-topology stays empty.
13 ... Use restconf to change PCEP configuration to use a wrong password, check pcep-topology stays empty.
14 ... Change ODL PCEP configuration to use the correct password, check pcep-topology shows the lsp.
15 ... Stop pcc-mock, check pcep-topology stays empty.
16 ... Start pcc-mock with new password, check pcep-topology stays empty.
17 ... Change ODL PCEP configuration to use the correct password, check pcep-topology shows the lsp.
18 ... Update the lsp, check a change in pcep-topology.
19 ... Change ODL PCEP configuration to not use password, pcep-topology empties, kill pcep-pcc-mock.
21 ... Stable/carbon and stable/nitrogen are using netconf-connector-ssh to send restconf requests.
22 ... Oxygen test cases no longer need netconf-connector-ssh, and they include comparison of
23 ... pcep-session-state, which is exclusive to oxygen.
25 Suite Teardown Tear_It_Down
26 Test Setup FailFast.Fail_This_Fast_On_Previous_Error
27 Test Teardown FailFast.Start_Failing_Fast_If_This_Failed
28 Library OperatingSystem
29 Library RequestsLibrary
30 Library SSHLibrary prompt=]>
31 Resource ../../../libraries/FailFast.robot
32 Resource ../../../libraries/KarafKeywords.robot
33 Resource ../../../libraries/NexusKeywords.robot
34 Resource ../../../libraries/TemplatedRequests.robot
35 Resource ../../../libraries/WaitForFailure.robot
36 Resource ../../../libraries/RemoteBash.robot
37 Resource ../../../libraries/CompareStream.robot
40 ${DIR_WITH_TEMPLATES} ${CURDIR}/../../../variables/tcpmd5user/
41 ${CONFIG_SESSION} session
42 ${CONNECTOR_FEATURE} odl-netconf-connector-all
43 ${PCEP_FEATURE} odl-bgpcep-pcep
44 ${RESTCONF_FEATURE} odl-restconf-all
48 [Documentation] Compare current pcep-topology to empty one.
49 ... Timeout is long enough to see that pcep is ready, with no PCC connected.
51 BuiltIn.Wait_Until_Keyword_Succeeds 300s 1s TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_off session=${CONFIG_SESSION} verify=True
54 [Documentation] Execute pcc-mock on Mininet with password set, fail if pcc-mock promptly exits. Keep pcc-mock running for next test cases.
55 Start_Pcc_Mock_Tool_With_Password password=topsecret
57 Topology_Unauthorized_1
58 [Documentation] Try to catch a glimpse of pcc-mock in pcep-topology. Pass if no change from Precondition is detected over 10 seconds.
60 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Test_Unauthorized
63 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
64 ... This password does not match what pcc-mock uses.
65 CompareStream.Run_Keyword_If_At_Least_Oxygen Replace_Password_On_Pcep_Node password=changeme
66 CompareStream.Run_Keyword_If_Less_Than_Oxygen Set_Password_Less_Than_Oxygen password=changeme
68 Topology_Unauthorized_2
69 [Documentation] The same logic as Topology_Unauthorized_1 as incorrect password was provided to ODL.
71 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Test_Unauthorized
74 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
75 ... This password finally matches what pcc-mock uses.
76 CompareStream.Run_Keyword_If_At_Least_Oxygen Replace_Password_On_Pcep_Node password=topsecret
77 CompareStream.Run_Keyword_If_Less_Than_Oxygen Set_Password_Less_Than_Oxygen password=topsecret
79 Topology_Intercondition
80 [Documentation] Compare pcep-topology/path-computation-client to filled one, which includes a tunnel from pcc-mock.
81 ... For oxygen compares full pcep-topology including pcep-session-state
82 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} CODE=${pcc_name_code} NAME=${pcc_name} IP_ODL=${ODL_SYSTEM_IP}
83 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_on ${mapping} ${CONFIG_SESSION}
85 CompareStream.Run_Keyword_If_Less_Than_Oxygen BuiltIn.Pass_Execution Rest of the test case valid only for versions oxygen and above.
86 BuiltIn.Wait_Until_Keyword_Succeeds 30s 1s TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_on_state ${mapping} ${CONFIG_SESSION}
90 [Documentation] Stops First instance of pcc-mock.
91 [Setup] FailFast.Run_Even_When_Failing_Fast
93 FailFast.Do_Not_Fail_Fast_From_Now_On
94 # NOTE: It is still possible to remain failing, if both previous and this test failed.
95 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
97 Topology_Unauthorized_3
98 [Documentation] The same logic as Topology_Unauthorized_1, with no pcc-mock running.
100 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Test_Unauthorized
102 Start_Secure_Pcc_Mock_2
103 [Documentation] Execute pcc-mock on Mininet with new password set, fail if pcc-mock promptly exits. Keep pcc-mock running for next test cases.
104 Start_Pcc_Mock_Tool_With_Password password=newtopsecret
106 Topology_Unauthorized_4
107 [Documentation] The same logic as Topology_Unauthorized_1, but ODL password became incorrect with new pcc-mock running.
109 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Test_Unauthorized
111 Set_Correct_Password_2
112 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
113 ... This password again matches what second pcc-mock instance uses.
114 CompareStream.Run_Keyword_If_At_Least_Oxygen Replace_Password_On_Pcep_Node password=newtopsecret
115 CompareStream.Run_Keyword_If_Less_Than_Oxygen Set_Password_Less_Than_Oxygen password=newtopsecret
117 Topology_Intercondition_2
118 [Documentation] Compare pcep-topology/path-computation-client to filled one, which includes a tunnel from pcc-mock.
119 ... For oxygen compares full pcep-topology including pcep-session-state
120 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} CODE=${pcc_name_code} NAME=${pcc_name} IP_ODL=${ODL_SYSTEM_IP}
121 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_on ${mapping} ${CONFIG_SESSION}
123 CompareStream.Run_Keyword_If_Less_Than_Oxygen BuiltIn.Pass_Execution Rest of the test case valid only for versions oxygen and above.
124 BuiltIn.Wait_Until_Keyword_Succeeds 30s 1s TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_on_state ${mapping} ${CONFIG_SESSION}
128 [Documentation] Perform update-lsp on the mocked tunnel, check response is success.
129 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} NAME=${pcc_name}
130 ${response}= TemplatedRequests.Post_As_Xml_Templated ${DIR_WITH_TEMPLATES}${/}update_delegated ${mapping} ${CONFIG_SESSION} verify=True
134 [Documentation] Compare pcep-topology/path-computation-client to default_on_updated, which includes the updated tunnel.
135 ... For oxygen compares full pcep-topology including pcep-session-state
137 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} CODE=${pcc_name_code} NAME=${pcc_name} IP_ODL=${ODL_SYSTEM_IP}
138 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_on_updated ${mapping} ${CONFIG_SESSION}
140 CompareStream.Run_Keyword_If_Less_Than_Oxygen BuiltIn.Pass_Execution Rest of the test case valid only for versions oxygen and above.
141 BuiltIn.Wait_Until_Keyword_Succeeds 30s 1s TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_on_updated_state ${mapping} ${CONFIG_SESSION}
145 [Documentation] De-configure password for pcep dispatcher for client with Mininet IP address.
146 [Setup] FailFast.Run_Even_When_Failing_Fast
147 CompareStream.Run_Keyword_If_At_Least_Oxygen Unset_Password_On_Pcep_Node
148 CompareStream.Run_Keyword_If_Less_Than_Oxygen Replace_Password_Xml_Element_In_Pcep_Client_Module_Less_Than_Oxygen
149 FailFast.Do_Not_Fail_Fast_From_Now_On
150 # NOTE: It is still possible to remain failing, if both previous and this test failed.
151 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
153 Topology_Unauthorized_5
154 [Documentation] Wait for pcep-topology to become empty again.
156 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Test_Unauthorized
159 [Documentation] Stops second instance of pcc-mock
160 [Setup] FailFast.Run_Even_When_Failing_Fast
162 FailFast.Do_Not_Fail_Fast_From_Now_On
163 # NOTE: It is still possible to remain failing, if both previous and this test failed.
164 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
166 Topology_Postcondition
167 [Documentation] Verify that pcep-topology stays empty.
169 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Test_Unauthorized
171 Delete_Pcep_Client_Module
172 [Documentation] Delete Pcep client module.
173 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP}
174 CompareStream.Run_Keyword_If_At_Least_Oxygen TemplatedRequests.Delete_Templated ${DIR_WITH_TEMPLATES}${/}pcep_topology_node ${mapping}
175 CompareStream.Run_Keyword_If_Less_Than_Oxygen TemplatedRequests.Delete_Templated ${DIR_WITH_TEMPLATES}${/}pcep_topology_client_module ${mapping}
179 [Documentation] Create SSH session to Mininet machine, prepare HTTP client session to Controller.
180 ... Figure out latest pcc-mock version and download it from Nexus to Mininet.
181 ... Also, delete and create directories for json diff handling.
182 ... Sets up netconf-connector on odl-streams less than oxygen.
183 KarafKeywords.Setup_Karaf_Keywords
184 TemplatedRequests.Create_Default_Session
185 BuiltIn.Run_Keyword_If """${USE_NETCONF_CONNECTOR}""" == """False""" CompareStream.Run_Keyword_If_Less_Than_Oxygen Install_Netconf_Connector
186 NexusKeywords.Initialize_Artifact_Deployment_And_Usage
187 ${current_connection}= SSHLibrary.Get_Connection
188 ${current_prompt}= BuiltIn.Set_Variable ${current_connection.prompt}
189 BuiltIn.Log ${current_prompt}
190 BuiltIn.Set_Suite_Variable ${prompt} ${current_prompt}
191 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
192 ${name}= NexusKeywords.Deploy_Test_Tool bgpcep pcep-pcc-mock
193 BuiltIn.Set_Suite_Variable ${filename} ${name}
194 #Setting Pcc Name and its code for mapping for templates
195 BuiltIn.Set_Suite_Variable ${pcc_name} pcc_${TOOLS_SYSTEM_IP}_tunnel_1
196 ${code}= Evaluate binascii.b2a_base64('${pcc_name}')[:-1] modules=binascii
197 BuiltIn.Set_Suite_Variable ${pcc_name_code} ${code}
198 FailFast.Do_Not_Fail_Fast_From_Now_On
201 [Documentation] Download pccmock.log and Log its contents.
202 ... Compute and Log the diff between expected and actual normalized responses.
203 ... Close both HTTP client session and SSH connection to Mininet.
204 SSHLibrary.Get_File pccmock.log
205 ${pccmocklog}= OperatingSystem.Run cat pccmock.log
206 BuiltIn.Log ${pccmocklog}
207 BuiltIn.Run_Keyword_If """${USE_NETCONF_CONNECTOR}""" == """False""" CompareStream.Run_Keyword_If_Less_Than_Oxygen Uninstall_Netconf_Connector
208 RequestsLibrary.Delete_All_Sessions
209 SSHLibrary.Close_All_Connections
211 Install_Netconf_Connector
212 [Documentation] Installs ${CONNECTOR_FEATURE} feature.
213 # During the netconf connector installation the karaf's ssh is restarted and connection to karaf console is droped. This is causing an error
214 # which is ignored, because the feature should be installed anyway.
215 ${status} ${results} = BuiltIn.Run_Keyword_And_Ignore_Error KarafKeywords.Install_A_Feature ${CONNECTOR_FEATURE}
216 ${status} ${results} = BuiltIn.Run_Keyword_And_Ignore_Error KarafKeywords.Install_A_Feature ${PCEP_FEATURE}
217 ${status} ${results} = BuiltIn.Run_Keyword_And_Ignore_Error KarafKeywords.Install_A_Feature ${RESTCONF_FEATURE}
218 BuiltIn.Log ${results}
219 BuiltIn.Wait_Until_Keyword_Succeeds 240s 3s Check_Netconf_Up_And_Running
221 Check_Netconf_Up_And_Running
222 [Documentation] Make a request to netconf connector's mounted pcep module and expect it is mounted.
223 TemplatedRequests.Get_From_Uri restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules/module/odl-pcep-topology-provider-cfg:pcep-topology-provider/pcep-topology
225 Uninstall_Netconf_Connector
226 [Documentation] Uninstalls ${CONNECTOR_FEATURE} feature.
227 ${status} ${results} = BuiltIn.Run_Keyword_And_Ignore_Error KarafKeywords.Uninstall_A_Feature ${CONNECTOR_FEATURE}
228 BuiltIn.Log ${results}
231 [Documentation] Try to access pcep topology with wrong password, should get empty topology
232 TemplatedRequests.Get_As_Json_Templated ${DIR_WITH_TEMPLATES}${/}default_off session=${CONFIG_SESSION} verify=True
234 Set_Password_Less_Than_Oxygen
235 [Arguments] ${password}=${EMPTY}
236 ${password_line}= Construct_Password_Element_Line_Using_Password password=${password}
237 Replace_Password_Xml_Element_In_Pcep_Client_Module_Less_Than_Oxygen ${password_line}
239 Read_Text_Before_Prompt
240 [Documentation] Log text gathered by SSHLibrary.Read_Until_Prompt.
241 ... This needs to be a separate keyword just because how Read_And_Fail_If_Prompt_Is_Seen is implemented.
242 ${text}= SSHLibrary.Read_Until_Prompt
245 Replace_Password_On_Pcep_Node
246 [Arguments] ${password}
247 [Documentation] Send restconf PUT to replace the config module specifying PCEP password element.
248 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} PASSWD=${password}
249 TemplatedRequests.Put_As_Xml_Templated ${DIR_WITH_TEMPLATES}${/}pcep_topology_node mapping=${mapping}
251 Unset_Password_On_Pcep_Node
252 [Documentation] Send restconf PUT to unset the config module.
253 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP}
254 TemplatedRequests.Put_As_Xml_Templated ${DIR_WITH_TEMPLATES}${/}pcep_topology_node_empty mapping=${mapping}
256 Construct_Password_Element_Line_Using_Password
257 [Arguments] ${password}
258 [Documentation] Return line with password XML element containing given password, whitespace is there so that data to send looks neat.
259 ${element}= String.Replace_String ${SPACE}${SPACE}<password>$PASSWORD</password>${\n} $PASSWORD ${password}
260 BuiltIn.Log ${element}
263 Replace_Password_Xml_Element_In_Pcep_Client_Module_Less_Than_Oxygen
264 [Arguments] ${password_element}=${EMPTY}
265 [Documentation] Send restconf PUT to replace the config module specifying PCEP password element (may be empty=missing).
266 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} PASSWD=${password_element}
267 TemplatedRequests.Put_As_Xml_Templated ${DIR_WITH_TEMPLATES}${/}pcep_topology_client_module mapping=${mapping}
270 [Documentation] Send ctrl+c to pcc-mock, fails if no prompt is seen
271 ... after 3 seconds (the default for SSHLibrary)
272 RemoteBash.Write_Bare_Ctrl_C
273 ${output}= SSHLibrary.Read_Until_Prompt
274 BuiltIn.Log ${output}
276 Start_Pcc_Mock_Tool_With_Password
277 [Arguments] ${password}
278 [Documentation] Starts pcc-mock with password argument.
279 ${command}= NexusKeywords.Compose_Full_Java_Command -jar ${filename} --password ${password} --reconnect 1 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_IP} 2>&1 | tee pccmock.log
280 BuiltIn.Log ${command}
281 SSHLibrary.Write ${command}