Use RFC8040 URL for DAEXIM tests
[integration/test.git] / csit / libraries / RestPerfClient.robot
index 56d0bd72790f05659a4da6013a0ecdbf6403221e..5be9901fea79ff877f7df7c91efb1208828d454e 100644 (file)
@@ -1,16 +1,19 @@
 *** Settings ***
 Documentation     RestPerfClient handling singleton resource.
 ...
-...               Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+...               Copyright (c) 2016,2017 Cisco Systems, Inc. and others. All rights reserved.
 ...
 ...               This program and the accompanying materials are made available under the
 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
 ...
+...
 ...               This singleton manages RestPerfClient invocation, tracks the log file
 ...               produced by the invocation, allows the test suite to easily search this
 ...               log file and collect it once done.
 ...
+...               TODO: RemoteBash.robot contains logic which could be reused here.
+...
 ...               TODO: Currently only one RestPerfClient invocation running at a time is
 ...               supported. Support for multiple concurrently running RestPerfClient
 ...               invocations might be needed for example when performance testing cluster
@@ -29,12 +32,14 @@ Resource          ${CURDIR}/NexusKeywords.robot
 Resource          ${CURDIR}/SetupUtils.robot
 Resource          ${CURDIR}/SSHKeywords.robot
 Resource          ${CURDIR}/Utils.robot
+Resource          ${CURDIR}/RemoteBash.robot
 
 *** Variables ***
 ${RestPerfClient__restperfclientlog}    ${EMPTY}
 
 *** Keywords ***
 Setup_Restperfclient
+    [Arguments]    ${build_version}=${EMPTY}    ${build_location}=${EMPTY}
     [Documentation]    Deploy RestPerfClient and determine the Java command to use to call it.
     ...    Open a SSH connection through which the RestPerfClient will be
     ...    invoked, deploy RestPerfClient and the data files it needs to do
@@ -43,19 +48,29 @@ Setup_Restperfclient
     ${connection}=    SSHKeywords.Open_Connection_To_Tools_System
     BuiltIn.Set_Suite_Variable    ${RestPerfClient__restperfclient}    ${connection}
     SSHLibrary.Put_File    ${CURDIR}/../variables/netconf/RestPerfClient/request1.json
-    ${filename}=    NexusKeywords.Deploy_Test_Tool    netconf    netconf-testtool    rest-perf-client
-    ${prefix}=    NexusKeywords.Compose_Full_Java_Command    -Xmx1G -XX:MaxPermSize=256M -jar ${filename}
+    ${filename}=    Run Keyword If    '${IS_KARAF_APPL}' == 'False'    Set Variable    ${RESTPERF_FILENAME}
+    ...    ELSE    NexusKeywords.Deploy_Test_Tool    netconf    netconf-testtool    rest-perf-client
+    ${prefix}=    NexusKeywords.Compose_Full_Java_Command    -Xmx4G -jar ${filename}
     BuiltIn.Set_Suite_Variable    ${RestPerfClient__restperfclient_invocation_command_prefix}    ${prefix}
 
 RestPerfClient__Kill
-    Utils.Write_Bare_Ctrl_C
+    RemoteBash.Write_Bare_Ctrl_C
     SSHLibrary.Set_Client_Configuration    timeout=5
     SSHLibrary.Read_Until_Prompt
 
+Restperfclient__Wait_For_Finish
+    SSHLibrary.Write    ${Empty}
+    ${stdout}=    SSHLibrary.Read_Until_Prompt
+
 Restperfclient__Invoke_With_Timeout
     [Arguments]    ${timeout}    ${command}
-    [Timeout]    ${timeout}
-    Execute_Command_Passes    ${command} >${RestPerfClient__restperfclientlog} 2>&1
+    ${stdout}=    SSHLibrary.Read
+    BuiltIn.Log    ${stdout}
+    ${cmd}=    BuiltIn.Set_Variable    ${command} 2>&1 | tee ${RestPerfClient__restperfclientlog}
+    SSHLibrary.Write    ${cmd}
+    SSHLibrary.Set_Client_Configuration    timeout=120
+    BuiltIn.Wait_Until_Keyword_Succeeds    ${timeout}    1s    Restperfclient__Wait_For_Finish
+    Execute_Command_Passes    cat ${RestPerfClient__restperfclientlog}
 
 Invoke_Restperfclient
     [Arguments]    ${timeout}    ${url}    ${testcase}=${EMPTY}    ${ip}=${ODL_SYSTEM_IP}    ${port}=${RESTCONFPORT}    ${count}=${REQUEST_COUNT}
@@ -64,7 +79,6 @@ Invoke_Restperfclient
     ...    Assemble the RestPerfClient invocation commad, setup the specified
     ...    timeout for the SSH connection, invoke the assembled command and
     ...    then check that RestPerfClient finished its run correctly.
-    [Teardown]    BuiltIn.Run_Keyword_If    ${restperfclient_running}    BuiltIn.Run_Keyword_And_Ignore_Error    RestPerfClient__Kill
     ${restperfclient_running}=    Set_Variable    False
     ${logname}=    Utils.Get_Log_File_Name    restperfclient    ${testcase}
     BuiltIn.Set_Suite_Variable    ${RestPerfClient__restperfclientlog}    ${logname}
@@ -76,7 +90,6 @@ Invoke_Restperfclient
     ${command}=    BuiltIn.Set_Variable    ${RestPerfClient__restperfclient_invocation_command_prefix} ${options}
     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
     ${restperfclient_running}=    Set_Variable    True
@@ -85,6 +98,7 @@ Invoke_Restperfclient
     SetupUtils.Set_Unknown_Bug_Id
     ${result}=    Grep_Restperfclient_Log    FINISHED. Execution time:
     BuiltIn.Should_Not_Be_Equal    '${result}'    ''
+    [Teardown]    BuiltIn.Run_Keyword_If    ${restperfclient_running}    BuiltIn.Run_Keyword_And_Ignore_Error    RestPerfClient__Kill
 
 Grep_Restperfclient_Log
     [Arguments]    ${pattern}