BUG 5343: Fix CSIT test case to verify dataflow in VTN Manager
[integration/test.git] / csit / libraries / TsdrUtils.robot
index 0e30f450f3a6175f0c25311804bb8c15b9fbe177..02acab61b20bcbd4453581175f2c2f65e8f40160 100644 (file)
@@ -9,6 +9,7 @@ Resource          Utils.robot
 Variables         ../variables/Variables.py
 Library           json
 Library           HttpLibrary.HTTP
 Variables         ../variables/Variables.py
 Library           json
 Library           HttpLibrary.HTTP
+Library           Process
 
 *** Variables ***
 ${HBASE_CLIENT}    /tmp/Hbase/hbase-0.94.15/bin
 
 *** Variables ***
 ${HBASE_CLIENT}    /tmp/Hbase/hbase-0.94.15/bin
@@ -28,6 +29,10 @@ ${SNMP_PATH}      ${KARAF_PATH}/etc/tsdr.snmp.cfg
 ${SNMP_COMMUNITY}    mib2dev\/if-mib
 &{HEADERS_QUERY}    Content-Type=application/json    Content-Type=application/json
 &{OPER_STATUS}    up=1    down=2    testing=3    unknown=4    dormant=5    notPresent=6    lowerLayerDown=7
 ${SNMP_COMMUNITY}    mib2dev\/if-mib
 &{HEADERS_QUERY}    Content-Type=application/json    Content-Type=application/json
 &{OPER_STATUS}    up=1    down=2    testing=3    unknown=4    dormant=5    notPresent=6    lowerLayerDown=7
+&{syslog_facility}    kern=0
+${MESSAGE}    Oct 29 18:10:31: ODL: %STKUNIT0-M:CP %IFMGR-5-ASTATE_UP: Changed interface Admin state to up: Te 0/0
+${MESSAGE_PATTERN}    Changed interface
+
 
 *** Keywords ***
 Start Tsdr Suite
 
 *** Keywords ***
 Start Tsdr Suite
@@ -35,7 +40,7 @@ Start Tsdr Suite
     [Documentation]    TSDR specific setup/cleanup work that can be done safely before any system.
     ...    is run.
     Clean Mininet System
     [Documentation]    TSDR specific setup/cleanup work that can be done safely before any system.
     ...    is run.
     Clean Mininet System
