Tidy updated test suites
[integration/test.git] / csit / libraries / TsdrUtils.robot
index 34c6d00fc4cce9e9c51aa3f32cce83f88a783b5c..cb08c4528d10b1f9999b94b69a2018acd9e6cfb9 100644 (file)
@@ -11,7 +11,7 @@ Library           json
 Library           HttpLibrary.HTTP
 
 *** Variables ***
-${HBASE_CLIENT}    /tmp/Hbase/hbase-0.94.15/bin
+${HBASE_CLIENT}    /usr/lib/hbase/hbase-0.94.15/bin
 ${CASSANDRA_CLIENT}    /tmp/cassandra/apache-cassandra-2.1.12/bin
 ${final}          ${EMPTY}
 ${prompt_timeout}    ${EMPTY}
@@ -57,23 +57,33 @@ Ping All Hosts
     Read Until    mininet>
 
 Iperf All Hosts
-    [Arguments]    ${pattern}
-    [Documentation]    Iperf between h1 and h2 and check Hbase
+    [Arguments]    ${host1}    ${host2}
+    [Documentation]    Iperf between ${host1} and ${host2}
     Switch Connection    ${mininet_conn_id1}
-    Write    iperf h1 h2
+    Write    iperf ${host1} ${host2}
     Read Until    mininet>
+
+Iperf All Hosts Hbase
+    [Arguments]    ${pattern}
+    [Documentation]    Iperf between h1 and h2 and check Hbase
+    Iperf All Hosts    h1    h2
     ${query_output}=    Query the Data from HBaseClient    count 'NETFLOW'
     Should Match Regexp    ${query_output}    ${pattern}
 
 Iperf All Hosts Cassandra
     [Arguments]    ${pattern}
     [Documentation]    Iperf between h1 and h2 and check Cassandra
-    Switch Connection    ${mininet_conn_id1}
-    Write    iperf h1 h2
-    Read Until    mininet>
+    Iperf All Hosts    h1    h2
     ${query_output}=    Count Cassandra rows    select count(*) from tsdr.metriclog;
     Should Match Regexp    ${query_output}    ${pattern}
 
+Iperf All Hosts HSQLDB
+    [Arguments]    ${pattern}
+    [Documentation]    Iperf between h1 and h2 and check Cassandra
+    Iperf All Hosts    h1    h2
+    ${query_output}=    Issue Command On Karaf Console    tsdr:list NETFLOW | wc -l
+    Should Match Regexp    ${query_output}    ${pattern}
+
 Stop Tsdr Suite
     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
     ...    tests
@@ -170,8 +180,8 @@ Initialize Cassandra Tables
     [Arguments]    ${remote}=${ODL_SYSTEM_IP}    ${user}=${TOOLS_SYSTEM_USER}    ${prompt_timeout}=120s    ${key_table}=metricpath    ${val_table}=metricval
     [Documentation]    Truncate Existing tables in Cassandra to Start it fresh.
     Log    Attempting to truncate tables in Cassandra
-    Run Command On Remote System    ${ODL_SYSTEM_IP}    rm -rf ${CASSANDRA_DB_PATH}${key_table}
-    Run Command On Remote System    ${ODL_SYSTEM_IP}    rm -rf ${CASSANDRA_DB_PATH}${val_table}
+    Run Command On Remote System    ${ODL_SYSTEM_IP}    sudo rm -rf ${CASSANDRA_DB_PATH}${key_table}
+    Run Command On Remote System    ${ODL_SYSTEM_IP}    sudo rm -rf ${CASSANDRA_DB_PATH}${val_table}
     ${conn_id}=    Open Connection    ${remote}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=${prompt_timeout}
     Login With Public Key    ${user}    ${USER_HOME}/.ssh/${SSH_KEY}    any
     Write    export JAVA_HOME=/usr
@@ -188,8 +198,8 @@ Initialize Cassandra Tables Metricval
     [Arguments]    ${remote}=${ODL_SYSTEM_IP}    ${user}=${TOOLS_SYSTEM_USER}    ${prompt_timeout}=120s    ${key_table}=metricpath    ${val_table}=metricval
     [Documentation]    Truncate Existing tables in Cassandra to Start it fresh
     Log    Attempting to truncate tables in Cassandra
-    Run Command On Remote System    ${ODL_SYSTEM_IP}    rm -rf ${CASSANDRA_DB_PATH}${key_table}
-    Run Command On Remote System    ${ODL_SYSTEM_IP}    rm -rf ${CASSANDRA_DB_PATH}${val_table}
+    Run Command On Remote System    ${ODL_SYSTEM_IP}    sudo rm -rf ${CASSANDRA_DB_PATH}${key_table}
+    Run Command On Remote System    ${ODL_SYSTEM_IP}    sudo rm -rf ${CASSANDRA_DB_PATH}${val_table}
     ${conn_id}=    Open Connection    ${remote}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=${prompt_timeout}
     Login With Public Key    ${user}    ${USER_HOME}/.ssh/${SSH_KEY}    any
     Write    export JAVA_HOME=/usr
