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

  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                //#include "StressTestControllerException.h"
 46                
 47                struct tm getCurrentActualTime(void);
 48                
 49                PEGASUS_NAMESPACE_BEGIN
 50                
 51                ////////////////////////////////////////////////////////////////////////////////
 52                // ConfigTable to contain the stressTest configurations
 53                ////////////////////////////////////////////////////////////////////////////////
 54                typedef HashTable<String, String, EqualFunc<String>, HashFunc<String> > Table;
 55                
 56                /**
 57                    This constant signifies that an operation option has not been recorded
 58                */
 59                static const Uint32 OPERATION_TYPE_UNINITIALIZED             = 0;
 60                
 61                /**
 62                    This constant represents a help operation
 63                */
 64 j.alex 1.1.2.1 static const Uint32 OPERATION_TYPE_HELP                      = 1;
 65                
 66                /**
 67                    This constant represents a version display operation
 68                */
 69                static const Uint32 OPERATION_TYPE_VERSION                   = 2;
 70                
 71                
 72                static Boolean  verboseEnabled                               = false;
 73                
 74                
 75                /**
 76                   The StressTestController command requires CIM Server to be
 77                   installed and running on the target host.
 78                
 79                 */
 80                class StressTestControllerCommand : public Command
 81                {
 82                public:
 83                
 84                    enum { DEFAULT_TIMEOUT_MILLISECONDS = 200000 };
 85 j.alex 1.1.2.1 
 86                    /**
 87                
 88                        Constructs an StressTestControllerCommand and initializes 
 89                        instance variables.
 90                
 91                     */
 92                
 93                    StressTestControllerCommand ();
 94                    /**
 95                
 96                        Parses the command line, validates the options, and sets instance
 97                        variables based on the option arguments.
 98                
 99                        @param   argc  the number of command line arguments
100                        @param   argv  the string vector of command line arguments
101                
102                        @exception  CommandFormatException  if an error is encountered in
103                                                            parsing the command line
104                
105                     */
106 j.alex 1.1.2.1 
107                    void setCommand (Uint32 argc, char* argv []);
108                
109                    /**
110                
111                        Executes the command and writes the results to the PrintWriters.
112                
113                        @param   outPrintWriter     the ostream to which output should be
114                                                    written
115                        @param   errPrintWriter     the ostream to which error output should be
116                                                    written
117                
118                        @return  0                  if the command is successful
119                                 1                  if an error occurs in executing the command
120                
121                     */
122                    Uint32 execute (ostream& outPrintWriter, ostream& errPrintWriter);
123                
124                    /**
125                
126                        Generates the actual commands for each of the test clients.
127 j.alex 1.1.2.1 
128                        @return  true               if the commands are generated successfully
129                                 false              if unsuccessful in generating commands.
130                
131                     */
132                    Boolean generateClientCommands(ostream& log_file);
133                
134                    /**
135                        Retrieves the config information from the stressController configuration
136                        file.
137                
138                        @param   filePath     the filename itself may or may not include an 
139                                              absolute path.
140                        @return  
141                     */
142                    Boolean getFileContent (String filePath,ostream& log_file);
143                
144                    /**
145                        Retrieves the config file path name
146                
147                        @return _configFilePath  The pathname is returned.
148 j.alex 1.1.2.1  
149                     */
150                    String getConfigFilePath(){ return _configFilePath;}
151                
152                    /**
153                        Checks to verify if new pathname was opted.
154                
155                        @return true   A path name was set.
156                                false  Use the default pathname.
157                 
158                     */
159                    Boolean IsConfigFilePathSpecified(){return _configFilePathSpecified;}
160                
161                    /**
162                        Retrieves the command operation type 
163                
164                        @return _operationType  The operation type is returned.
165                 
166                     */
167                    Uint32 getOperationType(){return _operationType;}
168                
169 j.alex 1.1.2.1     /**
170                        Populate test with default configuration values if default configuration file
171                        is not found.
172                
173                        @return 
174                               
175                     */
176                    void getDefaultClients(ostream& log_file);
177                
178                    /**
179                        The command name.
180                     */
181                    static const char   COMMAND_NAME [];
182                
183                
184                    /**
185                       Will generate or create all the required files for the tests.
186                       Required log files, pid files etc are created here.
187                       
188                       @parm    strTime         The time stamp for the tests.
189                
190 j.alex 1.1.2.1        @return  
191                
192                    */
193                    Boolean generateRequiredFileNames(char *strTime);
194                
195                    /**
196                       Will remove all the unused files for the tests.
197                       - Unused log files & pid files are removed here.
198                
199                    */
200                    void removeUnusedFiles(void);
201                
202                    /**
203                        Retrieves the stress Test log file path name
204                
205                        @return StressTestLogFile  The log filename is returned.
206                 
207                     */
208                    String getStressTestLogFile(){ return StressTestLogFile;}
209                
210                    static char   FILENAME [];
211 j.alex 1.1.2.1 
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* pegasusRoot;
224                
225                    char* pegasusHome;
226                
227                private:
228                
229                    /**
230                        Parses each line in the stressController config file
231                
232 j.alex 1.1.2.1         @return true   Parse was successful.
233                                false  Parsing resulted in a failure or invalid config.
234                     */
235                    Boolean parseLine(const String & string, int line,String & name, String & value,ostream& log_file);
236                
237                    /**
238                        Stores client details from config file
239                
240                        @return true   Successfully retrieved and stored the details.
241                                false  Un-successfull.
242                     */
243                    Boolean storeClientDetails(String name, String value);
244                
245                    /**
246                        Validate StressTest configuration properties & clients
247                
248                        @return true   Successfully validated.
249                                false  Un-successfull.
250                     */
251                    Boolean validateConfiguration(String & var, const String & value,ostream& log_file);
252                    
253 j.alex 1.1.2.1     /**
254                        parse and save all the options for each client 
255                
256                        @return 
257                 
258                     */
259                    void getClientOptions(const Char16* p,ostream& log_file);
260                
261                    /**
262                        Checks if the actual tolerance level of the current tests
263                        are within expected tolerances.
264                
265                        @return true   Within tolerance level
266                                false  Failed tolerance expectations.
267                 
268                     */
269                    Boolean checkToleranceLevel(int act_clients,Uint64 nowMilliseconds,ostream& log_file);
270                
271                    /**
272                        Retrieves and stores client details from client pid file
273                
274 j.alex 1.1.2.1         @return true   Successfully retrieved and stored the details.
275                                false  Un-successfull.
276                     */
277                    Boolean getClientPIDs(int clients,ostream& log_file);
278                
279                
280                    /**
281                        The host on which the command is to be executed.  A CIM Server must be
282                        running on this host when the command is executed.  The default host is
283                        the local host.
284                     */
285                    String _hostName;
286                
287                    /**
288                        A Boolean indicating whether a hostname was specified on the command
289                        line.  The default host is the local host.
290                     */
291                    Boolean _hostNameSpecified;
292                
293                    /**
294                        The timeout value to be used, in milliseconds.
295 j.alex 1.1.2.1         The default timeout value is DEFAULT_TIMEOUT_MILLISECONDS.
296                     */
297                    Uint32 _timeout;
298                
299                
300                    /**
301                
302                        The port to be used when the command is executed. The
303                        port number must be the port number on which the
304                        target CIM Server is running.
305                
306                        If no port is specified, StressTestController will attempt to locate 
307                        the port associated with the service "wbem-http" for non-SSL connections
308                        and "wbem-https" for SSL connections. If not found, the DMTF
309                        recommended default port number will be used.
310                
311                        _portNumberStr and _portNumber are not used with
312                        connectLocal().
313                
314                        The default port for non-SSL 5988 and 5989 for SSL.
315                
316 j.alex 1.1.2.1      */
317                    String _portNumberStr;
318                    Uint32 _portNumber;
319                    Uint32   _port;  // JA not sure..if needed
320                
321                    /**
322                        A Boolean indicating whether a port number was specified on the
323                	command line.
324                     */
325                    Boolean _portNumberSpecified;
326                
327                    /**
328                        The username to be used for authentication and
329                        authorization of the operation.
330                     */
331                    String _userName;
332                
333                    /**
334                        Indicates that the user name is set.
335                     */
336                    Boolean _userNameSpecified;
337 j.alex 1.1.2.1 
338                    /**
339                        The password to be used for authentication.
340                     */
341                    String _password;
342                
343                    /**
344                        Indicates that the password is set.
345                     */
346                    Boolean _passwordSpecified;
347                
348                    /**
349                        A Boolean indicating whether an SSL connection was specified on the
350                        command line.
351                     */
352                    Boolean _useSSL;
353                
354                    /**
355                        The duration of the stress tests
356                     */
357                    static double _duration;
358 j.alex 1.1.2.1 
359                    /**
360                        Indicates that the duration is set.
361                     */
362                    Boolean _durationSpecified;
363                
364                    /**
365                        The ToleranceLevel used for the stress tests
366                     */
367                    Uint32 _toleranceLevel;
368                
369                    /**
370                        Indicates that the toleranceLevel is set.
371                     */
372                    Boolean _toleranceLevelSpecified;
373                
374                    /**
375                        The NameSpace that may be used by the clients
376                     */
377                    String _nameSpace;
378                
379 j.alex 1.1.2.1     /**
380                        Indicates that the Name Space is set.
381                     */
382                    Boolean _nameSpaceSpecified;
383                
384                    /**
385                        The Class Name that may be used by the clients
386                     */
387                    String _className;
388                
389                    /**
390                        Indicates that the Class Name is set.
391                     */
392                    Boolean _ClassNameSpecified;
393                
394                
395                    /**
396                        The option character used to specify the hostname.
397                     */
398                    static const char   _OPTION_HOSTNAME;
399                
400 j.alex 1.1.2.1     /**
401                        The option character used to specify the port number.
402                     */
403                    static const char   _OPTION_PORTNUMBER;
404                
405                    /**
406                        The option character used to specify the timeout value.
407                     */
408                    static const char   _OPTION_TIMEOUT;
409                
410                    /**
411                        The option character used to specify the username.
412                     */
413                    static const char   _OPTION_USERNAME;
414                
415                    /**
416                        The option character used to specify the password.
417                     */
418                    static const char   _OPTION_PASSWORD;
419                
420                    /**
421 j.alex 1.1.2.1         The option character used to specify whether SSL should be used.
422                     */
423                    static const char   _OPTION_SSL;
424                
425                    /**
426                        Label for the usage string for this command.
427                     */
428                    static const char   _USAGE [];
429                
430                    /**
431                        The minimum valid portnumber.
432                     */
433                    static const Uint32 _MIN_PORTNUMBER;
434                
435                    /**
436                        The maximum valid portnumber.
437                     */
438                    static const Uint32 _MAX_PORTNUMBER;
439                
440                    /**
441                        The minimum valid duration level.
442 j.alex 1.1.2.1      */
443                    static const Uint32 _MIN_DURATION;
444                
445                    /**
446                        The minimum valid tolerance level.
447                     */
448                    static const Uint32 _MIN_TOLERANCE;
449                
450                    /**
451                        The maximum valid tolerance level.
452                     */
453                    static const Uint32 _MAX_TOLERANCE;
454                
455                    /**
456                        The path of the config file containing the configuration info.
457                     */
458                    String _configFilePath;
459                
460                    /**
461                        A Boolean indicating whether a config file path was specified on the
462                        command line.
463 j.alex 1.1.2.1      */
464                    Boolean _configFilePathSpecified;
465                
466                    /**
467                        A String containing the usage information for the command.
468                     */
469                    String usage;
470                
471                    /**
472                        The type of operation specified on the command line.
473                     */
474                    Uint32        _operationType;
475                
476                    Table* _propertyTable;
477                    Table* _clientTable;
478                    String* _clientCommands;
479                    Uint64* _clientDurations;
480                    Uint64* _clientDelays;
481                
482                    /**
483                        The total number of clients for this test
484 j.alex 1.1.2.1      */
485                    Uint32 _clientCount;
486                    String _currClient;
487                    Uint32 _currClientCount;
488                    /**
489                      Stress Controller Log file.
490                    */
491                    String StressTestLogFile;
492                
493                    /**
494                      StressTest Client PID file
495                    */
496                    String StressTestClientPIDFile;
497                
498                    /**
499                      StressTest Client Log file
500                    */
501                    String StressTestClientLogFile;
502                
503                    /**
504                      StressTest temporary Client PID file
505 j.alex 1.1.2.1     */
506                    String tmpStressTestClientPIDFile;
507                };
508                
509                PEGASUS_NAMESPACE_END
510                
511                #endif /* Pegasus_StressTestControllerCommand_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2