3 Library ./UtilLibrary.py
6 ${start} sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,1 --switch ovsk,protocols=OpenFlow13
11 [Documentation] Basic setup/cleanup work that can be done safely before any system
13 Log Start the test on the base edition
14 ${mininet_conn_id}= Open Connection ${MININET} prompt=${linux_prompt} timeout=30s
15 Set Suite Variable ${mininet_conn_id}
16 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
17 Write sudo ovs-vsctl set-manager ptcp:6644
18 Read Until ${linux_prompt}
20 Read Until ${linux_prompt}
26 [Documentation] Cleanup/Shutdown work that should be done at the completion of all
28 Log Stop the test on the base edition
29 Switch Connection ${mininet_conn_id}
32 Read Until ${linux_prompt}
35 Ensure All Nodes Are In Response
36 [Arguments] ${URI} ${node_list}
37 [Documentation] A GET is made to the supplied ${URI} and every item in the ${node_list}
38 ... is verified to exist in the repsonse. This keyword currently implies that it's node
39 ... specific but any list of strings can be given in ${node_list}. Refactoring of this
40 ... to make it more generic should be done. (see keyword "Check For Elements At URI")
41 : FOR ${node} IN @{node_list}
42 \ ${resp} RequestsLibrary.Get session ${URI}
43 \ Should Be Equal As Strings ${resp.status_code} 200
44 \ Should Contain ${resp.content} ${node}
48 [Documentation] A GET on the /node/${node} API is made and specific flow stat
49 ... strings are checked for existence.
50 ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/node/${node}
51 Should Be Equal As Strings ${resp.status_code} 200
52 Should Contain ${resp.content} flow-capable-node-connector-statistics
53 Should Contain ${resp.content} flow-table-statistics
55 Check That Port Count Is Ok
56 [Arguments] ${node} ${count}
57 [Documentation] A GET on the /port API is made and the specified port ${count} is
58 ... verified. A more generic Keyword "Check For Specific Number Of Elements At URI"
59 ... also does this work and further consolidation should be done.
60 ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/${CONTAINER}/port
62 Should Be Equal As Strings ${resp.status_code} 200
63 Should Contain X Times ${resp.content} ${node} ${count}
65 Check For Specific Number Of Elements At URI
66 [Arguments] ${uri} ${element} ${expected_count}
67 [Documentation] A GET is made to the specified ${URI} and the specific count of a
68 ... given element is done (as supplied by ${element} and ${expected_count})
69 ${resp} RequestsLibrary.Get session ${uri}
71 Should Be Equal As Strings ${resp.status_code} 200
72 Should Contain X Times ${resp.content} ${element} ${expected_count}
74 Check For Elements At URI
75 [Arguments] ${uri} ${elements}
76 [Documentation] A GET is made at the supplied ${URI} and every item in the list of
77 ... ${elements} is verified to exist in the response
78 ${resp} RequestsLibrary.Get session ${uri}
80 Should Be Equal As Strings ${resp.status_code} 200
81 : FOR ${i} IN @{elements}
82 \ Should Contain ${resp.content} ${i}
84 Check For Elements Not At URI
85 [Arguments] ${uri} ${elements}
86 [Documentation] A GET is made at the supplied ${URI} and every item in the list of
87 ... ${elements} is verified to NOT exist in the response
88 ${resp} RequestsLibrary.Get session ${uri}
90 Should Be Equal As Strings ${resp.status_code} 200
91 : FOR ${i} IN @{elements}
92 \ Should Not Contain ${resp.content} ${i}
94 Extract Value From Content
95 [Arguments] ${content} ${index} ${strip}=nostrip
96 [Documentation] Will take the given response content and return the value at the given index as a string
97 ${value}= Get Json Value ${content} ${index}
98 ${value}= Convert To String ${value}
99 ${value}= Run Keyword If '${strip}' == 'strip' Strip Quotes ${value}
103 [Arguments] ${string_to_strip}
104 [Documentation] Will strip ALL quotes from given string and return the new string
105 ${string_to_return}= Replace String ${string_to_strip} " \ count=-1
106 [Return] ${string_to_return}
108 Run Command On Remote System
109 [Arguments] ${remote_system} ${cmd} ${user}=${MININET_USER} ${prompt}=${LINUX_PROMPT} ${prompt_timeout}=30s
110 [Documentation] Reduces the common work of running a command on a remote system to a single higher level robot keyword,
111 ... taking care to log in with a public key and. The command given is written and the output returned. No test conditions
113 Log Attempting to execute ${cmd} on ${remote_system}
114 ${conn_id}= Open Connection ${remote_system} prompt=${prompt} timeout=${prompt_timeout}
115 Login With Public Key ${user} ${USER_HOME}/.ssh/id_rsa any
117 ${output}= Read Until ${linux_prompt}
120 Verify File Exists On Remote System
121 [Arguments] ${remote_system} ${file} ${user}=${MININET_USER} ${prompt}=${LINUX_PROMPT} ${prompt_timeout}=5s
122 [Documentation] Will create connection with public key and will PASS if the given ${file} exists, otherwise will FAIL
123 ${conn_id}= Open Connection ${remote_system} prompt=${prompt} timeout=${prompt_timeout}
124 Login With Public Key ${user} ${USER_HOME}/.ssh/id_rsa any
125 SSHLibrary.File Should Exist ${file}