@@ -244,9 +254,14 @@ Verify the Metrics Attributes on Cassandra Client
     ${keya_bool}=    Evaluate    ${keya} < 0
     ${keya}=    Run Keyword If    '${keya_bool}' == 'True'    Catenate    SEPARATOR=    \\    ${keya}
     ...    ELSE    Catenate    ${keya}
-    Create Temporary Key Info    ${keya} ${keyb}
-    ${metric_value}=    Verify Metric Val File
-    [Return]    ${metric_value}
+    ${metricval}=    Create Temporary Key Info    ${keya} ${keyb}
+    @{lines}=    Split to lines    ${metricval}
+    ${mv_len}=    Get Length    ${lines}
+    ${mv_len}=    Evaluate    ${mv_len} - 1
+    ${found_line}=    Get From List    ${lines}    ${mv_len}
+    @{split_line}=    Split String    ${found_line}    ${SPACE}
+    ${metric_count}=    Get From List    ${split_line}    3
+    [Return]    ${metric_count}
 
 Form Portstats Query Pattern
     [Arguments]    ${metric}    ${node}    ${port}    ${attribute}
@@ -264,10 +279,9 @@ Form Portstats Query Pattern
 
 Create Temporary Key Info
     [Arguments]    ${pattern}    ${remote}=${ODL_SYSTEM_IP}    ${user}=${TOOLS_SYSTEM_USER}    ${prompt_timeout}=120s    ${val_table}=metricval
-    [Documentation]    Creates a temporary File with matching keya,keyb values.
-    Log    Removing existing file
-    Run Command On Remote System    ${ODL_SYSTEM_IP}    rm -rf ${CASSANDRA_DB_PATH}${temp_metric_val}
-    Run Command On Remote System    ${ODL_SYSTEM_IP}    cat ${CASSANDRA_DB_PATH}${val_table}|grep "${pattern}" > ${CASSANDRA_DB_PATH}${temp_metric_val}
+    [Documentation]    Return rows matching keya and keyb
+    ${output}=    Run Command On Remote System    ${ODL_SYSTEM_IP}    cat ${CASSANDRA_DB_PATH}${val_table}|grep "${pattern}"
+    [Return]    ${output}
 
 Verify Metric Val File
     [Documentation]    Returns Value for metric matching particular keya,keyb
@@ -282,14 +296,20 @@ Verify Metric Val File
 Verify Metric log File
     [Arguments]    ${pattern}
     [Documentation]    Returns Value for lines in Metriclog file matching the pattern
-    ${contents}=    Grep File    ${CASSANDRA_DB_PATH}${temp_metric_val}    ${pattern}
+    ${contents}=    Grep From File    ${CASSANDRA_DB_PATH}${temp_metric_val}    ${pattern}
     [Return]    ${contents}
 
+Grep From File
+    [Arguments]    ${file}    ${pattern}
+    [Documentation]    Use cat to grep from the file and return the output
+    ${output}=    Run Command On Remote System    ${ODL_SYSTEM_IP}    cat ${file} | ${pattern}
+    [Return]    ${output}
+
 Find Metricval Keys
     [Arguments]    ${pattern}    ${file}
     [Documentation]    Return list element which has the particular pattern.
-    ${db_grep}=    Grep File    ${CASSANDRA_DB_PATH}${file}    ${pattern}
-    ${metric_grep}=    Grep File    ${TSDR_PATH}/tsdrKeyCache.txt    ${pattern}
+    ${db_grep}=    Grep From File    ${CASSANDRA_DB_PATH}${file}    ${pattern}
+    ${metric_grep}=    Grep From File    ${TSDR_PATH}/tsdrKeyCache.txt    ${pattern}
     @{split_line}=    Split String    ${metric_grep}    |
     ${keypath}=    Get From List    ${split_line}    0
     Should Contain    ${db_grep}    ${keypath}
@@ -302,7 +322,7 @@ Copy TSDR tables
     ${conn_id}=    Open Connection    ${remote}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=${prompt_timeout}
     Login With Public Key    ${user}    ${USER_HOME}/.ssh/${SSH_KEY}    any
     Write    export JAVA_HOME=/usr
-    Write    ${CASSANDRA_CLIENT}/cqlsh
+    Write    sudo ${CASSANDRA_CLIENT}/cqlsh
     Read Until    cqlsh>
     Write    COPY tsdr.${key_table} TO '${CASSANDRA_DB_PATH}${key_table}' WITH DELIMITER = ' ';
     Read Until    cqlsh>
@@ -343,7 +363,7 @@ Count Cassandra rows
 Read File and Return Split Lines
     [Arguments]    ${filename}
     [Documentation]    Reads the file and returns each line as list
-    ${contents}=    OperatingSystem.Get File    ${filename}
+    ${contents}=    Run Command On Remote System    ${ODL_SYSTEM_IP}    cat ${filename}
     @{lines}=    Split to lines    ${contents}
     [Return]    @{lines}
 
