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

Diff for /pegasus/test/StressTestController/StressTestControllerMain.cpp between version 1.1.2.1 and 1.7

version 1.1.2.1, 2006/04/18 03:15:28 version 1.7, 2008/06/18 18:12:11
Line 29 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: John Alex  
 //  
 // Modified By:  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <iostream> #include <iostream>
Line 41 
Line 37 
 #include "StressTestController.h" #include "StressTestController.h"
 #include <Pegasus/Common/TimeValue.h> #include <Pegasus/Common/TimeValue.h>
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
   
 //#define DEBUG //#define DEBUG
 #include <time.h> #include <time.h>
 //Windows  
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  //
 #include <windows.h>     /* for DWORD etc. */  // For Windows
 typedef DWORD pid_t;     /* getpid() and others */  //
   #ifdef PEGASUS_OS_TYPE_WINDOWS
    // for DWORD etc.
   # include <windows.h>
    // getpid() and others
    typedef DWORD pid_t;
 #include <process.h> #include <process.h>
 #elif !defined(PEGASUS_OS_OS400)  #else
 #include <unistd.h> #include <unistd.h>
 #endif #endif
  
Line 60 
Line 62 
  
  
 /** /**
  * Message resource name     Message resource name
  */  */
 static const char MSG_PATH []                                = "pegasus/pegasusCLI";  
   
 static const char REQUIRED_ARGS_MISSING []                   =  
                      "Required arguments missing.";  
 static const char REQUIRED_ARGS_MISSING_KEY []               =  
                      "Clients.cimuser.CIMUserCommand.REQUIRED_ARGS_MISSING";  
  
 static const char ERR_OPTION_NOT_SUPPORTED []                = static const char ERR_OPTION_NOT_SUPPORTED []                =
                      "Invalid option. Use '--help' to obtain command syntax.";                      "Invalid option. Use '--help' to obtain command syntax.";
  
 static const char ERR_OPTION_NOT_SUPPORTED_KEY[]             =  
                      "Clients.cimuser.CIMUserCommand..ERR_OPTION_NOT_SUPPORTED";  
   
 static const char ERR_USAGE []                               = static const char ERR_USAGE []                               =
                      "Incorrect usage. Use '--help' to obtain command syntax.";                      "Incorrect usage. Use '--help' to obtain command syntax.";
  
 static const char ERR_USAGE_KEY []                           =  
                      "Clients.cimuser.CIMUserCommand..ERR_USAGE";  
   
  
   //
 // exclude main from the Pegasus Namespace // exclude main from the Pegasus Namespace
   //
 PEGASUS_USING_PEGASUS; PEGASUS_USING_PEGASUS;
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
Line 92 
Line 84 
     char     strTime[256];     char     strTime[256];
     struct tm tmTime;     struct tm tmTime;
     int      rc;     int      rc;
     String   fileName = String::EMPTY;      String fileName;
     ofstream log_file;     ofstream log_file;
  
  
     tmTime = getCurrentActualTime();     tmTime = getCurrentActualTime();
     strftime(strTime,256,"%d%m%Y%H%M%S.",&tmTime);     strftime(strTime,256,"%d%m%Y%H%M%S.",&tmTime);
  
     StressTestControllerCommand    command=StressTestControllerCommand();      StressTestControllerCommand command;
  
     // generate log files and PID files      //
       // Generate log files and PID files
       //
     if(!command.generateRequiredFileNames(strTime))     if(!command.generateRequiredFileNames(strTime))
     {     {
        cout<<StressTestControllerCommand::COMMAND_NAME<<"::Failed to generate required files for tests. "<<endl;          cout<<StressTestControllerCommand::COMMAND_NAME\
               <<"::Failed to generate required files for tests. "<<endl;
        command.removeUnusedFiles();        command.removeUnusedFiles();
        exit (Command::RC_ERROR);          return Command::RC_ERROR;
     }     }
  
       //
     // open the log file     // open the log file
       //
     OpenAppend(log_file,command.getStressTestLogFile());     OpenAppend(log_file,command.getStressTestLogFile());
  
     if (!log_file)     if (!log_file)
