2 Documentation Basic tests for odl-bgpcep-pcep-all feature.
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 Library OperatingSystem
12 Library RequestsLibrary
13 Library ../../../libraries/norm_json.py
14 Resource ../../../libraries/NexusKeywords.robot
15 Resource ../../../libraries/PcepOperations.robot
16 Resource ../../../libraries/Utils.robot
17 Resource ../../../libraries/RemoteBash.robot
18 Resource ../../../libraries/TemplatedRequests.robot
19 Resource ../../../variables/Variables.robot
20 Variables ../../../variables/pcepuser/${ODL_STREAM}/variables.py ${TOOLS_SYSTEM_IP}
23 Suite Teardown Tear_It_Down
27 ${CONFIG_SESSION} session
28 ${PATH_SESSION_URI} node=pcc:%2F%2F${TOOLS_SYSTEM_IP}/network-topology-pcep:path-computation-client
29 ${PCEP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/pcepuser/${ODL_STREAM}
34 [Documentation] Compare current pcep-topology to off_json variable.
35 ... Timeout is long enough to ODL boot, to see that pcep is ready, with no PCC is connected.
37 Wait_Until_Keyword_Succeeds 300s 1s Compare_Topology ${off_json}
40 [Documentation] Execute pcc-mock on Mininet, fail is Open is not sent, keep it running for next tests.
41 ${command}= NexusKeywords.Compose_Full_Java_Command
42 ... -jar ${filename} --reconnect 1 --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_IP} 2>&1 | tee pccmock.log
45 Read_Until started, sent proposal Open
46 # Sleep required because of BGPCEP-890
49 Configure_Speaker_Entity_Identifier
50 [Documentation] Additional PCEP Speaker configuration for at least oxygen streams.
51 ... Allows PCEP speaker to determine if state synchronization can be skipped when a PCEP session is restarted.
52 &{mapping}= BuiltIn.Create_Dictionary IP=${ODL_SYSTEM_IP}
53 TemplatedRequests.Put_As_Xml_Templated
54 ... ${PCEP_VARIABLES_FOLDER}${/}node_speaker_entity_identifier
55 ... mapping=${mapping}
56 ... session=${CONFIG_SESSION}
59 [Documentation] Compare pcep-topology to default_json, which includes a tunnel from pcc-mock.
60 ... Timeout is lower than in Precondition, as state from pcc-mock should be updated quickly.
62 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${default_json} ${PATH_SESSION_URI}
65 [Documentation] Perform update-lsp on the mocked tunnel, check response is success.
67 ${text}= Update_Xml_Lsp_Return_Json ${update_delegated_xml}
70 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel.
72 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_json} ${PATH_SESSION_URI}
74 Refuse_Remove_Delegated
75 [Documentation] Perform remove-lsp on the mocked tunnel, check that mock-pcc has refused to remove it.
77 ${text}= Remove_Xml_Lsp_Return_Json ${remove_delegated_xml}
78 Pcep_Json_Is_Refused ${text}
80 Topology_Still_Updated
81 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel, to verify that refusal did not break topology.
83 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_json} ${PATH_SESSION_URI}
86 [Documentation] Perform add-lsp to create new tunnel, check that response is success.
88 ${text}= Add_Xml_Lsp_Return_Json ${add_instantiated_xml}
90 Topology_Second_Default
91 [Documentation] Compare pcep-topology to default_json, which includes the updated delegated and default instantiated tunnel.
93 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_default_json} ${PATH_SESSION_URI}
96 [Documentation] Perform update-lsp on the newly instantiated tunnel, check that response is success.
98 ${text}= Update_Xml_Lsp_Return_Json ${update_instantiated_xml}
100 Topology_Second_Updated
101 [Documentation] Compare pcep-topology to default_json, which includes the updated delegated and updated instantiated tunnel.
103 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_updated_json} ${PATH_SESSION_URI}
106 [Documentation] Perform remove-lsp on the instantiated tunnel, check that response is success.
108 ${text}= Remove_Xml_Lsp_Return_Json ${remove_instantiated_xml}
110 Topology_Again_Updated
111 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel, to verify that instantiated tunnel was removed.
113 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_json} ${PATH_SESSION_URI}
116 [Documentation] Send ctrl+c to pcc-mock, fails if no prompt is seen
117 ... after 3 seconds (the default for SSHLibrary)
118 RemoteBash.Write_Bare_Ctrl_C
119 ${output}= SSHLibrary.Read_Until_Prompt
120 BuiltIn.Log ${output}
122 Topology_Postcondition
123 [Documentation] Compare curent pcep-topology to "off_json" again.
125 Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${off_json}
130 [Documentation] Create SSH session to Mininet machine, prepare HTTP client session to Controller.
131 ... Figure out latest pcc-mock version and download it from Nexus to Mininet.
132 NexusKeywords.Initialize_Artifact_Deployment_And_Usage
133 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
134 ${name}= NexusKeywords.Deploy_Test_Tool bgpcep pcep-pcc-mock
135 BuiltIn.Set_Suite_Variable ${filename} ${name}
136 PcepOperations.Setup_Pcep_Operations
139 [Documentation] Download pccmock.log and Log its contents.
140 ... Compute and Log the diff between expected and actual normalized responses.
141 ... Close both HTTP client session and SSH connection to Mininet.
142 SSHLibrary.Get_File pccmock.log
143 ${pccmocklog}= OperatingSystem.Run cat pccmock.log
144 BuiltIn.Log ${pccmocklog}
145 PcepOperations.Teardown_Pcep_Operations
147 Close_All_Connections
150 [Documentation] Get current pcep-topology as json, compare both expected and actual json.
151 ... Error codes and normalized jsons should match exactly.
152 [Arguments] ${exp} ${uri}=${EMPTY}
153 # TODO: Add Node Session State Check For Oxygen, see tcpmd5user
154 # TODO: Possibly remake all tests with TemplatedRequests
155 ${topology_uri}= BuiltIn.Set_Variable_If
156 ... '${uri}'=='${EMPTY}'
157 ... ${REST_API}/${TOPOLOGY_URL}=pcep-topology?content=nonconfig
158 ... ${REST_API}/${TOPOLOGY_URL}=pcep-topology/${uri}?content=nonconfig
159 ${response}= RequestsLibrary.GET On Session ${CONFIG_SESSION} ${topology_uri} expected_status=200
160 TemplatedRequests.Normalize_Jsons_And_Compare ${exp} ${response.text}