3 Library ./UtilLibrary.py
4 Resource KarafKeywords.txt
7 ${start} sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,1 --switch ovsk,protocols=OpenFlow13
12 [Documentation] Basic setup/cleanup work that can be done safely before any system
14 Log Start the test on the base edition
15 ${mininet_conn_id}= Open Connection ${MININET} prompt=${linux_prompt} timeout=30s
16 Set Suite Variable ${mininet_conn_id}
17 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
18 Execute Command sudo ovs-vsctl set-manager ptcp:6644
19 Execute Command sudo mn -c
25 [Documentation] Cleanup/Shutdown work that should be done at the completion of all
27 Log Stop the test on the base edition
28 Switch Connection ${mininet_conn_id}
31 Read Until ${linux_prompt}
34 Ensure All Nodes Are In Response
35 [Arguments] ${URI} ${node_list}
36 [Documentation] A GET is made to the supplied ${URI} and every item in the ${node_list}
37 ... is verified to exist in the repsonse. This keyword currently implies that it's node
38 ... specific but any list of strings can be given in ${node_list}. Refactoring of this
39 ... to make it more generic should be done. (see keyword "Check For Elements At URI")
40 : FOR ${node} IN @{node_list}
41 \ ${resp} RequestsLibrary.Get session ${URI}
42 \ Should Be Equal As Strings ${resp.status_code} 200
43 \ Should Contain ${resp.content} ${node}
47 [Documentation] A GET on the /node/${node} API is made and specific flow stat
48 ... strings are checked for existence.
49 ${resp} RequestsLibrary.Get session ${OPERATIONAL_NODES_API}/node/${node}
50 Should Be Equal As Strings ${resp.status_code} 200
51 Should Contain ${resp.content} flow-capable-node-connector-statistics
52 Should Contain ${resp.content} flow-table-statistics
54 Check That Port Count Is Ok
55 [Arguments] ${node} ${count}
56 [Documentation] A GET on the /port API is made and the specified port ${count} is
57 ... verified. A more generic Keyword "Check For Specific Number Of Elements At URI"
58 ... also does this work and further consolidation should be done.
59 ${resp} RequestsLibrary.Get session ${REST_CONTEXT}/${CONTAINER}/port
61 Should Be Equal As Strings ${resp.status_code} 200
62 Should Contain X Times ${resp.content} ${node} ${count}
64 Check For Specific Number Of Elements At URI
65 [Arguments] ${uri} ${element} ${expected_count}
66 [Documentation] A GET is made to the specified ${URI} and the specific count of a
67 ... given element is done (as supplied by ${element} and ${expected_count})
68 ${resp} RequestsLibrary.Get session ${uri}
70 Should Be Equal As Strings ${resp.status_code} 200
71 Should Contain X Times ${resp.content} ${element} ${expected_count}
73 Check For Elements At URI
74 [Arguments] ${uri} ${elements}
75 [Documentation] A GET is made at the supplied ${URI} and every item in the list of
76 ... ${elements} is verified to exist in the response
77 ${resp} RequestsLibrary.Get session ${uri}
79 Should Be Equal As Strings ${resp.status_code} 200
80 : FOR ${i} IN @{elements}
81 \ Should Contain ${resp.content} ${i}
83 Check For Elements Not At URI
84 [Arguments] ${uri} ${elements}
85 [Documentation] A GET is made at the supplied ${URI} and every item in the list of
86 ... ${elements} is verified to NOT exist in the response
87 ${resp} RequestsLibrary.Get session ${uri}
89 Should Be Equal As Strings ${resp.status_code} 200
90 : FOR ${i} IN @{elements}
91 \ Should Not Contain ${resp.content} ${i}
94 [Arguments] ${mininet_system}=${MININET}
95 Run Command On Remote System ${mininet_system} sudo mn -c
96 Run Command On Remote System ${mininet_system} sudo ps -elf | egrep 'usr/local/bin/mn' | egrep python | awk '{print "sudo kill -9",$4}' | sh
98 Extract Value From Content
99 [Arguments] ${content} ${index} ${strip}=nostrip
100 [Documentation] Will take the given response content and return the value at the given index as a string
101 ${value}= Get Json Value ${content} ${index}
102 ${value}= Convert To String ${value}
103 ${value}= Run Keyword If '${strip}' == 'strip' Strip Quotes ${value}
107 [Arguments] ${string_to_strip}
108 [Documentation] Will strip ALL quotes from given string and return the new string
109 ${string_to_return}= Replace String ${string_to_strip} " \ count=-1
110 [Return] ${string_to_return}
112 Run Command On Remote System
113 [Arguments] ${remote_system} ${cmd} ${user}=${MININET_USER} ${prompt}=${LINUX_PROMPT} ${prompt_timeout}=30s
114 [Documentation] Reduces the common work of running a command on a remote system to a single higher level robot keyword,
115 ... taking care to log in with a public key and. The command given is written and the output returned. No test conditions
117 Log Attempting to execute ${cmd} on ${remote_system}
118 ${conn_id}= SSHLibrary.Open Connection ${remote_system} prompt=${prompt} timeout=${prompt_timeout}
119 Login With Public Key ${user} ${USER_HOME}/.ssh/id_rsa any
120 SSHLibrary.Write ${cmd}
121 ${output}= SSHLibrary.Read Until ${linux_prompt}
122 SSHLibrary.Close Connection
125 Verify File Exists On Remote System
126 [Arguments] ${remote_system} ${file} ${user}=${MININET_USER} ${prompt}=${LINUX_PROMPT} ${prompt_timeout}=5s
127 [Documentation] Will create connection with public key and will PASS if the given ${file} exists, otherwise will FAIL
128 ${conn_id}= Open Connection ${remote_system} prompt=${prompt} timeout=${prompt_timeout}
129 Login With Public Key ${user} ${USER_HOME}/.ssh/id_rsa any
130 SSHLibrary.File Should Exist ${file}
133 Verify Controller Is Not Dead
134 [Arguments] ${controller_ip}=${CONTROLLER}
135 [Documentation] Will execute any tests to verify the controller is not dead. Some checks are
136 ... Out Of Memory Execptions.
137 Check Karaf Log File Does Not Have Messages ${controller_ip} java.lang.OutOfMemoryError