-    ${mininet_conn_id1}=    Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
+    ${mininet_conn_id1}=    Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=120s
     Set Suite Variable    ${mininet_conn_id1}
     Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
     Execute Command    sudo ovs-vsctl set-manager ptcp:6644
     Set Suite Variable    ${mininet_conn_id1}
     Login With Public Key    ${TOOLS_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
     Execute Command    sudo ovs-vsctl set-manager ptcp:6644
@@ -56,33 +61,32 @@ Ping All Hosts
     Write    pingall
     Read Until    mininet>
 
     Write    pingall
     Read Until    mininet>
 
-Iperf All Hosts
+Ping Pair Hosts
     [Arguments]    ${host1}    ${host2}
     [Arguments]    ${host1}    ${host2}
-    [Documentation]    Iperf between ${host1} and ${host2}
+    [Documentation]    Ping between ${host1} and ${host2}
     Switch Connection    ${mininet_conn_id1}
     Switch Connection    ${mininet_conn_id1}
-    Write    iperf ${host1} ${host2}
+    Write    pingpair ${host1} ${host2}
     Read Until    mininet>
 
     Read Until    mininet>
 
-
-Iperf All Hosts Hbase
+Ping Pair Hosts Hbase
     [Arguments]    ${pattern}
     [Arguments]    ${pattern}
-    [Documentation]    Iperf between h1 and h2 and check Hbase
-    Iperf All Hosts    h1    h2
+    [Documentation]    Ping between h1 and h2 and check Hbase
+    Ping Pair Hosts    h1    h2
     ${query_output}=    Query the Data from HBaseClient    count 'NETFLOW'
     Should Match Regexp    ${query_output}    ${pattern}
 
     ${query_output}=    Query the Data from HBaseClient    count 'NETFLOW'
     Should Match Regexp    ${query_output}    ${pattern}
 
-Iperf All Hosts Cassandra
+Ping Pair Hosts Cassandra
     [Arguments]    ${pattern}
     [Arguments]    ${pattern}
-    [Documentation]    Iperf between h1 and h2 and check Cassandra
-    Iperf All Hosts    h1    h2
+    [Documentation]    Ping between h1 and h2 and check Cassandra
+    Ping Pair Hosts    h1    h2
     ${query_output}=    Count Cassandra rows    select count(*) from tsdr.metriclog;
     Should Match Regexp    ${query_output}    ${pattern}
 
     ${query_output}=    Count Cassandra rows    select count(*) from tsdr.metriclog;
     Should Match Regexp    ${query_output}    ${pattern}
 
-Iperf All Hosts HSQLDB
+Ping Pair Hosts HSQLDB
     [Arguments]    ${pattern}
     [Documentation]    Iperf between h1 and h2 and check Cassandra
     [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
+    Ping Pair Hosts    h1    h2
+    ${query_output}=    Issue Command On Karaf Console    tsdr:list NETFLOW | wc -l
     Should Match Regexp    ${query_output}    ${pattern}
 
 Stop Tsdr Suite
     Should Match Regexp    ${query_output}    ${pattern}
 
 Stop Tsdr Suite
@@ -264,7 +268,6 @@ Verify the Metrics Attributes on Cassandra Client
     ${metric_count}=    Get From List    ${split_line}    3
     [Return]    ${metric_count}
 
     ${metric_count}=    Get From List    ${split_line}    3
     [Return]    ${metric_count}
 
-
 Form Portstats Query Pattern
     [Arguments]    ${metric}    ${node}    ${port}    ${attribute}
     [Documentation]    Used for geneating openflow metrics Queries for Cassandra.
 Form Portstats Query Pattern
     [Arguments]    ${metric}    ${node}    ${port}    ${attribute}
     [Documentation]    Used for geneating openflow metrics Queries for Cassandra.
@@ -285,7 +288,6 @@ Create Temporary Key Info
     ${output}=    Run Command On Remote System    ${ODL_SYSTEM_IP}    cat ${CASSANDRA_DB_PATH}${val_table}|grep "${pattern}"
     [Return]    ${output}
 
     ${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
     @{metricval}=    Read File and Return Split Lines    ${CASSANDRA_DB_PATH}${temp_metric_val}
 Verify Metric Val File
     [Documentation]    Returns Value for metric matching particular keya,keyb
     @{metricval}=    Read File and Return Split Lines    ${CASSANDRA_DB_PATH}${temp_metric_val}
@@ -303,7 +305,6 @@ Verify Metric log File
     [Return]    ${contents}
 
 Grep From File
     [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}
     [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}
@@ -400,9 +401,9 @@ Compare Tsdr XML Metrics
     Should Be True    ${val_diff} <= ${val_max}
 
 Generate Syslog
     Should Be True    ${val_diff} <= ${val_max}
 
 Generate Syslog
-    [Arguments]    ${facility}    ${level}    ${MESSAGE}
-    [Documentation]    Uses syslogd to generate syslogs
-    Run Command On Remote System    ${ODL_SYSTEM_IP}    logger -p ${facility}.${level} -n 127.0.0.1 -u 514 ${MESSAGE}
+    [Arguments]    ${facility}
+    [Documentation]    Uses netcat to generate logs and send it to port ${ODL_SYSTEM_IP}:1514
+    Run    echo "<${facility}>${MESSAGE}" | nc -w 4 -u ${ODL_SYSTEM_IP} 1514
 
 Verify Metric Val File For Syslog
     [Documentation]    Returns Value for metric matching particular keya,keyb
 
 Verify Metric Val File For Syslog
     [Documentation]    Returns Value for metric matching particular keya,keyb
@@ -460,35 +461,6 @@ Check Metric Log
     ${query_output}=    Count Cassandra rows    select count(*) from tsdr.metriclog;
     Should Match Regexp    ${query_output}    ${pattern}
 
     ${query_output}=    Count Cassandra rows    select count(*) from tsdr.metriclog;
     Should Match Regexp    ${query_output}    ${pattern}
 
-Severity Iterator
-    [Arguments]    ${key}    ${MESSAGE}    ${syslog_severity}
-    [Documentation]    Simulating FOR loop for generating syslogs for each syslog_severity
-    : FOR    ${level}    IN ZIP    &{syslog_severity}
-    \    ${level_value}=    Get From Dictionary    ${syslog_severity}    ${level}
-    \    Generate Syslog    ${key}    ${level}    ${MESSAGE}
-
-Severity Iterator For TSDR
-    [Arguments]    ${key}    ${facility_value}    ${iterator_value}    ${syslogs}    ${MESSAGE}    ${syslog_severity}
-    [Documentation]    Simulating FOR loop for checking TSDR for each syslog_severity
-    ${iterator}=    Evaluate    ${iterator_value} * 8
-    : FOR    ${level}    IN ZIP    &{syslog_severity}
-    \    ${severity_value}=    Get From Dictionary    ${syslog_severity}    ${level}
-    \    ${fac_sev}=    Evaluate    ${facility_value} * 8 + ${severity_value}
-    \    Should Contain    @{syslogs}[${iterator}]    ${MESSAGE}
-    \    Should Contain    @{syslogs}[${iterator}]    <${fac_sev}>
-    \    ${iterator}=    Evaluate    ${iterator} + 1
-
-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'
-    Should Contain X Times    ${output}    ${message}    8
-    ${iterator}=    Evaluate    ${value} * 8
-    : FOR    ${level}    IN ZIP    &{syslog_severity}
-    \    ${severity_value}=    Get From Dictionary    ${syslog_severity}    ${level}
-    \    ${fac_sev}=    Evaluate    ${iterator} + ${severity_value}
-    \    Should Match    ${output}    *${fac_sev}>*
-
 Generate TSDR Query
     [Arguments]    ${DC}=    ${MN}=    ${NID}=    ${RK}=    ${from}=0    ${until}=now
     [Documentation]    Issues TSDR Query and returns the list
 Generate TSDR Query
     [Arguments]    ${DC}=    ${MN}=    ${NID}=    ${RK}=    ${from}=0    ${until}=now
     [Documentation]    Issues TSDR Query and returns the list
@@ -613,12 +585,11 @@ Write SNMP config
 Bringup Netflow
     [Documentation]    Brings up basic netflow setup .
     Verify Feature Is Installed    odl-tsdr-netflow-statistics-collector
 Bringup Netflow
     [Documentation]    Brings up basic netflow setup .
     Verify Feature Is Installed    odl-tsdr-netflow-statistics-collector
-    Wait Until Keyword Succeeds    24x    10 sec    Check Karaf Log Has Messages     NetFlow Data Colletor Initialized
+    Wait Until Keyword Succeeds    24x    10 sec    Check Karaf Log Has Messages    NetFlow Data Colletor Initialized
     Start Tsdr Suite
     Ping All Hosts
     Configure Netflow
 
     Start Tsdr Suite
     Ping All Hosts
     Configure Netflow
 
-
 Collect Data from SNMP Agent
     [Arguments]    ${SNMP_IP}=127.0.0.1    ${SNMP_AGENT_COMM}=${SNMP_COMMUNITY}
     [Documentation]    Poll for SNMP Agent OID
 Collect Data from SNMP Agent
     [Arguments]    ${SNMP_IP}=127.0.0.1    ${SNMP_AGENT_COMM}=${SNMP_COMMUNITY}
     [Documentation]    Poll for SNMP Agent OID
@@ -658,7 +629,7 @@ Collect Data from SNMP Agent
     \    ${ifOperStatus}=    Get From Dictionary    ${OPER_STATUS}    ${ifOperStatus1}
     \    Append To List    ${SNMP_ENTRY}    grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutDiscards
     \    Append To List    ${SNMP_VALUES}    ${ifOutDiscards}
     \    ${ifOperStatus}=    Get From Dictionary    ${OPER_STATUS}    ${ifOperStatus1}
     \    Append To List    ${SNMP_ENTRY}    grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOutDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOutDiscards
     \    Append To List    ${SNMP_VALUES}    ${ifOutDiscards}
-    \    Append To List    ${SNMP_ENTRY}     grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInDiscards
+    \    Append To List    ${SNMP_ENTRY}    grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInDiscards | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInDiscards
     \    Append To List    ${SNMP_VALUES}    ${ifInDiscards}
     \    Append To List    ${SNMP_ENTRY}    grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInOctets | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInOctets
     \    Append To List    ${SNMP_VALUES}    ${ifInOctets}
     \    Append To List    ${SNMP_VALUES}    ${ifInDiscards}
     \    Append To List    ${SNMP_ENTRY}    grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfInOctets | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfInOctets
     \    Append To List    ${SNMP_VALUES}    ${ifInOctets}
@@ -685,4 +656,3 @@ Collect Data from SNMP Agent
     \    Append To List    ${SNMP_ENTRY}    grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOperStatus | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOperStatus
     \    Append To List    ${SNMP_VALUES}    ${ifOperStatus}
     [Return]    ${SNMP_ENTRY}    ${SNMP_VALUES}
     \    Append To List    ${SNMP_ENTRY}    grep NID=${SNMP_IP} | grep DC=SNMPINTERFACES | grep MN=IfOperStatus | grep RK=ifIndex:${ifindex},ifName:Iso88023Csmacd,SnmpMetric:IfOperStatus
     \    Append To List    ${SNMP_VALUES}    ${ifOperStatus}
     [Return]    ${SNMP_ENTRY}    ${SNMP_VALUES}
-