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 ... As dispatcher configuration differs between Lithium and Beryllium, two checks and two workarounds are needed.
72 ${success}= BuiltIn.Run_Keyword_And_Return_Status ConfigViaRestconf.Verify_Json_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_dispatcher_module
73 BuiltIn.Pass_Execution_If ${success} Bug 4267 not present, Beryllium data.
74 ${success}= BuiltIn.Run_Keyword_And_Return_Status ConfigViaRestconf.Verify_Json_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}lithium_pcep_dispatcher_module
75 BuiltIn.Pass_Execution_If ${success} Bug 4267 not present, Lithium data.
76 ${success}= BuiltIn.Run_Keyword_And_Return_Status ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_dispatcher_module
77 BuiltIn.Run_Keyword_If ${success} BuiltIn.Fail Bug 4267 present, Beryllium workaround successful.
78 ${success}= BuiltIn.Run_Keyword_And_Return_Status ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}lithium_pcep_dispatcher_module
79 BuiltIn.Run_Keyword_If ${success} BuiltIn.Fail Bug 4267 present, Lithium workaround successful.
80 BuiltIn.Fail Bug 4267 probably present. No workaround succeeded, so Bug 4491 is probably present too.
81 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
83 Topology_Unauthorized_2
84 [Documentation] The same logic as Topology_Unauthorized_1 as no password was provided to ODL.
86 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 030_Unauthorized_2.json
89 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
90 ... This password does not match what pcc-mock uses.
91 ${password_line}= Construct_Password_Element_Line_Using_Password changeme
92 BuiltIn.Log ${password_line}
93 Replace_Password_Xml_Element_In_Pcep_Client_Module ${password_line}
95 Topology_Unauthorized_3
96 [Documentation] The same logic as Topology_Unauthorized_1 as incorrect password was provided to ODL.
98 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 040_Unauthorized_3.json
101 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
102 ... This password finally matches what pcc-mock uses.
103 ${password_line}= Construct_Password_Element_Line_Using_Password topsecret
104 BuiltIn.Log ${password_line}
105 Replace_Password_Xml_Element_In_Pcep_Client_Module ${password_line}
107 Topology_Intercondition
108 [Documentation] Compare pcep-topology to filled one, which includes a tunnel from pcc-mock.
109 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${default_json} 050_Intercondition.json
112 [Documentation] Perform update-lsp on the mocked tunnel, check response is success.
113 ${text}= PcepOperations.Update_Xml_Lsp_Return_Json ${update_delegated_xml}
114 Pcep_Json_Is_Success ${text}
117 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel.
119 BuiltIn.Wait_Until_Keyword_succeeds 5s 1s Compare_Topology ${updated_json} 060_Topology_Updated.json
122 [Documentation] De-configure password for pcep dispatcher for client with Mininet IP address.
123 [Setup] FailFast.Run_Even_When_Failing_Fast
124 Replace_Password_Xml_Element_In_Pcep_Client_Module ${EMPTY}
125 FailFast.Do_Not_Fail_Fast_From_Now_On
126 # NOTE: It is still possible to remain failing, if both previous and this test failed.
127 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
129 Topology_Unauthorized_4
130 [Documentation] Wait for pcep-topology to become empty again.
132 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${offjson} 070_Unauthorized_4.json
135 [Documentation] Send ctrl+c to pcc-mock, fails if no prompt is seen
136 ... after 3 seconds (the default for SSHLibrary)
137 [Setup] FailFast.Run_Even_When_Failing_Fast
138 # FIXME: Bgpcepuser has Write_Ctrl_C keyword. Re-use it.
139 ${command}= BuiltIn.Evaluate chr(int(3))
140 BuiltIn.Log ${command}
141 SSHLibrary.Write ${command}
142 SSHLibrary.Read_Until_Prompt
143 FailFast.Do_Not_Fail_Fast_From_Now_On
144 # NOTE: It is still possible to remain failing, if both previous and this test failed.
145 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
147 Topology_Postcondition
148 [Documentation] Verify that pcep-topology stays empty.
150 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10 1 Compare_Topology ${offjson} 080_Postcondition.json
151 # FIXME: We should delete config changes to not affect next suite.
155 [Documentation] Create SSH session to Mininet machine, prepare HTTP client session to Controller.
156 ... Figure out latest pcc-mock version and download it from Nexus to Mininet.
157 ... Also, delete and create directories for json diff handling.
158 SSHLibrary.Open_Connection ${MININET}
159 SSHLibrary.Login_With_Public_Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
160 ${current_connection}= SSHLibrary.Get_Connection
161 ${current_prompt}= BuiltIn.Set_Variable ${current_connection.prompt}
162 BuiltIn.Log ${current_prompt}
163 BuiltIn.Set_Suite_Variable ${prompt} ${current_prompt}
164 RequestsLibrary.Create_Session ses http://${CONTROLLER}:${RESTCONFPORT}${OPERATIONAL_TOPO_API} auth=${AUTH}
165 # TODO: See corresponding bgpuser TODO.
166 ${urlbase}= BuiltIn.Set_Variable ${NEXUSURL_PREFIX}/content/repositories/opendaylight.snapshot/org/opendaylight/bgpcep/pcep-pcc-mock
167 ${version}= SSHLibrary.Execute_Command curl ${urlbase}/maven-metadata.xml | grep latest | cut -d '>' -f 2 | cut -d '<' -f 1
168 # TODO: Use RequestsLibrary and String instead of curl and bash utilities?
169 BuiltIn.Log ${version}
170 ${namepart}= SSHLibrary.Execute_Command curl ${urlbase}/${version}/maven-metadata.xml | grep value | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1
171 BuiltIn.Log ${namepart}
172 BuiltIn.Set_Suite_Variable ${filename} pcep-pcc-mock-${namepart}-executable.jar
173 BuiltIn.Log ${filename}
174 ${response}= SSHLibrary.Execute_Command wget -q -N ${urlbase}/${version}/${filename} 2>&1
175 BuiltIn.Log ${response}
176 OperatingSystem.Remove_Directory ${directory_for_expected_responses} recursive=True
177 OperatingSystem.Remove_Directory ${directory_for_actual_responses} recursive=True
178 # The previous suite may have been using the same directories.
179 OperatingSystem.Create_Directory ${directory_for_expected_responses}
180 OperatingSystem.Create_Directory ${directory_for_actual_responses}
181 ConfigViaRestconf.Setup_Config_Via_Restconf
182 PcepOperations.Setup_Pcep_Operations
183 FailFast.Do_Not_Fail_Fast_From_Now_On
186 [Documentation] Download pccmock.log and Log its contents.
187 ... Compute and Log the diff between expected and actual normalized responses.
188 ... Close both HTTP client session and SSH connection to Mininet.
189 SSHLibrary.Get_File pccmock.log
190 ${pccmocklog}= OperatingSystem.Run cat pccmock.log
191 BuiltIn.Log ${pccmocklog}
192 ${diff}= OperatingSystem.Run diff -dur ${directory_for_expected_responses} ${directory_for_actual_responses}
194 PcepOperations.Teardown_Pcep_Operations
195 ConfigViaRestconf.Teardown_Config_Via_Restconf
196 RequestsLibrary.Delete_All_Sessions
197 SSHLibrary.Close_All_Connections
199 Read_And_Fail_If_Prompt_Is_Seen
200 [Documentation] Try to read SSH to see prompt, but expect to see no prompt within SSHLibrary's timeout.
201 BuiltIn.Run_Keyword_And_Expect_Error No match found for '${prompt}' in *. Read_Text_Before_Prompt
203 Read_Text_Before_Prompt
204 [Documentation] Log text gathered by SSHLibrary.Read_Until_Prompt.
205 ... This needs to be a separate keyword just because how Read_And_Fail_If_Prompt_Is_Seen is implemented.
206 ${text}= SSHLibrary.Read_Until_Prompt
210 [Arguments] ${expected} ${name}
211 [Documentation] Get current pcep-topology as json, normalize both expected and actual json.
212 ... Save normalized jsons to files for later processing.
213 ... Error codes and normalized jsons should match exactly.
214 # FIXME: See bgpuser to move handling of expected outside WUKS loop, as in bgpuser suite.
215 ${normexp}= hsf_json.Hsf_Json ${expected}
216 BuiltIn.Log ${normexp}
217 OperatingSystem.Create_File ${directory_for_expected_responses}${/}${name} ${normexp}
218 ${resp}= RequestsLibrary.Get_Request ses topology/pcep-topology
220 BuiltIn.Log ${resp.text}
221 ${normresp}= hsf_json.Hsf_Json ${resp.text}
222 BuiltIn.Log ${normresp}
223 OperatingSystem.Create_File ${directory_for_actual_responses}${/}${name} ${normresp}
224 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
225 BuiltIn.Should_Be_Equal ${normresp} ${normexp}
227 Construct_Password_Element_Line_Using_Password
228 [Arguments] ${password}
229 [Documentation] Return line with password XML element containing given password, whitespace is there so that data to send looks neat.
230 ${element}= String.Replace_String ${SPACE}${SPACE}<password>$PASSWORD</password>${\n} $PASSWORD ${password}
231 BuiltIn.Log ${element}
234 Replace_Password_Xml_Element_In_Pcep_Client_Module
235 [Arguments] ${password_element}
236 [Documentation] Send restconf PUT to replace the config module specifying PCEP password element (may me empty=missing).
237 ${mapping_as_string}= BuiltIn.Set_Variable {'IP': '${MININET}', 'PASSWD': '''${password_element}'''}
238 BuiltIn.Log ${mapping_as_string}
239 ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf ${directory_with_template_folders}${/}pcep_topology_client_module ${mapping_as_string}