1 martin 1.4 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.5 //
|
3 martin 1.4 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.5 //
|
10 martin 1.4 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.5 //
|
17 martin 1.4 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.5 //
|
20 martin 1.4 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.5 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.4 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.5 //
|
28 martin 1.4 //////////////////////////////////////////////////////////////////////////
|
29 j.alex 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_StressTestControllerCommand_h
33 #define Pegasus_StressTestControllerCommand_h
34
35 #include <Pegasus/Common/String.h>
36 #include <Pegasus/Common/HashTable.h>
|
37 kumpf 1.3 #include <Pegasus/Common/AutoPtr.h>
|
38 j.alex 1.2 #include <Clients/cliutils/Command.h>
39 #include <Clients/cliutils/CommandException.h>
40
41 struct tm getCurrentActualTime();
42
43 PEGASUS_NAMESPACE_BEGIN
44
45 ////////////////////////////////////////////////////////////////////////////////
46 // ConfigTable to contain the stressTest configurations
47 ////////////////////////////////////////////////////////////////////////////////
48 typedef HashTable<String, String, EqualFunc<String>, HashFunc<String> > Table;
49
50 /**
51 This constant signifies that an operation option has not been recorded.
52 */
53 static const Uint32 OPERATION_TYPE_UNINITIALIZED = 0;
54
55 /**
56 This constant represents a help operation.
57 */
58 static const Uint32 OPERATION_TYPE_HELP = 1;
59 j.alex 1.2
60 /**
61 This constant represents a version display operation.
62 */
63 static const Uint32 OPERATION_TYPE_VERSION = 2;
64
65
66 static Boolean verboseEnabled = false;
67
68
69 /**
70 The StressTestController command requires CIM Server to be
71 installed and running on the target host.
72
73 */
74 class StressTestControllerCommand : public Command
75 {
76 public:
77
78 enum { DEFAULT_TIMEOUT_MILLISECONDS = 200000 };
79
80 j.alex 1.2 /**
81
|
82 kumpf 1.6 Constructs an StressTestControllerCommand and initializes
|
83 j.alex 1.2 instance variables.
84
85 */
86
87 StressTestControllerCommand ();
88 /**
89
90 Parses the command line, validates the options, and sets instance
91 variables based on the option arguments.
92
93 @param argc the number of command line arguments
94 @param argv the string vector of command line arguments
95
96 @exception CommandFormatException if an error is encountered in
97 parsing the command line
98
99 */
100
101 void setCommand (Uint32 argc, char* argv []);
102
103 /**
104 j.alex 1.2
105 Executes the command and writes the results to the PrintWriters.
106
107 @param outPrintWriter the ostream to which output should be
108 written
109 @param errPrintWriter the ostream to which error output should be
110 written
111
112 @return 0 if the command is successful
113 1 if an error occurs in executing the command
114
115 */
116 Uint32 execute(ostream& outPrintWriter, ostream& errPrintWriter);
117
118 /**
119
120 Generates the actual commands for each of the test clients.
121
122 @return true if the commands are generated successfully
123 false if unsuccessful in generating commands.
124
125 j.alex 1.2 */
126 Boolean generateClientCommands(ostream& log_file);
127
128 /**
129 Retrieves the config information from the stressController configuration
130 file.
131
|
132 kumpf 1.6 @param filePath the filename itself may or may not include an
|
133 j.alex 1.2 absolute path.
|
134 kumpf 1.6 @return
|
135 j.alex 1.2 */
136 Boolean getFileContent (String filePath,ostream& log_file);
137
138 /**
139 Retrieves the config file path name
140
141 @return _configFilePath The pathname is returned.
|
142 kumpf 1.6
|
143 j.alex 1.2 */
144 String getConfigFilePath(){ return _configFilePath;}
145
146 /**
147 Checks to verify if new pathname was opted.
148
149 @return true A path name was set.
150 false Use the default pathname.
|
151 kumpf 1.6
|
152 j.alex 1.2 */
153 Boolean IsConfigFilePathSpecified(){return _configFilePathSpecified;}
154
155 /**
|
156 kumpf 1.6 Retrieves the command operation type
|
157 j.alex 1.2
158 @return _operationType The operation type is returned.
|
159 kumpf 1.6
|
160 j.alex 1.2 */
161 Uint32 getOperationType(){return _operationType;}
162
163 /**
|
164 kumpf 1.3 Populate test with default configuration values if default
165 configuration file is not found.
|
166 j.alex 1.2
|
167 kumpf 1.6 @return
168
|
169 j.alex 1.2 */
170 void getDefaultClients(ostream& log_file);
171
172 /**
173 The command name.
174 */
175 static const char COMMAND_NAME [];
176
177
178 /**
179 Will generate or create all the required files for the tests.
180 Required log files, pid files etc are created here.
|
181 kumpf 1.6
|
182 j.alex 1.2 @parm strTime The time stamp for the tests.
183
|
184 kumpf 1.6 @return
|
185 j.alex 1.2
186 */
187 Boolean generateRequiredFileNames(char *strTime);
188
189 /**
190 Will remove all the unused files for the tests.
191 - Unused log files & pid files are removed here.
192
193 */
194 void removeUnusedFiles();
195
196 /**
197 Retrieves the stress Test log file path name.
198
199 @return StressTestLogFile The log filename is returned.
|
200 kumpf 1.6
|
201 j.alex 1.2 */
202 String getStressTestLogFile(){ return _stressTestLogFile;}
203 String getStressClientLogFile(){ return _stressTestClientLogFile;}
204
205 /**
206 Stress Test directories and files.
|
207 kumpf 1.6 */
|
208 j.alex 1.2 static char FILENAME[];
209 static char TESTDIR[];
210 static char STRESSTESTDIR[];
211 static char LOGDIR[];
212 static char BINDIR[];
213 static char DEFAULT_DIR[];
214 static char DEFAULT_CFGDIR[];
215 static char DEFAULT_LOGDIR[];
216 static char DEFAULT_TMPDIR[];
217
218 //
219 // Environment variable:
220 //
221 char* pegasusHome;
222
223 private:
224
225 /**
226 Parses each line in the stressController config file.
227
228 @return true Parse was successful.
229 j.alex 1.2 false Parsing resulted in a failure or invalid config.
230 */
231 Boolean _parseLine(
232 const String & string,
233 int line,
234 String & name,
235 String & value,
236 ostream& log_file);
237
238 /**
239 Stores client details from config file.
240
241 @return true Successfully retrieved and stored the details.
242 false Un-successfull.
243 */
244 Boolean _storeClientDetails(String name, String value);
245
246 /**
247 Validate StressTest configuration properties & clients.
248
249 @return true Successfully validated.
250 j.alex 1.2 false Un-successfull.
251 */
252 Boolean _validateConfiguration(
253 String & var,
254 const String & value,
255 ostream& log_file);
|
256 kumpf 1.6
|
257 j.alex 1.2 /**
|
258 kumpf 1.6 parse and save all the options for each client.
259
260 @return
|
261 j.alex 1.2
262 */
263 void _getClientOptions(const Char16* p,ostream& log_file);
264
265 /**
266 Checks if the actual tolerance level of the current tests
267 are within expected tolerances.
268
269 @return true Within tolerance level
270 false Failed tolerance expectations.
|
271 kumpf 1.6
|
272 j.alex 1.2 */
273 Boolean _checkToleranceLevel(
274 int act_clients,
275 Uint64 nowMilliseconds,
276 ostream& log_file);
277
278 /**
279 Retrieves and stores client details from client pid file.
280
281 @return true Successfully retrieved and stored the details.
282 false Un-successfull.
283 */
284 Boolean _getClientPIDs(int clients,ostream& log_file);
285
286
287 /**
288 The host on which the command is to be executed. A CIM Server must be
289 running on this host when the command is executed. The default host is
290 the local host.
291 */
292 String _hostName;
293 j.alex 1.2
294 /**
295 A Boolean indicating whether a hostname was specified on the command
296 line. The default host is the local host.
297 */
298 Boolean _hostNameSpecified;
299
300 /**
301 The timeout value to be used, in milliseconds.
302 The default timeout value is DEFAULT_TIMEOUT_MILLISECONDS.
303 */
304 Uint32 _timeout;
305
306
307 /**
308
309 The port to be used when the command is executed. The
310 port number must be the port number on which the
311 target CIM Server is running.
312
|
313 kumpf 1.6 If no port is specified, StressTestController will attempt to locate
|
314 j.alex 1.2 the port associated with the service "wbem-http" for non-SSL connections
315 and "wbem-https" for SSL connections. If not found, the DMTF
316 recommended default port number will be used.
317
318 _portNumberStr and _portNumber are not used with
319 connectLocal().
320
321 The default port for non-SSL 5988 and 5989 for SSL.
322
323 */
324 String _portNumberStr;
325 Uint32 _portNumber;
326
327 /**
328 A Boolean indicating whether a port number was specified on the
|
329 kumpf 1.3 command line.
|
330 j.alex 1.2 */
331 Boolean _portNumberSpecified;
332
333 /**
334 The username to be used for authentication and
335 authorization of the operation.
336 */
337 String _userName;
338
339 /**
340 Indicates that the user name is set.
341 */
342 Boolean _userNameSpecified;
343
344 /**
345 The password to be used for authentication.
346 */
347 String _password;
348
349 /**
350 Indicates that the password is set.
351 j.alex 1.2 */
352 Boolean _passwordSpecified;
353
354 /**
355 A Boolean indicating whether an SSL connection was specified on the
356 command line.
357 */
358 Boolean _useSSL;
359
360 /**
361 The duration of the stress tests
362 */
363 static double _duration;
364
365 /**
366 The ToleranceLevel used for the stress tests
367 */
368 Uint32 _toleranceLevel;
369
370 /**
371 The NameSpace that may be used by the clients
372 j.alex 1.2 */
373 String _nameSpace;
374
375 /**
376 The Class Name that may be used by the clients
377 */
378 String _className;
379
380 /**
381 The option character used to specify the hostname.
382 */
383 static const char _OPTION_HOSTNAME;
384
385 /**
386 The option character used to specify the port number.
387 */
388 static const char _OPTION_PORTNUMBER;
389
390 /**
391 The option character used to specify the timeout value.
392 */
393 j.alex 1.2 static const char _OPTION_TIMEOUT;
394
395 /**
396 The option character used to specify the username.
397 */
398 static const char _OPTION_USERNAME;
399
400 /**
401 The option character used to specify the password.
402 */
403 static const char _OPTION_PASSWORD;
404
405 /**
406 The option character used to specify whether SSL should be used.
407 */
408 static const char _OPTION_SSL;
409
410 /**
411 Label for the usage string for this command.
412 */
413 static const char _USAGE [];
414 j.alex 1.2
415 /**
416 The minimum valid portnumber.
417 */
418 static const Uint32 _MIN_PORTNUMBER;
419
420 /**
421 The maximum valid portnumber.
422 */
423 static const Uint32 _MAX_PORTNUMBER;
424
425 /**
426 The minimum valid duration level.
427 */
428 static const Uint32 _MIN_DURATION;
429
430 /**
431 The minimum valid tolerance level.
432 */
433 static const Uint32 _MIN_TOLERANCE;
434
435 j.alex 1.2 /**
436 The maximum valid tolerance level.
437 */
438 static const Uint32 _MAX_TOLERANCE;
439
440 /**
441 The path of the config file containing the configuration info.
442 */
443 String _configFilePath;
444
445 /**
446 A Boolean indicating whether a config file path was specified on the
447 command line.
448 */
449 Boolean _configFilePathSpecified;
450
451 /**
452 A String containing the usage information for the command.
453 */
454 String _usage;
455
456 j.alex 1.2 /**
457 The type of operation specified on the command line.
458 */
459 Uint32 _operationType;
460
461 /**
462 Property table that stores the properties
463 */
|
464 kumpf 1.3 Table _propertyTable;
|
465 j.alex 1.2
466 /**
467 Client table that stores the client specific properties
468 */
|
469 kumpf 1.3 AutoArrayPtr<Table> _clientTable;
|
470 j.alex 1.2
471 /**
472 Client commands
473 */
|
474 kumpf 1.3 AutoArrayPtr<String> _clientCommands;
|
475 j.alex 1.2
476 /**
477 Client specific durations
478 */
|
479 kumpf 1.3 AutoArrayPtr<Uint64> _clientDurations;
|
480 j.alex 1.2
481 /**
482 Client specific delays
483 */
|
484 kumpf 1.3 AutoArrayPtr<Uint64> _clientDelays;
|
485 j.alex 1.2
486 /**
487 The total number of clients for this test
488 */
489 Uint32 _clientCount;
490
491 /**
|
492 kumpf 1.6 current client name
|
493 j.alex 1.2 */
494 String _currClient;
495
496 /**
|
497 kumpf 1.6 current client count
|
498 j.alex 1.2 */
499 Uint32 _currClientCount;
500
501 /**
502 Stress Controller Log file.
503 */
504 String _stressTestLogFile;
505
506 /**
507 StressTest Client PID file
508 */
509 String _stressTestClientPIDFile;
510
511 /**
512 StressTest Client Log file
513 */
514 String _stressTestClientLogFile;
515
516 /**
517 StressTest temporary Client PID file
518 */
519 j.alex 1.2 String _tmpStressTestClientPIDFile;
520 };
521
522 PEGASUS_NAMESPACE_END
523
524 #endif /* Pegasus_StressTestControllerCommand_h */
|