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
11 ... The original brief description of this suite is at
12 ... https://wiki.opendaylight.org/view/TCPMD5:Lithium_Feature_Tests#How_to_test
14 Suite Teardown Tear_It_Down
15 Test Setup FailFast.Fail_This_Fast_On_Previous_Error
16 Test Teardown FailFast.Start_Failing_Fast_If_This_Failed
17 Library OperatingSystem
18 Library RequestsLibrary
19 Library SSHLibrary prompt=]>
21 Library ${CURDIR}/../../../libraries/HsfJson/hsf_json.py
22 Resource ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
23 Resource ${CURDIR}/../../../libraries/FailFast.robot
24 Resource ${CURDIR}/../../../libraries/PcepOperations.robot
25 Resource ${CURDIR}/../../../libraries/WaitForFailure.robot
26 Variables ${CURDIR}/../../../variables/Variables.py
27 Variables ${CURDIR}/../../../variables/pcepuser/variables.py ${MININET}
30 ${directory_for_actual_responses} ${TEMPDIR}${/}actual
31 ${directory_for_expected_responses} ${TEMPDIR}${/}expected
32 ${directory_with_template_folders} ${CURDIR}/../../../variables/tcpmd5user/
36 [Documentation] Compare current pcep-topology to empty one.
37 ... Timeout is long enough to see that pcep is ready, with no PCC is connected.
39 BuiltIn.Wait_Until_Keyword_Succeeds 300 1 Compare_Topology ${off_json} 010_Precondition.json
42 [Documentation] Execute pcc-mock on Mininet with password set, fail if pcc-mock promptly exits. Keep pcc-mock running for next test cases.
43 ${command}= BuiltIn.Set_Variable java -jar ${filename} --password topsecret --reconnect 1 --local-address ${MININET} --remote-address ${CONTROLLER} 2>&1 | tee pccmock.log
44 BuiltIn.Log ${command}
45 SSHLibrary.Write ${command}
46 Read_And_Fail_If_Prompt_Is_Seen
48 Topology_Unauthorized_1
49 [Documentation] Try to catch a glimpse of pcc-mock in pcep-topology. Pass if no change from Precondition is detected over 1 minute.
51 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 020_Unauthorized_1.json
53 Enable_Tcpmd5_No_Password_Yet
54 [Documentation] Send series of restconf puts derived from https://wiki.opendaylight.org/view/BGP_LS_PCEP:TCP_MD5_Guide#RESTCONF_Configuration
55 ... Every put should return empty text with allwed status code.
56 # No ${mapping_as_string} is given, as there are no placeholders present in the following folders.
57 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}key_access_module
58 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}key_access_service
59 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}md5_client_channel_module
60 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}md5_client_channel_service
61 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}md5_server_channel_module
62 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}md5_server_channel_service
63 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_client_channel_module
64 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_server_channel_module
65 # TODO: Is it worth changing ConfigViaRestconf to read ${directory_with_template_folders} variable by default?
67 Check_For_Bug_3753_Via_Bug_4267
68 [Documentation] Check state of disptcher configuration module, apply workaround if needed.
69 ... This test case should not be failing, failure indicates Bug 3753 was not fixed enough yet.
70 ... For more details, see https://bugs.opendaylight.org/show_bug.cgi?id=4267#c2
71 ConfigViaRestconf.Verify_Json_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_dispatcher_module
72 [Teardown] BuiltIn.Run_Keyword_If_Test_Failed ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_dispatcher_module
74 Topology_Unauthorized_2
75 [Documentation] The same logic as Topology_Unauthorized_1 as no password was provided to ODL.
77 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 030_Unauthorized_2.json
80 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
81 ... This password does not match what pcc-mock uses.
82 ${password_line}= Construct_Password_Element_Line_Using_Password changeme
83 BuiltIn.Log ${password_line}
84 Replace_Password_Xml_Element_In_Pcep_Client_Module ${password_line}
86 Topology_Unauthorized_3
87 [Documentation] The same logic as Topology_Unauthorized_1 as incorrect password was provided to ODL.
89 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 040_Unauthorized_3.json
92 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
93 ... This password finally matches what pcc-mock uses.
94 ${password_line}= Construct_Password_Element_Line_Using_Password topsecret
95 BuiltIn.Log ${password_line}
96 Replace_Password_Xml_Element_In_Pcep_Client_Module ${password_line}
98 Topology_Intercondition
99 [Documentation] Compare pcep-topology to filled one, which includes a tunnel from pcc-mock.
101 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${default_json} 050_Intercondition.json
104 [Documentation] Perform update-lsp on the mocked tunnel, check response is success.
105 ${text}= PcepOperations.Update_Xml_Lsp_Return_Json ${update_delegated_xml}
106 Pcep_Json_Is_Success ${text}
109 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel.
111 BuiltIn.Wait_Until_Keyword_succeeds 5s 1s Compare_Topology ${updated_json} 060_Topology_Updated.json
114 [Documentation] De-configure password for pcep dispatcher for client with Mininet IP address.
115 [Setup] FailFast.Run_Even_When_Failing_Fast
116 Replace_Password_Xml_Element_In_Pcep_Client_Module ${EMPTY}
117 FailFast.Do_Not_Fail_Fast_From_Now_On
118 # NOTE: It is still possible to remain failing, if both previous and this test failed.
119 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
121 Topology_Unauthorized_4
122 [Documentation] Wait for pcep-topology to become empty again.
124 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${offjson} 070_Unauthorized_4.json
127 [Documentation] Send ctrl+c to pcc-mock, fails if no prompt is seen
128 ... after 3 seconds (the default for SSHLibrary)
129 [Setup] FailFast.Run_Even_When_Failing_Fast
130 # FIXME: Bgpcepuser has Write_Ctrl_C keyword. Re-use it.
131 ${command}= BuiltIn.Evaluate chr(int(3))
132 BuiltIn.Log ${command}
133 SSHLibrary.Write ${command}
134 SSHLibrary.Read_Until_Prompt
135 FailFast.Do_Not_Fail_Fast_From_Now_On
136 # NOTE: It is still possible to remain failing, if both previous and this test failed.
137 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
139 Topology_Postcondition
140 [Documentation] Verify that pcep-topology stays empty.
142 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10 1 Compare_Topology ${offjson} 080_Postcondition.json
143 # FIXME: We should delete config changes to not affect next suite.
147 [Documentation] Create SSH session to Mininet machine, prepare HTTP client session to Controller.
148 ... Figure out latest pcc-mock version and download it from Nexus to Mininet.
149 ... Also, delete and create directories for json diff handling.
150 SSHLibrary.Open_Connection ${MININET}
151 SSHLibrary.Login_With_Public_Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
152 ${current_connection}= SSHLibrary.Get_Connection
153 ${current_prompt}= BuiltIn.Set_Variable ${current_connection.prompt}
154 BuiltIn.Log ${current_prompt}
155 BuiltIn.Set_Suite_Variable ${prompt} ${current_prompt}
156 RequestsLibrary.Create_Session ses http://${CONTROLLER}:${RESTCONFPORT}${OPERATIONAL_TOPO_API} auth=${AUTH}
157 # TODO: See corresponding bgpuser TODO.
158 ${urlbase}= BuiltIn.Set_Variable ${NEXUSURL_PREFIX}/content/repositories/opendaylight.snapshot/org/opendaylight/bgpcep/pcep-pcc-mock
159 ${version}= SSHLibrary.Execute_Command curl ${urlbase}/maven-metadata.xml | grep latest | cut -d '>' -f 2 | cut -d '<' -f 1
160 # TODO: Use RequestsLibrary and String instead of curl and bash utilities?
161 BuiltIn.Log ${version}
162 ${namepart}= SSHLibrary.Execute_Command curl ${urlbase}/${version}/maven-metadata.xml | grep value | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1
163 BuiltIn.Log ${namepart}
164 BuiltIn.Set_Suite_Variable ${filename} pcep-pcc-mock-${namepart}-executable.jar
165 BuiltIn.Log ${filename}
166 ${response}= SSHLibrary.Execute_Command wget -q -N ${urlbase}/${version}/${filename} 2>&1
167 BuiltIn.Log ${response}
168 OperatingSystem.Remove_Directory ${directory_for_expected_responses} recursive=True
169 OperatingSystem.Remove_Directory ${directory_for_actual_responses} recursive=True
170 # The previous suite may have been using the same directories.
171 OperatingSystem.Create_Directory ${directory_for_expected_responses}
172 OperatingSystem.Create_Directory ${directory_for_actual_responses}
173 ConfigViaRestconf.Setup_Config_Via_Restconf
174 PcepOperations.Setup_Pcep_Operations
175 FailFast.Do_Not_Fail_Fast_From_Now_On
178 [Documentation] Download pccmock.log and Log its contents.
179 ... Compute and Log the diff between expected and actual normalized responses.
180 ... Close both HTTP client session and SSH connection to Mininet.
181 SSHLibrary.Get_File pccmock.log
182 ${pccmocklog}= OperatingSystem.Run cat pccmock.log
183 BuiltIn.Log ${pccmocklog}
184 ${diff}= OperatingSystem.Run diff -dur ${directory_for_expected_responses} ${directory_for_actual_responses}
186 PcepOperations.Teardown_Pcep_Operations
187 ConfigViaRestconf.Teardown_Config_Via_Restconf
188 RequestsLibrary.Delete_All_Sessions
189 SSHLibrary.Close_All_Connections
191 Read_And_Fail_If_Prompt_Is_Seen
192 [Documentation] Try to read SSH to see prompt, but expect to see no prompt within SSHLibrary's timeout.
193 BuiltIn.Run_Keyword_And_Expect_Error No match found for '${prompt}' in *. Read_Text_Before_Prompt
195 Read_Text_Before_Prompt
196 [Documentation] Log text gathered by SSHLibrary.Read_Until_Prompt.
197 ... This needs to be a separate keyword just because how Read_And_Fail_If_Prompt_Is_Seen is implemented.
198 ${text}= SSHLibrary.Read_Until_Prompt
202 [Arguments] ${expected} ${name}
203 [Documentation] Get current pcep-topology as json, normalize both expected and actual json.
204 ... Save normalized jsons to files for later processing.
205 ... Error codes and normalized jsons should match exactly.
206 # FIXME: See bgpuser to move handling of expected outside WUKS loop, as in bgpuser suite.
207 ${normexp}= hsf_json.Hsf_Json ${expected}
208 BuiltIn.Log ${normexp}
209 OperatingSystem.Create_File ${directory_for_expected_responses}${/}${name} ${normexp}
210 ${resp}= RequestsLibrary.Get_Request ses topology/pcep-topology
212 BuiltIn.Log ${resp.text}
213 ${normresp}= hsf_json.Hsf_Json ${resp.text}
214 BuiltIn.Log ${normresp}
215 OperatingSystem.Create_File ${directory_for_actual_responses}${/}${name} ${normresp}
216 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
217 BuiltIn.Should_Be_Equal ${normresp} ${normexp}
219 Construct_Password_Element_Line_Using_Password
220 [Arguments] ${password}
221 [Documentation] Return line with password XML element containing given password, whitespace is there so that data to send looks neat.
222 ${element}= String.Replace_String ${SPACE}${SPACE}<password>$PASSWORD</password>${\n} $PASSWORD ${password}
223 BuiltIn.Log ${element}
226 Replace_Password_Xml_Element_In_Pcep_Client_Module
227 [Arguments] ${password_element}
228 [Documentation] Send restconf PUT to replace the config module specifying PCEP password element (may me empty=missing).
229 ${mapping_as_string}= BuiltIn.Set_Variable {'IP': '${MININET}', 'PASSWD': '''${password_element}'''}
230 BuiltIn.Log ${mapping_as_string}
231 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_topology_client_module ${mapping_as_string}