1 j.alex 1.2 //%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.2 // 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.2 #include <Clients/cliutils/Command.h>
44 #include <Clients/cliutils/CommandException.h>
45
46 struct tm getCurrentActualTime();
47
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 This constant signifies that an operation option has not been recorded.
57 */
58 static const Uint32 OPERATION_TYPE_UNINITIALIZED = 0;
59
60 /**
61 This constant represents a help operation.
62 */
63 static const Uint32 OPERATION_TYPE_HELP = 1;
64 j.alex 1.2
65 /**
66 This constant represents a version display operation.
67 */
68 static const Uint32 OPERATION_TYPE_VERSION = 2;
69
70
71 static Boolean verboseEnabled = false;
72
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 j.alex 1.2 /**
86
87 Constructs an StressTestControllerCommand and initializes
88 instance variables.
89
90 */
91
92 StressTestControllerCommand ();
93 /**
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 j.alex 1.2 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 @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 Uint32 execute(ostream& outPrintWriter, ostream& errPrintWriter);
122
123 /**
124
125 Generates the actual commands for each of the test clients.
126
127 j.alex 1.2 @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 /**
144 Retrieves the config file path name
145
146 @return _configFilePath The pathname is returned.
147
148 j.alex 1.2 */
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
165 */
166 Uint32 getOperationType(){return _operationType;}
167
168 /**
169 j.alex 1.2 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 Required log files, pid files etc are created here.
186
187 @parm strTime The time stamp for the tests.
188
189 @return
190 j.alex 1.2
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 void removeUnusedFiles();
200
201 /**
202 Retrieves the stress Test log file path name.
203
204 @return StressTestLogFile The log filename is returned.
205
206 */
207 String getStressTestLogFile(){ return _stressTestLogFile;}
208 String getStressClientLogFile(){ return _stressTestClientLogFile;}
209
210 /**
211 j.alex 1.2 Stress Test directories and files.
212 */
213 static char FILENAME[];
214 static char TESTDIR[];
215 static char STRESSTESTDIR[];
216 static char LOGDIR[];
217 static char BINDIR[];
218 static char DEFAULT_DIR[];
219 static char DEFAULT_CFGDIR[];
220 static char DEFAULT_LOGDIR[];
221 static char DEFAULT_TMPDIR[];
222
223 //
224 // Environment variable:
225 //
226 char* pegasusHome;
227
228 private:
229
230 /**
231 Parses each line in the stressController config file.
232 j.alex 1.2
233 @return true Parse was successful.
234 false Parsing resulted in a failure or invalid config.
235 */
236 Boolean _parseLine(
237 const String & string,
238 int line,
239 String & name,
240 String & value,
241 ostream& log_file);
242
243 /**
244 Stores client details from config file.
245
246 @return true Successfully retrieved and stored the details.
247 false Un-successfull.
248 */
249 Boolean _storeClientDetails(String name, String value);
250
251 /**
252 Validate StressTest configuration properties & clients.
253 j.alex 1.2
254 @return true Successfully validated.
255 false Un-successfull.
256 */
257 Boolean _validateConfiguration(
258 String & var,
259 const String & value,
260 ostream& log_file);
261
262 /**
263 parse and save all the options for each client.
264
265 @return
266
267 */
268 void _getClientOptions(const Char16* p,ostream& log_file);
269
270 /**
271 Checks if the actual tolerance level of the current tests
272 are within expected tolerances.
273
274 j.alex 1.2 @return true Within tolerance level
275 false Failed tolerance expectations.
276
277 */
278 Boolean _checkToleranceLevel(
279 int act_clients,
280 Uint64 nowMilliseconds,
281 ostream& log_file);
282
283 /**
284 Retrieves and stores client details from client pid file.
285
286 @return true Successfully retrieved and stored the details.
287 false Un-successfull.
288 */
289 Boolean _getClientPIDs(int clients,ostream& log_file);
290
291
292 /**
293 The host on which the command is to be executed. A CIM Server must be
294 running on this host when the command is executed. The default host is
295 j.alex 1.2 the local host.
296 */
297 String _hostName;
298
299 /**
300 A Boolean indicating whether a hostname was specified on the command
301 line. The default host is the local host.
302 */
303 Boolean _hostNameSpecified;
304
305 /**
306 The timeout value to be used, in milliseconds.
307 The default timeout value is DEFAULT_TIMEOUT_MILLISECONDS.
308 */
309 Uint32 _timeout;
310
311
312 /**
313
314 The port to be used when the command is executed. The
315 port number must be the port number on which the
316 j.alex 1.2 target CIM Server is running.
317
318 If no port is specified, StressTestController will attempt to locate
319 the port associated with the service "wbem-http" for non-SSL connections
320 and "wbem-https" for SSL connections. If not found, the DMTF
321 recommended default port number will be used.
322
323 _portNumberStr and _portNumber are not used with
324 connectLocal().
325
326 The default port for non-SSL 5988 and 5989 for SSL.
327
328 */
329 String _portNumberStr;
330 Uint32 _portNumber;
331 Uint32 _port; // JA not sure..if needed
332
333 /**
334 A Boolean indicating whether a port number was specified on the
335 command line.
336 */
337 j.alex 1.2 Boolean _portNumberSpecified;
338
339 /**
340 The username to be used for authentication and
341 authorization of the operation.
342 */
343 String _userName;
344
345 /**
346 Indicates that the user name is set.
347 */
348 Boolean _userNameSpecified;
349
350 /**
351 The password to be used for authentication.
352 */
353 String _password;
354
355 /**
356 Indicates that the password is set.
357 */
358 j.alex 1.2 Boolean _passwordSpecified;
359
360 /**
361 A Boolean indicating whether an SSL connection was specified on the
362 command line.
363 */
364 Boolean _useSSL;
365
366 /**
367 The duration of the stress tests
368 */
369 static double _duration;
370
371 /**
372 Indicates that the duration is set.
373 */
374 Boolean _durationSpecified;
375
376 /**
377 The ToleranceLevel used for the stress tests
378 */
379 j.alex 1.2 Uint32 _toleranceLevel;
380
381 /**
382 Indicates that the toleranceLevel is set.
383 */
384 Boolean _toleranceLevelSpecified;
385
386 /**
387 The NameSpace that may be used by the clients
388 */
389 String _nameSpace;
390
391 /**
392 Indicates that the Name Space is set.
393 */
394 Boolean _nameSpaceSpecified;
395
396 /**
397 The Class Name that may be used by the clients
398 */
399 String _className;
400 j.alex 1.2
401 /**
402 Indicates that the Class Name is set.
403 */
404 Boolean _ClassNameSpecified;
405
406
407 /**
408 The option character used to specify the hostname.
409 */
410 static const char _OPTION_HOSTNAME;
411
412 /**
413 The option character used to specify the port number.
414 */
415 static const char _OPTION_PORTNUMBER;
416
417 /**
418 The option character used to specify the timeout value.
419 */
420 static const char _OPTION_TIMEOUT;
421 j.alex 1.2
422 /**
423 The option character used to specify the username.
424 */
425 static const char _OPTION_USERNAME;
426
427 /**
428 The option character used to specify the password.
429 */
430 static const char _OPTION_PASSWORD;
431
432 /**
433 The option character used to specify whether SSL should be used.
434 */
435 static const char _OPTION_SSL;
436
437 /**
438 Label for the usage string for this command.
439 */
440 static const char _USAGE [];
441
442 j.alex 1.2 /**
443 The minimum valid portnumber.
444 */
445 static const Uint32 _MIN_PORTNUMBER;
446
447 /**
448 The maximum valid portnumber.
449 */
450 static const Uint32 _MAX_PORTNUMBER;
451
452 /**
453 The minimum valid duration level.
454 */
455 static const Uint32 _MIN_DURATION;
456
457 /**
458 The minimum valid tolerance level.
459 */
460 static const Uint32 _MIN_TOLERANCE;
461
462 /**
463 j.alex 1.2 The maximum valid tolerance level.
464 */
465 static const Uint32 _MAX_TOLERANCE;
466
467 /**
468 The path of the config file containing the configuration info.
469 */
470 String _configFilePath;
471
472 /**
473 A Boolean indicating whether a config file path was specified on the
474 command line.
475 */
476 Boolean _configFilePathSpecified;
477
478 /**
479 A String containing the usage information for the command.
480 */
481 String _usage;
482
483 /**
484 j.alex 1.2 The type of operation specified on the command line.
485 */
486 Uint32 _operationType;
487
488 /**
489 Property table that stores the properties
490 */
491 Table* _propertyTable;
492
493 /**
494 Client table that stores the client specific properties
495 */
496 Table* _clientTable;
497
498 /**
499 Client commands
500 */
501 String* _clientCommands;
502
503 /**
504 Client specific durations
505 j.alex 1.2 */
506 Uint64* _clientDurations;
507
508 /**
509 Client specific delays
510 */
511 Uint64* _clientDelays;
512
513 /**
514 The total number of clients for this test
515 */
516 Uint32 _clientCount;
517
518 /**
519 current client name
520 */
521 String _currClient;
522
523 /**
524 current client count
525 */
526 j.alex 1.2 Uint32 _currClientCount;
527
528 /**
529 Stress Controller Log file.
530 */
531 String _stressTestLogFile;
532
533 /**
534 StressTest Client PID file
535 */
536 String _stressTestClientPIDFile;
537
538 /**
539 StressTest Client Log file
540 */
541 String _stressTestClientLogFile;
542
543 /**
544 StressTest temporary Client PID file
545 */
546 String _tmpStressTestClientPIDFile;
547 j.alex 1.2 };
548
549 PEGASUS_NAMESPACE_END
550
551 #endif /* Pegasus_StressTestControllerCommand_h */
|