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
12 Library SSHLibrary prompt=]>
13 Library ${CURDIR}/../../../libraries/RequestsLibrary.py
14 Library ${CURDIR}/../../../libraries/HsfJson/hsf_json.py
15 Variables ${CURDIR}/../../../variables/Variables.py
16 Variables ${CURDIR}/../../../variables/basicpcep/variables.py ${MININET}
19 ${ExpDir} ${CURDIR}/expected
20 ${ActDir} ${CURDIR}/actual
24 [Documentation] Compare current pcep-topology to "offjson" variable.
25 ... Timeout is long enough to see that pcep is ready, with no PCC is connected.
27 Wait_Until_Keyword_Succeeds 900 1 Compare_Topology ${offjson} Pre
30 [Documentation] Execute pcc-mock on Mininet, fail is Open is not sent, keep it running for next tests.
31 ${command}= Set_Variable java -jar ${filename} --local-address ${MININET} --remote-address ${CONTROLLER} 2>&1 | tee pccmock.log
34 Read_Until started, sent proposal Open
36 Topology_Intercondition
37 [Documentation] Compare pcep-topology to "onjson", which includes a tunnel from pcc-mock.
39 Wait_Until_Keyword_succeeds 30 1 Compare_Topology ${onjson} Inter
42 [Documentation] Send ctrl+c to pcc-mock, fails if no prompt is seen
43 ... after 3 seconds (the default for SSHLibrary)
44 ${command}= Evaluate chr(int(3))
49 Topology_Postcondition
50 [Documentation] Compare curent pcep-topology to "offjson" again.
51 ... Timeout is lower than in Precondition,
52 ... but data from pcc-mock should be gone quickly.
54 Wait_Until_Keyword_Succeeds 30 1 Compare_Topology ${offjson} Post
58 [Documentation] Create SSH session to Mininet machine, prepare HTTP client session to Controller.
59 ... Figure out latest pcc-mock version and download it from Nexus to Mininet.
60 ... Also, delete and create directories for json diff handling.
61 Open_Connection ${MININET}
62 Login_With_Public_Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
63 Create_Session ses http://${CONTROLLER}:8181/restconf/operational/network-topology:network-topology auth=${AUTH}
64 ${urlbase}= Set_Variable https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/bgpcep/pcep-pcc-mock
65 ${version}= Execute_Command curl ${urlbase}/maven-metadata.xml | grep latest | cut -d '>' -f 2 | cut -d '<' -f 1
67 ${namepart}= Execute_Command curl ${urlbase}/${version}/maven-metadata.xml | grep value | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1
69 Set_Suite_Variable ${filename} pcep-pcc-mock-${namepart}-executable.jar
71 ${response}= Execute_Command wget -q -N ${urlbase}/${version}/${filename} 2>&1
73 Remove_Directory ${ExpDir}
74 Remove_Directory ${ActDir}
75 Create_Directory ${ExpDir}
76 Create_Directory ${ActDir}
79 [Arguments] ${expected} ${name}
80 [Documentation] Get current pcep-topology as json, normalize both expected and actual json.
81 ... Save normalized jsons to files for later processing.
82 ... Error codes and normalized jsons should match exactly.
83 ${normexp}= Hsf_Json ${expected}
85 Create_File ${ExpDir}${/}${name} ${normexp}
86 ${resp}= RequestsLibrary.Get ses topology/pcep-topology
89 ${normresp}= Hsf_Json ${resp.text}
91 Create_File ${ActDir}${/}${name} ${normresp}
92 Should_Be_Equal_As_Strings ${resp.status_code} 200
93 Should_Be_Equal ${normresp} ${normexp}
96 [Documentation] Download pccmock.log and Log its contents.
97 ... Compute and Log the diff between expected and actual normalized responses.
98 ... Close both HTTP client session and SSH connection to Mininet.
99 SSHLibrary.Get_File pccmock.log
100 ${pccmocklog}= Run cat pccmock.log
102 ${diff}= Run diff -dur ${ExpDir} ${ActDir}
105 Close_All_Connections