Refactor performance suites to use keyword timeouts 25/36725/4
authorJozef Behran <jbehran@cisco.com>
Thu, 24 Mar 2016 09:58:46 +0000 (10:58 +0100)
committerJozef Behran <jbehran@cisco.com>
Thu, 24 Mar 2016 12:28:17 +0000 (13:28 +0100)
This removes the ugly hack with ${XXX_TIMEOUT_FOR_TEST_CASE}
global variables and test timeouts for a more elegant
solution that uses a keyword timeout instead. Requires Robot
Framework 3.0.

Change-Id: If5876cce5edccfc693a06fff5a9c8c892b2da0f2
Signed-off-by: Jozef Behran <jbehran@cisco.com>
csit/libraries/RestPerfClient.robot
csit/suites/netconf/restperfclient/mdsal.robot
csit/suites/netconf/restperfclient/performance.robot

index b1b2f21cda89431a0d1fe079e021a4670c824c17..0fa35ecbaf49a5f5c1a204613102be03b2ddf6eb 100644 (file)
@@ -23,6 +23,7 @@ Documentation     RestPerfClient handling singleton resource.
 ...               and currently all suites using this use also NetconfKeywords so this
 ...               was postponed. Workaround for the problem: Initialize NexusKeywords
 ...               manually before initializing this resource.
+Library           DateTime
 Library           SSHLibrary
 Resource          ${CURDIR}/NexusKeywords.robot
 Resource          ${CURDIR}/SetupUtils.robot
@@ -46,6 +47,11 @@ Setup_Restperfclient
     ${prefix}=    NexusKeywords.Compose_Full_Java_Command    -Xmx1G -XX:MaxPermSize=256M -jar ${filename}
     BuiltIn.Set_Suite_Variable    ${RestPerfClient__restperfclient_invocation_command_prefix}    ${prefix}
 
+Restperfclient__Invoke_With_Timeout
+    [Arguments]    ${timeout}    ${command}
+    [Timeout]    ${timeout}
+    Execute_Command_Passes    ${command} >${RestPerfClient__restperfclientlog} 2>&1
+
 Invoke_Restperfclient
     [Arguments]    ${timeout}    ${url}    ${testcase}=${EMPTY}    ${ip}=${ODL_SYSTEM_IP}    ${port}=${RESTCONFPORT}    ${count}=${REQUEST_COUNT}
     ...    ${async}=false    ${user}=${ODL_RESTCONF_USER}    ${password}=${ODL_RESTCONF_PASSWORD}
@@ -64,8 +70,9 @@ Invoke_Restperfclient
     BuiltIn.Log    Running restperfclient: ${command}
     SSHLibrary.Switch_Connection    ${RestPerfClient__restperfclient}
     SSHLibrary.Set_Client_Configuration    timeout=${timeout}
+    ${keyword_timeout}=    DateTime.Add_Time_To_Time    ${timeout}    2m    result_format=compact
     SetupUtils.Set_Known_Bug_Id    5413
-    Execute_Command_Passes    ${command} >${RestPerfClient__restperfclientlog} 2>&1
+    Restperfclient__Invoke_With_Timeout    ${keyword_timeout}    ${command}
     SetupUtils.Set_Unknown_Bug_Id
     ${result}=    Grep_Restperfclient_Log    FINISHED. Execution time:
     BuiltIn.Should_Not_Be_Equal    '${result}'    ''
index 9fcf81bf3633aa7012866bdfaff3ac2659470d29..8b098b6a9eebf1ba011db2a76f1898d64c12dfe2 100644 (file)
@@ -20,7 +20,6 @@ Suite Setup       Setup_Everything
 Suite Teardown    Teardown_Everything
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
-Library           DateTime
 Library           RequestsLibrary
 Library           OperatingSystem
 Library           SSHLibrary    timeout=10s
@@ -43,7 +42,6 @@ Create_Test_Data_For_Direct_Access
 
 Run_RestPerfClient_Directly_On_MDSAL
     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the MDSAL via Restconf.
