Refactor flow service test
[integration/test.git] / csit / libraries / Utils.robot
index 350c165bf72af1fc24dd7219fab3267159308924..efdae2ea038bcf864120b66cf82faf226364419a 100644 (file)
@@ -6,10 +6,10 @@ Library           DateTime
 Library           Process
 Library           Collections
 Library           RequestsLibrary
-Library           ./UtilLibrary.py
-Resource          KarafKeywords.robot
-Resource          TemplatedRequests.robot
-Variables         ../variables/Variables.py
+Library           ${CURDIR}/UtilLibrary.py
+Resource          ${CURDIR}/SSHKeywords.robot
+Resource          ${CURDIR}/TemplatedRequests.robot
+Variables         ${CURDIR}/../variables/Variables.py
 
 *** Variables ***
 # TODO: Introduce ${tree_size} and use instead of 1 in the next line.
@@ -98,17 +98,6 @@ Report_Failure_And_Point_To_Linked_Bugs
     BuiltIn.Set Test Message    ${msg}${newline}${bugs}${newline}${newline}${TEST_MESSAGE}
     BuiltIn.Log    ${msg}${newline}${bugs}
 
-Ensure All Nodes Are In Response
-    [Arguments]    ${URI}    ${node_list}
-    [Documentation]    A GET is made to the supplied ${URI} and every item in the ${node_list}
-    ...    is verified to exist in the repsonse. This keyword currently implies that it's node
-    ...    specific but any list of strings can be given in ${node_list}. Refactoring of this
-    ...    to make it more generic should be done. (see keyword "Check For Elements At URI")
-    : FOR    ${node}    IN    @{node_list}
-    \    ${resp}    RequestsLibrary.Get Request    session    ${URI}
-    \    Should Be Equal As Strings    ${resp.status_code}    200
-    \    Should Contain    ${resp.content}    ${node}
-
 Check Nodes Stats
     [Arguments]    ${node}
     [Documentation]    A GET on the /node/${node} API is made and specific flow stat
@@ -118,16 +107,6 @@ Check Nodes Stats
     Should Contain    ${resp.content}    flow-capable-node-connector-statistics
     Should Contain    ${resp.content}    flow-table-statistics
 
-Check That Port Count Is Ok
-    [Arguments]    ${node}    ${count}
-    [Documentation]    A GET on the /port API is made and the specified port ${count} is
-    ...    verified. A more generic Keyword "Check For Specific Number Of Elements At URI"
-    ...    also does this work and further consolidation should be done.
-    ${resp}    RequestsLibrary.Get Request    session    ${REST_CONTEXT}/${CONTAINER}/port
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    Should Contain X Times    ${resp.content}    ${node}    ${count}
-
 Check For Specific Number Of Elements At URI
     [Arguments]    ${uri}    ${element}    ${expected_count}
     [Documentation]    A GET is made to the specified ${URI} and the specific count of a
@@ -241,7 +220,7 @@ Run Command On Remote System
     ${stdout}    ${stderr}    SSHLibrary.Execute Command    ${cmd}    return_stderr=True
     SSHLibrary.Close Connection
     Log    ${stderr}
-    [Teardown]    KarafKeywords.Restore_Current_SSH_Connection_From_Index    ${current_ssh_connection.index}
+    [Teardown]    SSHKeywords.Restore_Current_SSH_Connection_From_Index    ${current_ssh_connection.index}
     [Return]    ${stdout}
 
 Write_Bare_Ctrl_C
@@ -276,6 +255,13 @@ Verify File Exists On Remote System
     SSHLibrary.File Should Exist    ${file}
     Close Connection
 
+Check Karaf Log File Does Not Have Messages
+    [Arguments]    ${ip}    ${message}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
+    [Documentation]    Fails if the provided ${message} is found in the karaf.log file. Uses grep to search. The
+    ...    karaf.log file can be overridden with ${log_file} to be any file on the given system @ ${ip}
+    ${output}=    Run Command On Controller    ${ip}    grep -c '${message}' ${log_file}    user=${user}    password=${password}    prompt=${prompt}
+    Should Be Equal As Strings    ${output}    0
+
 Verify Controller Is Not Dead
     [Arguments]    ${controller_ip}=${ODL_SYSTEM_IP}
     [Documentation]    Will execute any tests to verify the controller is not dead. Some checks are