(file) Return to StressTestController.h CVS log (file) (dir) Up to [Pegasus] / pegasus / test / StressTestController

  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            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #ifndef Pegasus_StressTestControllerCommand_h
 35            #define Pegasus_StressTestControllerCommand_h
 36            
 37            #include <Pegasus/Common/String.h>
 38            #include <Pegasus/Common/HashTable.h>
 39 kumpf  1.3 #include <Pegasus/Common/AutoPtr.h>
 40 j.alex 1.2 #include <Clients/cliutils/Command.h>
 41            #include <Clients/cliutils/CommandException.h>
 42            
 43            struct tm getCurrentActualTime();
 44            
 45            PEGASUS_NAMESPACE_BEGIN
 46            
 47            ////////////////////////////////////////////////////////////////////////////////
 48            // ConfigTable to contain the stressTest configurations
 49            ////////////////////////////////////////////////////////////////////////////////
 50            typedef HashTable<String, String, EqualFunc<String>, HashFunc<String> > Table;
 51            
 52            /**
 53                This constant signifies that an operation option has not been recorded.
 54            */
 55            static const Uint32 OPERATION_TYPE_UNINITIALIZED = 0;
 56            
 57            /**
 58                This constant represents a help operation.
 59            */
 60            static const Uint32 OPERATION_TYPE_HELP = 1;
 61 j.alex 1.2 
 62            /**
 63                This constant represents a version display operation.
 64            */
 65            static const Uint32 OPERATION_TYPE_VERSION = 2;
 66            
 67            
 68            static Boolean verboseEnabled = false;
 69            
 70            
 71            /**
 72               The StressTestController command requires CIM Server to be
 73               installed and running on the target host.
 74            
 75             */
 76            class StressTestControllerCommand : public Command
 77            {
 78            public:
 79            
 80                enum { DEFAULT_TIMEOUT_MILLISECONDS = 200000 };
 81            
 82 j.alex 1.2     /**
 83            
 84                    Constructs an StressTestControllerCommand and initializes 
 85                    instance variables.
 86            
 87                 */
 88            
 89                StressTestControllerCommand ();
 90                /**
 91            
 92                    Parses the command line, validates the options, and sets instance
 93                    variables based on the option arguments.
 94            
 95                    @param   argc  the number of command line arguments
 96                    @param   argv  the string vector of command line arguments
 97            
 98                    @exception  CommandFormatException  if an error is encountered in
 99                                                        parsing the command line
100            
101                 */
102            
103 j.alex 1.2     void setCommand (Uint32 argc, char* argv []);
104            
105                /**
106            
107                    Executes the command and writes the results to the PrintWriters.
108            
109                    @param   outPrintWriter     the ostream to which output should be
110                                                written
111                    @param   errPrintWriter     the ostream to which error output should be
112                                                written
113            
114                    @return  0                  if the command is successful
115                             1                  if an error occurs in executing the command
116            
117                 */
118                Uint32 execute(ostream& outPrintWriter, ostream& errPrintWriter);
119            
120                /**
121            
122                    Generates the actual commands for each of the test clients.
123            
124 j.alex 1.2         @return  true               if the commands are generated successfully
125                             false              if unsuccessful in generating commands.
126            
127                 */
128                Boolean generateClientCommands(ostream& log_file);
129            
130                /**
131                    Retrieves the config information from the stressController configuration
132                    file.
133            
134                    @param   filePath     the filename itself may or may not include an 
135                                          absolute path.
136                    @return  
137                 */
138                Boolean getFileContent (String filePath,ostream& log_file);
139            
140                /**
141                    Retrieves the config file path name
142            
143                    @return _configFilePath  The pathname is returned.
144             
145 j.alex 1.2      */
146                String getConfigFilePath(){ return _configFilePath;}
147            
148                /**
149                    Checks to verify if new pathname was opted.
150            
151                    @return true   A path name was set.
152                            false  Use the default pathname.
153             
154                 */
155                Boolean IsConfigFilePathSpecified(){return _configFilePathSpecified;}
156            
157                /**
158                    Retrieves the command operation type 
159            
160                    @return _operationType  The operation type is returned.
161             
162                 */
163                Uint32 getOperationType(){return _operationType;}
164            
165                /**
166 kumpf  1.3         Populate test with default configuration values if default
167                    configuration file is not found.
168 j.alex 1.2 
169                    @return 
170                           
171                 */
172                void getDefaultClients(ostream& log_file);
173            
174                /**
175                    The command name.
176                 */
177                static const char   COMMAND_NAME [];
178            
179            
180                /**
181                   Will generate or create all the required files for the tests.
182                   Required log files, pid files etc are created here.
183                   
184                   @parm    strTime         The time stamp for the tests.
185            
186                   @return  
187            
188                */
189 j.alex 1.2     Boolean generateRequiredFileNames(char *strTime);
190            
191                /**
192                   Will remove all the unused files for the tests.
193                   - Unused log files & pid files are removed here.
194            
195                */
196                void removeUnusedFiles();
197            
198                /**
199                    Retrieves the stress Test log file path name.
200            
201                    @return StressTestLogFile  The log filename is returned.
202             
203                 */
204                String getStressTestLogFile(){ return _stressTestLogFile;}
205                String getStressClientLogFile(){ return _stressTestClientLogFile;}
206            
207                /**
208                  Stress Test directories and files.
209                 */  
210 j.alex 1.2     static char FILENAME[];
211                static char TESTDIR[];
212                static char STRESSTESTDIR[];
213                static char LOGDIR[];
214                static char BINDIR[];
215                static char DEFAULT_DIR[];
216                static char DEFAULT_CFGDIR[];
217                static char DEFAULT_LOGDIR[];
218                static char DEFAULT_TMPDIR[];
219            
220                //
221                // Environment variable:
222                //
223                char* pegasusHome;
224            
225            private:
226            
227                /**
228                    Parses each line in the stressController config file.
229            
230                    @return true   Parse was successful.
231 j.alex 1.2                 false  Parsing resulted in a failure or invalid config.
232                 */
233                Boolean _parseLine(
234                    const String & string,
235                    int line,
236                    String & name,
237                    String & value,
238                    ostream& log_file);
239            
240                /**
241                    Stores client details from config file.
242            
243                    @return true   Successfully retrieved and stored the details.
244                            false  Un-successfull.
245                 */
246                Boolean _storeClientDetails(String name, String value);
247            
248                /**
249                    Validate StressTest configuration properties & clients.
250            
251                    @return true   Successfully validated.
252 j.alex 1.2                 false  Un-successfull.
253                 */
254                Boolean _validateConfiguration(
255                    String & var,
256                    const String & value,
257                    ostream& log_file);
258                
259                /**
260                    parse and save all the options for each client. 
261            
262                    @return 
263             
264                 */
265                void _getClientOptions(const Char16* p,ostream& log_file);
266            
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 j.alex 1.2  
274                 */
275                Boolean _checkToleranceLevel(
276                    int act_clients,
277                    Uint64 nowMilliseconds,
278                    ostream& log_file);
279            
280                /**
281                    Retrieves and stores client details from client pid file.
282            
283                    @return true   Successfully retrieved and stored the details.
284                            false  Un-successfull.
285                 */
286                Boolean _getClientPIDs(int clients,ostream& log_file);
287            
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 j.alex 1.2     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            
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 j.alex 1.2         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            
329                /**
330                    A Boolean indicating whether a port number was specified on the
331 kumpf  1.3         command line.
332 j.alex 1.2      */
333                Boolean _portNumberSpecified;
334            
335                /**
336                    The username to be used for authentication and
337                    authorization of the operation.
338                 */
339                String _userName;
340            
341                /**
342                    Indicates that the user name is set.
343                 */
344                Boolean _userNameSpecified;
345            
346                /**
347                    The password to be used for authentication.
348                 */
349                String _password;
350            
351                /**
352                    Indicates that the password is set.
353 j.alex 1.2      */
354                Boolean _passwordSpecified;
355            
356                /**
357                    A Boolean indicating whether an SSL connection was specified on the
358                    command line.
359                 */
360                Boolean _useSSL;
361            
362                /**
363                    The duration of the stress tests
364                 */
365                static double _duration;
366            
367                /**
368                    Indicates that the duration is set.
369                 */
370                Boolean _durationSpecified;
371            
372                /**
373                    The ToleranceLevel used for the stress tests
374 j.alex 1.2      */
375                Uint32 _toleranceLevel;
376            
377                /**
378                    Indicates that the toleranceLevel is set.
379                 */
380                Boolean _toleranceLevelSpecified;
381            
382                /**
383                    The NameSpace that may be used by the clients
384                 */
385                String _nameSpace;
386            
387                /**
388                    Indicates that the Name Space is set.
389                 */
390                Boolean _nameSpaceSpecified;
391            
392                /**
393                    The Class Name that may be used by the clients
394                 */
395 j.alex 1.2     String _className;
396            
397                /**
398                    Indicates that the Class Name is set.
399                 */
400                Boolean _ClassNameSpecified;
401            
402            
403                /**
404                    The option character used to specify the hostname.
405                 */
406                static const char   _OPTION_HOSTNAME;
407            
408                /**
409                    The option character used to specify the port number.
410                 */
411                static const char   _OPTION_PORTNUMBER;
412            
413                /**
414                    The option character used to specify the timeout value.
415                 */
416 j.alex 1.2     static const char   _OPTION_TIMEOUT;
417            
418                /**
419                    The option character used to specify the username.
420                 */
421                static const char   _OPTION_USERNAME;
422            
423                /**
424                    The option character used to specify the password.
425                 */
426                static const char   _OPTION_PASSWORD;
427            
428                /**
429                    The option character used to specify whether SSL should be used.
430                 */
431                static const char   _OPTION_SSL;
432            
433                /**
434                    Label for the usage string for this command.
435                 */
436                static const char   _USAGE [];
437 j.alex 1.2 
438                /**
439                    The minimum valid portnumber.
440                 */
441                static const Uint32 _MIN_PORTNUMBER;
442            
443                /**
444                    The maximum valid portnumber.
445                 */
446                static const Uint32 _MAX_PORTNUMBER;
447            
448                /**
449                    The minimum valid duration level.
450                 */
451                static const Uint32 _MIN_DURATION;
452            
453                /**
454                    The minimum valid tolerance level.
455                 */
456                static const Uint32 _MIN_TOLERANCE;
457            
458 j.alex 1.2     /**
459                    The maximum valid tolerance level.
460                 */
461                static const Uint32 _MAX_TOLERANCE;
462            
463                /**
464                    The path of the config file containing the configuration info.
465                 */
466                String _configFilePath;
467            
468                /**
469                    A Boolean indicating whether a config file path was specified on the
470                    command line.
471                 */
472                Boolean _configFilePathSpecified;
473            
474                /**
475                    A String containing the usage information for the command.
476                 */
477                String _usage;
478            
479 j.alex 1.2     /**
480                    The type of operation specified on the command line.
481                 */
482                Uint32 _operationType;
483            
484                /**
485                    Property table that stores the properties
486                 */
487 kumpf  1.3     Table _propertyTable;
488 j.alex 1.2 
489                /**
490                    Client table that stores the client specific properties
491                 */
492 kumpf  1.3     AutoArrayPtr<Table> _clientTable;
493 j.alex 1.2 
494                /**
495                    Client commands
496                 */
497 kumpf  1.3     AutoArrayPtr<String> _clientCommands;
498 j.alex 1.2 
499                /**
500                    Client specific durations
501                 */
502 kumpf  1.3     AutoArrayPtr<Uint64> _clientDurations;
503 j.alex 1.2 
504                /**
505                    Client specific delays
506                 */
507 kumpf  1.3     AutoArrayPtr<Uint64> _clientDelays;
508 j.alex 1.2 
509                /**
510                    The total number of clients for this test
511                 */
512                Uint32 _clientCount;
513            
514                /**
515                    current client name 
516                 */
517                String _currClient;
518            
519                /**
520                    current client count 
521                 */
522                Uint32 _currClientCount;
523            
524                /**
525                  Stress Controller Log file.
526                */
527                String _stressTestLogFile;
528            
529 j.alex 1.2     /**
530                  StressTest Client PID file
531                */
532                String _stressTestClientPIDFile;
533            
534                /**
535                  StressTest Client Log file
536                */
537                String _stressTestClientLogFile;
538            
539                /**
540                  StressTest temporary Client PID file
541                */
542                String _tmpStressTestClientPIDFile;
543            };
544            
545            PEGASUS_NAMESPACE_END
546            
547            #endif /* Pegasus_StressTestControllerCommand_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2