@@ -458,7 +478,7 @@ Severity Iterator For TSDR
 Severity Iterator For Syslog HBase
     [Arguments]    ${message}    ${value}    &{syslog_severity}
     [Documentation]    Simulating FOR loop for checking HBASE for each syslog_severity
-    ${output}=    Query the Data from HBaseClient    scan 'SysLog'
+    ${output}=    Query the Data from HBaseClient    scan 'SYSLOG'
     Should Contain X Times    ${output}    ${message}    8
     ${iterator}=    Evaluate    ${value} * 8
     : FOR    ${level}    IN ZIP    &{syslog_severity}
@@ -549,7 +569,6 @@ Extract Row Values from TSDR Query
     ...    ELSE IF    '${DATA_CATEGORY}'=='QUEUESTATS'    Extract QUEUESTATS RecordKeys    ${RK}
     ${epoch_time}=    Convert Date    ${time}    epoch    date_format=%a %b %d %H:%M:%S %Z %Y
     ${epoch_time_int}=    Convert To Integer    ${epoch_time}
-    LOG    [NID=${NID}][DC=${DC}][MN=${MN}][${RK_VAL}][TS=${epoch_time_int}][${MV}]
     Should Match    ${tsdr_row}    *${NID}*
     Should Match    ${tsdr_row}    *${DC}*
     Should Match    ${tsdr_row}    *${MN}*
@@ -625,32 +644,32 @@ Collect Data from SNMP Agent
     \    ${ifMtu}=    Get From Dictionary    ${int}    ifMtu
     \    ${ifOperStatus1}=    Get From Dictionary    ${int}    ifOperStatus
     \    ${ifOperStatus}=    Get From Dictionary    ${OPER_STATUS}    ${ifOperStatus1}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutDiscards*RK=ifIndex:${ifindex},SnmpMetric:IfOutDiscards*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutDiscards*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutDiscards*
     \    Append To List    ${SNMP_VALUES}    ${ifOutDiscards}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInDiscards*RK=ifIndex:${ifindex},SnmpMetric:IfInDiscards*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInDiscards*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInDiscards*
     \    Append To List    ${SNMP_VALUES}    ${ifInDiscards}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInOctets*RK=ifIndex:${ifindex},SnmpMetric:IfInOctets*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInOctets*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInOctets*
     \    Append To List    ${SNMP_VALUES}    ${ifInOctets}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutQLen*RK=ifIndex:${ifindex},SnmpMetric:IfOutQLen*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutQLen*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutQLen*
     \    Append To List    ${SNMP_VALUES}    ${ifOutQLen}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutErrors*RK=ifIndex:${ifindex},SnmpMetric:IfOutErrors*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutErrors*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutErrors*
     \    Append To List    ${SNMP_VALUES}    ${ifOutErrors}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfInUcastPkts*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInUcastPkts*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInUcastPkts*
     \    Append To List    ${SNMP_VALUES}    ${ifInUcastPkts}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutNUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfOutNUcastPkts*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutNUcastPkts*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutNUcastPkts*
     \    Append To List    ${SNMP_VALUES}    ${ifOutNUcastPkts}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInErrors*RK=ifIndex:${ifindex},SnmpMetric:IfInErrors*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInErrors*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInErrors*
     \    Append To List    ${SNMP_VALUES}    ${ifInErrors}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutOctets*RK=ifIndex:${ifindex},SnmpMetric:IfOutOctets*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutOctets*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutOctets*
     \    Append To List    ${SNMP_VALUES}    ${ifOutOctets}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfAdminStatus*RK=ifIndex:${ifindex},SnmpMetric:IfAdminStatus*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfAdminStatus*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfAdminStatus*
     \    Append To List    ${SNMP_VALUES}    ${ifAdminStatus}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInUnknownProtos*RK=ifIndex:${ifindex},SnmpMetric:IfInUnknownProtos*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInUnknownProtos*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInUnknownProtos*
     \    Append To List    ${SNMP_VALUES}    ${ifInUnknownProtos}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfOutUcastPkts*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOutUcastPkts*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutUcastPkts*
     \    Append To List    ${SNMP_VALUES}    ${ifOutUcastPkts}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInNUcastPkts*RK=ifIndex:${ifindex},SnmpMetric:IfInNUcastPkts*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfInNUcastPkts*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInNUcastPkts*
     \    Append To List    ${SNMP_VALUES}    ${ifInNUcastPkts}
-    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOperStatus*RK=ifIndex:${ifindex},SnmpMetric:IfOperStatus*
+    \    Append To List    ${SNMP_ENTRY}    *NID=${SNMP_IP}*DC=SNMPINTERFACES*MN=IfOperStatus*RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOperStatus*
     \    Append To List    ${SNMP_VALUES}    ${ifOperStatus}
     [Return]    ${SNMP_ENTRY}    ${SNMP_VALUES}