2 Library RequestsLibrary
4 Library OperatingSystem
9 Variables ../variables/Variables.py
15 ${HBASE_CLIENT} /tmp/Hbase/hbase-0.94.27/bin
16 ${CASSANDRA_CLIENT} /tmp/cassandra/apache-cassandra-2.1.16/bin
18 ${prompt_timeout} ${EMPTY}
19 ${CASSANDRA_DB_PATH} /tmp/cassandra/apache-cassandra-2.1.16/
20 ${metric_path} metricpath
21 ${metric_val} metricval
22 ${metric_log} metriclog
23 ${temp_metric_val} temp_metric_val
25 ${KARAF_PATH} ${WORKSPACE}/${BUNDLEFOLDER}
26 ${TSDR_PATH} ${KARAF_PATH}/tsdr
27 ${PURGE_PATH} ${KARAF_PATH}/etc/tsdr.data.purge.cfg
28 ${SNMP_PATH} ${KARAF_PATH}/etc/tsdr.snmp.cfg
29 ${SNMP_COMMUNITY} mib2dev\/if-mib
30 &{HEADERS_QUERY} Content-Type=application/json Content-Type=application/json
31 &{OPER_STATUS} up=1 down=2 testing=3 unknown=4 dormant=5 notPresent=6 lowerLayerDown=7
32 &{syslog_facility} kern=0
34 ... Oct 29 18:10:31: ODL: %STKUNIT0-M:CP %IFMGR-5-ASTATE_UP: Changed interface Admin state to up: Te 0/0
35 ${MESSAGE_PATTERN} Changed interface
40 [Documentation] TSDR specific setup/cleanup work that can be done safely before any system.
42 [Arguments] ${switch}=ovsk ${switch_count}=3
44 ${mininet_conn_id1}= Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=120s
45 Set Suite Variable ${mininet_conn_id1}
46 Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
47 Execute Command sudo ovs-vsctl set-manager ptcp:6644
48 ${start}= Set Variable
49 ... sudo mn --controller=remote,ip=${ODL_SYSTEM_IP} --topo=linear,${switch_count} --switch ${switch},protocols=OpenFlow13
55 [Documentation] Configure Netflow
56 [Arguments] ${user}=${TOOLS_SYSTEM_USER}
57 ${output}= Run Command On Controller
58 ... ${TOOLS_SYSTEM_IP}
59 ... sudo ovs-vsctl -- set Bridge s1 netflow=@nf -- --id=@nf create NetFlow target=\\"${ODL_SYSTEM_IP}:${NETFLOW_PORT}\\" active-timeout=10
63 [Documentation] Ping between all hosts in mininet topology.
64 [Arguments] ${switch}=ovsk
65 Switch Connection ${mininet_conn_id1}
70 [Documentation] Ping between ${host1} and ${host2}
71 [Arguments] ${host1} ${host2}
72 Switch Connection ${mininet_conn_id1}
73 Write pingpair ${host1} ${host2}
77 [Documentation] Ping between h1 and h2 and check Hbase
78 [Arguments] ${pattern}
80 ${query_output}= Query the Data from HBaseClient count 'NETFLOW'
81 Should Match Regexp ${query_output} ${pattern}
83 Ping Pair Hosts Cassandra
84 [Documentation] Ping between h1 and h2 and check Cassandra
85 [Arguments] ${pattern}
87 ${query_output}= Count Cassandra rows select count(*) from tsdr.metriclog;
88 Should Match Regexp ${query_output} ${pattern}
90 Ping Pair Hosts HSQLDB
91 [Documentation] Iperf between h1 and h2 and check Cassandra
92 [Arguments] ${pattern}
94 ${query_output}= Issue Command On Karaf Console tsdr:list NETFLOW | wc -l
95 Should Match Regexp ${query_output} ${pattern}
98 [Documentation] Cleanup/Shutdown work that should be done at the completion of all
100 Switch Connection ${mininet_conn_id1}
103 Read Until ${DEFAULT_LINUX_PROMPT}
107 [Documentation] Write Purge file and copy it to directory.127.0.0.1 refers local controller
108 [Arguments] ${HOST}=127.0.0.1 ${purge_enabled}=true ${purge_time}=00:00:00 ${purge_interval}=1400 ${retention}=0
109 Create File purge.cfg \#TSDR Project Configuration file
110 Append To File purge.cfg \n
111 Append To File purge.cfg host=${HOST}
112 Append To File purge.cfg \n
113 Append To File purge.cfg data_purge_enabled=${purge_enabled}
114 Append To File purge.cfg \n
115 Append To File purge.cfg data_purge_time=${purge_time}
116 Append To File purge.cfg \n
117 Append To File purge.cfg data_purge_interval_in_minutes=${purge_interval}
118 Append To File purge.cfg \n
119 Append To File purge.cfg retention_time_in_hours=${retention}
120 Append To File purge.cfg \n
121 Move File purge.cfg ${PURGE_PATH}
123 Initialize the HBase for TSDR
124 [Documentation] Install and initialize the tsdr tables on HBase Server
125 ${hbase_server}= Run Command On Remote System
127 ... export JAVA_HOME=/usr && ${HBASE_CLIENT}/start-hbase.sh
128 ... ${TOOLS_SYSTEM_USER}
129 ... ${prompt_timeout}=120
131 ${hbase_process}= Run Command On Remote System ${ODL_SYSTEM_IP} ps -ef | grep HMaster
134 Stop the HBase Server
135 [Documentation] Stop the HBase server
136 ${hbase_server}= Run Command On Remote System
138 ... export JAVA_HOME=/usr && ${HBASE_CLIENT}/stop-hbase.sh
139 ... ${TOOLS_SYSTEM_USER}
140 ... ${prompt_timeout}=90
143 Configure the Queue on Switch
144 [Documentation] Configure the 2 queues on specified openvswitch interface
145 [Arguments] ${queue_interface} ${user}=${TOOLS_SYSTEM_USER}
146 Log Configure the queue on ${queue_interface}
147 ${output}= Run Command On Remote System
148 ... ${TOOLS_SYSTEM_IP}
149 ... sudo ovs-vsctl set port ${queue_interface} qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=200000000 queues=0=@q0,1=@q1,2=@q2 -- --id=@q0 create queue other-config:min-rate=100000 other-config:max-rate=200000 -- --id=@q1 create queue other-config:min-rate=10001 other-config:max-rate=300000 -- --id=@q2 create queue other-config:min-rate=300001 other-config:max-rate=200000000
152 Query the Data from HBaseClient
153 [Documentation] Execute the HBase Query and return the result
154 [Arguments] ${query} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
155 Log Attempting to execute ${query} on ${remote} via HbaseClient
156 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
157 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
158 Write export JAVA_HOME=/usr
159 Write ${HBASE_CLIENT}/hbase shell
160 Read Until hbase(main):001:0>
162 ${output}= Read Until hbase(main):
165 Comment ${output}= Read Until ${DEFAULT_LINUX_PROMPT}
169 Verify the Metric is Collected?
170 [Documentation] Verify the ${tsdr_cmd} output contains ${metric}
171 [Arguments] ${tsdr_cmd} ${metric} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
172 ${output}= Issue Command On Karaf Console
175 ... ${KARAF_SHELL_PORT}
176 ... ${prompt_timeout}
177 Should Contain ${output} ${metric}
180 [Documentation] Prepare the Hbase Filter from Tsdr List output
181 [Arguments] ${left_str} ${right_str} ${connector}
182 ${left_str}= Remove Space on String ${left_str}
183 ${right_str}= Remove Space on String ${right_str} 1
184 IF '${left_str}' == 'MetricID'
185 ${x}= Catenate ${SPACE} _
186 ELSE IF '${left_str}' == 'ObjectKeys'
187 ${x}= Catenate ${right_str} _
188 ELSE IF '${left_str}' == 'TimeStamp'
189 ${x}= Get Epoch Time ${right_str}
191 ${x}= Catenate ${SPACE}
195 Create the Hbase table row
196 [Documentation] Create the Hbase table row from tsdr:list
197 [Arguments] ${tsdr_line} ${metrics}
198 @{words}= Split String ${tsdr_line} |
199 FOR ${li} IN @{words}
200 ${key}= Fetch From Left ${li} =
201 ${value}= Fetch From Right ${li} =
202 ${each_value}= Prepare HBase Filter ${key} ${value} _
203 ${final}= Concatenate the String ${final} ${each_value}
205 ${query}= Concatenate the String ${metrics} ${final}
206 ${query}= Remove Space on String ${query}
209 Initialize Cassandra Tables
210 [Documentation] Truncate Existing tables in Cassandra to Start it fresh.
211 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
212 Log Attempting to truncate tables in Cassandra
213 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${key_table}
214 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${val_table}
215 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
216 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
217 Write export JAVA_HOME=/usr
218 Write ${CASSANDRA_CLIENT}/cqlsh
220 Write TRUNCATE tsdr.${key_table} ;
222 Write TRUNCATE tsdr.${val_table} ;
227 Initialize Cassandra Tables Metricval
228 [Documentation] Truncate Existing tables in Cassandra to Start it fresh
229 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
230 Log Attempting to truncate tables in Cassandra
231 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${key_table}
232 Run Command On Remote System ${ODL_SYSTEM_IP} sudo rm -rf ${CASSANDRA_DB_PATH}${val_table}
233 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
234 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
235 Write export JAVA_HOME=/usr
236 Write ${CASSANDRA_CLIENT}/cqlsh
238 Write TRUNCATE tsdr.${val_table} ;
243 Query Metrics on H2 Datastore
244 [Documentation] Generate the JDBC query for H2 Datastore
245 [Arguments] ${category} ${attribute} ${nodeid}=openflow:1
246 ${h2_query}= Concatenate the String
247 ... jdbc:query metric "select * from Metric where MetricCategory=
248 ... '${category}' and
249 ${h2_query}= Concatenate the String
251 ... MetricName = '${attribute}' and NODEID = '${nodeid}' order by ID desc limit 5"
252 ${output}= Issue Command On Karaf Console ${h2_query} ${ODL_SYSTEM_IP} ${KARAF_SHELL_PORT} 30
256 [Documentation] Scan the Hbase Table with Filter
257 [Arguments] ${table} ${filter} ${metric}
258 ${hbase_query}= Concatenate the String scan '${table}'
259 ${hbase_query}= Concatenate the String ${hbase_query} ,{ FILTER =>\"(RowFilter(=,
260 ${hbase_query}= Concatenate the String ${hbase_query} 'regexstring:${filter}*\')) AND (RowFilter(=,
261 ${hbase_query}= Concatenate the String ${hbase_query} 'regexstring:${metric}*\'))\",LIMIT=>10}
262 RETURN ${hbase_query}
265 [Documentation] Get Metric Value from tsdr:list
266 [Arguments] ${tsdr_line}
267 ${value}= Fetch From Right ${tsdr_line} |
268 ${value}= Replace String ${value} MetricValue value
269 ${value}= Replace String ${value} [m ${EMPTY}
270 ${value}= Replace String ${value} = \=
271 ${value}= Remove Space on String ${value}
272 ${value}= Convert to String ${value}
275 Verify the Metrics Attributes on Hbase Client
276 [Documentation] Verification on Metrics attributes on Hbase Client
277 [Arguments] ${attribute} ${rowfilter} ${table}=PortStats
278 ${query}= Generate HBase Query ${table} ${rowfilter} ${attribute}
279 ${out}= Query the Data from HBaseClient ${query}
280 Should Match Regexp ${out} (?mui)value
282 Verify the Metrics Attributes on Cassandra Client
283 [Documentation] Verification on Metrics attributes on Cassandra Client
284 [Arguments] ${pattern}
285 @{metric_row}= Find Metricval Keys ${pattern} metricpath
286 ${keya}= Get From List ${metric_row} 1
287 ${keyb}= Get From List ${metric_row} 2
288 ${keya_bool}= Evaluate ${keya} < 0
289 IF '${keya_bool}' == 'True'
290 ${keya}= Catenate SEPARATOR= \\ ${keya}
292 ${keya}= Catenate ${keya}
294 ${metricval}= Create Temporary Key Info ${keya} ${keyb}
295 @{lines}= Split to lines ${metricval}
296 ${mv_len}= Get Length ${lines}
297 ${mv_len}= Evaluate ${mv_len} - 1
298 ${found_line}= Get From List ${lines} ${mv_len}
299 @{split_line}= Split String ${found_line} ${SPACE}
300 ${metric_count}= Get From List ${split_line} 3
301 RETURN ${metric_count}
303 Form Portstats Query Pattern
304 [Documentation] Used for geneating openflow metrics Queries for Cassandra.
305 [Arguments] ${metric} ${node} ${port} ${attribute}
306 ${pattern}= Concatenate the String ${attribute} .
307 ${pattern}= Concatenate the String ${pattern} ${metric}
308 ${pattern}= Concatenate the String ${pattern} .
309 ${pattern}= Concatenate the String ${pattern} ${node}
310 ${pattern}= Concatenate the String ${pattern} .
311 ${pattern}= Concatenate the String ${pattern} Node_${node}
312 ${pattern}= Concatenate the String ${pattern} .
313 ${pattern}= Concatenate the String ${pattern} NodeConnector_${node}:${port}
314 ${pattern}= Remove Space on String ${pattern}
317 Create Temporary Key Info
318 [Documentation] Return rows matching keya and keyb
319 [Arguments] ${pattern} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${val_table}=metricval
320 ${output}= Run Command On Remote System
322 ... cat ${CASSANDRA_DB_PATH}${val_table}|grep "${pattern}"
325 Verify Metric Val File
326 [Documentation] Returns Value for metric matching particular keya,keyb
327 @{metricval}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${temp_metric_val}
328 ${mv_len}= Get Length ${metricval}
329 ${mv_len}= Evaluate ${mv_len} - 1
330 ${found_line}= Get From List ${metricval} ${mv_len}
331 @{split_line}= Split String ${found_line} ${SPACE}
332 ${metric_count}= Get From List ${split_line} 3
333 RETURN ${metric_count}
335 Verify Metric log File
336 [Documentation] Returns Value for lines in Metriclog matching the pattern
337 [Arguments] ${metric_log} ${pattern}
338 ${contents}= Grep From File ${CASSANDRA_DB_PATH}${temp_metric_val} ${pattern}
342 [Documentation] Use cat to grep from the file and return the output
343 [Arguments] ${file} ${pattern}
344 ${output}= Run Command On Remote System ${ODL_SYSTEM_IP} cat ${file} | ${pattern}
348 [Documentation] Return list element which has the particular pattern.
349 [Arguments] ${pattern} ${file}
350 ${metric_grep}= Grep From File ${TSDR_PATH}/tsdrKeyCache.txt ${pattern}
351 @{split_line}= Split String ${metric_grep} |
352 ${keypath}= Get From List ${split_line} 0
356 [Documentation] Copy TSDR files to external File system for text processing.
357 [Arguments] ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s ${key_table}=metricpath ${val_table}=metricval
358 Log Attempting to truncate tables in Cassandra
359 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
360 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
361 Write export JAVA_HOME=/usr
362 Write sudo ${CASSANDRA_CLIENT}/cqlsh
364 Write COPY tsdr.${key_table} TO '${CASSANDRA_DB_PATH}${key_table}' WITH DELIMITER = ' ';
366 Write COPY tsdr.${val_table} TO '${CASSANDRA_DB_PATH}${val_table}' WITH DELIMITER = ' ';
371 Issue Cassandra Query
372 [Documentation] Issue query in cqlsh and match it with output which is passed as a argument
373 [Arguments] ${query} ${output} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
374 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
375 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
376 Write export JAVA_HOME=/usr
377 Write ${CASSANDRA_CLIENT}/cqlsh
379 ${query_output}= Write ${query}
380 ${query_output}= Read Until cqlsh>
381 ${str_output}= Convert To String ${output}
382 Should Contain ${query_output} ${str_output}
387 [Documentation] Issue query in cqlsh and match it with output which is passed as a argument
388 [Arguments] ${query} ${remote}=${ODL_SYSTEM_IP} ${user}=${TOOLS_SYSTEM_USER} ${prompt_timeout}=120s
389 ${conn_id}= Open Connection ${remote} prompt=${DEFAULT_LINUX_PROMPT} timeout=${prompt_timeout}
390 Login With Public Key ${user} ${USER_HOME}/.ssh/${SSH_KEY} any
391 Write export JAVA_HOME=/usr
392 Write ${CASSANDRA_CLIENT}/cqlsh
394 ${query_output}= Write ${query}
395 ${query_output}= Read Until cqlsh>
398 RETURN ${query_output}
400 Read File and Return Split Lines
401 [Documentation] Reads the file and returns each line as list
402 [Arguments] ${filename}
403 ${contents}= Run Command On Remote System ${ODL_SYSTEM_IP} cat ${filename}
404 @{lines}= Split to lines ${contents}
408 [Documentation] Parse the xml output and returns it.
409 [Arguments] ${query} ${xpath}
410 ${sid}= RequestsLibrary.Create_Session
412 ... http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
413 ... headers=${SEND_ACCEPT_XML_HEADERS}
415 ${resp}= RequestsLibrary.Get Request session ${query} headers=${SEND_ACCEPT_XML_HEADERS}
416 ${resp_xml}= Parse XML ${resp.text}
417 ${id1}= Get Element Text ${resp_xml} ${xpath}
421 Return all XML matches
422 [Documentation] Returns all the values from xpath
423 [Arguments] ${query} ${xpath}
424 ${sid}= RequestsLibrary.Create_Session
426 ... http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
427 ... headers=${SEND_ACCEPT_XML_HEADERS}
429 ${resp}= RequestsLibrary.Get Request session ${query} headers=${SEND_ACCEPT_XML_HEADERS}
430 ${resp_xml}= Parse XML ${resp.text}
431 @{id1}= Get Elements Texts ${resp_xml} ${xpath}
435 Compare Tsdr XML Metrics
436 [Documentation] Compares xml metrics from openflow plugin with TSDR metric values
437 [Arguments] ${xml} ${tsdr} ${deviation}=10
438 ${val_max}= Evaluate ${xml}*${deviation}/100
439 ${val_diff}= Evaluate ${tsdr} - ${xml}
440 ${find_negative}= Evaluate ${val_diff} < 0
441 IF '${find_negative}' == 'True'
442 ${val_diff}= Evaluate ${val_diff}*-1
444 ${val_diff}= Evaluate ${val_diff}*1
446 Should Be True ${val_diff} <= ${val_max}
449 [Documentation] Uses netcat to generate logs and send it to port ${ODL_SYSTEM_IP}:1514
450 [Arguments] ${facility}
451 Run echo "<${facility}>${MESSAGE}" | nc -w 4 -u ${ODL_SYSTEM_IP} 1514
453 Verify Metric Val File For Syslog
454 [Documentation] Returns Value for metric matching particular keya,keyb
455 @{metricval}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${temp_metric_val}
458 Verify the Metrics Syslog on Cassandra Client
459 [Documentation] Getting the keya and keyb for a particular syslog agent and create a temporary file from metriclog
460 [Arguments] ${pattern}
461 @{metric_row}= Find Metricval Keys ${pattern} metricpath
462 ${keya}= Get From List ${metric_row} 1
463 ${keyb}= Get From List ${metric_row} 2
464 ${keya_bool}= Evaluate ${keya} < 0
465 IF '${keya_bool}' == 'True'
466 ${keya}= Catenate SEPARATOR= \\ ${keya}
468 ${keya}= Catenate ${keya}
470 ${metric_log}= Create Temporary Key Info ${keya} ${keyb} val_table=metriclog
473 Iterating over metricpath
474 [Documentation] Used to traverse over metricpath file and traverse over metricpath file and get the keys
475 @{mp_lines}= Read File and Return Split Lines ${CASSANDRA_DB_PATH}${metric_path}
476 FOR ${line} IN @{mp_lines}
477 @{split_line}= Split String ${line} ${SPACE}
478 ${keya}= Get From List ${split_line} 1
479 ${keyb}= Get From List ${split_line} 2
480 Iterating over metricval ${keya} ${keyb}
483 Iterating over metricval
484 [Documentation] Used to traverse over metricval file and check if keya and keyb are present.
485 [Arguments] ${keya} ${keyb}
486 ${mv_contents}= OperatingSystem.Get File ${CASSANDRA_DB_PATH}${metric_val}
487 Should Contain ${mv_contents} ${keya} ${keyb}
490 [Documentation] Count the number of rows in metricpath and compare with the pattern.
491 [Arguments] ${pattern}
492 ${query_output}= Count Cassandra rows select count(*) from tsdr.metricpath;
493 Should Match Regexp ${query_output} ${pattern}
496 [Documentation] Count the number of rows in HSQLDB with Metric ${TYPE}
497 [Arguments] ${pattern} ${TYPE}
498 ${output}= Issue Command On Karaf Console tsdr:list ${TYPE}
499 Should Match Regexp ${output} ${pattern}
502 [Documentation] Count the number of rows in metricval table and compare with the pattern.
503 [Arguments] ${pattern}
504 ${query_output}= Count Cassandra rows select count(*) from tsdr.metricval;
505 Should Match Regexp ${query_output} ${pattern}
508 [Documentation] Count the number of rows in metriclog and compare with the pattern.
509 [Arguments] ${pattern}
510 ${query_output}= Count Cassandra rows select count(*) from tsdr.metriclog;
511 Should Match Regexp ${query_output} ${pattern}
514 [Documentation] Issues TSDR Query and returns the list
515 [Arguments] ${DC}= ${MN}= ${NID}= ${RK}= ${from}=0 ${until}=now
516 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
517 ${resp}= RequestsLibrary.Get Request
519 ... /tsdr/metrics/query?tsdrkey="[NID=${NID}][DC=${DC}][MN=${MN}][RK=${RK}]"&from=${from}&until=${until}
520 ... headers=${HEADERS_QUERY}
521 @{convert}= Parse Json ${resp.text}
526 [Documentation] Issues TSDR Query and returns the list
527 [Arguments] ${DC}= ${MN}= ${NID}= ${RK}= ${from}=0 ${until}=now
528 ... ${datapts}=1000000
529 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
530 ${resp}= RequestsLibrary.Get Request
532 ... /tsdr/nbi/render?target="[NID=${NID}][DC=${DC}][MN=${MN}][RK=${RK}]"&from=${from}&until=${until}&maxDataPoints=${datapts}
533 ... headers=${HEADERS_QUERY}
534 @{convert}= Parse Json ${resp.text}
535 ${dict_convert}= Convert To Dictionary @{convert}
536 @{dict}= Get Dictionary Values ${dict_convert}
537 ${datapoints_list}= Convert to List ${dict}[0]
539 RETURN @{datapoints_list}
541 Extract PORTSTATS RecordKeys
542 [Documentation] Dissect Record keys for Portstats
543 [Arguments] ${Record_keys}
544 ${node_dict}= Get From List ${Record_keys} 0
545 ${nc_dict}= Get From List ${Record_keys} 1
546 ${NODE}= Get From Dictionary ${node_dict} keyValue
547 ${NC}= Get From Dictionary ${nc_dict} keyValue
548 ${rk_val}= Set Variable Node:${NODE},NodeConnector:${NC}
551 Extract QUEUESTATS RecordKeys
552 [Documentation] Dissect Record keys for Queuestats
553 [Arguments] ${Record_keys}
554 ${node_dict}= Get From List ${Record_keys} 0
555 ${connect_dict}= Get From List ${Record_keys} 1
556 ${queue_dict}= Get From List ${Record_keys} 2
557 ${NODE}= Get From Dictionary ${node_dict} keyValue
558 ${CONNECT}= Get From Dictionary ${connect_dict} keyValue
559 ${QUEUE}= Get From Dictionary ${queue_dict} keyValue
560 ${rk_val}= Set Variable Node:${NODE},NodeConnector:${CONNECT},Queue:${QUEUE}
563 Extract FLOWSTATS RecordKeys
564 [Documentation] Dissect Record keys for Flowstats
565 [Arguments] ${Record_keys}
566 ${node_dict}= Get From List ${Record_keys} 0
567 ${table_dict}= Get From List ${Record_keys} 1
568 ${flow_dict}= Get From List ${Record_keys} 2
569 ${NODE}= Get From Dictionary ${node_dict} keyValue
570 ${TABLE}= Get From Dictionary ${table_dict} keyValue
571 ${FLOW}= Get From Dictionary ${flow_dict} keyValue
572 ${rk_val}= Set Variable Node:${NODE},Table:${TABLE},Flow:${FLOW}
575 Extract FLOWTABLESTATS RecordKeys
576 [Documentation] Dissect Record keys for Flowtablestats
577 [Arguments] ${Record_keys}
578 ${node_dict}= Get From List ${Record_keys} 0
579 ${table_dict}= Get From List ${Record_keys} 1
580 ${NODE}= Get From Dictionary ${node_dict} keyValue
581 ${TABLE}= Get From Dictionary ${table_dict} keyValue
582 ${rk_val}= Set Variable Node:${NODE},Table:${TABLE}
585 Extract Row Values from TSDR Query
586 [Documentation] Extract the row values from query and generate it in DB format
587 [Arguments] ${row_dict} ${tsdr_row} ${nbi_row} ${DATA_CATEGORY}
588 ${nbi_value}= Get From List ${nbi_row} 0
589 ${nbi_time}= Get From List ${nbi_row} 1
590 ${MN}= Get From Dictionary ${row_dict} metricName
591 ${MV}= Get From Dictionary ${row_dict} metricValue
592 ${NID}= Get From Dictionary ${row_dict} nodeID
593 ${RK}= Get From Dictionary ${row_dict} recordKeys
594 ${time}= Get From Dictionary ${row_dict} timeStamp
595 ${DC}= Get From Dictionary ${row_dict} tsdrDataCategory
596 IF '${DATA_CATEGORY}'=='PORTSTATS'
597 ${RK_VAL}= Extract PORTSTATS RecordKeys ${RK}
598 ELSE IF '${DATA_CATEGORY}'=='FLOWSTATS'
599 ${RK_VAL}= Extract FLOWSTATS RecordKeys ${RK}
600 ELSE IF '${DATA_CATEGORY}'=='FLOWTABLESTATS'
601 ${RK_VAL}= Extract FLOWTABLESTATS RecordKeys ${RK}
602 ELSE IF '${DATA_CATEGORY}'=='QUEUESTATS'
603 ${RK_VAL}= Extract QUEUESTATS RecordKeys ${RK}
605 ${RK_VAL}= Set Variable ${None}
607 ${epoch_time}= Convert Date ${time} epoch date_format=%a %b %d %H:%M:%S %Z %Y
608 ${epoch_time_int}= Convert To Integer ${epoch_time}
609 Should Match ${tsdr_row} *${NID}*
610 Should Match ${tsdr_row} *${DC}*
611 Should Match ${tsdr_row} *${MN}*
612 Should Match ${tsdr_row} *${RK_VAL}*
613 Should Match ${tsdr_row} *[${MV}]*
614 Should Match ${tsdr_row} *${epoch_time_int}*
615 Should Be Equal As Numbers ${nbi_time} ${epoch_time_int}
616 Should Be Equal As Numbers ${nbi_value} ${MV}
618 Evaluate Datasets Length
619 [Documentation] Compare the outputs returned from all Data Stores
620 [Arguments] ${tsdr_lines} ${query_output} ${nbi_output}
621 ${query_count}= Get Length ${query_output}
622 ${tsdr_count}= Get Length ${tsdr_lines}
623 ${nbi_count}= Get Length ${nbi_output}
624 Should Be Equal As Numbers ${query_count} ${tsdr_count}
625 Should Be Equal As Numbers ${nbi_count} ${tsdr_count}
627 Evaluate Datasets Value
628 [Documentation] Compare the outputs returned from all Data Stores
629 [Arguments] ${tsdr_lines} ${query_output} ${nbi_output} ${TYPE}
630 FOR ${q_item} ${t_item} ${n_item} IN ZIP ${query_output} ${tsdr_lines}
632 ${query_row}= Extract Row Values from TSDR Query ${q_item} ${t_item} ${n_item} ${TYPE}
634 FOR ${found_line} IN @{matching_list}
635 @{split_line}= Split String ${found_line} |
636 ${hex_name}= Get From List ${split_line} 2
637 ${if_desc}= Decode Bytes To String ${hex_name} HEX
638 Append To List ${ifdesc_list} ${if_desc}
640 RETURN @{ifdesc_list}
643 [Documentation] Write SNMP Config File
644 [Arguments] ${HOST}=127.0.0.1 ${community}=${SNMP_COMMUNITY}
645 Create File snmp.cfg credentials=[${HOST},${community}]
646 Append To File snmp.cfg \n
647 Move File snmp.cfg ${SNMP_PATH}
650 [Documentation] Brings up basic netflow setup .
651 Verify Feature Is Installed odl-tsdr-netflow-statistics-collector
652 Wait Until Keyword Succeeds 24x 10 sec Check Karaf Log Has Messages NetFlow Data Colletor Initialized
657 Collect Data from SNMP Agent
658 [Documentation] Poll for SNMP Agent OID
659 [Arguments] ${SNMP_IP}=127.0.0.1 ${SNMP_AGENT_COMM}=${SNMP_COMMUNITY}
660 ${snmpagentinfo}= Create Dictionary ip-address=${SNMP_IP} community=${SNMP_AGENT_COMM}
661 ${snmpagentcreate}= Create Dictionary input=${snmpagentinfo}
662 ${snmpagentcreate_json}= json.dumps ${snmpagentcreate}
663 Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS_QUERY}
664 ${resp}= RequestsLibrary.Post Request
666 ... /restconf/operations/snmp:get-interfaces
667 ... data=${snmpagentcreate_json}
668 ${convert}= To Json ${resp.text}
669 @{dict1}= Get Dictionary Keys ${convert}
670 ${dict1_0}= Get From List ${dict1} 0
671 ${dict1_val}= Get From Dictionary ${convert} ${dict1_0}
672 @{ifEntry}= Get From Dictionary ${dict1_val} ifEntry
673 @{SNMP_ENTRY}= Create List
674 @{SNMP_VALUES}= Create List
675 FOR ${int} IN @{ifEntry}
676 ${ifindex}= Get From Dictionary ${int} ifIndex
677 ${ifOutDiscards}= Get From Dictionary ${int} ifOutDiscards
678 ${ifInDiscards}= Get From Dictionary ${int} ifInDiscards
679 ${ifType}= Get From Dictionary ${int} ifType
680 ${ifInOctets}= Get From Dictionary ${int} ifInOctets
681 ${ifSpeed}= Get From Dictionary ${int} ifSpeed
682 ${ifOutQLen}= Get From Dictionary ${int} ifOutQLen
683 ${ifOutErrors}= Get From Dictionary ${int} ifOutErrors
684 ${ifPhysAddress}= Get From Dictionary ${int} ifPhysAddress
685 ${ifInUcastPkts}= Get From Dictionary ${int} ifInUcastPkts
686 ${ifOutNUcastPkts}= Get From Dictionary ${int} ifOutNUcastPkts
687 ${ifInErrors}= Get From Dictionary ${int} ifInErrors
688 ${ifOutOctets}= Get From Dictionary ${int} ifOutOctets
689 ${ifAdminStatus1}= Get From Dictionary ${int} ifAdminStatus
690 ${ifAdminStatus}= Get From Dictionary ${OPER_STATUS} ${ifAdminStatus1}
691 ${ifInUnknownProtos}= Get From Dictionary ${int} ifInUnknownProtos
692 ${ifOutUcastPkts}= Get From Dictionary ${int} ifOutUcastPkts
693 ${ifInNUcastPkts}= Get From Dictionary ${int} ifInNUcastPkts
694 ${ifMtu}= Get From Dictionary ${int} ifMtu
695 ${ifOperStatus1}= Get From Dictionary ${int} ifOperStatus
696 ${ifOperStatus}= Get From Dictionary ${OPER_STATUS} ${ifOperStatus1}
699 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutDiscards
700 Append To List ${SNMP_VALUES} ${ifOutDiscards}
703 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInDiscards
704 Append To List ${SNMP_VALUES} ${ifInDiscards}
707 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInOctets | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInOctets
708 Append To List ${SNMP_VALUES} ${ifInOctets}
711 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutQLen | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutQLen
712 Append To List ${SNMP_VALUES} ${ifOutQLen}
715 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutErrors | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutErrors
716 Append To List ${SNMP_VALUES} ${ifOutErrors}
719 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInUcastPkts
720 Append To List ${SNMP_VALUES} ${ifInUcastPkts}
723 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutNUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutNUcastPkts
724 Append To List ${SNMP_VALUES} ${ifOutNUcastPkts}
727 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInErrors | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInErrors
728 Append To List ${SNMP_VALUES} ${ifInErrors}
731 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutOctets | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutOctets
732 Append To List ${SNMP_VALUES} ${ifOutOctets}
735 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfAdminStatus | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfAdminStatus
736 Append To List ${SNMP_VALUES} ${ifAdminStatus}
739 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInUnknownProtos | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInUnknownProtos
740 Append To List ${SNMP_VALUES} ${ifInUnknownProtos}
743 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutUcastPkts
744 Append To List ${SNMP_VALUES} ${ifOutUcastPkts}
747 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInNUcastPkts | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInNUcastPkts
748 Append To List ${SNMP_VALUES} ${ifInNUcastPkts}
751 ... grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOperStatus | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOperStatus
752 Append To List ${SNMP_VALUES} ${ifOperStatus}
754 RETURN ${SNMP_ENTRY} ${SNMP_VALUES}
756 Retrieve Value From Elasticsearch
757 [Documentation] Retrieve the last record of Elastic Search from index TSDR. Query is done by data category, metricname and node ID
758 [Arguments] ${data_category} ${metric_name} ${node_id} ${rk_node_id}
759 Create Session session http://${ODL_SYSTEM_IP}:${ELASTICPORT} auth=${AUTH} headers=${HEADERS_QUERY}
760 ${els_query}= create_query_string_search ${data_category} ${metric_name} ${node_id} ${rk_node_id}
761 ${els_JSON_request}= build_elastic_search_JSON_request ${els_query}
762 ${resp}= RequestsLibrary.Post_Request session _search?pretty data=${els_JSON_request}
763 Should Be Equal As Strings ${resp.status_code} 200
764 @{convert}= Parse Json ${resp.text}
765 ${json}= RequestsLibrary.To Json ${resp.text}
766 ${result}= extract_metric_value_search ${json}
768 [Teardown] Delete All Sessions
770 Check Available values from Elasticsearch
771 [Documentation] Check whether data were sent to Elastic Search. We retrieve all data by data category and then compare its count
772 [Arguments] ${data_category} ${number_items}
773 Create Session session http://${ODL_SYSTEM_IP}:${ELASTICPORT} auth=${AUTH} headers=${HEADERS_QUERY}
774 ${els_query}= create_query_string_count ${data_category}
775 ${els_JSON_request}= build_elastic_search_JSON_request ${els_query}
776 ${resp}= RequestsLibrary.Post_Request session _search?pretty data=${els_JSON_request}
777 Should Be Equal As Strings ${resp.status_code} 200
778 @{convert}= Parse Json ${resp.text}
779 ${json}= RequestsLibrary.To Json ${resp.text}
780 ${result}= extract_metric_value_count ${json}
781 Log To Console Elasticsearch: Check number of elements
782 Should Be True ${result} > ${number_items}
783 [Teardown] Delete All Sessions
785 Clear Elasticsearch Datastore
786 [Documentation] Clear Elastic Search Datastore
787 Create Session session http://${ODL_SYSTEM_IP}:${ELASTICPORT} auth=${AUTH} headers=${HEADERS_QUERY}
788 ${resp}= RequestsLibrary.Delete_Request session tsdr
789 Should Be Equal As Strings ${resp.status_code} 200
790 RETURN ${resp.status_code}
791 [Teardown] Delete All Sessions