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 Suite Teardown Tear_It_Down
11 Library OperatingSystem
13 Library RequestsLibrary
14 Library ../../../libraries/norm_json.py
15 Resource ../../../libraries/NexusKeywords.robot
16 Resource ../../../libraries/PcepOperations.robot
17 Resource ../../../libraries/Utils.robot
18 Resource ../../../libraries/RemoteBash.robot
19 Resource ../../../libraries/TemplatedRequests.robot
20 Resource ../../../libraries/KarafKeywords.robot
21 Variables ../../../variables/Variables.py
22 Variables ../../../variables/pcepuser/variables.py ${TOOLS_SYSTEM_IP}
25 ${CONFIG_SESSION} session
26 ${PATH_SESSION_URI} node/pcc:%2F%2F${TOOLS_SYSTEM_IP}/path-computation-client
30 [Documentation] Compare current pcep-topology to off_json variable.
31 ... Timeout is long enough to ODL boot, to see that pcep is ready, with no PCC is connected.
33 Wait_Until_Keyword_Succeeds 300s 1s Compare_Topology ${off_json}
36 [Documentation] Execute pcc-mock on Mininet, fail is Open is not sent, keep it running for next tests.
37 ${command}= NexusKeywords.Compose_Full_Java_Command -jar ${filename} --local-address ${TOOLS_SYSTEM_IP} --remote-address ${ODL_SYSTEM_IP} 2>&1 | tee pccmock.log
40 Read_Until started, sent proposal Open
43 [Documentation] Compare pcep-topology to default_json, which includes a tunnel from pcc-mock.
44 ... Timeout is lower than in Precondition, as state from pcc-mock should be updated quickly.
46 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${default_json} ${PATH_SESSION_URI}
49 [Documentation] Perform update-lsp on the mocked tunnel, check response is success.
51 ${text}= Update_Xml_Lsp_Return_Json ${update_delegated_xml}
52 Pcep_Json_Is_Success ${text}
55 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel.
57 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_json} ${PATH_SESSION_URI}
59 Refuse_Remove_Delegated
60 [Documentation] Perform remove-lsp on the mocked tunnel, check that mock-pcc has refused to remove it.
62 ${text}= Remove_Xml_Lsp_Return_Json ${remove_delegated_xml}
63 Pcep_Json_Is_Refused ${text}
65 Topology_Still_Updated
66 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel, to verify that refusal did not break topology.
68 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_json} ${PATH_SESSION_URI}
71 [Documentation] Perform add-lsp to create new tunnel, check that response is success.
73 ${text}= Add_Xml_Lsp_Return_Json ${add_instantiated_xml}
74 Pcep_Json_Is_Success ${text}
76 Topology_Second_Default
77 [Documentation] Compare pcep-topology to default_json, which includes the updated delegated and default instantiated tunnel.
79 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_default_json} ${PATH_SESSION_URI}
82 [Documentation] Perform update-lsp on the newly instantiated tunnel, check that response is success.
84 ${text}= Update_Xml_Lsp_Return_Json ${update_instantiated_xml}
85 Pcep_Json_Is_Success ${text}
87 Topology_Second_Updated
88 [Documentation] Compare pcep-topology to default_json, which includes the updated delegated and updated instantiated tunnel.
90 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_updated_json} ${PATH_SESSION_URI}
93 [Documentation] Perform remove-lsp on the instantiated tunnel, check that response is success.
95 ${text}= Remove_Xml_Lsp_Return_Json ${remove_instantiated_xml}
96 Pcep_Json_Is_Success ${text}
98 Topology_Again_Updated
99 [Documentation] Compare pcep-topology to default_json, which includes the updated tunnel, to verify that instantiated tunnel was removed.
101 Wait_Until_Keyword_succeeds 10s 1s Compare_Topology ${updated_json} ${PATH_SESSION_URI}
104 [Documentation] Send ctrl+c to pcc-mock, fails if no prompt is seen
105 ... after 3 seconds (the default for SSHLibrary)
106 RemoteBash.Write_Bare_Ctrl_C
107 ${output}= SSHLibrary.Read_Until_Prompt
108 BuiltIn.Log ${output}
110 Topology_Postcondition
111 [Documentation] Compare curent pcep-topology to "off_json" again.
113 Wait_Until_Keyword_Succeeds 10s 1s Compare_Topology ${off_json}
117 [Documentation] Create SSH session to Mininet machine, prepare HTTP client session to Controller.
118 ... Figure out latest pcc-mock version and download it from Nexus to Mininet.
119 NexusKeywords.Initialize_Artifact_Deployment_And_Usage
120 RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
121 ${name}= NexusKeywords.Deploy_Test_Tool bgpcep pcep-pcc-mock
122 BuiltIn.Set_Suite_Variable ${filename} ${name}
123 PcepOperations.Setup_Pcep_Operations
126 [Documentation] Download pccmock.log and Log its contents.
127 ... Compute and Log the diff between expected and actual normalized responses.
128 ... Close both HTTP client session and SSH connection to Mininet.
129 SSHLibrary.Get_File pccmock.log
130 ${pccmocklog}= OperatingSystem.Run cat pccmock.log
131 BuiltIn.Log ${pccmocklog}
132 PcepOperations.Teardown_Pcep_Operations
134 Close_All_Connections
137 [Arguments] ${exp} ${uri}=${EMPTY}
138 [Documentation] Get current pcep-topology as json, compare both expected and actual json.
139 ... Error codes and normalized jsons should match exactly.
140 # TODO: Add Node Session State Check For Oxygen, see tcpmd5user
141 # TODO: Possibly remake all tests with TemplatedRequests
142 ${response}= RequestsLibrary.Get Request ${CONFIG_SESSION} ${OPERATIONAL_TOPO_API}/topology/pcep-topology/${uri}
143 BuiltIn.Should_Be_Equal_As_Strings ${response.status_code} 200
144 TemplatedRequests.Normalize_Jsons_And_Compare ${exp} ${response.text}