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

Diff for /pegasus/test/StressTestController/StressTestController.cpp between version 1.1.2.3 and 1.1.2.4

version 1.1.2.3, 2006/04/24 19:15:09 version 1.1.2.4, 2006/04/27 15:08:33
Line 54 
Line 54 
 //Windows //Windows
 // //
 #ifdef PEGASUS_OS_TYPE_WINDOWS #ifdef PEGASUS_OS_TYPE_WINDOWS
  #include <windows.h>     /* for DWORD etc. */   // for DWORD etc.
  typedef DWORD pid_t;     /* getpid() and others */   #include <windows.h>
    // getpid() and others
    typedef DWORD pid_t;
  #include <process.h>  #include <process.h>
 #elif !defined(PEGASUS_OS_OS400) #elif !defined(PEGASUS_OS_OS400)
  #include <unistd.h>  #include <unistd.h>
Line 84 
Line 86 
  
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
   PEGASUS_USING_PEGASUS;
   PEGASUS_USING_STD;
   
  
  
 /** /**
Line 139 
Line 144 
 /** /**
   Temporary arrays to store client information   Temporary arrays to store client information
 */ */
   
 /** /**
   Client PID's   Client PID's
 */ */
Line 358 
Line 364 
     _passwordSpecified = false;     _passwordSpecified = false;
     _useSSL = false;     _useSSL = false;
  
       //
     // initialize     // initialize
       //
     _clientCount = 0;     _clientCount = 0;
     _currClientCount = 0;     _currClientCount = 0;
  
Line 372 
Line 380 
     //     //
     _propertyTable = new Table;     _propertyTable = new Table;
  
       //
     // Client Information     // Client Information
       //
     _clientCommands = 0;     _clientCommands = 0;
     _clientDurations = 0;     _clientDurations = 0;
     _clientDelays = 0;     _clientDelays = 0;
  
       //
     // Get environment variables:     // Get environment variables:
     //     //
     pegasusHome = getenv("PEGASUS_HOME");     pegasusHome = getenv("PEGASUS_HOME");
Line 470 
Line 481 
  
     ofstream log_file;     ofstream log_file;
  
       //
     // opens  the log file     // opens  the log file
       //
     OpenAppend(log_file,_stressTestLogFile);     OpenAppend(log_file,_stressTestLogFile);
  
     if (!log_file)     if (!log_file)
Line 504 
Line 517 
     getOpts = getoopt ();     getOpts = getoopt ();
     getOpts.addFlagspec (GetOptString);     getOpts.addFlagspec (GetOptString);
  
       //
     // per PEP#167     // per PEP#167
       //
     getOpts.addLongFlagspec(LONG_HELP,getoopt::NOARG);     getOpts.addLongFlagspec(LONG_HELP,getoopt::NOARG);
     getOpts.addLongFlagspec(LONG_VERSION,getoopt::NOARG);     getOpts.addLongFlagspec(LONG_VERSION,getoopt::NOARG);
     getOpts.addLongFlagspec(LONG_VERBOSE,getoopt::NOARG);     getOpts.addLongFlagspec(LONG_VERBOSE,getoopt::NOARG);
