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

  1 martin 1.4 //%LICENSE////////////////////////////////////////////////////////////////
  2            // 
  3            // 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            // 
 10            // 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            // 
 17            // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19            // 
 20            // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21            // 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            // 
 28            //////////////////////////////////////////////////////////////////////////
 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                    Constructs an StressTestControllerCommand and initializes 
 83                    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 j.alex 1.2     void setCommand (Uint32 argc, char* argv []);
102            
103                /**
104            
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 j.alex 1.2         @return  true               if the commands are generated successfully
123                             false              if unsuccessful in generating commands.
124            
125                 */
126                Boolean generateClientCommands(ostream& log_file);
127            
128                /**
129                    Retrieves the config information from the stressController configuration
130                    file.
131            
132                    @param   filePath     the filename itself may or may not include an 
133                                          absolute path.
134                    @return  
135                 */
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             
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             
152                 */
153                Boolean IsConfigFilePathSpecified(){return _configFilePathSpecified;}
154            
155                /**
156                    Retrieves the command operation type 
157            
158                    @return _operationType  The operation type is returned.
159             
160                 */
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                    @return 
168                           
169                 */
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                   
182                   @parm    strTime         The time stamp for the tests.
183            
184                   @return  
185            
186                */
187 j.alex 1.2     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             
201                 */
202                String getStressTestLogFile(){ return _stressTestLogFile;}
203                String getStressClientLogFile(){ return _stressTestClientLogFile;}
204            
205                /**
206                  Stress Test directories and files.
207                 */  
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                
257                /**
258                    parse and save all the options for each client. 
259            
260                    @return 
261             
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 j.alex 1.2  
272                 */
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 j.alex 1.2     String _hostName;
293            
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 j.alex 1.2         If no port is specified, StressTestController will attempt to locate 
314                    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                    Indicates that the duration is set.
367                 */
368                Boolean _durationSpecified;
369            
370                /**
371                    The ToleranceLevel used for the stress tests
372 j.alex 1.2      */
373                Uint32 _toleranceLevel;
374            
375                /**
376                    Indicates that the toleranceLevel is set.
377                 */
378                Boolean _toleranceLevelSpecified;
379            
380                /**
381                    The NameSpace that may be used by the clients
382                 */
383                String _nameSpace;
384            
385                /**
386                    Indicates that the Name Space is set.
387                 */
388                Boolean _nameSpaceSpecified;
389            
390                /**
391                    The Class Name that may be used by the clients
392                 */
393 j.alex 1.2     String _className;
394            
395                /**
396                    Indicates that the Class Name is set.
397                 */
398                Boolean _ClassNameSpecified;
399            
400            
401                /**
402                    The option character used to specify the hostname.
403                 */
404                static const char   _OPTION_HOSTNAME;
405            
406                /**
407                    The option character used to specify the port number.
408                 */
409                static const char   _OPTION_PORTNUMBER;
410            
411                /**
412                    The option character used to specify the timeout value.
413                 */
414 j.alex 1.2     static const char   _OPTION_TIMEOUT;
415            
416                /**
417                    The option character used to specify the username.
418                 */
419                static const char   _OPTION_USERNAME;
420            
421                /**
422                    The option character used to specify the password.
423                 */
424                static const char   _OPTION_PASSWORD;
425            
426                /**
427                    The option character used to specify whether SSL should be used.
428                 */
429                static const char   _OPTION_SSL;
430            
431                /**
432                    Label for the usage string for this command.
433                 */
434                static const char   _USAGE [];
435 j.alex 1.2 
436                /**
437                    The minimum valid portnumber.
438                 */
439                static const Uint32 _MIN_PORTNUMBER;
440            
441                /**
442                    The maximum valid portnumber.
443                 */
444                static const Uint32 _MAX_PORTNUMBER;
445            
446                /**
447                    The minimum valid duration level.
448                 */
449                static const Uint32 _MIN_DURATION;
450            
451                /**
452                    The minimum valid tolerance level.
453                 */
454                static const Uint32 _MIN_TOLERANCE;
455            
456 j.alex 1.2     /**
457                    The maximum valid tolerance level.
458                 */
459                static const Uint32 _MAX_TOLERANCE;
460            
461                /**
462                    The path of the config file containing the configuration info.
463                 */
464                String _configFilePath;
465            
466                /**
467                    A Boolean indicating whether a config file path was specified on the
468                    command line.
469                 */
470                Boolean _configFilePathSpecified;
471            
472                /**
473                    A String containing the usage information for the command.
474                 */
475                String _usage;
476            
477 j.alex 1.2     /**
478                    The type of operation specified on the command line.
479                 */
480                Uint32 _operationType;
481            
482                /**
483                    Property table that stores the properties
484                 */
485 kumpf  1.3     Table _propertyTable;
486 j.alex 1.2 
487                /**
488                    Client table that stores the client specific properties
489                 */
490 kumpf  1.3     AutoArrayPtr<Table> _clientTable;
491 j.alex 1.2 
492                /**
493                    Client commands
494                 */
495 kumpf  1.3     AutoArrayPtr<String> _clientCommands;
496 j.alex 1.2 
497                /**
498                    Client specific durations
499                 */
500 kumpf  1.3     AutoArrayPtr<Uint64> _clientDurations;
501 j.alex 1.2 
502                /**
503                    Client specific delays
504                 */
505 kumpf  1.3     AutoArrayPtr<Uint64> _clientDelays;
506 j.alex 1.2 
507                /**
508                    The total number of clients for this test
509                 */
510                Uint32 _clientCount;
511            
512                /**
513                    current client name 
514                 */
515                String _currClient;
516            
517                /**
518                    current client count 
519                 */
520                Uint32 _currClientCount;
521            
522                /**
523                  Stress Controller Log file.
524                */
525                String _stressTestLogFile;
526            
527 j.alex 1.2     /**
528                  StressTest Client PID file
529                */
530                String _stressTestClientPIDFile;
531            
532                /**
533                  StressTest Client Log file
534                */
535                String _stressTestClientLogFile;
536            
537                /**
538                  StressTest temporary Client PID file
539                */
540                String _tmpStressTestClientPIDFile;
541            };
542            
543            PEGASUS_NAMESPACE_END
544            
545            #endif /* Pegasus_StressTestControllerCommand_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2