-    [Timeout]    ${DIRECT_MDSAL_TIMEOUT_FOR_TESTCASE}
     ${url}=    BuiltIn.Set_Variable    /restconf/config/car:cars
     RestPerfClient.Invoke_Restperfclient    ${DIRECT_MDSAL_TIMEOUT}    ${url}    testcase=direct
 
@@ -78,7 +76,6 @@ Configure_ODL_As_A_Device_On_Netconf
 
 Run_RestPerfClient_Through_Netconf_Connector
     [Documentation]    Ask RestPerfClient to send the requests to the MDSAL mapped via a netconf connector.
-    [Timeout]    ${NETCONF_CONNECTOR_MDSAL_TIMEOUT_FOR_TESTCASE}
     ${url}=    BuiltIn.Set_Variable    /restconf/config/network-topology:network-topology/topology/topology-netconf/node/odl-mdsal-northbound-via-netconf-connector/yang-ext:mount/car:cars
     RestPerfClient.Invoke_Restperfclient    ${NETCONF_CONNECTOR_MDSAL_TIMEOUT}    ${url}    testcase=netconf-connector
 
@@ -118,12 +115,8 @@ Setup_Everything
     # Calculate timeouts
     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/50+10
     Utils.Set_User_Configurable_Variable_Default    DIRECT_MDSAL_TIMEOUT    ${value} s
-    ${value}=    DateTime.Add_Time_To_Time    ${DIRECT_MDSAL_TIMEOUT}    2m    result_format=compact
-    Utils.Set_User_Configurable_Variable_Default    DIRECT_MDSAL_TIMEOUT_FOR_TESTCASE    ${value}
     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/10+10
     Utils.Set_User_Configurable_Variable_Default    NETCONF_CONNECTOR_MDSAL_TIMEOUT    ${value} s
-    ${value}=    DateTime.Add_Time_To_Time    ${NETCONF_CONNECTOR_MDSAL_TIMEOUT}    2m    result_format=compact
-    Utils.Set_User_Configurable_Variable_Default    NETCONF_CONNECTOR_MDSAL_TIMEOUT_FOR_TESTCASE    ${value}
 
 Teardown_Everything
     [Documentation]    Teardown the test infrastructure, perform cleanup and release all resources.
index 17f24a277e2fa5ba408c8920a6d2f8536e4674f7..9185e91622a1f4559afc2d653186db07f1db8721 100644 (file)
@@ -60,7 +60,6 @@ Create_Device_Data
 
 Run_Restperfclient
     [Documentation]    Deploy and execute restperfclient, asking it to send the specified amount of requests to the netconf connector of the device.
-    [Timeout]    ${TESTTOOL_DEVICE_TIMEOUT_FOR_TESTCASE}
     ${url}=    BuiltIn.Set_Variable    /restconf/config/network-topology:network-topology/topology/topology-netconf/node/${DEVICE_NAME}/yang-ext:mount/car:cars
     RestPerfClient.Invoke_Restperfclient    ${TESTTOOL_DEVICE_TIMEOUT}    ${url}    async=true
 
@@ -88,8 +87,6 @@ Setup_Everything
     # Calculate and set the value of the timeout
     ${value}=    BuiltIn.Evaluate    ${REQUEST_COUNT}/50+10
     Utils.Set_User_Configurable_Variable_Default    TESTTOOL_DEVICE_TIMEOUT    ${value} s
-    ${value}=    DateTime.Add_Time_To_Time    ${TESTTOOL_DEVICE_TIMEOUT}    2m    result_format=compact
-    Utils.Set_User_Configurable_Variable_Default    TESTTOOL_DEVICE_TIMEOUT_FOR_TESTCASE    ${value}
     # Setup resources used by the suite.
     SetupUtils.Setup_Utils_For_Setup_And_Teardown
     NetconfKeywords.Setup_Netconf_Keywords