2 Documentation RestPerfClient handling singleton resource.
4 ... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
10 ... This singleton manages RestPerfClient invocation, tracks the log file
11 ... produced by the invocation, allows the test suite to easily search this
12 ... log file and collect it once done.
14 ... TODO: Currently only one RestPerfClient invocation running at a time is
15 ... supported. Support for multiple concurrently running RestPerfClient
16 ... invocations might be needed for example when performance testing cluster
17 ... nodes. However no such suites are planned for now.
19 ... FIXME: There may be suites which want to use this Resource without
20 ... NetconfKeywords, in which case NexusKeywords will not be initialized
21 ... and Setup_Restperfclient will fail. Fixing this problem will require
22 ... updating NexusKeywords initialization (which may break other suites)
23 ... and currently all suites using this use also NetconfKeywords so this
24 ... was postponed. Workaround for the problem: Initialize NexusKeywords
25 ... manually before initializing this resource.
28 Resource ${CURDIR}/NexusKeywords.robot
29 Resource ${CURDIR}/SetupUtils.robot
30 Resource ${CURDIR}/SSHKeywords.robot
31 Resource ${CURDIR}/Utils.robot
34 ${RestPerfClient__restperfclientlog} ${EMPTY}
38 [Documentation] Deploy RestPerfClient and determine the Java command to use to call it.
39 ... Open a SSH connection through which the RestPerfClient will be
40 ... invoked, deploy RestPerfClient and the data files it needs to do
41 ... its work and initialize the internal state for the remaining
43 ${connection}= SSHKeywords.Open_Connection_To_Tools_System
44 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclient} ${connection}
45 SSHLibrary.Put_File ${CURDIR}/../variables/netconf/RestPerfClient/request1.json
46 ${filename}= NexusKeywords.Deploy_Test_Tool netconf netconf-testtool rest-perf-client
47 ${prefix}= NexusKeywords.Compose_Full_Java_Command -Xmx1G -XX:MaxPermSize=256M -jar ${filename}
48 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclient_invocation_command_prefix} ${prefix}
50 Restperfclient__Invoke_With_Timeout
51 [Arguments] ${timeout} ${command}
53 Execute_Command_Passes ${command} >${RestPerfClient__restperfclientlog} 2>&1
56 [Arguments] ${timeout} ${url} ${testcase}=${EMPTY} ${ip}=${ODL_SYSTEM_IP} ${port}=${RESTCONFPORT} ${count}=${REQUEST_COUNT}
57 ... ${async}=false ${user}=${ODL_RESTCONF_USER} ${password}=${ODL_RESTCONF_PASSWORD}
58 [Documentation] Invoke RestPerfClient on the specified URL with the specified timeout.
59 ... Assemble the RestPerfClient invocation commad, setup the specified
60 ... timeout for the SSH connection, invoke the assembled command and
61 ... then check that RestPerfClient finished its run correctly.
62 ${logname}= Utils.Get_Log_File_Name restperfclient ${testcase}
63 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclientlog} ${logname}
64 ${options}= BuiltIn.Set_Variable --ip ${ip} --port ${port} --edits ${count}
65 ${options}= BuiltIn.Set_Variable ${options} --edit-content request1.json --async-requests ${async}
66 ${options}= BuiltIn.Set_Variable ${options} --auth ${user} ${password}
67 ${timeout_in_minutes}= Utils.Convert_To_Minutes ${timeout}
68 ${options}= BuiltIn.Set_Variable ${options} --timeout ${timeout_in_minutes} --destination ${url}
69 ${command}= BuiltIn.Set_Variable ${RestPerfClient__restperfclient_invocation_command_prefix} ${options}
70 BuiltIn.Log Running restperfclient: ${command}
71 SSHLibrary.Switch_Connection ${RestPerfClient__restperfclient}
72 SSHLibrary.Set_Client_Configuration timeout=${timeout}
73 ${keyword_timeout}= DateTime.Add_Time_To_Time ${timeout} 2m result_format=compact
74 SetupUtils.Set_Known_Bug_Id 5413
75 Restperfclient__Invoke_With_Timeout ${keyword_timeout} ${command}
76 SetupUtils.Set_Unknown_Bug_Id
77 ${result}= Grep_Restperfclient_Log FINISHED. Execution time:
78 BuiltIn.Should_Not_Be_Equal '${result}' ''
80 Grep_Restperfclient_Log
81 [Arguments] ${pattern}
82 [Documentation] Search for the specified string in the log file produced by latest invocation of RestPerfClient
83 BuiltIn.Should_Not_Be_Equal '${RestPerfClient__restperfclientlog}' ''
84 ${result}= SSHLibrary.Execute_Command grep '${pattern}' ${RestPerfClient__restperfclientlog}
87 Collect_From_Restperfclient
88 [Documentation] Collect useful data produced by restperfclient
89 BuiltIn.Should_Not_Be_Equal '${RestPerfClient__restperfclientlog}' ''
90 SSHLibrary.Get_File ${RestPerfClient__restperfclientlog}
91 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclientlog} ${EMPTY}
93 Teardown_Restperfclient
94 [Documentation] Free resources allocated during the RestPerfClient setup
95 SSHLibrary.Switch_Connection ${RestPerfClient__restperfclient}
96 SSHLibrary.Close_Connection