Line 771 
Line 786 
     _clientDurations = new Uint64[_clientCount];     _clientDurations = new Uint64[_clientCount];
     _clientDelays = new Uint64[_clientCount];     _clientDelays = new Uint64[_clientCount];
  
       //
     // Retrieve all the client options from the client table     // Retrieve all the client options from the client table
     // and build commands for respective clients.     // and build commands for respective clients.
     // Add appropriate options to command string  as required     // Add appropriate options to command string  as required
       //
     for (Uint32 j=0; j< _clientCount; j++)     for (Uint32 j=0; j< _clientCount; j++)
     {     {
         delay = 0;         delay = 0;
Line 812 
Line 829 
             }             }
             else if (String::equalNoCase(i.key(),NAME))             else if (String::equalNoCase(i.key(),NAME))
             {             {
                   //
                 // should be ignored - already saved using clientName                 // should be ignored - already saved using clientName
                   //
             }             }
             else if (String::equalNoCase(i.key(),PORTNUMBER))             else if (String::equalNoCase(i.key(),PORTNUMBER))
             {             {
Line 879 
Line 898 
                       ||(String::equalNoCase(i.key(),CLIENTWAIT))                       ||(String::equalNoCase(i.key(),CLIENTWAIT))
                       ||(String::equalNoCase(i.key(),CLIENTDURATION)))                       ||(String::equalNoCase(i.key(),CLIENTDURATION)))
             {             {
                   //
                 // do nothing here                 // do nothing here
                 //   will be utilized to run the clients later.                 //   will be utilized to run the clients later.
                   //
             }             }
             else             else
             {             {
                   //
                 // Save all other options for the commands                 // Save all other options for the commands
                   //
                 client_command.append(" -");                 client_command.append(" -");
                 client_command.append(i.key());                 client_command.append(i.key());
                 client_command.append(" ");                 client_command.append(" ");
Line 903 
Line 926 
         // Acquire all the common properties listed in the property table         // Acquire all the common properties listed in the property table
         // from config file and include it as part of the client command         // from config file and include it as part of the client command
         // as required.         // as required.
           //
         for (Table::Iterator k = _propertyTable->start(); k; k++)         for (Table::Iterator k = _propertyTable->start(); k; k++)
         {         {
             String propertyValue = String::EMPTY;             String propertyValue = String::EMPTY;
               //
             // Only include the common properties that are not already             // Only include the common properties that are not already
             // listed for the clients.             // listed for the clients.
               //
             if (!_clientTable[j].lookup(k.key(), propertyValue))             if (!_clientTable[j].lookup(k.key(), propertyValue))
             {             {
                   //
                 // Include options other than ToleranceLevel                 // Include options other than ToleranceLevel
                 // clientDuration,clientwait and Duration                 // clientDuration,clientwait and Duration
                 // in the command string for the clients.                 // in the command string for the clients.
                   //
                 if ((!String::equalNoCase(k.key(),TOLERANCELEVEL))                 if ((!String::equalNoCase(k.key(),TOLERANCELEVEL))
                      && (!String::equalNoCase(k.key(),CLIENTDURATION))                      && (!String::equalNoCase(k.key(),CLIENTDURATION))
                      && (!String::equalNoCase(k.key(),CLIENTWAIT))                      && (!String::equalNoCase(k.key(),CLIENTWAIT))
Line 948 
Line 976 
         //         //
         for (Table::Iterator k = _clientTable[j].start(); k; k++)         for (Table::Iterator k = _clientTable[j].start(); k; k++)
         {         {
               //
             // Overwrite duration if client duration set             // Overwrite duration if client duration set
               //
             if (String::equalNoCase(k.key(),CLIENTDURATION))             if (String::equalNoCase(k.key(),CLIENTDURATION))
             {             {
                 duration = atof(k.value().getCString());                 duration = atof(k.value().getCString());
Line 1105 
Line 1135 
         return (RC_SUCCESS);         return (RC_SUCCESS);
     }     }
  
     // graceful shutdown when interrupted      //
       // gracefully shutdown when interrupted
       //
     signal(SIGABRT, endAllTests);     signal(SIGABRT, endAllTests);
     signal(SIGINT, endAllTests);     signal(SIGINT, endAllTests);
  
Line 1132 
Line 1164 
  
     try     try
     {     {
           //
         // Initializing the Boolean array's to false.         // Initializing the Boolean array's to false.
           //
         for (Uint32 i=0;i<_clientCount;i++)         for (Uint32 i=0;i<_clientCount;i++)
         {         {
             clientStopped[i] = false;             clientStopped[i] = false;
             clientDelayed[i] = false;             clientDelayed[i] = false;
         }         }
           //
         // Set up duration of the tests         // Set up duration of the tests
           //
         startMilliseconds   = TimeValue::getCurrentTime().toMilliseconds();         startMilliseconds   = TimeValue::getCurrentTime().toMilliseconds();
         nowMilliseconds     = startMilliseconds;         nowMilliseconds     = startMilliseconds;
         timeoutMilliseconds = (Uint64)convertmin2millisecs(_duration);         timeoutMilliseconds = (Uint64)convertmin2millisecs(_duration);
Line 1191 
Line 1227 
             Sleep(RUN_DELAY * 1000);             Sleep(RUN_DELAY * 1000);
 #endif #endif
  
               //
             // Quit if SIGINT, SIGABRT is caught             // Quit if SIGINT, SIGABRT is caught
             // So the clients can be gracefully shutdown.             // So the clients can be gracefully shutdown.
               //
             if(Quit)             if(Quit)
             {             {
                 log_file<<                 log_file<<
Line 1272 
Line 1310 
                     //   - Additional required parameters are added to the                     //   - Additional required parameters are added to the
                     //     commands.                     //     commands.
                     //     like, -clientid, -pidfile, -clientlog                     //     like, -clientid, -pidfile, -clientlog
                       //
                     for (int instanceID =0;instanceID<clientInstance[j];                     for (int instanceID =0;instanceID<clientInstance[j];
                          instanceID++)                          instanceID++)
                     {                     {
Line 1333 
Line 1372 
                                     "Command failed to Execute."<<endl;                                     "Command failed to Execute."<<endl;
                             }                             }
                         }                         }
                           //
                         // Increment the actual number of clients                         // Increment the actual number of clients
                           //
                         ++actual_client;                         ++actual_client;
                     } /* for(int instanceID =0;instanceID<clientInstance[j]...*/                     } /* for(int instanceID =0;instanceID<clientInstance[j]...*/
  
Line 1387 
Line 1428 
                  all the clients and then exit.                  all the clients and then exit.
                 */                 */
  
                   //
                 // Retreive all the client PIDs                 // Retreive all the client PIDs
                   //
                 int rc = _getClientPIDs(actual_client,log_file);                 int rc = _getClientPIDs(actual_client,log_file);
  
                 //                 //
Line 1479 
Line 1522 
                 //                 //
                 for (Uint32 clientID=0; clientID < _clientCount; clientID++)                 for (Uint32 clientID=0; clientID < _clientCount; clientID++)
                 {                 {
                       //
                     // Get Current time                     // Get Current time
                       //
                     nowMilliseconds =                     nowMilliseconds =
                         TimeValue::getCurrentTime().toMilliseconds();                         TimeValue::getCurrentTime().toMilliseconds();
  
Line 1527 
Line 1572 
                                     "%d",                                     "%d",
                                     clientPIDs[clientID+instanceID]);                                     clientPIDs[clientID+instanceID]);
                                 stopClientFile.append(str);                                 stopClientFile.append(str);
                                   //
                                 // Required for Windows                                 // Required for Windows
                                   //
                                 ofstream stop_file(                                 ofstream stop_file(
                                     stopClientFile.getCString(),                                     stopClientFile.getCString(),
                                     ios::out);                                     ios::out);
Line 1547 
Line 1594 
                                         clientID + instanceID<<")"<<endl;                                         clientID + instanceID<<")"<<endl;
                                 }                                 }
 #endif #endif
                                   //
                                 // Set the client as inactive.                                 // Set the client as inactive.
                                   //
                                 clientActive[clientID + instanceID] = false;                                 clientActive[clientID + instanceID] = false;
                             }/* for (int instanceID =0;instanceID<clientInst..*/                             }/* for (int instanceID =0;instanceID<clientInst..*/
                               //
                             // indicate that the client was stopped.                             // indicate that the client was stopped.
                               //
                             clientStopped[clientID] = true;                             clientStopped[clientID] = true;
                             //                             //
                             // If the Client has a Wait time                             // If the Client has a Wait time
Line 1570 
Line 1621 
                         //                         //
                         if (clientDelayed[clientID])                         if (clientDelayed[clientID])
                         {                         {
                               //
                             // When waiting period is consumed.                             // When waiting period is consumed.
                               //
                             if (clientDelayMilliseconds[clientID]<=                             if (clientDelayMilliseconds[clientID]<=
                                 nowMilliseconds)                                 nowMilliseconds)
                             {                             {
Line 1698 
Line 1751 
                 clientPIDs[i]<<endl;                 clientPIDs[i]<<endl;
         }         }
         log_file<<"Stopping Client("<<i<<") with PID:"<<clientPIDs[i]<<endl;         log_file<<"Stopping Client("<<i<<") with PID:"<<clientPIDs[i]<<endl;
           //
         // Required for Windows         // Required for Windows
           //
         String stopClientFile = String::EMPTY;         String stopClientFile = String::EMPTY;
         stopClientFile.append(pegasusHome);         stopClientFile.append(pegasusHome);
         stopClientFile.append(DEFAULT_TMPDIR);         stopClientFile.append(DEFAULT_TMPDIR);
Line 1855 
Line 1910 
         {         {
             _currClient=name;             _currClient=name;
             _currClientCount=_clientCount;             _currClientCount=_clientCount;
               //
             // save the client details in a table             // save the client details in a table
               //
             if (!_storeClientDetails(name,value))             if (!_storeClientDetails(name,value))
             {             {
                 log_file<<StressTestControllerCommand::COMMAND_NAME<<                 log_file<<StressTestControllerCommand::COMMAND_NAME<<
Line 2096 
Line 2153 
     {     {
         vars=String::EMPTY;         vars=String::EMPTY;
         vars.append(DURATION);         vars.append(DURATION);
           //
         // converting to a double         // converting to a double
           //
         if (!IsAClient)         if (!IsAClient)
         {         {
             _duration = atof(value.getCString());             _duration = atof(value.getCString());
Line 2155 
Line 2214 
            //            //
            if (instance <=0)            if (instance <=0)
            {            {
                 //
               // Invalid Instance value               // Invalid Instance value
                 //
               return false;               return false;
            }            }
            //            //
Line 2182 
Line 2243 
 #endif #endif
                    if (!FileSystem::exists(clientName))                    if (!FileSystem::exists(clientName))
                    {                    {
                          //
                        // Invalid client name                        // Invalid client name
                          //
                        IsValid = false;                        IsValid = false;
                    }                    }
                    else                    else
Line 2195 
Line 2258 
                else                else
                {                {
  
                      //
                    // Invalid client name                    // Invalid client name
                      //
                    IsValid = false;                    IsValid = false;
                }                }
            }            }
Line 2455 
Line 2520 
             continue;             continue;
         }         }
  
           //
         // Get the client ID         // Get the client ID
           //
         String client = String::EMPTY;         String client = String::EMPTY;
         while (isalnum(*p) || *p == '_')         while (isalnum(*p) || *p == '_')
         {         {
             client.append(*p++);             client.append(*p++);
         }         }
  
           //
         // Skip whitespace after property name         // Skip whitespace after property name
           //
         while (*p && isspace(*p))         while (*p && isspace(*p))
         {         {
             p++;             p++;
         }         }
  
           //
         // Expecting a colon         // Expecting a colon
           //
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
Line 2483 
Line 2554 
         //         //
         p++;         p++;
  
           //
         // Expecting a colon         // Expecting a colon
           //
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
Line 2506 
Line 2579 
             p++;             p++;
         }         }
  
           //
         // Get the client PID         // Get the client PID
           //
         String clntPID = String::EMPTY;         String clntPID = String::EMPTY;
         while (isalnum(*p) || *p == '_')         while (isalnum(*p) || *p == '_')
         {         {
             clntPID.append(*p++);             clntPID.append(*p++);
         }         }
  
           //
         // Skip whitespace after property name         // Skip whitespace after property name
           //
         while (*p && isspace(*p))         while (*p && isspace(*p))
         {         {
             p++;             p++;
Line 2549 
Line 2626 
         }         }
         p++;         p++;
  
           //
         // Skip whitespace after the colon if any         // Skip whitespace after the colon if any
           //
         while (*p && isspace(*p))         while (*p && isspace(*p))
         {         {
             p++;             p++;
Line 2561 
Line 2640 
             clntStatus.append(*p++);             clntStatus.append(*p++);
         }         }
  
           //
         // Skip whitespace after property name         // Skip whitespace after property name
           //
         while (*p && isspace(*p))         while (*p && isspace(*p))
         {         {
             p++;             p++;
Line 2596 
Line 2677 
         // next character in line.         // next character in line.
         //         //
         p++;         p++;
           //
         // Skip whitespace after the colon if any         // Skip whitespace after the colon if any
           //
         while (*p && isspace(*p))         while (*p && isspace(*p))
         {         {
             p++;             p++;
         }         }
  
           //
         // Get the client timestamp         // Get the client timestamp
           //
         String clntTmStmp = String::EMPTY;         String clntTmStmp = String::EMPTY;
         while (isalnum(*p))         while (isalnum(*p))
         {         {
Line 2754 
Line 2839 
        }        }
        catch (...)        catch (...)
        {        {
            // throw what was caught  
            String msg = String(            String msg = String(
                "Unknown exception caught when geting client options.");                "Unknown exception caught when geting client options.");
            log_file<<StressTestControllerCommand::COMMAND_NAME <<            log_file<<StressTestControllerCommand::COMMAND_NAME <<
Line 2968 
Line 3052 
             //             //
             if(clientStatus[i]== VALID_RESPONSE)             if(clientStatus[i]== VALID_RESPONSE)
             {             {
                   //
                 //check with the last timestamp                 //check with the last timestamp
                   //
                 lastUpdateinMilliSec = nowMilliseconds - clientTimeStamp[i];                 lastUpdateinMilliSec = nowMilliseconds - clientTimeStamp[i];
                 //                 //
                 // Assume failure if status update is                 // Assume failure if status update is
Line 3018 
Line 3104 
                 }                 }
                 ++failed_count;                 ++failed_count;
             } /* if (((clientStatus[i]== NO_RESPONSE) ... */             } /* if (((clientStatus[i]== NO_RESPONSE) ... */
               //
             // Save previous time stamp of client             // Save previous time stamp of client
               //
             prev_clientTimeStamp[i] = clientTimeStamp[i];             prev_clientTimeStamp[i] = clientTimeStamp[i];
             prev_clientStatus[i] = clientStatus[i];             prev_clientStatus[i] = clientStatus[i];
         } /* if (clientActive[i]) */         } /* if (clientActive[i]) */
     }     }
       //
     // check actual tolerance     // check actual tolerance
       //
     if(count > 0)     if(count > 0)
     {     {
         double curr_tolerancePercent = getToleranceInPercent(         double curr_tolerancePercent = getToleranceInPercent(
Line 3046 
Line 3136 
         }         }
         return(withinTolerance);         return(withinTolerance);
     }     }
       //
     // All process are stopped.     // All process are stopped.
       //
     return(withinTolerance = true);     return(withinTolerance = true);
 } /* _checkToleranceLevel */ } /* _checkToleranceLevel */
  
Line 3074 
Line 3166 
     {     {
         cout << "Populating default configuration for stress Tests." << endl;         cout << "Populating default configuration for stress Tests." << endl;
     }     }
       //
     // Populating default client attributes     // Populating default client attributes
       //
     for (Uint32 i=0;i<_clientCount; i++)     for (Uint32 i=0;i<_clientCount; i++)
     {     {
         //         //
         // Adding the default instance value to each client table         // Adding the default instance value to each client table
           //
         if (!_clientTable[i].insert(INSTANCE, DEFAULT_INSTANCE))         if (!_clientTable[i].insert(INSTANCE, DEFAULT_INSTANCE))
         {         {
             log_file <<  "Duplicate name already saved: "<<INSTANCE<<endl;             log_file <<  "Duplicate name already saved: "<<INSTANCE<<endl;
Line 3178 
Line 3273 
  
     sprintf(pid_str, "%d", getpid());     sprintf(pid_str, "%d", getpid());
  
       //
     // Stress Controller Log file     // Stress Controller Log file
       //
     _stressTestLogFile.append(pegasusHome);     _stressTestLogFile.append(pegasusHome);
     _stressTestLogFile.append(TESTDIR);     _stressTestLogFile.append(TESTDIR);
     FileSystem::makeDirectory(_stressTestLogFile);     FileSystem::makeDirectory(_stressTestLogFile);
Line 3191 
Line 3288 
     _stressTestLogFile.append(strTime);     _stressTestLogFile.append(strTime);
     _stressTestLogFile.append("log");     _stressTestLogFile.append("log");
  
       //
     // StressClient PID  file     // StressClient PID  file
       //
     _stressTestClientPIDFile.append(pegasusHome);     _stressTestClientPIDFile.append(pegasusHome);
     _stressTestClientPIDFile.append(DEFAULT_TMPDIR);     _stressTestClientPIDFile.append(DEFAULT_TMPDIR);
     FileSystem::makeDirectory(_stressTestClientPIDFile);     FileSystem::makeDirectory(_stressTestClientPIDFile);
Line 3200 
Line 3299 
     _stressTestClientPIDFile.append(strTime);     _stressTestClientPIDFile.append(strTime);
     _stressTestClientPIDFile.append("pid");     _stressTestClientPIDFile.append("pid");
  
       //
     // StressClient Log  file     // StressClient Log  file
       //
     _stressTestClientLogFile.append(pegasusHome);     _stressTestClientLogFile.append(pegasusHome);
     _stressTestClientLogFile.append(DEFAULT_LOGDIR);     _stressTestClientLogFile.append(DEFAULT_LOGDIR);
     _stressTestClientLogFile.append(pid_str);     _stressTestClientLogFile.append(pid_str);
     _stressTestClientLogFile.append("_StressTestClients");     _stressTestClientLogFile.append("_StressTestClients");
     _stressTestClientLogFile.append(".log");     _stressTestClientLogFile.append(".log");
  
       //
     // Temporary StressClient PID/status  file     // Temporary StressClient PID/status  file
       //
     _tmpStressTestClientPIDFile.append(pegasusHome);     _tmpStressTestClientPIDFile.append(pegasusHome);
     _tmpStressTestClientPIDFile.append(DEFAULT_TMPDIR);     _tmpStressTestClientPIDFile.append(DEFAULT_TMPDIR);
     _tmpStressTestClientPIDFile.append(pid_str);     _tmpStressTestClientPIDFile.append(pid_str);
Line 3215 
Line 3318 
     _tmpStressTestClientPIDFile.append("_Clients");     _tmpStressTestClientPIDFile.append("_Clients");
     _tmpStressTestClientPIDFile.append(".pid");     _tmpStressTestClientPIDFile.append(".pid");
  
       //
     // Translate slashed for appropriate OS     // Translate slashed for appropriate OS
       //
     FileSystem::translateSlashes(_stressTestClientPIDFile);     FileSystem::translateSlashes(_stressTestClientPIDFile);
     FileSystem::translateSlashes(_stressTestClientLogFile);     FileSystem::translateSlashes(_stressTestClientLogFile);
     FileSystem::translateSlashes(_stressTestLogFile);     FileSystem::translateSlashes(_stressTestLogFile);
     FileSystem::translateSlashes(_tmpStressTestClientPIDFile);     FileSystem::translateSlashes(_tmpStressTestClientPIDFile);
  
       //
     // open the file     // open the file
       //
     OpenAppend(log_file,_stressTestLogFile);     OpenAppend(log_file,_stressTestLogFile);
     Open(pid_file,_stressTestClientPIDFile);     Open(pid_file,_stressTestClientPIDFile);
     Open(clntlog_file,_stressTestClientLogFile);     Open(clntlog_file,_stressTestClientLogFile);


Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2