3 Library ./UtilLibrary.py
6 ${start} sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,1 --switch ovsk,protocols=OpenFlow13
10 [Documentation] Basic setup/cleanup work that can be done safely before any system
12 Log Start the test on the base edition
13 Open Connection ${MININET} prompt=> timeout=30s
14 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
15 Write sudo ovs-vsctl set-manager ptcp:6644
24 [Documentation] Cleanup/Shutdown work that should be done at the completion of all
26 Log Stop the test on the base edition
32 Ensure All Nodes Are In Response
33 [Arguments] ${URI} ${node_list}
34 [Documentation] A GET is made to the supplied ${URI} and every item in the ${node_list}
35 ... is verified to exist in the repsonse. This keyword currently implies that it's node
36 ... specific but any list of strings can be given in ${node_list}. Refactoring of this
37 ... to make it more generic should be done. (see keyword "Check For Elements At URI")
38 : FOR ${node} IN @{node_list}
39 \ ${resp} RequestsLibrary.Get session ${URI}
40 \ Should Be Equal As Strings ${resp.status_code} 200
41 \ Should Contain ${resp.content} ${node}
45 [Documentation] A GET on the /node/${node} API is made and specific flow stat
46 ... strings are checked for existence.
47 ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/node/${node}
48 Should Be Equal As Strings ${resp.status_code} 200
49 Should Contain ${resp.content} flow-capable-node-connector-statistics
50 Should Contain ${resp.content} flow-table-statistics
52 Check That Port Count Is Ok
53 [Arguments] ${node} ${count}
54 [Documentation] A GET on the /port API is made and the specified port ${count} is
55 ... verified. A more generic Keyword "Check For Specific Number Of Elements At URI"
56 ... also does this work and further consolidation should be done.
57 ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/${CONTAINER}/port
59 Should Be Equal As Strings ${resp.status_code} 200
60 Should Contain X Times ${resp.content} ${node} ${count}
62 Check For Specific Number Of Elements At URI
63 [Arguments] ${uri} ${element} ${expected_count}
64 [Documentation] A GET is made to the specified ${URI} and the specific count of a
65 ... given element is done (as supplied by ${element} and ${expected_count})
66 ${resp} RequestsLibrary.Get session ${uri}
68 Should Be Equal As Strings ${resp.status_code} 200
69 Should Contain X Times ${resp.content} ${element} ${expected_count}
71 Check For Elements At URI
72 [Arguments] ${uri} ${elements}
73 [Documentation] A GET is made at the supplied ${URI} and every item in the list of
74 ... ${elements} is verified to exist in the response
75 ${resp} RequestsLibrary.Get session ${uri}
77 Should Be Equal As Strings ${resp.status_code} 200
78 : FOR ${i} IN @{elements}
79 \ Should Contain ${resp.content} ${i}
81 Check For Elements Not At URI
82 [Arguments] ${uri} ${elements}
83 [Documentation] A GET is made at the supplied ${URI} and every item in the list of
84 ... ${elements} is verified to NOT exist in the response
85 ${resp} RequestsLibrary.Get session ${uri}
87 Should Be Equal As Strings ${resp.status_code} 200
88 : FOR ${i} IN @{elements}
89 \ Should Not Contain ${resp.content} ${i}
91 Extract Value From Content
92 [Arguments] ${content} ${index} ${strip}=nostrip
93 [Documentation] Will take the given response content and return the value at the given index as a string
94 ${value}= Get Json Value ${content} ${index}
95 ${value}= Convert To String ${value}
96 ${value}= Run Keyword If '${strip}' == 'strip' Strip Quotes ${value}
100 [Arguments] ${string_to_strip}
101 [Documentation] Will strip ALL quotes from given string and return the new string
102 ${string_to_return}= Replace String ${string_to_strip} " \ count=-1
103 [Return] ${string_to_return}