Line 117 
Line 114 
        log_file.close();        log_file.close();
        cout<<"Cannot get file "<<command.getStressTestLogFile()<<endl;        cout<<"Cannot get file "<<command.getStressTestLogFile()<<endl;
        command.removeUnusedFiles();        command.removeUnusedFiles();
        exit (Command::RC_ERROR);         return Command::RC_ERROR;
   
     }     }
     strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);     strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);
     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Initiated on "<<strTime<<endl;      log_file<<StressTestControllerCommand::COMMAND_NAME\
     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Process ID: "<<getpid()<<endl;          <<"::Initiated on "<<strTime<<endl;
       log_file<<StressTestControllerCommand::COMMAND_NAME\
           <<"::Process ID: "<<getpid()<<endl;
  
     MessageLoader::setPegasusMsgHomeRelative(argv[0]);  
     try     try
     {     {
         log_file<<StressTestControllerCommand::COMMAND_NAME;         log_file<<StressTestControllerCommand::COMMAND_NAME;
Line 144 
Line 140 
     {     {
         String msg(cfe.getMessage());         String msg(cfe.getMessage());
  
         log_file << StressTestControllerCommand::COMMAND_NAME << "::" << msg <<  endl;          log_file<< StressTestControllerCommand::COMMAND_NAME << "::" \
         cerr << StressTestControllerCommand::COMMAND_NAME << "::" << msg <<  endl;              << msg <<  endl;
           cerr<< StressTestControllerCommand::COMMAND_NAME << "::"\
               << msg <<  endl;
  
         if (msg.find(String("Unknown flag")) != PEG_NOT_FOUND)         if (msg.find(String("Unknown flag")) != PEG_NOT_FOUND)
         {         {
            MessageLoaderParms parms(ERR_OPTION_NOT_SUPPORTED_KEY,ERR_OPTION_NOT_SUPPORTED);  
               parms.msg_src_path = MSG_PATH;  
               cerr << StressTestControllerCommand::COMMAND_NAME <<               cerr << StressTestControllerCommand::COMMAND_NAME <<
                    ": " << MessageLoader::getMessage(parms) << endl;                  "::" << ERR_OPTION_NOT_SUPPORTED << endl;
               log_file<< StressTestControllerCommand::COMMAND_NAME <<               log_file<< StressTestControllerCommand::COMMAND_NAME <<
                    ": " << MessageLoader::getMessage(parms) << endl;                  "::" << ERR_OPTION_NOT_SUPPORTED << endl;
         }         }
         else         else
         {         {
            MessageLoaderParms parms(ERR_USAGE_KEY,ERR_USAGE);  
               parms.msg_src_path = MSG_PATH;  
            cerr << StressTestControllerCommand::COMMAND_NAME <<            cerr << StressTestControllerCommand::COMMAND_NAME <<
              ": " << MessageLoader::getMessage(parms) << endl;                  "::" << ERR_USAGE << endl;
            log_file << StressTestControllerCommand::COMMAND_NAME <<            log_file << StressTestControllerCommand::COMMAND_NAME <<
              ": " << MessageLoader::getMessage(parms) << endl;                  "::" << ERR_USAGE << endl;
         }         }
  
         log_file.close();         log_file.close();
         command.removeUnusedFiles();         command.removeUnusedFiles();
         exit (Command::RC_ERROR);          return Command::RC_ERROR;
     }     }
     catch(...)     catch(...)
     {     {
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Unknown exception caught when setting commands."<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
         cerr<<StressTestControllerCommand::COMMAND_NAME<<"::Unknown exception caught when setting commands."<<endl;              "::Unknown exception caught when setting commands."<<endl;
           cerr<<StressTestControllerCommand::COMMAND_NAME<<
               "::Unknown exception caught when setting commands."<<endl;
         log_file.close();         log_file.close();
         command.removeUnusedFiles();         command.removeUnusedFiles();
         exit (Command::RC_ERROR);          return Command::RC_ERROR;
     }     }
  
       //
     // For help or version options execute usage/version and     // For help or version options execute usage/version and
     // exit     // exit
       //
     if((command.getOperationType() == OPERATION_TYPE_HELP)     if((command.getOperationType() == OPERATION_TYPE_HELP)
        ||(command.getOperationType() == OPERATION_TYPE_VERSION))        ||(command.getOperationType() == OPERATION_TYPE_VERSION))
     {     {
Line 191 
Line 189 
         // Log file not required when help or verbose is opted.         // Log file not required when help or verbose is opted.
         //         //
         FileSystem::removeFile(command.getStressTestLogFile());         FileSystem::removeFile(command.getStressTestLogFile());
         exit (rc);          return rc;
     }     }
  
     String filename;     String filename;
Line 210 
Line 208 
        //        //
        if (!FileSystem::exists(filename))        if (!FileSystem::exists(filename))
        {        {
               //
            // Check for file in default directory as well            // Check for file in default directory as well
            fileName = String::EMPTY;              //
            fileName.append(command.pegasusRoot);              fileName = StressTestControllerCommand::DEFAULT_CFGDIR;
            fileName.append(StressTestControllerCommand::DEFAULT_CFGDIR);  
            fileName.append(filename);            fileName.append(filename);
  
            if (!FileSystem::exists(fileName))            if (!FileSystem::exists(fileName))
Line 223 
Line 221 
               cerr << "\" does not exist."<<endl;               cerr << "\" does not exist."<<endl;
               log_file.close();               log_file.close();
               command.removeUnusedFiles();               command.removeUnusedFiles();
               exit (Command::RC_ERROR);                  return Command::RC_ERROR;
            }            }
            log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Using config file: "<<fileName<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<
                   "::Using config file: "<<fileName<<endl;
        }        }
        else        else
           {
           fileName = filename;           fileName = filename;
           }
  
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Using config file: "<<fileName<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
        cout<<StressTestControllerCommand::COMMAND_NAME<<"::Using config file: "<<fileName<<endl;              "::Using config file: "<<fileName<<endl;
           cout<<StressTestControllerCommand::COMMAND_NAME<<
              "::Using config file: "<<fileName<<endl;
     }     }
     else     else
     {     {
        //        //
        // Use default file in default dir.        // Use default file in default dir.
        //        //
        fileName = String::EMPTY;          fileName = StressTestControllerCommand::DEFAULT_CFGDIR;
        fileName.append(command.pegasusRoot);  
        fileName.append(StressTestControllerCommand::DEFAULT_CFGDIR);  
        fileName.append(StressTestControllerCommand::FILENAME);        fileName.append(StressTestControllerCommand::FILENAME);
        //        //
        // Use hard coded default configuration values if default conf. file        // Use hard coded default configuration values if default conf. file
Line 271 
Line 272 
        //        //
        if(useDefaults)        if(useDefaults)
        {        {
            log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Using hard coded default config values."<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<
            cout<<StressTestControllerCommand::COMMAND_NAME<<"::Using hard coded default config values."<<endl;                  "::Using hard coded default config values."<<endl;
               cout<<StressTestControllerCommand::COMMAND_NAME<<
                   "::Using hard coded default config values."<<endl;
            command.getDefaultClients(log_file);            command.getDefaultClients(log_file);
        }        }
        else        else
Line 291 
Line 294 
     {     {
         String msg(e.getMessage());         String msg(e.getMessage());
  
         log_file << StressTestControllerCommand::COMMAND_NAME << ": " << msg <<  endl;          log_file << StressTestControllerCommand::COMMAND_NAME <<
         cerr << StressTestControllerCommand::COMMAND_NAME << ": " << msg <<  endl;              ": " << msg <<  endl;
           cerr << StressTestControllerCommand::COMMAND_NAME <<
               ": " << msg <<  endl;
         log_file.close();         log_file.close();
         command.removeUnusedFiles();         command.removeUnusedFiles();
         exit (Command::RC_ERROR);          return Command::RC_ERROR;
   
     }     }
     catch(Exception& e )     catch(Exception& e )
     {     {
         String msg(e.getMessage());         String msg(e.getMessage());
         log_file << StressTestControllerCommand::COMMAND_NAME << "::" << msg <<  endl;          log_file << StressTestControllerCommand::COMMAND_NAME <<
         cerr << StressTestControllerCommand::COMMAND_NAME << "::Invalid Configuration ";              "::" << msg <<  endl;
           cerr << StressTestControllerCommand::COMMAND_NAME <<
               "::Invalid Configuration ";
         cerr << "in File: " << fileName <<  endl;         cerr << "in File: " << fileName <<  endl;
         cerr << msg <<  endl;         cerr << msg <<  endl;
         log_file.close();         log_file.close();
         command.removeUnusedFiles();         command.removeUnusedFiles();
         exit (Command::RC_ERROR);          return Command::RC_ERROR;
     }     }
     catch(...)     catch(...)
     {     {
         // throw what was caught          log_file<<StressTestControllerCommand::COMMAND_NAME<<
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Unknown exception caught when acquiring configuration."<<endl;              "::Unknown exception caught when acquiring configuration."<<endl;
         cerr<<StressTestControllerCommand::COMMAND_NAME<<"::Unknown exception caught when acquiring configuration."<<endl;          cerr<<StressTestControllerCommand::COMMAND_NAME<<
               "::Unknown exception caught when acquiring configuration."<<endl;
         log_file.close();         log_file.close();
         command.removeUnusedFiles();         command.removeUnusedFiles();
         exit (Command::RC_ERROR);          return Command::RC_ERROR;
     }     }
  
     log_file << StressTestControllerCommand::COMMAND_NAME << "::Generating Client Commands"<<  endl;      log_file << StressTestControllerCommand::COMMAND_NAME <<
           "::Generating Client Commands"<<  endl;
     if(verboseEnabled)     if(verboseEnabled)
         cout << StressTestControllerCommand::COMMAND_NAME << "::Generating Client Commands"<<  endl;      {
           cout << StressTestControllerCommand::COMMAND_NAME <<
               "::Generating Client Commands"<<  endl;
       }
  
     //     //
     // TimeStamp     // TimeStamp
     //     //
     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Initiated on "<<strTime<<endl;      log_file<<StressTestControllerCommand::COMMAND_NAME<<
     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Process ID: "<<getpid()<<endl;          "::Initiated on "<<strTime<<endl;
     cout<<StressTestControllerCommand::COMMAND_NAME<<"::Initiated on "<<strTime<<endl;      log_file<<StressTestControllerCommand::COMMAND_NAME<<
     cout<<StressTestControllerCommand::COMMAND_NAME<<"::Process ID: "<<getpid()<<endl;          "::Process ID: "<<getpid()<<endl;
       cout<<StressTestControllerCommand::COMMAND_NAME<<
           "::Initiated on "<<strTime<<endl;
       cout<<StressTestControllerCommand::COMMAND_NAME<<
           "::Process ID: "<<getpid()<<endl;
  
     if(!command.generateClientCommands(log_file))     if(!command.generateClientCommands(log_file))
     {     {
        cerr << StressTestControllerCommand::COMMAND_NAME << "::Failed to Generate Client Commands."<<  endl;          cerr << StressTestControllerCommand::COMMAND_NAME <<
        log_file << StressTestControllerCommand::COMMAND_NAME << "::Failed to Generate Client Commands."<<  endl;              "::Failed to Generate Client Commands."<<  endl;
           log_file << StressTestControllerCommand::COMMAND_NAME <<
               "::Failed to Generate Client Commands."<<  endl;
        log_file.close();        log_file.close();
        command.removeUnusedFiles();        command.removeUnusedFiles();
        exit (Command::RC_ERROR);          return Command::RC_ERROR;
     }     }
   
     //     //
     // Getting current time     // Getting current time
     //     //
Line 348 
Line 364 
     strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);     strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);
     log_file << StressTestControllerCommand::COMMAND_NAME <<endl;     log_file << StressTestControllerCommand::COMMAND_NAME <<endl;
     log_file << "   Preparing to execute Clients on "<<strTime<<endl;     log_file << "   Preparing to execute Clients on "<<strTime<<endl;
   
       //
     // Begin to run stress Tests     // Begin to run stress Tests
       //
     rc = command.execute (cout, cerr);     rc = command.execute (cout, cerr);
   
     //     //
     // Getting current time after stress Tests are completed     // Getting current time after stress Tests are completed
     //     //
     tmTime = getCurrentActualTime();     tmTime = getCurrentActualTime();
   
     strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);     strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);
   
     //     //
     // Check overall status of tests     // Check overall status of tests
     //     //
Line 370 
Line 392 
        cout << StressTestControllerCommand::COMMAND_NAME;        cout << StressTestControllerCommand::COMMAND_NAME;
        cout << "::successfully completed on "<<strTime<<endl;        cout << "::successfully completed on "<<strTime<<endl;
     }     }
       cout <<"IMPORTANT: ";
       cout <<"Please check the Controller log file for additional info and the"
            << endl;
       cout <<"           Client log file for individual errors which may or may "
            <<"not have "<< endl;
       cout <<"           caused a stress test failure. "<< endl;
       cout <<" Log Directory:"<<endl;
       cout <<"     "<<
           FileSystem::extractFilePath(command.getStressTestLogFile())<<endl;
       cout <<"\n Controller log: "<<
           FileSystem::extractFileName(command.getStressTestLogFile())<<endl;
       cout <<" Client log:     "<<
           FileSystem::extractFileName(command.getStressClientLogFile())<<endl;
     log_file.close();     log_file.close();
     exit (rc);  
     return rc;     return rc;
 }  } /* main */


Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.7

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2