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