2 Documentation RestPerfClient handling singleton resource.
4 ... Copyright (c) 2016,2017 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
11 ... This singleton manages RestPerfClient invocation, tracks the log file
12 ... produced by the invocation, allows the test suite to easily search this
13 ... log file and collect it once done.
15 ... TODO: RemoteBash.robot contains logic which could be reused here.
17 ... TODO: Currently only one RestPerfClient invocation running at a time is
18 ... supported. Support for multiple concurrently running RestPerfClient
19 ... invocations might be needed for example when performance testing cluster
20 ... nodes. However no such suites are planned for now.
22 ... FIXME: There may be suites which want to use this Resource without
23 ... NetconfKeywords, in which case NexusKeywords will not be initialized
24 ... and Setup_Restperfclient will fail. Fixing this problem will require
25 ... updating NexusKeywords initialization (which may break other suites)
26 ... and currently all suites using this use also NetconfKeywords so this
27 ... was postponed. Workaround for the problem: Initialize NexusKeywords
28 ... manually before initializing this resource.
31 Resource ${CURDIR}/NexusKeywords.robot
32 Resource ${CURDIR}/SetupUtils.robot
33 Resource ${CURDIR}/SSHKeywords.robot
34 Resource ${CURDIR}/Utils.robot
35 Resource ${CURDIR}/RemoteBash.robot
38 ${RestPerfClient__restperfclientlog} ${EMPTY}
42 [Documentation] Deploy RestPerfClient and determine the Java command to use to call it.
43 ... Open a SSH connection through which the RestPerfClient will be
44 ... invoked, deploy RestPerfClient and the data files it needs to do
45 ... its work and initialize the internal state for the remaining
47 ${connection}= SSHKeywords.Open_Connection_To_Tools_System
48 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclient} ${connection}
49 SSHLibrary.Put_File ${CURDIR}/../variables/netconf/RestPerfClient/request1.json
50 ${filename}= NexusKeywords.Deploy_Test_Tool netconf netconf-testtool rest-perf-client
51 ${prefix}= NexusKeywords.Compose_Full_Java_Command -Xmx1G -XX:MaxPermSize=256M -jar ${filename}
52 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclient_invocation_command_prefix} ${prefix}
55 RemoteBash.Write_Bare_Ctrl_C
56 SSHLibrary.Set_Client_Configuration timeout=5
57 SSHLibrary.Read_Until_Prompt
59 Restperfclient__Wait_For_Finish
60 SSHLibrary.Write ${Empty}
61 ${stdout}= SSHLibrary.Read_Until_Prompt
63 Restperfclient__Invoke_With_Timeout
64 [Arguments] ${timeout} ${command}
65 ${stdout}= SSHLibrary.Read
67 ${cmd}= BuiltIn.Set_Variable ${command} 2>&1 | tee ${RestPerfClient__restperfclientlog}
68 SSHLibrary.Write ${cmd}
69 SSHLibrary.Set_Client_Configuration timeout=120
70 BuiltIn.Wait_Until_Keyword_Succeeds ${timeout} 1s Restperfclient__Wait_For_Finish
71 Execute_Command_Passes cat ${RestPerfClient__restperfclientlog}
74 [Arguments] ${timeout} ${url} ${testcase}=${EMPTY} ${ip}=${ODL_SYSTEM_IP} ${port}=${RESTCONFPORT} ${count}=${REQUEST_COUNT}
75 ... ${async}=false ${user}=${ODL_RESTCONF_USER} ${password}=${ODL_RESTCONF_PASSWORD}
76 [Documentation] Invoke RestPerfClient on the specified URL with the specified timeout.
77 ... Assemble the RestPerfClient invocation commad, setup the specified
78 ... timeout for the SSH connection, invoke the assembled command and
79 ... then check that RestPerfClient finished its run correctly.
80 ${restperfclient_running}= Set_Variable False
81 ${logname}= Utils.Get_Log_File_Name restperfclient ${testcase}
82 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclientlog} ${logname}
83 ${options}= BuiltIn.Set_Variable --ip ${ip} --port ${port} --edits ${count}
84 ${options}= BuiltIn.Set_Variable ${options} --edit-content request1.json --async-requests ${async}
85 ${options}= BuiltIn.Set_Variable ${options} --auth ${user} ${password}
86 ${timeout_in_minutes}= Utils.Convert_To_Minutes ${timeout}
87 ${options}= BuiltIn.Set_Variable ${options} --timeout ${timeout_in_minutes} --destination ${url}
88 ${command}= BuiltIn.Set_Variable ${RestPerfClient__restperfclient_invocation_command_prefix} ${options}
89 BuiltIn.Log Running restperfclient: ${command}
90 SSHLibrary.Switch_Connection ${RestPerfClient__restperfclient}
91 ${keyword_timeout}= DateTime.Add_Time_To_Time ${timeout} 2m result_format=compact
92 SetupUtils.Set_Known_Bug_Id 5413
93 ${restperfclient_running}= Set_Variable True
94 Restperfclient__Invoke_With_Timeout ${keyword_timeout} ${command}
95 ${restperfclient_running}= Set_Variable False
96 SetupUtils.Set_Unknown_Bug_Id
97 ${result}= Grep_Restperfclient_Log FINISHED. Execution time:
98 BuiltIn.Should_Not_Be_Equal '${result}' ''
99 [Teardown] BuiltIn.Run_Keyword_If ${restperfclient_running} BuiltIn.Run_Keyword_And_Ignore_Error RestPerfClient__Kill
101 Grep_Restperfclient_Log
102 [Arguments] ${pattern}
103 [Documentation] Search for the specified string in the log file produced by latest invocation of RestPerfClient
104 BuiltIn.Should_Not_Be_Equal '${RestPerfClient__restperfclientlog}' ''
105 ${result}= SSHLibrary.Execute_Command grep '${pattern}' ${RestPerfClient__restperfclientlog}
108 Collect_From_Restperfclient
109 [Documentation] Collect useful data produced by restperfclient
110 BuiltIn.Should_Not_Be_Equal '${RestPerfClient__restperfclientlog}' ''
111 SSHLibrary.Get_File ${RestPerfClient__restperfclientlog}
112 BuiltIn.Set_Suite_Variable ${RestPerfClient__restperfclientlog} ${EMPTY}
114 Teardown_Restperfclient
115 [Documentation] Free resources allocated during the RestPerfClient setup
116 SSHLibrary.Switch_Connection ${RestPerfClient__restperfclient}
117 SSHLibrary.Close_Connection