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/norm_json.py
22 Resource ${CURDIR}/../../../libraries/FailFast.robot
23 Resource ${CURDIR}/../../../libraries/NexusKeywords.robot
24 Resource ${CURDIR}/../../../libraries/PcepOperations.robot
25 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
26 Resource ${CURDIR}/../../../libraries/WaitForFailure.robot
27 Variables ${CURDIR}/../../../variables/Variables.py
28 Variables ${CURDIR}/../../../variables/pcepuser/variables.py ${TOOLS_SYSTEM_IP}
31 ${directory_for_actual_responses} ${TEMPDIR}${/}actual
32 ${directory_for_expected_responses} ${TEMPDIR}${/}expected
33 ${directory_with_template_folders} ${CURDIR}/../../../variables/tcpmd5user/
37 [Documentation] Compare current pcep-topology to empty one.
38 ... Timeout is long enough to see that pcep is ready, with no PCC is connected.
40 BuiltIn.Wait_Until_Keyword_Succeeds 300 1 Compare_Topology ${off_json} 010_Precondition.json
43 [Documentation] Execute pcc-mock on Mininet with password set, fail if pcc-mock promptly exits. Keep pcc-mock running for next test cases.
44 ${command}= NexusKeywords.Compose_Full_Java_Command -jar ${filename} --password topsecret --reconnect 1 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_IP} 2>&1 | tee pccmock.log
45 BuiltIn.Log ${command}
46 SSHLibrary.Write ${command}
47 Read_And_Fail_If_Prompt_Is_Seen
49 Topology_Unauthorized_1
50 [Documentation] Try to catch a glimpse of pcc-mock in pcep-topology. Pass if no change from Precondition is detected over 1 minute.
52 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 020_Unauthorized_1.json
54 Topology_Unauthorized_2
55 [Documentation] The same logic as Topology_Unauthorized_1 as no password was provided to ODL.
57 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 030_Unauthorized_2.json
60 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
61 ... This password does not match what pcc-mock uses.
62 ${password_line}= Construct_Password_Element_Line_Using_Password changeme
63 BuiltIn.Log ${password_line}
64 Replace_Password_Xml_Element_In_Pcep_Client_Module ${password_line}
66 Topology_Unauthorized_3
67 [Documentation] The same logic as Topology_Unauthorized_1 as incorrect password was provided to ODL.
69 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10s 1s Compare_Topology ${off_json} 040_Unauthorized_3.json
72 [Documentation] Configure password in pcep dispatcher for client with Mininet IP address.
73 ... This password finally matches what pcc-mock uses.
74 ${password_line}= Construct_Password_Element_Line_Using_Password topsecret
75 BuiltIn.Log ${password_line}
76 Replace_Password_Xml_Element_In_Pcep_Client_Module ${password_line}
78 Topology_Intercondition
79 [Documentation] Compare pcep-topology to filled one, which includes a tunnel from pcc-mock.
80 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${default_json} 050_Intercondition.json
83 [Documentation] Perform update-lsp on the mocked tunnel, check response is success.
84 ${text}= PcepOperations.Update_Xml_Lsp_Return_Json ${update_delegated_xml}
85 Pcep_Json_Is_Success ${text}
88 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel.
90 BuiltIn.Wait_Until_Keyword_succeeds 5s 1s Compare_Topology ${updated_json} 060_Topology_Updated.json
93 [Documentation] De-configure password for pcep dispatcher for client with Mininet IP address.
94 [Setup] FailFast.Run_Even_When_Failing_Fast
95 Replace_Password_Xml_Element_In_Pcep_Client_Module ${EMPTY}
96 FailFast.Do_Not_Fail_Fast_From_Now_On
97 # NOTE: It is still possible to remain failing, if both previous and this test failed.
98 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
100 Topology_Unauthorized_4
101 [Documentation] Wait for pcep-topology to become empty again.
103 BuiltIn.Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${offjson} 070_Unauthorized_4.json
106 [Documentation] Send ctrl+c to pcc-mock, fails if no prompt is seen
107 ... after 3 seconds (the default for SSHLibrary)
108 [Setup] FailFast.Run_Even_When_Failing_Fast
109 # FIXME: Bgpcepuser has Write_Ctrl_C keyword. Re-use it.
110 ${command}= BuiltIn.Evaluate chr(int(3))
111 BuiltIn.Log ${command}
112 SSHLibrary.Write ${command}
113 SSHLibrary.Read_Until_Prompt
114 FailFast.Do_Not_Fail_Fast_From_Now_On
115 # NOTE: It is still possible to remain failing, if both previous and this test failed.
116 [Teardown] FailFast.Do_Not_Start_Failing_If_This_Failed
118 Topology_Postcondition
119 [Documentation] Verify that pcep-topology stays empty.
121 WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 10 1 Compare_Topology ${offjson} 080_Postcondition.json
122 # FIXME: We should delete config changes to not affect next suite.
126 [Documentation] Create SSH session to Mininet machine, prepare HTTP client session to Controller.
127 ... Figure out latest pcc-mock version and download it from Nexus to Mininet.
128 ... Also, delete and create directories for json diff handling.
129 NexusKeywords.Initialize_Artifact_Deployment_And_Usage
130 ${current_connection}= SSHLibrary.Get_Connection
131 ${current_prompt}= BuiltIn.Set_Variable ${current_connection.prompt}
132 BuiltIn.Log ${current_prompt}
133 BuiltIn.Set_Suite_Variable ${prompt} ${current_prompt}
134 RequestsLibrary.Create_Session ses http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_TOPO_API} auth=${AUTH}
135 ${name}= NexusKeywords.Deploy_Test_Tool bgpcep pcep-pcc-mock
136 BuiltIn.Set_Suite_Variable ${filename} ${name}
137 OperatingSystem.Remove_Directory ${directory_for_expected_responses} recursive=True
138 OperatingSystem.Remove_Directory ${directory_for_actual_responses} recursive=True
139 # The previous suite may have been using the same directories.
140 OperatingSystem.Create_Directory ${directory_for_expected_responses}
141 OperatingSystem.Create_Directory ${directory_for_actual_responses}
142 TemplatedRequests.Create_Default_Session
143 PcepOperations.Setup_Pcep_Operations
144 FailFast.Do_Not_Fail_Fast_From_Now_On
147 [Documentation] Download pccmock.log and Log its contents.
148 ... Compute and Log the diff between expected and actual normalized responses.
149 ... Close both HTTP client session and SSH connection to Mininet.
150 SSHLibrary.Get_File pccmock.log
151 ${pccmocklog}= OperatingSystem.Run cat pccmock.log
152 BuiltIn.Log ${pccmocklog}
153 ${diff}= OperatingSystem.Run diff -dur ${directory_for_expected_responses} ${directory_for_actual_responses}
155 PcepOperations.Teardown_Pcep_Operations
156 RequestsLibrary.Delete_All_Sessions
157 SSHLibrary.Close_All_Connections
159 Read_And_Fail_If_Prompt_Is_Seen
160 [Documentation] Try to read SSH to see prompt, but expect to see no prompt within SSHLibrary's timeout.
161 BuiltIn.Run_Keyword_And_Expect_Error No match found for '${prompt}' in *. Read_Text_Before_Prompt
163 Read_Text_Before_Prompt
164 [Documentation] Log text gathered by SSHLibrary.Read_Until_Prompt.
165 ... This needs to be a separate keyword just because how Read_And_Fail_If_Prompt_Is_Seen is implemented.
166 ${text}= SSHLibrary.Read_Until_Prompt
170 [Arguments] ${expected} ${name}
171 [Documentation] Get current pcep-topology as json, normalize both expected and actual json.
172 ... Save normalized jsons to files for later processing.
173 ... Error codes and normalized jsons should match exactly.
174 # FIXME: See bgpuser to move handling of expected outside WUKS loop, as in bgpuser suite.
175 ${normexp}= norm_json.normalize_json_text ${expected}
176 BuiltIn.Log ${normexp}
177 OperatingSystem.Create_File ${directory_for_expected_responses}${/}${name} ${normexp}
178 ${resp}= RequestsLibrary.Get_Request ses topology/pcep-topology
180 BuiltIn.Log ${resp.text}
181 ${normresp}= norm_json.normalize_json_text ${resp.text}
182 BuiltIn.Log ${normresp}
183 OperatingSystem.Create_File ${directory_for_actual_responses}${/}${name} ${normresp}
184 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
185 BuiltIn.Should_Be_Equal ${normresp} ${normexp}
187 Construct_Password_Element_Line_Using_Password
188 [Arguments] ${password}
189 [Documentation] Return line with password XML element containing given password, whitespace is there so that data to send looks neat.
190 ${element}= String.Replace_String ${SPACE}${SPACE}<password>$PASSWORD</password>${\n} $PASSWORD ${password}
191 BuiltIn.Log ${element}
194 Replace_Password_Xml_Element_In_Pcep_Client_Module
195 [Arguments] ${password_element}
196 [Documentation] Send restconf PUT to replace the config module specifying PCEP password element (may me empty=missing).
197 &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} PASSWD=${password_element}
198 TemplatedRequests.Put_As_Xml_Templated ${directory_with_template_folders}${/}pcep_topology_client_module mapping=${mapping}