version 1.1.2.2, 2006/04/19 22:00:44
|
version 1.1.2.3, 2006/04/24 19:15:09
|
|
|
// | // |
//Windows | //Windows |
// | // |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
#include <windows.h> /* for DWORD etc. */ | #include <windows.h> /* for DWORD etc. */ |
typedef DWORD pid_t; /* getpid() and others */ | typedef DWORD pid_t; /* getpid() and others */ |
#include <process.h> | #include <process.h> |
|
|
| |
static void endAllTests(int signum); | static void endAllTests(int signum); |
| |
static void cleanupProcess(void); |
static void cleanupProcess(); |
| |
static String convertUint64toString(Uint64 x); | static String convertUint64toString(Uint64 x); |
| |
|
|
/** | /** |
The command name. | The command name. |
*/ | */ |
const char StressTestControllerCommand::COMMAND_NAME [] = "TestStressTestController"; |
const char StressTestControllerCommand::COMMAND_NAME [] = |
|
"TestStressTestController"; |
| |
| |
/** | /** |
|
|
*/ | */ |
char StressTestControllerCommand::FILENAME [] = "default_stresstest.conf"; | char StressTestControllerCommand::FILENAME [] = "default_stresstest.conf"; |
char StressTestControllerCommand::TESTDIR[] = "/test/"; | char StressTestControllerCommand::TESTDIR[] = "/test/"; |
char StressTestControllerCommand::STRESSTESTDIR[] = "/StressTestController/"; |
char StressTestControllerCommand::STRESSTESTDIR[] = "StressTestController/"; |
char StressTestControllerCommand::LOGDIR[] = "/log/"; |
char StressTestControllerCommand::LOGDIR[] = "log/"; |
char StressTestControllerCommand::BINDIR[] = "/bin/"; | char StressTestControllerCommand::BINDIR[] = "/bin/"; |
char StressTestControllerCommand::DEFAULT_CFGDIR[] = "/test/StressTestController/"; |
char StressTestControllerCommand::DEFAULT_CFGDIR[] = |
char StressTestControllerCommand::DEFAULT_LOGDIR[] = "/test/StressTestController/log/"; |
STRESSTEST_DEFAULTCFGDIR; |
char StressTestControllerCommand::DEFAULT_TMPDIR[] = "/test/StressTestController/tmp/"; |
char StressTestControllerCommand::DEFAULT_LOGDIR[] = |
|
"/test/StressTestController/log/"; |
|
char StressTestControllerCommand::DEFAULT_TMPDIR[] = |
|
"/test/StressTestController/tmp/"; |
| |
String DEFAULT_BINDIR = String::EMPTY; | String DEFAULT_BINDIR = String::EMPTY; |
| |
|
|
/** | /** |
* Message resource name | * Message resource name |
*/ | */ |
static const char MSG_PATH [] = "pegasus/pegasusCLI"; |
|
static const char PASSWORD_PROMPT [] = | static const char PASSWORD_PROMPT [] = |
"Please enter your password: "; | "Please enter your password: "; |
static const char PASSWORD_BLANK [] = | static const char PASSWORD_BLANK [] = |
|
|
_propertyTable = new Table; | _propertyTable = new Table; |
| |
// Client Information | // Client Information |
_clientCommands = NULL; |
_clientCommands = 0; |
_clientDurations = NULL; |
_clientDurations = 0; |
_clientDelays = NULL; |
_clientDelays = 0; |
| |
// Get environment variables: | // Get environment variables: |
// | // |
pegasusRoot = getenv("PEGASUS_ROOT"); |
|
pegasusHome = getenv("PEGASUS_HOME"); | pegasusHome = getenv("PEGASUS_HOME"); |
| |
DEFAULT_BINDIR = String(pegasusHome); | DEFAULT_BINDIR = String(pegasusHome); |
DEFAULT_BINDIR.append(BINDIR); | DEFAULT_BINDIR.append(BINDIR); |
| |
StressTestLogFile = String::EMPTY; |
_stressTestLogFile = String::EMPTY; |
| |
StressTestClientPIDFile = String::EMPTY; |
_stressTestClientPIDFile = String::EMPTY; |
| |
StressTestClientLogFile = String::EMPTY; |
_stressTestClientLogFile = String::EMPTY; |
| |
tmpStressTestClientPIDFile = String::EMPTY; |
_tmpStressTestClientPIDFile = String::EMPTY; |
| |
| |
| |
usage = String (_USAGE); |
_usage = String (_USAGE); |
| |
usage.append (COMMAND_NAME); |
_usage.append (COMMAND_NAME); |
#ifndef DISABLE_SUPPORT_FOR_REMOTE_CONNECTIONS | #ifndef DISABLE_SUPPORT_FOR_REMOTE_CONNECTIONS |
usage.append (" [ -"); |
_usage.append (" [ -"); |
usage.append (_OPTION_SSL); |
_usage.append (_OPTION_SSL); |
usage.append (" ] [ -"); |
_usage.append (" ] [ -"); |
usage.append (_OPTION_HOSTNAME); |
_usage.append (_OPTION_HOSTNAME); |
usage.append (" hostname ] [ -"); |
_usage.append (" hostname ] [ -"); |
usage.append (_OPTION_PORTNUMBER); |
_usage.append (_OPTION_PORTNUMBER); |
usage.append (" portnumber ]\n [ -"); |
_usage.append (" portnumber ]\n [ -"); |
usage.append (_OPTION_USERNAME); |
_usage.append (_OPTION_USERNAME); |
usage.append (" username ] [ -"); |
_usage.append (" username ] [ -"); |
usage.append (_OPTION_PASSWORD); |
_usage.append (_OPTION_PASSWORD); |
usage.append (" password ]"); |
_usage.append (" password ]"); |
#endif | #endif |
usage.append (" [ --"); |
_usage.append (" [ --"); |
usage.append (LONG_HELP); |
_usage.append (LONG_HELP); |
usage.append(" ]\n [ --").append(LONG_VERSION).append(" ]"); |
_usage.append(" ]\n"); |
usage.append(" [ --").append(LONG_VERBOSE).append(" ]").append(" [<config_filename>] \n"); |
_usage.append(" "); |
|
_usage.append("[ --").append(LONG_VERSION).append(" ]"); |
usage.append("Options : \n"); |
_usage.append(" [ --").append(LONG_VERBOSE).append(" ]").append(\ |
usage.append(" -h - Connect to CIM Server on specified hostname\n"); |
" [<config_filename>] \n"); |
usage.append(" --help - Display this help message\n"); |
|
usage.append(" -p - Connect to CIM Server on specified portnumber\n"); |
_usage.append("Options : \n"); |
usage.append(" -s - Use SSL protocol between 'stressTestController' client\n"); |
_usage.append(" -h - Connect to CIM Server on specified "); |
usage.append(" and the CIM Server\n"); |
_usage.append("hostname. \n"); |
//usage.append(" -t - Specify response timeout value in milliseconds\n"); |
_usage.append(" --help - Display this help message.\n"); |
usage.append(" -u - Connect to CIM Server using the specified username\n"); |
_usage.append(" -p - Connect to CIM Server on specified "); |
usage.append(" --version - Display CIM Server version number\n"); |
_usage.append("portnumber.\n"); |
usage.append(" --verbose - Display verbose information\n"); |
_usage.append(" -s - Use SSL protocol between Stress Test "); |
usage.append(" -w - Connect to CIM Server using the specified password\n"); |
_usage.append("Client\n"); |
usage.append("\nOperands : \n"); |
_usage.append(" and the CIM Server\n"); |
usage.append(" <config_filename>\n"); |
_usage.append(" -u - Connect to CIM Server using the specified"); |
usage.append(" - Specifies the name of the configuration file that is to be used \n"); |
_usage.append(" username\n"); |
usage.append(" for the tests.\n"); |
_usage.append(" --version - Display CIM Server version number\n"); |
|
_usage.append(" --verbose - Display verbose information\n"); |
|
_usage.append(" -w - Connect to CIM Server using the specified"); |
|
_usage.append(" password\n"); |
|
_usage.append("\nOperands : \n"); |
|
_usage.append(" <config_filename>\n"); |
|
_usage.append(" - Specifies the name of the configuration "); |
|
_usage.append("file that is to be used \n"); |
|
_usage.append(" for the tests.\n"); |
| |
setUsage(usage); |
setUsage(_usage); |
| |
} /* StressTestControllerCommand */ | } /* StressTestControllerCommand */ |
| |
|
|
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) |
{ | { |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Cannot get file "<<StressTestLogFile<<endl; |
cout<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Cannot get file "<<_stressTestLogFile<<endl; |
} | } |
| |
} | } |
log_file<<StressTestControllerCommand::COMMAND_NAME<<":: Preparing to set up parameters: "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
":: Preparing to set up parameters: "<<endl; |
| |
// | // |
// Construct GetOptString | // Construct GetOptString |
|
|
// | // |
// more than one _configFilePath argument was found | // more than one _configFilePath argument was found |
// | // |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::More than one arguement was found "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::More than one arguement was found "<<endl; |
log_file.close(); | log_file.close(); |
UnexpectedArgumentException e ( |
UnexpectedArgumentException e(getOpts[i].Value()); |
getOpts [i].Value ()); |
|
throw e; | throw e; |
} | } |
_configFilePath = getOpts [i].Value (); | _configFilePath = getOpts [i].Value (); |
|
|
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME; | cout<<StressTestControllerCommand::COMMAND_NAME; |
cout<<"::Property Name name already saved: "<<"hostname"<<endl; |
cout<<"::Property Name name already saved: "<< |
|
"hostname"<<endl; |
} | } |
} | } |
break; | break; |
} | } |
|
|
case _OPTION_PORTNUMBER: | case _OPTION_PORTNUMBER: |
{ | { |
if (getOpts.isSet (_OPTION_PORTNUMBER) > 1) | if (getOpts.isSet (_OPTION_PORTNUMBER) > 1) |
|
|
DuplicateOptionException e (_OPTION_PORTNUMBER); | DuplicateOptionException e (_OPTION_PORTNUMBER); |
throw e; | throw e; |
} | } |
|
|
_portNumberStr = getOpts [i].Value (); | _portNumberStr = getOpts [i].Value (); |
|
|
try | try |
{ | { |
getOpts [i].Value (_portNumber); | getOpts [i].Value (_portNumber); |
|
|
catch (const TypeMismatchException&) | catch (const TypeMismatchException&) |
{ | { |
log_file.close(); | log_file.close(); |
InvalidOptionArgumentException e (_portNumberStr, _OPTION_PORTNUMBER); |
InvalidOptionArgumentException e( |
|
_portNumberStr, |
|
_OPTION_PORTNUMBER); |
throw e; | throw e; |
} | } |
_portNumberSpecified = true; | _portNumberSpecified = true; |
|
|
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME; | cout<<StressTestControllerCommand::COMMAND_NAME; |
cout<<"::Property Name:duplicate name already saved: "<<"port"<<endl; |
cout<<"::Property Name:duplicate name already saved:" |
|
<<"port"<<endl; |
} | } |
} | } |
break; | break; |
} | } |
|
|
case _OPTION_SSL: | case _OPTION_SSL: |
{ | { |
// | // |
|
|
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME; | cout<<StressTestControllerCommand::COMMAND_NAME; |
cout<<"::Property Name already saved: "<<"port"<<endl; |
cout<<"::Property Name already saved: "<<"port"<< |
|
endl; |
} | } |
} | } |
} | } |
|
|
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME; | cout<<StressTestControllerCommand::COMMAND_NAME; |
cout<<"::Property Name already saved: "<<"ssl"<<endl; |
cout<<"::Property Name already saved: "<<"ssl"<< |
|
endl; |
} | } |
} | } |
break; | break; |
|
|
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME; | cout<<StressTestControllerCommand::COMMAND_NAME; |
cout<< "::Property Name already saved: "<<"username"<<endl; |
cout<< "::Property Name already saved: "<< |
|
"username"<<endl; |
} | } |
} | } |
break; | break; |
} | } |
|
|
case _OPTION_PASSWORD: | case _OPTION_PASSWORD: |
{ | { |
if (getOpts.isSet (_OPTION_PASSWORD) > 1) | if (getOpts.isSet (_OPTION_PASSWORD) > 1) |
|
|
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME; | cout<<StressTestControllerCommand::COMMAND_NAME; |
cout<<"::Property Name already saved: "<<"password"<<endl; |
cout<<"::Property Name already saved: "<< |
|
"password"<<endl; |
} | } |
} | } |
break; | break; |
|
|
// PEP#167 unless an empty '-' is specified | // PEP#167 unless an empty '-' is specified |
// | // |
log_file.close(); | log_file.close(); |
String ErrReport = String(StressTestControllerCommand::COMMAND_NAME); |
String ErrReport = |
|
String(StressTestControllerCommand::COMMAND_NAME); |
ErrReport.append("::Invalid or unknown option specified"); | ErrReport.append("::Invalid or unknown option specified"); |
throw StressTestControllerException(ErrReport); | throw StressTestControllerException(ErrReport); |
| |
//DuplicateOptionException e (_OPTION_PASSWORD); |
|
//throw e; |
|
break; | break; |
} | } |
} | } |
|
|
// | // |
if (!_clientTable[j].lookup(NAME, clientName)) | if (!_clientTable[j].lookup(NAME, clientName)) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Required property NAME not found."<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Required property NAME not found."<<endl; |
return false; | return false; |
} | } |
// | // |
|
|
if(_hostNameSpecified) | if(_hostNameSpecified) |
{ | { |
client_command.append(_hostName); | client_command.append(_hostName); |
} else |
} |
|
else |
|
{ |
client_command.append(i.value()); | client_command.append(i.value()); |
} | } |
|
} |
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 |
|
|
if(_portNumberSpecified) | if(_portNumberSpecified) |
{ | { |
client_command.append(_portNumberStr); | client_command.append(_portNumberStr); |
} else |
} |
|
else |
|
{ |
client_command.append(i.value()); | client_command.append(i.value()); |
} | } |
|
} |
else if (String::equalNoCase(i.key(),SSL)) | else if (String::equalNoCase(i.key(),SSL)) |
{ | { |
client_command.append(" -"); | client_command.append(" -"); |
|
|
||(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 |
{ | { |
|
|
// Include verbose if enabled to clients | // Include verbose if enabled to clients |
// | // |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
client_command.append(" -verbose "); | client_command.append(" -verbose "); |
|
} |
| |
// | // |
// Acquire all the common properties listed in the property table from config file |
// Acquire all the common properties listed in the property table |
// and include it as part of the client command as required. |
// from config file and include it as part of the client command |
// |
// 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; |
|
|
// 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. |
|
|
} | } |
} | } |
// | // |
// Use default duration if one was not specified in the Config file |
// Use default duration if one was not specified in the Config file. |
// | // |
if (String::equalNoCase(k.key(),DURATION)) | if (String::equalNoCase(k.key(),DURATION)) |
{ | { |
duration = atof(k.value().getCString()); | duration = atof(k.value().getCString()); |
} else |
} |
|
else |
|
{ |
duration = _duration; | duration = _duration; |
|
} |
} /* for (Table::Iterator k = _propertyTable->start(); k; k++) */ | } /* for (Table::Iterator k = _propertyTable->start(); k; k++) */ |
| |
// | // |
// Looking up table while ignoring cases for Client Duration/Client Wait |
// Looking up table while ignoring cases for Client Duration/Wait. |
// | // |
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()); |
|
} |
if (String::equalNoCase(k.key(),CLIENTWAIT)) | if (String::equalNoCase(k.key(),CLIENTWAIT)) |
|
{ |
delay = atof(k.value().getCString()); | delay = atof(k.value().getCString()); |
} | } |
|
} |
| |
// | // |
// Save the generated command to corresponding element in clientCommand array |
// Save the generated command to corresponding element in the |
|
// clientCommand array. |
// | // |
_clientCommands[j] = client_command; | _clientCommands[j] = client_command; |
| |
|
|
// | // |
// Saving logs | // Saving logs |
// | // |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Client Command["; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Client Command["; |
log_file<<j<<"]"<<endl; | log_file<<j<<"]"<<endl; |
log_file<<" "<<_clientCommands[j]<<endl; | log_file<<" "<<_clientCommands[j]<<endl; |
log_file<<" Client Duration: "<<convertUint64toString(_clientDurations[j])<<endl; |
log_file<<" Client Duration: "<< |
log_file<<" Client Delay: "<<convertUint64toString(_clientDelays[j])<<endl; |
convertUint64toString(_clientDurations[j])<<endl; |
|
log_file<< |
|
" Client Delay: "<<convertUint64toString(_clientDelays[j])<<endl; |
| |
// | // |
// Verbose | // Verbose |
// | // |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Client Command["; |
cout<< |
|
StressTestControllerCommand::COMMAND_NAME<<"::Client Command["; |
cout<<j<<"]"<<endl; | cout<<j<<"]"<<endl; |
cout<<" "<<_clientCommands[j]<<endl; | cout<<" "<<_clientCommands[j]<<endl; |
cout<<" Client Duration: "<<convertUint64toString(_clientDurations[j])<<endl; |
cout<<" Client Duration: "<< |
cout<<" Client Delay: "<<convertUint64toString(_clientDelays[j])<<endl; |
convertUint64toString(_clientDurations[j])<<endl; |
|
cout<<" Client Delay: "<<convertUint64toString(_clientDelays[j])<< |
|
endl; |
} | } |
} /* for(Uint32 j=0; j< _clientCount; j++) */ | } /* for(Uint32 j=0; j< _clientCount; j++) */ |
return true; | return true; |
|
|
1 if an error occurs in executing the command | 1 if an error occurs in executing the command |
| |
*/ | */ |
Uint32 StressTestControllerCommand::execute (ostream& outPrintWriter, |
Uint32 StressTestControllerCommand::execute ( |
|
ostream& outPrintWriter, |
ostream& errPrintWriter) | ostream& errPrintWriter) |
{ | { |
| |
|
|
Uint64 nowMilliseconds = 0; | Uint64 nowMilliseconds = 0; |
Uint64 stopMilliseconds = 0; | Uint64 stopMilliseconds = 0; |
Uint64 timeoutMilliseconds = 0; | Uint64 timeoutMilliseconds = 0; |
Uint64 *clientStartMilliseconds = NULL; |
Uint64 *clientStartMilliseconds = 0; |
Uint64 *clientStopMilliseconds = NULL; |
Uint64 *clientStopMilliseconds = 0; |
Uint64 *clientDelayMilliseconds = NULL; |
Uint64 *clientDelayMilliseconds = 0; |
Boolean *clientStopped = NULL; |
Boolean *clientStopped = 0; |
Boolean *clientDelayed = NULL; |
Boolean *clientDelayed = 0; |
String act_command = String::EMPTY; | String act_command = String::EMPTY; |
Boolean TestFailed = false; | Boolean TestFailed = false; |
char str[15]; | char str[15]; |
|
|
// | // |
// open the file | // open the file |
// | // |
OpenAppend(log_file,StressTestLogFile); |
OpenAppend(log_file,_stressTestLogFile); |
| |
// | // |
// Failed to read log file. | // Failed to read log file. |
|
|
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
outPrintWriter<<StressTestControllerCommand::COMMAND_NAME; | outPrintWriter<<StressTestControllerCommand::COMMAND_NAME; |
outPrintWriter<<"Cannot read file "<<StressTestLogFile<<endl; |
outPrintWriter<<"Cannot read file "<<_stressTestLogFile<<endl; |
} | } |
return RC_ERROR; | return RC_ERROR; |
} | } |
|
|
// | // |
if ( _operationType == OPERATION_TYPE_HELP ) | if ( _operationType == OPERATION_TYPE_HELP ) |
{ | { |
outPrintWriter << usage << endl; |
outPrintWriter << _usage << endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Listing usage information "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Listing usage information "<<endl; |
log_file.close(); | log_file.close(); |
// | // |
// No need for the client pid and log file. | // No need for the client pid and log file. |
// | // |
FileSystem::removeFile(StressTestClientPIDFile); |
FileSystem::removeFile(_stressTestClientPIDFile); |
FileSystem::removeFile(StressTestClientLogFile); |
FileSystem::removeFile(_stressTestClientLogFile); |
return (RC_SUCCESS); | return (RC_SUCCESS); |
} | } |
// | // |
|
|
else if ( _operationType == OPERATION_TYPE_VERSION ) | else if ( _operationType == OPERATION_TYPE_VERSION ) |
{ | { |
outPrintWriter << "Version " << PEGASUS_PRODUCT_VERSION << endl; | outPrintWriter << "Version " << PEGASUS_PRODUCT_VERSION << endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Listing version information "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Listing version information "<<endl; |
log_file<<"Version " << PEGASUS_PRODUCT_VERSION << endl; | log_file<<"Version " << PEGASUS_PRODUCT_VERSION << endl; |
log_file.close(); | log_file.close(); |
// | // |
// No need for the client pid and log file. | // No need for the client pid and log file. |
// | // |
FileSystem::removeFile(StressTestClientPIDFile); |
FileSystem::removeFile(_stressTestClientPIDFile); |
FileSystem::removeFile(StressTestClientLogFile); |
FileSystem::removeFile(_stressTestClientLogFile); |
return (RC_SUCCESS); | return (RC_SUCCESS); |
} | } |
| |
|
|
else | else |
{ | { |
errPrintWriter << "Stress Tests must have at least one Client." << endl; | errPrintWriter << "Stress Tests must have at least one Client." << endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Stress Tests must have at least one Client."<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Stress Tests must have at least one Client."<<endl; |
log_file.close(); | log_file.close(); |
return (RC_ERROR); | return (RC_ERROR); |
} | } |
|
|
timeoutMilliseconds = (Uint64)convertmin2millisecs(_duration); | timeoutMilliseconds = (Uint64)convertmin2millisecs(_duration); |
stopMilliseconds = nowMilliseconds + timeoutMilliseconds; | stopMilliseconds = nowMilliseconds + timeoutMilliseconds; |
| |
log_file<<StressTestControllerCommand::COMMAND_NAME<<":: Test Duration information "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
log_file<<" Start Time in milliseconds: "<<convertUint64toString(startMilliseconds)<<endl; |
":: Test Duration information "<<endl; |
log_file<<" Total duration in milliseconds: "<<convertUint64toString(timeoutMilliseconds)<<endl; |
log_file<<" Start Time in milliseconds: "<< |
log_file<<" Actual Stop Time in milliseconds: "<<convertUint64toString(stopMilliseconds)<<endl; |
convertUint64toString(startMilliseconds)<<endl; |
|
log_file<<" Total duration in milliseconds: "<< |
|
convertUint64toString(timeoutMilliseconds)<<endl; |
|
log_file<<" Actual Stop Time in milliseconds: "<< |
|
convertUint64toString(stopMilliseconds)<<endl; |
// | // |
// Verbose details for Stress Test duration | // Verbose details for Stress Test duration |
// | // |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<":: Test Duration information "<<endl; |
outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<< |
outPrintWriter<<" Start Time in milliseconds: "<<convertUint64toString(startMilliseconds)<<endl; |
":: Test Duration information "<<endl; |
outPrintWriter<<" Total duration in milliseconds: "<<convertUint64toString(timeoutMilliseconds)<<endl; |
outPrintWriter<<" Start Time in milliseconds: "<< |
outPrintWriter<<" Actual Stop Time in milliseconds: "<<convertUint64toString(stopMilliseconds)<<endl; |
convertUint64toString(startMilliseconds)<<endl; |
|
outPrintWriter<<" Total duration in milliseconds: "<< |
|
convertUint64toString(timeoutMilliseconds)<<endl; |
|
outPrintWriter<< |
|
" Actual Stop Time in milliseconds: "<< |
|
convertUint64toString(stopMilliseconds)<<endl; |
} | } |
| |
// | // |
|
|
// the CHECKUP_INTERVAL. This should give the clients enough time | // the CHECKUP_INTERVAL. This should give the clients enough time |
// to update its PID, status etc. | // to update its PID, status etc. |
// | // |
Uint64 nextCheckupInMillisecs = (Uint64)convertmin2millisecs(2 * CHECKUP_INTERVAL) + nowMilliseconds; |
Uint64 nextCheckupInMillisecs = |
|
(Uint64)convertmin2millisecs(2 * CHECKUP_INTERVAL) + nowMilliseconds; |
|
|
// | // |
// Main "while" loop where the clients are initiated. | // Main "while" loop where the clients are initiated. |
// | // |
|
|
// Small delay in the while loop seemed to reduce the CPU usage | // Small delay in the while loop seemed to reduce the CPU usage |
// considerably in Windows. (From 80% to 1%) | // considerably in Windows. (From 80% to 1%) |
// | // |
#ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifndef PEGASUS_OS_TYPE_WINDOWS |
sleep(RUN_DELAY); | sleep(RUN_DELAY); |
#else | #else |
Sleep(RUN_DELAY * 1000); | Sleep(RUN_DELAY * 1000); |
|
|
// So the clients can be gracefully shutdown. | // So the clients can be gracefully shutdown. |
if(Quit) | if(Quit) |
{ | { |
log_file<<"Test interrupted by either SIGINT or SIGABORT."<<endl; |
log_file<< |
|
"Test interrupted by either SIGINT or SIGABORT."<<endl; |
TestFailed = true; | TestFailed = true; |
break; | break; |
} | } |
|
|
// | // |
if(!actual_client) | if(!actual_client) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Running the following tests: "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<"::Running the following tests: "<<endl; |
"::Running the following tests: "<<endl; |
|
outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Running the following tests: "<<endl; |
for(Uint32 j=0; j< _clientCount; j++) | for(Uint32 j=0; j< _clientCount; j++) |
{ | { |
String clientInst = String::EMPTY; | String clientInst = String::EMPTY; |
|
|
// | // |
if (!_clientTable[j].lookup(INSTANCE, clientInst)) | if (!_clientTable[j].lookup(INSTANCE, clientInst)) |
{ | { |
throw InvalidPropertyValue(INSTANCE, clientInst); |
String ErrReport = String("Invalid Property Value: "); |
//throw UnrecognizedConfigProperty(HOSTNAME); |
ErrReport.append(INSTANCE); |
|
ErrReport.append("="); |
|
ErrReport.append(clientInst); |
|
throw StressTestControllerException(ErrReport); |
} | } |
clientInstance[j] = atoi(clientInst.getCString()); | clientInstance[j] = atoi(clientInst.getCString()); |
| |
// | // |
// Acquire and set client specific duration | // Acquire and set client specific duration |
// | // |
clientStartMilliseconds[j]=TimeValue::getCurrentTime().toMilliseconds(); |
clientStartMilliseconds[j] = |
clientStopMilliseconds[j]=clientStartMilliseconds[j] + _clientDurations[j]; |
TimeValue::getCurrentTime().toMilliseconds(); |
|
clientStopMilliseconds[j] = |
|
clientStartMilliseconds[j] + _clientDurations[j]; |
| |
// | // |
// for verbose only | // for verbose only |
|
|
{ | { |
outPrintWriter<<"Client:"<<"["<<j<<"]"<<endl; | outPrintWriter<<"Client:"<<"["<<j<<"]"<<endl; |
log_file<<"Client:"<<"["<<j<<"]"<<endl; | log_file<<"Client:"<<"["<<j<<"]"<<endl; |
outPrintWriter<<"ClientStart:"<<convertUint64toString(clientStartMilliseconds[j])<<endl; |
outPrintWriter<<"ClientStart:"<< |
outPrintWriter<<"ClientStop:"<<convertUint64toString(clientStopMilliseconds[j])<<endl; |
convertUint64toString(clientStartMilliseconds[j])<< |
outPrintWriter<<"ClientDuration:"<<convertUint64toString(_clientDurations[j])<<endl; |
endl; |
log_file<<"ClientStart:"<<convertUint64toString(clientStartMilliseconds[j])<<endl; |
outPrintWriter<<"ClientStop:"<< |
log_file<<"ClientStop:"<<convertUint64toString(clientStopMilliseconds[j])<<endl; |
convertUint64toString(clientStopMilliseconds[j])<< |
log_file<<"ClientDuration:"<<convertUint64toString(_clientDurations[j])<<endl; |
endl; |
|
outPrintWriter<<"ClientDuration:"<< |
|
convertUint64toString(_clientDurations[j])<<endl; |
|
log_file<<"ClientStart:"<< |
|
convertUint64toString(clientStartMilliseconds[j])<< |
|
endl; |
|
log_file<<"ClientStop:"<< |
|
convertUint64toString(clientStopMilliseconds[j])<< |
|
endl; |
|
log_file<< |
|
"ClientDuration:"<< |
|
convertUint64toString(_clientDurations[j])<<endl; |
|
} |
|
log_file<< |
|
"Number of instances of this client: "<< |
|
clientInstance[j]<<endl; |
|
if(verboseEnabled) |
|
{ |
|
outPrintWriter<< |
|
"Number of instances of this client:"<< |
|
clientInstance[j]<<endl; |
} | } |
log_file<<"Number of instances of this client: "<<clientInstance[j]<<endl; |
|
if(verboseEnabled) |
|
outPrintWriter<<"Number of instances of this client:"<<clientInstance[j]<<endl; |
|
// | // |
// Execute each instance of the client. | // Execute each instance of the client. |
// - Additional required parameters are added to the commands |
// - Additional required parameters are added to the |
|
// commands. |
// like, -clientid, -pidfile, -clientlog | // like, -clientid, -pidfile, -clientlog |
for(int instanceID =0;instanceID<clientInstance[j];instanceID++) |
for (int instanceID =0;instanceID<clientInstance[j]; |
|
instanceID++) |
{ | { |
outPrintWriter<<"Running Client("<<actual_client<<")"<<endl; |
outPrintWriter<< |
log_file<<"Running Client("<<actual_client<<")"<<endl; |
"Running Client("<<actual_client<<")"<<endl; |
|
log_file<< |
|
"Running Client("<<actual_client<<")"<<endl; |
act_command=String::EMPTY; | act_command=String::EMPTY; |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
act_command.append("start "); | act_command.append("start "); |
#endif | #endif |
// | // |
|
|
act_command.append(str); | act_command.append(str); |
act_command.append(" -pidfile "); | act_command.append(" -pidfile "); |
act_command.append(" \""); | act_command.append(" \""); |
act_command.append(StressTestClientPIDFile); |
act_command.append(_stressTestClientPIDFile); |
act_command.append("\""); | act_command.append("\""); |
act_command.append(" -clientlog"); | act_command.append(" -clientlog"); |
act_command.append(" \""); | act_command.append(" \""); |
act_command.append(StressTestClientLogFile); |
act_command.append(_stressTestClientLogFile); |
act_command.append("\""); | act_command.append("\""); |
act_command.append("&"); | act_command.append("&"); |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
outPrintWriter<<" "<<act_command<<endl; | outPrintWriter<<" "<<act_command<<endl; |
tmTime = getCurrentActualTime(); | tmTime = getCurrentActualTime(); |
strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime); |
strftime( |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Running following command on "<<strTime<<endl; |
strTime, |
log_file<<" ("<<actual_client<<") \n"<<act_command<<endl; |
256, |
|
"%d/%m/%Y at %H:%M:%S\n", |
|
&tmTime); |
|
log_file<< |
|
StressTestControllerCommand::COMMAND_NAME<< |
|
"::Running following command on "<< |
|
strTime<<endl; |
|
log_file<<" ("<<actual_client<<") \n"<< |
|
act_command<<endl; |
} | } |
| |
// | // |
|
|
{ | { |
log_file<<"Command failed to Execute."<<endl; | log_file<<"Command failed to Execute."<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
outPrintWriter<<"Command failed to Execute."<<endl; |
{ |
|
outPrintWriter<< |
|
"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];instanceID++) */ |
} /* for(int instanceID =0;instanceID<clientInstance[j]...*/ |
| |
}/* for(Uint32 j=0; j< _clientCount; j++) */ | }/* for(Uint32 j=0; j< _clientCount; j++) */ |
| |
|
|
clientTimeStamp[i] = nowMilliseconds; | clientTimeStamp[i] = nowMilliseconds; |
prev_clientTimeStamp[i] = nowMilliseconds; | prev_clientTimeStamp[i] = nowMilliseconds; |
} | } |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Getting client PID's and status. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Getting client PID's and status. "<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
outPrintWriter <<StressTestControllerCommand::COMMAND_NAME<<"::Getting client PID's and status. "<<endl; |
{ |
int rc = getClientPIDs(actual_client,log_file); |
outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Getting client PID's and status. "<<endl; |
|
} |
|
int rc = _getClientPIDs(actual_client,log_file); |
if(!rc) | if(!rc) |
{ | { |
outPrintWriter<<"Failed to communicate with clients."<<endl; |
outPrintWriter<< |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Failed to communicate with clients. "<<endl; |
"Failed to communicate with clients."<<endl; |
log_file<<" ::Failed to get client PID & status. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Failed to communicate with clients. "<<endl; |
|
log_file<< |
|
" ::Failed to get client PID & status. " |
|
<<endl; |
TestFailed = true; | TestFailed = true; |
break; | break; |
} | } |
|
|
*/ | */ |
| |
// Retreive all the client PIDs | // Retreive all the client PIDs |
int rc = getClientPIDs(actual_client,log_file); |
int rc = _getClientPIDs(actual_client,log_file); |
| |
// | // |
// Get Current Time | // Get Current Time |
|
|
// | // |
// Set up the next tolerance time | // Set up the next tolerance time |
// | // |
nextCheckupInMillisecs = (Uint64)convertmin2millisecs(CHECKUP_INTERVAL)\ |
nextCheckupInMillisecs = |
+ nowMilliseconds; |
(Uint64)convertmin2millisecs(CHECKUP_INTERVAL) + |
|
nowMilliseconds; |
// | // |
// End tests when failed to acquire the Client PID or status |
// End tests when failed to acquire the Client PID or |
|
// status. |
// | // |
if(!rc) | if(!rc) |
{ | { |
outPrintWriter<<"Failed to communicate with clients."<<endl; |
outPrintWriter<< |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Failed to communicate with clients. "<<endl; |
"Failed to communicate with clients."<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Get Client PID FAILED. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Failed to communicate with clients. "<<endl; |
|
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Get Client PID FAILED. "<<endl; |
TestFailed = true; | TestFailed = true; |
break; | break; |
} | } |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Checking current tolerance level. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Checking current tolerance level. "<<endl; |
// | // |
// Output Client info if verbose is enabled. | // Output Client info if verbose is enabled. |
// | // |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<"::Checking current tolerance level. "<<endl; |
outPrintWriter<< |
|
StressTestControllerCommand::COMMAND_NAME<< |
|
"::Checking current tolerance level. "<<endl; |
for(int i=0;i< actual_client; i++) | for(int i=0;i< actual_client; i++) |
{ | { |
outPrintWriter <<" Client: "<<i; | outPrintWriter <<" Client: "<<i; |
|
|
log_file <<" Client: "<<i; | log_file <<" Client: "<<i; |
log_file <<" PID: "<<clientPIDs[i]<<", "; | log_file <<" PID: "<<clientPIDs[i]<<", "; |
log_file <<" Status: "<<clientStatus[i]<<", "; | log_file <<" Status: "<<clientStatus[i]<<", "; |
log_file<<" TimeStamp: "<<convertUint64toString(clientTimeStamp[i])<<endl; |
log_file<<" TimeStamp: "<< |
|
convertUint64toString(clientTimeStamp[i])<< |
|
endl; |
} | } |
} | } |
// | // |
// Check the actual tolerance level | // Check the actual tolerance level |
// | // |
Boolean withinTolerance = checkToleranceLevel(actual_client,nowMilliseconds,log_file); |
Boolean withinTolerance = _checkToleranceLevel( |
|
actual_client, |
|
nowMilliseconds, |
|
log_file); |
// | // |
// End tests if not within tolerance | // End tests if not within tolerance |
// | // |
if(!withinTolerance) | if(!withinTolerance) |
{ | { |
log_file<<"FAILED::Tests NOT within tolerance."<<endl; | log_file<<"FAILED::Tests NOT within tolerance."<<endl; |
errPrintWriter<<"FAILED::Tests NOT within tolerance."<<endl; |
errPrintWriter<<"FAILED::Tests NOT within tolerance." |
|
<<endl; |
TestFailed = true; | TestFailed = true; |
break; | break; |
} | } |
// | // |
// Within Tolerance - Continue tests. | // Within Tolerance - Continue tests. |
// | // |
log_file<<"********Tests are within tolerance.********* "<<endl; |
log_file<<"********Tests are within tolerance.********* "<< |
|
endl; |
if(verboseEnabled) | if(verboseEnabled) |
outPrintWriter<<" ********Tests are within tolerance.**********"<<endl; |
{ |
|
outPrintWriter<< |
} /* if(nowMilliseconds >= nextCheckupInMillisecs) -- Tolerance Level check*/ |
" ********Tests are within tolerance.**********"<< |
|
endl; |
|
} |
|
} /* if (nowMilliseconds >= nextCheckupInMillisecs)*/ |
// | // |
// Stop clients with delay | // Stop clients with delay |
// | // |
for(Uint32 clientID=0; clientID < _clientCount; clientID++) | for(Uint32 clientID=0; clientID < _clientCount; clientID++) |
{ | { |
// Get Current time | // Get Current time |
nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds(); |
nowMilliseconds = |
|
TimeValue::getCurrentTime().toMilliseconds(); |
| |
// | // |
// Stop only running clients as required. | // Stop only running clients as required. |
|
|
// | // |
// Stop all the instances of this client | // Stop all the instances of this client |
// | // |
for(int instanceID =0;instanceID<clientInstance[clientID];instanceID++) |
for (int instanceID =0; |
{ |
instanceID<clientInstance[clientID]; |
log_file<<"Stopping client:("<<clientID+instanceID<<")"<<endl; |
instanceID++) |
log_file<<" with PID = "<<clientPIDs[clientID+instanceID]<<endl; |
{ |
outPrintWriter<<"Stopping client:("<<clientID+instanceID<<")"<<endl; |
log_file<<"Stopping client:("<< |
outPrintWriter<<" with PID = "<<clientPIDs[clientID+instanceID]<<endl; |
clientID+instanceID<<")"<<endl; |
|
log_file<<" with PID = "<< |
|
clientPIDs[clientID+instanceID]<<endl; |
|
outPrintWriter<<"Stopping client:("<< |
|
clientID+instanceID<<")"<<endl; |
|
outPrintWriter<<" with PID = "<< |
|
clientPIDs[clientID+instanceID]<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
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); |
log_file<<" Stopped on "<<strTime<<endl; | log_file<<" Stopped on "<<strTime<<endl; |
} | } |
String stopClientFile = String::EMPTY; | String stopClientFile = String::EMPTY; |
stopClientFile.append(pegasusHome); | stopClientFile.append(pegasusHome); |
stopClientFile.append(DEFAULT_TMPDIR); | stopClientFile.append(DEFAULT_TMPDIR); |
stopClientFile.append("STOP_"); | stopClientFile.append("STOP_"); |
sprintf(str,"%d",clientPIDs[clientID+instanceID]); |
sprintf( |
|
str, |
|
"%d", |
|
clientPIDs[clientID+instanceID]); |
stopClientFile.append(str); | stopClientFile.append(str); |
// Required for Windows | // Required for Windows |
ofstream stop_file(stopClientFile.getCString(),ios::out); |
ofstream stop_file( |
stop_file << "Stop Client PID : "<<clientPIDs[clientID + instanceID]<<endl; |
stopClientFile.getCString(), |
|
ios::out); |
|
stop_file << "Stop Client PID : "<< |
|
clientPIDs[clientID + instanceID]<< |
|
endl; |
stop_file.close(); | stop_file.close(); |
#ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifndef PEGASUS_OS_TYPE_WINDOWS |
// one more way to stop the clients. | // one more way to stop the clients. |
int rc = kill(clientPIDs[clientID+instanceID], SIGINT); |
int rc = |
|
kill(clientPIDs[clientID+instanceID], SIGINT); |
if(rc) | if(rc) |
{ | { |
outPrintWriter<<"FAILED to stop client:("<<clientID+instanceID<<")"<<endl; |
outPrintWriter<<"FAILED to stop client:("<< |
log_file<<"FAILED to stop client:("<<clientID + instanceID<<")"<<endl; |
clientID+instanceID<<")"<<endl; |
|
log_file<<"FAILED to stop client:("<< |
|
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..*/ |
// indicate that the client was stopped. | // indicate that the client was stopped. |
clientStopped[clientID] = true; | clientStopped[clientID] = true; |
// | // |
|
|
// | // |
if(_clientDelays[clientID] !=0) | if(_clientDelays[clientID] !=0) |
{ | { |
clientDelayMilliseconds[clientID]=nowMilliseconds + _clientDelays[clientID]; |
clientDelayMilliseconds[clientID] = |
|
nowMilliseconds + _clientDelays[clientID]; |
clientDelayed[clientID] = true; | clientDelayed[clientID] = true; |
} | } |
} /* if(clientStopMilliseconds[clientID]<= nowMilliseconds) */ |
} /* if (clientStopMilliseconds[clientID]<= nowMilli..*/ |
} /* if(!clientStopped[clientID]) */ | } /* if(!clientStopped[clientID]) */ |
else | else |
{ | { |
|
|
if(clientDelayed[clientID]) | if(clientDelayed[clientID]) |
{ | { |
// When waiting period is consumed. | // When waiting period is consumed. |
if(clientDelayMilliseconds[clientID]<= nowMilliseconds) |
if (clientDelayMilliseconds[clientID]<= |
|
nowMilliseconds) |
{ | { |
// | // |
// Restart all the instances of the client. | // Restart all the instances of the client. |
// | // |
for(int instanceID =0;instanceID<clientInstance[clientID];instanceID++) |
for (int instanceID =0; |
|
instanceID<clientInstance[clientID]; |
|
instanceID++) |
{ | { |
act_command=String::EMPTY; | act_command=String::EMPTY; |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
act_command.append("start "); | act_command.append("start "); |
#endif | #endif |
act_command.append(_clientCommands[clientID].getCString()); |
act_command.append( |
|
_clientCommands[clientID].getCString()); |
act_command.append(" -clientid "); | act_command.append(" -clientid "); |
sprintf(str,"%d",clientID+instanceID); | sprintf(str,"%d",clientID+instanceID); |
act_command.append(str); | act_command.append(str); |
act_command.append(" -pidfile "); | act_command.append(" -pidfile "); |
act_command.append(" \""); | act_command.append(" \""); |
act_command.append(StressTestClientPIDFile); |
act_command.append(_stressTestClientPIDFile); |
act_command.append("\""); | act_command.append("\""); |
act_command.append(" -clientlog"); | act_command.append(" -clientlog"); |
act_command.append(" \""); | act_command.append(" \""); |
act_command.append(StressTestClientLogFile); |
act_command.append(_stressTestClientLogFile); |
act_command.append("\""); | act_command.append("\""); |
act_command.append("&"); | act_command.append("&"); |
log_file<<"Restarting client:("<<clientID+instanceID<<")"<<endl; |
log_file<<"Restarting client:("<< |
outPrintWriter<<"Restarting client:("<<clientID+instanceID<<")"<<endl; |
clientID+instanceID<<")"<<endl; |
|
outPrintWriter<<"Restarting client:("<< |
|
clientID+instanceID<<")"<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
outPrintWriter<<" "<<act_command<<endl; | outPrintWriter<<" "<<act_command<<endl; |
log_file<<" ("<<clientID+instanceID<<") \n"<<act_command<<endl; |
log_file<<" ("<< |
|
clientID+instanceID<< |
|
") \n"<<act_command<<endl; |
tmTime = getCurrentActualTime(); | tmTime = getCurrentActualTime(); |
strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime); |
strftime( |
log_file<<" Restarted on "<<strTime<<endl; |
strTime, |
|
256, |
|
"%d/%m/%Y at %H:%M:%S\n", |
|
&tmTime); |
|
log_file<<" Restarted on "<< |
|
strTime<<endl; |
} | } |
int rc = system(act_command.getCString()); | int rc = system(act_command.getCString()); |
if(rc) | if(rc) |
{ | { |
log_file<<"Command failed to Execute."<<endl; |
log_file<<"Command failed to Execute."<< |
|
endl; |
if(verboseEnabled) | if(verboseEnabled) |
outPrintWriter<<act_command <<"Command failed to Execute."<<endl; |
{ |
|
outPrintWriter<<act_command<< |
|
"Command failed to Execute."<< |
|
endl; |
} | } |
clientActive[clientID+instanceID] = true; |
|
} | } |
clientStopMilliseconds[clientID]=nowMilliseconds + _clientDurations[clientID]; |
clientActive[clientID+instanceID] = true; |
|
} /* for (int instanceID =0;instanceID .. */ |
|
clientStopMilliseconds[clientID] = |
|
nowMilliseconds + |
|
_clientDurations[clientID]; |
clientStopped[clientID] = false; | clientStopped[clientID] = false; |
clientDelayed[clientID] = false; | clientDelayed[clientID] = false; |
} /* if(clientDelayMilliseconds[clientID]<= nowMilliseconds) */ |
}/* if(clientDelayMilliseconds[clientID]<=nowMi.. */ |
} /* if(clientDelayed[clientID]) */ | } /* if(clientDelayed[clientID]) */ |
} |
} /* else ..*/ |
} /* for(Uint32 clientID=0; clientID < _clientCount; clientID++) */ | } /* for(Uint32 clientID=0; clientID < _clientCount; clientID++) */ |
} /* else for if(!actual_client) */ | } /* else for if(!actual_client) */ |
// | // |
|
|
| |
catch (const StressTestControllerException& e) | catch (const StressTestControllerException& e) |
{ | { |
errPrintWriter << StressTestControllerCommand::COMMAND_NAME << ": " << e.getMessage () << endl; |
errPrintWriter << StressTestControllerCommand::COMMAND_NAME << |
|
": " << e.getMessage () << endl; |
return (RC_ERROR); | return (RC_ERROR); |
} | } |
| |
|
|
// just before the tests were ended to add | // just before the tests were ended to add |
// its pid to the pid file. | // its pid to the pid file. |
| |
#ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifndef PEGASUS_OS_TYPE_WINDOWS |
sleep(STOP_DELAY); | sleep(STOP_DELAY); |
#else | #else |
Sleep(STOP_DELAY * 1000); | Sleep(STOP_DELAY * 1000); |
|
|
// | // |
// get all the clientPIDs before it is stopped. | // get all the clientPIDs before it is stopped. |
// | // |
int rc = getClientPIDs(actual_client,log_file); |
int rc = _getClientPIDs(actual_client,log_file); |
if(!rc) | if(!rc) |
{ | { |
outPrintWriter<<"Failed to communicate with clients."<<endl; | outPrintWriter<<"Failed to communicate with clients."<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Failed to communicate with clients. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
log_file<<" ::Failed to get client PID & status. "<<endl; |
"::Failed to communicate with clients. "<<endl; |
|
log_file<<" ::Failed to get client PID & status. "<< |
|
endl; |
TestFailed = true; | TestFailed = true; |
} | } |
tmTime = getCurrentActualTime(); | tmTime = getCurrentActualTime(); |
|
|
for(int i=0;i<actual_client;i++) | for(int i=0;i<actual_client;i++) |
{ | { |
if(verboseEnabled) | if(verboseEnabled) |
outPrintWriter<<"Stopping Client("<<i<<") with PID:"<<clientPIDs[i]<<endl; |
{ |
|
outPrintWriter<<"Stopping Client("<<i<<") with PID:"<< |
|
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; |
|
|
ofstream stop_file(stopClientFile.getCString(),ios::out); | ofstream stop_file(stopClientFile.getCString(),ios::out); |
stop_file << "Stop Client PID : "<<clientPIDs[i]<<endl; | stop_file << "Stop Client PID : "<<clientPIDs[i]<<endl; |
stop_file.close(); | stop_file.close(); |
#ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifndef PEGASUS_OS_TYPE_WINDOWS |
// Another way to stop the client | // Another way to stop the client |
int rc = 0; | int rc = 0; |
rc = kill(clientPIDs[i], SIGINT); | rc = kill(clientPIDs[i], SIGINT); |
if(rc) | if(rc) |
{ | { |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
outPrintWriter<<"Failed to stop client:("<<i<<")"<<endl; | outPrintWriter<<"Failed to stop client:("<<i<<")"<<endl; |
|
} |
log_file<<"Failed to stop client:("<<i<<")"<<endl; | log_file<<"Failed to stop client:("<<i<<")"<<endl; |
} | } |
#endif | #endif |
} | } |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
outPrintWriter<<"Cleaning all resources"<<endl; | outPrintWriter<<"Cleaning all resources"<<endl; |
|
} |
log_file<<"Cleaning all resources."<<endl; | log_file<<"Cleaning all resources."<<endl; |
cleanupProcess(); | cleanupProcess(); |
| |
// | // |
// Waiting to allow clients to shutdown | // Waiting to allow clients to shutdown |
// | // |
#ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifndef PEGASUS_OS_TYPE_WINDOWS |
sleep(SHUTDOWN_DELAY); | sleep(SHUTDOWN_DELAY); |
#else | #else |
Sleep(SHUTDOWN_DELAY * 1000); | Sleep(SHUTDOWN_DELAY * 1000); |
|
|
| |
| |
/* | /* |
Retrieves the contents of the config file if specified or uses default values from |
Retrieves the contents of the config file if specified or uses default |
either the default config file |
values from either the default config file |
| |
@param fileName The specified or default config file for the | @param fileName The specified or default config file for the |
tests. | tests. |
|
|
false if file was not read successfully. | false if file was not read successfully. |
| |
*/ | */ |
Boolean StressTestControllerCommand::getFileContent(String fileName,ostream& log_file) |
Boolean StressTestControllerCommand::getFileContent( |
|
String fileName, |
|
ostream& log_file) |
{ | { |
String configData = String::EMPTY; | String configData = String::EMPTY; |
String line; | String line; |
|
|
Open(ifs,fileName); | Open(ifs,fileName); |
if (!ifs) | if (!ifs) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Cannot read config file: "<<fileName<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Cannot read config file: "<<fileName<<endl; |
throw NoSuchFile(fileName); | throw NoSuchFile(fileName); |
return false; |
|
} | } |
| |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Storing client details. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
|
"::Storing client details. "<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Storing config details. "<<endl; |
{ |
|
cout<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Storing config details. "<<endl; |
|
} |
// | // |
// Get each line of the file. | // Get each line of the file. |
// | // |
|
|
IsAClient = false; | IsAClient = false; |
name = String::EMPTY; | name = String::EMPTY; |
value = String::EMPTY; | value = String::EMPTY; |
try { |
try |
|
{ |
// | // |
// Parse each line of Config file | // Parse each line of Config file |
// | // |
parseLine(line,lineNumber,name,value,log_file); |
_parseLine(line,lineNumber,name,value,log_file); |
} | } |
// | // |
// catch all the exceptions if any thrown from parseLine | // catch all the exceptions if any thrown from parseLine |
|
|
ErrReports.append(line_num); | ErrReports.append(line_num); |
ErrReports.append(":: "); | ErrReports.append(":: "); |
ErrReports.append(msg.getCString()); | ErrReports.append(msg.getCString()); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::"<<msg<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::" |
|
<<msg<<endl; |
isSuccess = false; | isSuccess = false; |
} | } |
catch(...) | catch(...) |
|
|
ErrReports.append(line_num); | ErrReports.append(line_num); |
ErrReports.append(":: "); | ErrReports.append(":: "); |
ErrReports.append("Unknown exception caught."); | ErrReports.append("Unknown exception caught."); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when parsing line."<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
cerr<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when parsing line."<<endl; |
":Unknown exception caught when parsing line."<<endl; |
|
cerr<<StressTestControllerCommand::COMMAND_NAME << |
|
":Unknown exception caught when parsing line."<<endl; |
return false; | return false; |
} | } |
| |
|
|
_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<<"::Syntax error found in line#"<<lineNumber<<" of config file: "<<fileName<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Syntax error found in line#"<<lineNumber<< |
|
" of config file: "<<fileName<<endl; |
isSuccess = false; | isSuccess = false; |
} | } |
} | } |
|
|
// Duplicate property, ignore the new property value. | // Duplicate property, ignore the new property value. |
// | // |
#ifdef DEBUG | #ifdef DEBUG |
cout<< "Property Name:duplicate name already saved: "<<name<<endl; |
cout<< "Property Name:duplicate name already saved: "<< |
|
name<<endl; |
#endif | #endif |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Duplicate property name "<<name<<" already saved."<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Duplicate property name "<<name<<" already saved."<< |
|
endl; |
} | } |
} | } |
} | } |
|
|
ErrReports.append("\n "); | ErrReports.append("\n "); |
ErrReports.append(StressTestControllerCommand::COMMAND_NAME); | ErrReports.append(StressTestControllerCommand::COMMAND_NAME); |
ErrReports.append("::No clients found."); | ErrReports.append("::No clients found."); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::No clients found in"<<" config file: "<<fileName<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
|
"::No clients found in"<<" config file: "<<fileName<<endl; |
isSuccess = false; | isSuccess = false; |
} | } |
// | // |
|
|
// | // |
cleanupProcess(); | cleanupProcess(); |
throw StressTestControllerException(ErrReports); | throw StressTestControllerException(ErrReports); |
return isSuccess; |
|
} | } |
| |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Common Properties:"<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Common Properties:"<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Common Properties:"<<endl; |
{ |
|
cout<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Common Properties:"<<endl; |
|
} |
for (Table::Iterator i = _propertyTable->start(); i; i++) | for (Table::Iterator i = _propertyTable->start(); i; i++) |
{ | { |
log_file<<" "<<i.key()<<"\t= "<<i.value()<<endl; | log_file<<" "<<i.key()<<"\t= "<<i.value()<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<<" "<<i.key()<<"\t= "<<i.value()<<endl; | cout<<" "<<i.key()<<"\t= "<<i.value()<<endl; |
} | } |
|
} |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<"Total clients found:"<<_clientCount<<endl; | cout<<"Total clients found:"<<_clientCount<<endl; |
cout<<"CLIENT TABLE CONTENTS:"<<endl; | cout<<"CLIENT TABLE CONTENTS:"<<endl; |
} | } |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Client Properties:"<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Client Properties:"<<endl; |
for(Uint32 j = 0; j < _clientCount; j++) | for(Uint32 j = 0; j < _clientCount; j++) |
{ | { |
log_file<<"Client information #"<<j+1<<" from config file:"<<endl; | log_file<<"Client information #"<<j+1<<" from config file:"<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<<"Client("<<j<<")"<<endl; | cout<<"Client("<<j<<")"<<endl; |
|
} |
for (Table::Iterator i = _clientTable[j].start(); i; i++) | for (Table::Iterator i = _clientTable[j].start(); i; i++) |
{ | { |
log_file<<" "<<i.key()<<" = "<<i.value()<<endl; | log_file<<" "<<i.key()<<" = "<<i.value()<<endl; |
|
|
| |
| |
if(isSuccess) | if(isSuccess) |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Successfully retreived config values from"<<" config file: "<<fileName<<endl; |
{ |
|
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Successfully retreived config values from" << |
|
" config file: "<<fileName<<endl; |
|
} |
return isSuccess; | return isSuccess; |
}/* getFileContent */ | }/* getFileContent */ |
| |
|
|
*/ | */ |
| |
| |
Boolean StressTestControllerCommand::validateConfiguration(String & vars,const String & value,ostream& log_file) |
Boolean StressTestControllerCommand::_validateConfiguration( |
|
String & vars, |
|
const String & value, |
|
ostream& log_file) |
{ | { |
Boolean IsValid = false; | Boolean IsValid = false; |
| |
|
|
if(!IsAClient) | if(!IsAClient) |
{ | { |
if(!_hostNameSpecified) | if(!_hostNameSpecified) |
|
{ |
_hostName = value; | _hostName = value; |
} | } |
|
} |
else | else |
{ | { |
// Should IP addresses if specified be converted to hostname for comparision? |
|
| |
if(_hostName != String::EMPTY) | if(_hostName != String::EMPTY) |
{ | { |
if (!String::equalNoCase(value,_hostName)) | if (!String::equalNoCase(value,_hostName)) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Multiple hostnames were found. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Multiple hostnames were found. "<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Multiple hostnames were found. "<<endl; |
{ |
|
cout<<StressTestControllerCommand::COMMAND_NAME << |
|
"::Multiple hostnames were found. "<<endl; |
|
} |
return false; | return false; |
} | } |
} | } |
else | else |
|
{ |
_hostName = value; | _hostName = value; |
|
} |
} | } |
} | } |
else if (String::equalNoCase(vars,PORTNUMBER)) | else if (String::equalNoCase(vars,PORTNUMBER)) |
|
|
vars.append(PORTNUMBER); | vars.append(PORTNUMBER); |
Uint32 vPortNumber = atoi(value.getCString()); | Uint32 vPortNumber = atoi(value.getCString()); |
| |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Portnumber specified in config = "<<vPortNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
|
"::Portnumber specified in config = "<<vPortNumber<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Portnumber specified in config = "<<vPortNumber<<endl; |
{ |
|
cout<<StressTestControllerCommand::COMMAND_NAME << |
|
"::Portnumber specified in config = "<<vPortNumber<<endl; |
|
} |
if (vPortNumber > _MAX_PORTNUMBER) | if (vPortNumber > _MAX_PORTNUMBER) |
{ | { |
// | // |
// Portnumber out of valid range | // Portnumber out of valid range |
// | // |
if(verboseEnabled) | if(verboseEnabled) |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid portnumber was found. "<<endl; |
{ |
|
cout<<StressTestControllerCommand::COMMAND_NAME << |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid portnumber was found. "<<endl; |
"::Invalid portnumber was found. "<<endl; |
|
} |
|
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Invalid portnumber was found. "<<endl; |
return false; | return false; |
} | } |
if(!_portNumberSpecified) | if(!_portNumberSpecified) |
|
{ |
_portNumber = atoi(value.getCString()); | _portNumber = atoi(value.getCString()); |
|
|
|
|
} | } |
|
|
|
}/* else if (String::equalNoCase ... */ |
else if (String::equalNoCase(vars,SSL)) | else if (String::equalNoCase(vars,SSL)) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::SSL enabled in config. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::SSL enabled in config. "<<endl; |
if(!_useSSL) | if(!_useSSL) |
{ | { |
_useSSL = true; | _useSSL = true; |
|
|
{ | { |
vars=String::EMPTY; | vars=String::EMPTY; |
vars.append(USERNAME); | vars.append(USERNAME); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::UserName specified in config = "<<value<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::UserName specified in config = "<<value<<endl; |
if(!_userNameSpecified) | if(!_userNameSpecified) |
{ | { |
_userName = value; | _userName = value; |
|
|
{ | { |
_password = value; | _password = value; |
} | } |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Password specified in config = "<<value<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Password specified in config = "<<value<<endl; |
} | } |
else if (String::equalNoCase(vars,DURATION)) | else if (String::equalNoCase(vars,DURATION)) |
{ | { |
|
|
_duration = atof(value.getCString()); | _duration = atof(value.getCString()); |
if (_duration > _MIN_DURATION) | if (_duration > _MIN_DURATION) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Duration specified in config = "<<value<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Duration specified in config = "<<value<<endl; |
} | } |
else | else |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Duration was specified. "<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Invalid Duration was specified. "<<endl; |
return false; | return false; |
} | } |
} | } |
|
|
else if (String::equalNoCase(vars,TOLERANCELEVEL)) | else if (String::equalNoCase(vars,TOLERANCELEVEL)) |
{ | { |
_toleranceLevel = atoi(value.getCString()); | _toleranceLevel = atoi(value.getCString()); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::ToleranceLevel specified in config = "<<value<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::ToleranceLevel specified in config = "<<value<<endl; |
if(_toleranceLevel > _MAX_TOLERANCE) | if(_toleranceLevel > _MAX_TOLERANCE) |
{ | { |
if(verboseEnabled) | if(verboseEnabled) |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Tolerance level was specified. "<<endl; |
{ |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Tolerance level was specified. "<<endl; |
cout<<StressTestControllerCommand::COMMAND_NAME << |
|
"::Invalid Tolerance level was specified. "<<endl; |
|
} |
|
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Invalid Tolerance level was specified. "<<endl; |
| |
return false; | return false; |
} | } |
|
|
else if (String::equalNoCase(vars,NAMESPACE)) | else if (String::equalNoCase(vars,NAMESPACE)) |
{ | { |
_nameSpace = value; | _nameSpace = value; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::NameSpace specified in config = "<<value<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
|
"::NameSpace specified in config = "<<value<<endl; |
} | } |
else if (String::equalNoCase(vars,CLASSNAME)) | else if (String::equalNoCase(vars,CLASSNAME)) |
{ | { |
_className = value; | _className = value; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Class name specified in config = "<<value<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Class name specified in config = "<<value<<endl; |
} | } |
else | else |
{ | { |
|
|
// | // |
String clientName = String(DEFAULT_BINDIR); | String clientName = String(DEFAULT_BINDIR); |
clientName.append(vars.getCString()); | clientName.append(vars.getCString()); |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
clientName.append(".exe"); | clientName.append(".exe"); |
#endif | #endif |
if (!FileSystem::exists(clientName)) | if (!FileSystem::exists(clientName)) |
|
|
clientName = String(DEFAULT_BINDIR); | clientName = String(DEFAULT_BINDIR); |
testString.append(vars.getCString()); | testString.append(vars.getCString()); |
clientName.append(testString.getCString()); | clientName.append(testString.getCString()); |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
clientName.append(".exe"); | clientName.append(".exe"); |
#endif | #endif |
if (!FileSystem::exists(clientName)) | if (!FileSystem::exists(clientName)) |
|
|
vars=String::EMPTY; | vars=String::EMPTY; |
vars.append(testString.getCString()); | vars.append(testString.getCString()); |
} | } |
} else |
} |
|
else |
|
{ |
|
|
// Invalid client name | // Invalid client name |
IsValid = false; | IsValid = false; |
} | } |
|
} |
else | else |
{ | { |
IsValid = true; | IsValid = true; |
|
|
{ | { |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Client Name = "<<vars<<endl; |
cout<<StressTestControllerCommand::COMMAND_NAME << |
|
"::Invalid Client Name = "<<vars<<endl; |
} | } |
String ErrReport = String("Invalid Client Name:"); | String ErrReport = String("Invalid Client Name:"); |
ErrReport.append(vars.getCString()); | ErrReport.append(vars.getCString()); |
|
|
} | } |
return IsValid; | return IsValid; |
} | } |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::"<<vars<<" = "<<value<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::"<<vars<< |
|
" = "<<value<<endl; |
|
// |
//otherwise accept the properties listed with the clients. | //otherwise accept the properties listed with the clients. |
|
// |
} | } |
return true; | return true; |
| |
} /* validateConfiguration */ |
} /* _validateConfiguration */ |
| |
/* | /* |
Retrieves the client specific options from the config file. | Retrieves the client specific options from the config file. |
|
|
| |
| |
*/ | */ |
void StressTestControllerCommand::getClientOptions(const Char16* p,ostream& log_file) |
void StressTestControllerCommand::_getClientOptions( |
|
const Char16* p, |
|
ostream& log_file) |
{ | { |
// | // |
// Get the property name | // Get the property name |
|
|
} | } |
if (!(isalpha(*p) || *p == '_')) | if (!(isalpha(*p) || *p == '_')) |
{ | { |
String ErrReport = String("Syntax Error Client option name:"); |
throw StressTestControllerException(StressTestControllerException::INVALID_OPTION); |
throw StressTestControllerException(ErrReport); |
|
return; |
|
} | } |
| |
name.append(*p++); | name.append(*p++); |
|
|
// | // |
if (*p != '=') | if (*p != '=') |
{ | { |
String ErrReport = String("Syntax Error Client option operator:"); |
throw StressTestControllerException(StressTestControllerException::INVALID_OPERATOR); |
throw StressTestControllerException(ErrReport); |
|
return; |
|
} | } |
| |
p++; | p++; |
|
|
// | // |
| |
while (*p && *p != ']' && *p != ',') | while (*p && *p != ']' && *p != ',') |
|
{ |
value.append(*p++); | value.append(*p++); |
|
} |
// | // |
// Skip whitespace after value | // Skip whitespace after value |
// | // |
|
|
| |
if(*p !=']' && *p != ',') | if(*p !=']' && *p != ',') |
{ | { |
String ErrReport = String("Missing closing square brace:"); |
throw StressTestControllerException(StressTestControllerException::MISSING_BRACE); |
throw StressTestControllerException(ErrReport); |
|
return; |
|
} | } |
if(value == String::EMPTY) | if(value == String::EMPTY) |
{ | { |
String ErrReport = String("Missing value for client option:"); |
throw StressTestControllerException(StressTestControllerException::MISSING_VALUE); |
throw StressTestControllerException(ErrReport); |
|
return; |
|
} | } |
| |
#ifdef DEBUG | #ifdef DEBUG |
|
|
// | // |
// validate client property | // validate client property |
// | // |
Boolean IsValid=validateConfiguration(name,value,log_file); |
Boolean IsValid=_validateConfiguration(name,value,log_file); |
if(!IsValid) | if(!IsValid) |
{ | { |
throw InvalidClientPropertyValue(name, value); |
String ErrReport = String("Invalid Client property value: "); |
|
ErrReport.append(name); |
|
ErrReport.append("="); |
|
ErrReport.append(value); |
|
throw StressTestControllerException(ErrReport); |
} | } |
// | // |
// Save client property in client table if valid. | // Save client property in client table if valid. |
|
|
// | // |
log_file<< "duplicate name already saved: "<<name<<endl; | log_file<< "duplicate name already saved: "<<name<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<< "duplicate name already saved: "<<name<<endl; | cout<< "duplicate name already saved: "<<name<<endl; |
} | } |
|
} |
if(*p ==',') | if(*p ==',') |
{ | { |
name = String::EMPTY; | name = String::EMPTY; |
|
|
{ | { |
String ErrReport = String("Missing Name & Value for client option:"); | String ErrReport = String("Missing Name & Value for client option:"); |
throw StressTestControllerException(ErrReport); | throw StressTestControllerException(ErrReport); |
return; |
|
} | } |
} /* getClientOptions */ |
} /* _getClientOptions */ |
| |
| |
/* | /* |
|
|
false Failed to read the status & PIDs of clients. | false Failed to read the status & PIDs of clients. |
| |
*/ | */ |
Boolean StressTestControllerCommand::getClientPIDs(int actual_clients,ostream& log_file) |
Boolean StressTestControllerCommand::_getClientPIDs( |
|
int actual_clients, |
|
ostream& log_file) |
{ | { |
| |
ifstream ifs; | ifstream ifs; |
|
|
// | // |
// Make a temp copy of the file | // Make a temp copy of the file |
// | // |
Boolean cTempFile = FileSystem::copyFile(StressTestClientPIDFile, |
Boolean cTempFile = FileSystem::copyFile( |
tmpStressTestClientPIDFile); |
_stressTestClientPIDFile, |
|
_tmpStressTestClientPIDFile); |
| |
if(!cTempFile) | if(!cTempFile) |
{ | { |
cout<<"Cannot copy file "<<StressTestClientPIDFile<<endl; |
cout<<"Cannot copy file "<<_stressTestClientPIDFile<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Cannot copy PID file: "<<StressTestClientPIDFile<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Cannot copy PID file: "<<_stressTestClientPIDFile<<endl; |
return (false); | return (false); |
|
|
} | } |
// | // |
// Open the temp PID file and retreive all the client PIDs and status | // Open the temp PID file and retreive all the client PIDs and status |
// | // |
Open(ifs,tmpStressTestClientPIDFile); |
Open(ifs,_tmpStressTestClientPIDFile); |
| |
String line; | String line; |
| |
|
|
#endif | #endif |
p = line.getChar16Data(); | p = line.getChar16Data(); |
| |
while (*p && isspace(*p)) p++; |
while (*p && isspace(*p)) |
|
{ |
|
p++; |
|
} |
| |
// | // |
// Skip comment lines | // Skip comment lines |
// | // |
if ((!*p)||(*p == '#')) continue; |
if ((!*p)||(*p == '#')) |
|
{ |
|
continue; |
|
} |
| |
// Get the client ID | // Get the client ID |
String client = String::EMPTY; | String client = String::EMPTY; |
while (isalnum(*p) || *p == '_') client.append(*p++); |
while (isalnum(*p) || *p == '_') |
|
{ |
|
client.append(*p++); |
|
} |
| |
// Skip whitespace after property name | // Skip whitespace after property name |
while (*p && isspace(*p)) p++; |
while (*p && isspace(*p)) |
|
{ |
|
p++; |
|
} |
| |
// Expecting a colon | // Expecting a colon |
if (*p != ':') | if (*p != ':') |
{ | { |
ifs.close(); | ifs.close(); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
FileSystem::removeFile(tmpStressTestClientPIDFile); |
"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
|
FileSystem::removeFile(_tmpStressTestClientPIDFile); |
return(isSuccess = false); | return(isSuccess = false); |
//throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber); |
|
} | } |
| |
// | // |
|
|
if (*p != ':') | if (*p != ':') |
{ | { |
ifs.close(); | ifs.close(); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
FileSystem::removeFile(tmpStressTestClientPIDFile); |
"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
|
FileSystem::removeFile(_tmpStressTestClientPIDFile); |
return(isSuccess = false); | return(isSuccess = false); |
//throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber); |
|
} | } |
| |
// | // |
|
|
// | // |
// Skip whitespace after colon | // Skip whitespace after colon |
// | // |
while (*p && isspace(*p)) p++; |
while (*p && isspace(*p)) |
|
{ |
|
p++; |
|
} |
| |
// Get the client PID | // Get the client PID |
String clntPID = String::EMPTY; | String clntPID = String::EMPTY; |
while (isalnum(*p) || *p == '_') clntPID.append(*p++); |
while (isalnum(*p) || *p == '_') |
|
{ |
|
clntPID.append(*p++); |
|
} |
| |
// Skip whitespace after property name | // Skip whitespace after property name |
while (*p && isspace(*p)) p++; |
while (*p && isspace(*p)) |
|
{ |
|
p++; |
|
} |
| |
// | // |
// Expecting a colon | // Expecting a colon |
|
|
if (*p != ':') | if (*p != ':') |
{ | { |
ifs.close(); | ifs.close(); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
FileSystem::removeFile(tmpStressTestClientPIDFile); |
"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
|
FileSystem::removeFile(_tmpStressTestClientPIDFile); |
return(isSuccess = false); | return(isSuccess = false); |
//throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber); |
|
} | } |
| |
// | // |
|
|
if (*p != ':') | if (*p != ':') |
{ | { |
ifs.close(); | ifs.close(); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
FileSystem::removeFile(tmpStressTestClientPIDFile); |
"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
|
FileSystem::removeFile(_tmpStressTestClientPIDFile); |
return(isSuccess = false); | return(isSuccess = false); |
//throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber); |
|
} | } |
p++; | p++; |
|
|
// Skip whitespace after the colon if any | // Skip whitespace after the colon if any |
while (*p && isspace(*p)) p++; |
while (*p && isspace(*p)) |
|
{ |
|
p++; |
|
} |
| |
String clntStatus = String::EMPTY; | String clntStatus = String::EMPTY; |
while (isalnum(*p) || *p == '_') clntStatus.append(*p++); |
while (isalnum(*p) || *p == '_') |
|
{ |
|
clntStatus.append(*p++); |
|
} |
| |
// Skip whitespace after property name | // Skip whitespace after property name |
while (*p && isspace(*p)) p++; |
while (*p && isspace(*p)) |
|
{ |
|
p++; |
|
} |
| |
// | // |
// Expecting a colon | // Expecting a colon |
|
|
if (*p != ':') | if (*p != ':') |
{ | { |
ifs.close(); | ifs.close(); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
FileSystem::removeFile(tmpStressTestClientPIDFile); |
"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
|
FileSystem::removeFile(_tmpStressTestClientPIDFile); |
return(isSuccess = false); | return(isSuccess = false); |
//throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber); |
|
} | } |
| |
// | // |
|
|
if (*p != ':') | if (*p != ':') |
{ | { |
ifs.close(); | ifs.close(); |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
FileSystem::removeFile(tmpStressTestClientPIDFile); |
"::Syntax Error in PID file line number:"<<lineNumber<<endl; |
|
FileSystem::removeFile(_tmpStressTestClientPIDFile); |
return(isSuccess = false); | return(isSuccess = false); |
//throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber); |
|
} | } |
// | // |
// 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)) p++; |
while (*p && isspace(*p)) |
|
{ |
|
p++; |
|
} |
| |
// Get the client timestamp | // Get the client timestamp |
String clntTmStmp = String::EMPTY; | String clntTmStmp = String::EMPTY; |
while (isalnum(*p)) clntTmStmp.append(*p++); |
while (isalnum(*p)) |
|
{ |
|
clntTmStmp.append(*p++); |
|
} |
| |
// | // |
// Store the PID, Status and TimeStamp for each client | // Store the PID, Status and TimeStamp for each client |
// | // |
if(atoi(client.getCString()) <= actual_clients) | if(atoi(client.getCString()) <= actual_clients) |
{ | { |
clientPIDs[atoi(client.getCString())]=(pid_t)atoi(clntPID.getCString()); |
clientPIDs[atoi(client.getCString())] = |
clientStatus[atoi(client.getCString())]=(pid_t)atoi(clntStatus.getCString()); |
(pid_t)atoi(clntPID.getCString()); |
sscanf((const char*)clntTmStmp.getCString(), "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", &clientTimeStamp[atoi(client.getCString())]); |
clientStatus[atoi(client.getCString())] = |
}else { |
(pid_t)atoi(clntStatus.getCString()); |
|
sscanf( |
|
(const char*)clntTmStmp.getCString(), |
|
"%" PEGASUS_64BIT_CONVERSION_WIDTH "u", |
|
&clientTimeStamp[atoi(client.getCString())]); |
|
} |
|
else |
|
{ |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Unknown client PID for client#"<<atoi(client.getCString())<<" read at line number:"<<lineNumber<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Unknown client PID for client#"<< |
|
atoi(client.getCString())<< |
|
" read at line number:"<<lineNumber<<endl; |
cout<<"Unknown Client PID recieved"<<endl; | cout<<"Unknown Client PID recieved"<<endl; |
} | } |
} | } |
|
|
// | // |
// remove the temporary file. | // remove the temporary file. |
// | // |
FileSystem::removeFile(tmpStressTestClientPIDFile); |
FileSystem::removeFile(_tmpStressTestClientPIDFile); |
return(isSuccess = true); | return(isSuccess = true); |
}/* getClientPIDs */ |
}/* _getClientPIDs */ |
| |
/* | /* |
Parses specified line to retrieve valid config data for the stress tests. | Parses specified line to retrieve valid config data for the stress tests. |
|
|
@return true Succesfully parsed the line. | @return true Succesfully parsed the line. |
false Failed to parse the lines successfully. | false Failed to parse the lines successfully. |
*/ | */ |
Boolean StressTestControllerCommand::parseLine(const String & line,int lineNumber,String &name, String &value,ostream& log_file) |
Boolean StressTestControllerCommand::_parseLine( |
|
const String & line, |
|
int lineNumber, |
|
String &name, |
|
String &value, |
|
ostream& log_file) |
{ | { |
| |
const Char16* p; | const Char16* p; |
p = line.getChar16Data(); | p = line.getChar16Data(); |
|
|
// | // |
// Skip whitespace | // Skip whitespace |
// | // |
|
|
{ | { |
p++; | p++; |
} | } |
|
|
// | // |
// Ignore empty lines | // Ignore empty lines |
// | // |
|
|
IgnoreLine = true; | IgnoreLine = true; |
return IgnoreLine; | return IgnoreLine; |
} | } |
|
|
// | // |
// Skip comment lines | // Skip comment lines |
// | // |
|
|
IgnoreLine = true; | IgnoreLine = true; |
return IgnoreLine; | return IgnoreLine; |
} | } |
|
|
// | // |
// Retreive all the Client Options | // Retreive all the Client Options |
// "[" indicates start of client options. | // "[" indicates start of client options. |
|
|
// | // |
// get and validate client options | // get and validate client options |
// | // |
getClientOptions(p,log_file); |
_getClientOptions(p,log_file); |
} | } |
catch(Exception& e) | catch(Exception& e) |
{ | { |
|
|
msg.append(line.getCString()); | msg.append(line.getCString()); |
} | } |
throw StressTestControllerException(msg); | throw StressTestControllerException(msg); |
return false; |
|
} | } |
catch(...) | catch(...) |
{ | { |
// throw what was caught | // throw what was caught |
String msg = String("Unknown exception caught when geting client options."); |
String msg = String( |
log_file<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when geting client options."<<endl; |
"Unknown exception caught when geting client options."); |
cerr<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when geting client options."<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME << |
|
":Unknown exception caught when geting client options."<<endl; |
|
cerr<<StressTestControllerCommand::COMMAND_NAME << |
|
":Unknown exception caught when geting client options."<<endl; |
throw StressTestControllerException(msg); | throw StressTestControllerException(msg); |
return false; |
|
} | } |
| |
// | // |
|
|
// | // |
return true; | return true; |
} | } |
|
|
// | // |
// Get Common Properties | // Get Common Properties |
// | // |
name = String::EMPTY; | name = String::EMPTY; |
|
|
// | // |
// Invalid Common Property name | // Invalid Common Property name |
// | // |
if (!(isalpha(*p) || *p == '_')) | if (!(isalpha(*p) || *p == '_')) |
{ | { |
throw InvalidPropertyValue(name, value); |
String ErrReport = String("Invalid Property Value: "); |
|
ErrReport.append(name); |
|
ErrReport.append("="); |
|
ErrReport.append(value); |
|
throw StressTestControllerException(ErrReport); |
} | } |
|
|
// | // |
// Save the property Name | // Save the property Name |
// | // |
|
|
{ | { |
name.append(*p++); | name.append(*p++); |
} | } |
|
|
// | // |
// Skip whitespace after property name | // Skip whitespace after property name |
// | // |
|
|
{ | { |
p++; | p++; |
} | } |
|
|
// | // |
// Expect an equal sign | // Expect an equal sign |
// | // |
if (*p != '=') | if (*p != '=') |
{ | { |
throw InvalidPropertyValue(name, value); |
String ErrReport = String("Invalid Property Value: "); |
|
ErrReport.append(name); |
|
ErrReport.append("="); |
|
ErrReport.append(value); |
|
throw StressTestControllerException(ErrReport); |
} | } |
|
|
// | // |
// go to next | // go to next |
// | // |
|
|
// | // |
try | try |
{ | { |
IsValid=validateConfiguration(name,value,log_file); |
IsValid=_validateConfiguration(name,value,log_file); |
} | } |
catch(Exception& e) | catch(Exception& e) |
{ | { |
String msg(e.getMessage()); | String msg(e.getMessage()); |
throw StressTestControllerException(msg); | throw StressTestControllerException(msg); |
return false; |
|
} | } |
if(!IsValid) | if(!IsValid) |
{ | { |
throw InvalidPropertyValue(name, value); |
String ErrReport = String("Invalid Property Value: "); |
return false; |
ErrReport.append(name); |
|
ErrReport.append("="); |
|
ErrReport.append(value); |
|
throw StressTestControllerException(ErrReport); |
} | } |
return true; | return true; |
} /* parseLine */ |
} /* _parseLine */ |
| |
/* | /* |
Storing client details in a table. | Storing client details in a table. |
|
|
@return true Succesfully stored the name or instance. | @return true Succesfully stored the name or instance. |
false Failed to store the name or instance. | false Failed to store the name or instance. |
*/ | */ |
Boolean StressTestControllerCommand::storeClientDetails(String name, String value) |
Boolean StressTestControllerCommand::_storeClientDetails( |
|
String name, |
|
String value) |
{ | { |
| |
// | // |
|
|
// Duplicate property, ignore the new property value. | // Duplicate property, ignore the new property value. |
// | // |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<< "Duplicate Client already saved: "<<endl; | cout<< "Duplicate Client already saved: "<<endl; |
|
} |
return false; | return false; |
} | } |
|
|
// | // |
// Store the number of instances for the client in the table | // Store the number of instances for the client in the table |
// | // |
if (!_clientTable[_clientCount].insert(INSTANCE, value)) | if (!_clientTable[_clientCount].insert(INSTANCE, value)) |
{ | { |
|
|
// | // |
// Duplicate property, ignore the new property value. | // Duplicate property, ignore the new property value. |
// | // |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<< "Duplicate Instance already saved: "<<endl; | cout<< "Duplicate Instance already saved: "<<endl; |
|
} |
return false; | return false; |
} | } |
++_clientCount; | ++_clientCount; |
return true; | return true; |
} /* storeClientDetails */ |
} /* _storeClientDetails */ |
| |
/* | /* |
Will check the current tolerance level of the running clients with | Will check the current tolerance level of the running clients with |
|
|
@return true Clients with tolerance. | @return true Clients with tolerance. |
false Clients failed tolerance. | false Clients failed tolerance. |
*/ | */ |
Boolean StressTestControllerCommand::checkToleranceLevel(int actual_client, Uint64 nowMilliseconds,ostream& log_file) |
Boolean StressTestControllerCommand::_checkToleranceLevel( |
|
int actual_client, |
|
Uint64 nowMilliseconds, |
|
ostream& log_file) |
{ | { |
|
|
int count = 0; | int count = 0; |
int failed_count = 0; | int failed_count = 0; |
Uint64 lastUpdateinMilliSec =0; | Uint64 lastUpdateinMilliSec =0; |
|
|
++count; | ++count; |
// | // |
// Validate the timestamps: | // Validate the timestamps: |
// The timestamps on the status is compared to the previous timestamp |
// The timestamps on the status is compared to the previous |
// to ensure that the status has been updated within the previous 2 updates |
// timestamp to ensure that the status has been updated within |
|
// the previous 2 updates. |
// | // |
if(clientStatus[i]== VALID_RESPONSE) | if(clientStatus[i]== VALID_RESPONSE) |
{ | { |
|
|
// longer than 2 * checkup interval | // longer than 2 * checkup interval |
// | // |
if((clientTimeStamp[i] == prev_clientTimeStamp[i]) | if((clientTimeStamp[i] == prev_clientTimeStamp[i]) |
&& (lastUpdateinMilliSec >= (2 * (Uint64)convertmin2millisecs(CHECKUP_INTERVAL)))) |
&& (lastUpdateinMilliSec >= |
|
(2 * (Uint64)convertmin2millisecs(CHECKUP_INTERVAL)))) |
{ | { |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
log_file <<" Status not updated for client ("<<i<<")pid :"<<clientPIDs[i]<<endl; |
log_file <<" Status not updated for client (" <<i<< |
log_file << " for the past " << 2*(CHECKUP_INTERVAL) << " minutes." << endl; |
")pid :"<<clientPIDs[i]<<endl; |
cout <<" Status not updated for client ("<<i<<")pid :"<<clientPIDs[i]<<endl; |
log_file << " for the past " << |
cout << " for the past " << 2*(CHECKUP_INTERVAL) << " minutes." << endl; |
2*(CHECKUP_INTERVAL) << " minutes." << endl; |
|
cout<<" Status not updated for client ("<<i<<")pid :"<< |
|
clientPIDs[i]<<endl; |
|
cout<<" for the past " << 2*(CHECKUP_INTERVAL)<< |
|
" minutes." << endl; |
} | } |
|
|
++failed_count; | ++failed_count; |
|
|
} | } |
} | } |
// | // |
// If unknown status - server or client may be hung. | // If unknown status - server or client may be hung. |
// Two consective failures will be counted as a failed client |
// Two consective failures on the same client will be counted |
|
// as a failed client. |
// | // |
if(((clientStatus[i]== NO_RESPONSE) | if(((clientStatus[i]== NO_RESPONSE) |
||(clientStatus[i]== INVALID_RESPONSE)) | ||(clientStatus[i]== INVALID_RESPONSE)) |
|
|
{ | { |
if(clientStatus[i]== INVALID_RESPONSE) | if(clientStatus[i]== INVALID_RESPONSE) |
{ | { |
log_file<<" Recieved an Invalid response Status from client ("<< i <<") pid :"<<clientPIDs[i]<<endl; |
log_file<< |
|
"Recieved an Invalid response Status from client("<< |
|
i <<") pid :"<<clientPIDs[i]<<endl; |
} | } |
else | else |
log_file<<" Recieved a no response Status from client ("<<i <<") pid :"<<clientPIDs[i]<<endl; |
{ |
|
log_file<<"Recieved a no response Status from client("<< |
|
i <<") pid :"<<clientPIDs[i]<<endl; |
} | } |
++failed_count; |
|
} | } |
|
++failed_count; |
|
} /* 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]) */ |
} | } |
// check actual tolerance | // check actual tolerance |
if(count > 0) | if(count > 0) |
{ | { |
double curr_tolerancePercent = getToleranceInPercent(failed_count,(double)count); |
double curr_tolerancePercent = getToleranceInPercent( |
|
failed_count, |
|
(double)count); |
if(verboseEnabled) | if(verboseEnabled) |
{ | { |
cout<<" total running clients ="<<count<<endl; | cout<<" total running clients ="<<count<<endl; |
|
|
} | } |
// All process are stopped. | // All process are stopped. |
return(withinTolerance = true); | return(withinTolerance = true); |
} /* checkToleranceLevel */ |
} /* _checkToleranceLevel */ |
| |
| |
/* | /* |
|
|
| |
log_file << "Populating default configuration for stress Tests." << endl; | log_file << "Populating default configuration for stress Tests." << endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
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; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<< "duplicate name already saved: "<<INSTANCE<<endl; | cout<< "duplicate name already saved: "<<INSTANCE<<endl; |
} | } |
|
} |
switch (i) | switch (i) |
{ | { |
case 0: | case 0: |
|
|
{ | { |
log_file << "Duplicate name already saved: "<<NAME<<endl; | log_file << "Duplicate name already saved: "<<NAME<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<< "Duplicate name already saved: "<<NAME<<endl; | cout<< "Duplicate name already saved: "<<NAME<<endl; |
} | } |
|
} |
log_file << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl; | log_file << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl; | cout << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl; |
|
} |
|
|
break; | break; |
} | } |
case 1: | case 1: |
|
|
{ | { |
log_file << "Duplicate name already saved: "<<NAME<<endl; | log_file << "Duplicate name already saved: "<<NAME<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<< "Duplicate name already saved: "<<NAME<<endl; | cout<< "Duplicate name already saved: "<<NAME<<endl; |
} | } |
|
} |
log_file << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl; | log_file << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl; | cout << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl; |
|
} |
if (!_clientTable[i].insert(CLIENTNAME, "CLI")) | if (!_clientTable[i].insert(CLIENTNAME, "CLI")) |
{ | { |
log_file<< "Duplicate name already saved: "<<CLIENTNAME<<endl; |
log_file<< "Duplicate name already saved: "<< |
|
CLIENTNAME<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
cout<< "Duplicate name already saved: "<<CLIENTNAME<<endl; |
{ |
|
cout<< "Duplicate name already saved: "<< |
|
CLIENTNAME<<endl; |
|
} |
} | } |
if (!_clientTable[i].insert(OPTIONS, "niall")) | if (!_clientTable[i].insert(OPTIONS, "niall")) |
{ | { |
log_file<< "Duplicate name already saved: "<<OPTIONS<<endl; | log_file<< "Duplicate name already saved: "<<OPTIONS<<endl; |
if(verboseEnabled) | if(verboseEnabled) |
|
{ |
cout<< "Duplicate name already saved: "<<OPTIONS<<endl; | cout<< "Duplicate name already saved: "<<OPTIONS<<endl; |
} | } |
log_file << " Client Command & options: CLI niall" << endl; |
|
if(verboseEnabled) |
|
cout << " Client Command & options: CLI niall" << endl; |
|
break; |
|
} | } |
|
log_file<< " Client Command & options: CLI niall"<< |
|
endl; |
|
if (verboseEnabled) |
|
{ |
|
cout<< " Client Command & options: CLI niall"<< |
|
endl; |
} | } |
|
break; |
|
} /* case 1: */ |
|
} /* switch(i) */ |
} /* for(Uint32 i=0;i<_clientCount; i++) */ | } /* for(Uint32 i=0;i<_clientCount; i++) */ |
| |
} /* getDefaultClients */ | } /* getDefaultClients */ |
|
|
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); |
StressTestLogFile.append(STRESSTESTDIR); |
_stressTestLogFile.append(STRESSTESTDIR); |
FileSystem::makeDirectory(StressTestLogFile); |
FileSystem::makeDirectory(_stressTestLogFile); |
StressTestLogFile.append(LOGDIR); |
_stressTestLogFile.append(LOGDIR); |
FileSystem::makeDirectory(StressTestLogFile); |
FileSystem::makeDirectory(_stressTestLogFile); |
StressTestLogFile.append(pid_str); |
_stressTestLogFile.append(pid_str); |
StressTestLogFile.append("_stressTest_"); |
_stressTestLogFile.append("_stressTest_"); |
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); |
StressTestClientPIDFile.append(pid_str); |
_stressTestClientPIDFile.append(pid_str); |
StressTestClientPIDFile.append("_StressTestClients"); |
_stressTestClientPIDFile.append("_StressTestClients"); |
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); |
tmpStressTestClientPIDFile.append("TEMP"); |
_tmpStressTestClientPIDFile.append("TEMP"); |
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); |
| |
// | // |
// Failed to open the log file | // Failed to open the log file |
|
|
log_file.close(); | log_file.close(); |
pid_file.close(); | pid_file.close(); |
clntlog_file.close(); | clntlog_file.close(); |
cout<<"Cannot get file "<<StressTestLogFile<<endl; |
cout<<"Cannot get file "<<_stressTestLogFile<<endl; |
return false; | return false; |
| |
} | } |
|
|
// | // |
if (!pid_file) | if (!pid_file) |
{ | { |
cout<<"Cannot get file "<<StressTestClientPIDFile<<endl; |
cout<<"Cannot get file "<<_stressTestClientPIDFile<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"Cannot read file "<<StressTestClientPIDFile<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"Cannot read file "<<_stressTestClientPIDFile<<endl; |
log_file.close(); | log_file.close(); |
clntlog_file.close(); | clntlog_file.close(); |
return false; | return false; |
|
|
// | // |
if (!clntlog_file) | if (!clntlog_file) |
{ | { |
log_file<<StressTestControllerCommand::COMMAND_NAME<<"Cannot read file "<<StressTestClientLogFile<<endl; |
log_file<<StressTestControllerCommand::COMMAND_NAME<< |
|
"Cannot read file "<<_stressTestClientLogFile<<endl; |
log_file.close(); | log_file.close(); |
pid_file.close(); | pid_file.close(); |
return false; | return false; |
} | } |
|
|
// | // |
// Successfully opened all the files. | // Successfully opened all the files. |
// | // |
pid_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<<" has the following clients:: \n"; |
pid_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<< |
clntlog_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<<"::Process ID:"<<getpid()<<endl; |
" has the following clients:: \n"; |
|
clntlog_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Process ID:"<<getpid()<<endl; |
clntlog_file.close(); | clntlog_file.close(); |
pid_file.close(); | pid_file.close(); |
return true; | return true; |
|
|
- Unused log files & pid files are removed here. | - Unused log files & pid files are removed here. |
| |
*/ | */ |
void StressTestControllerCommand::removeUnusedFiles(void) |
void StressTestControllerCommand::removeUnusedFiles() |
{ | { |
FileSystem::removeFile(StressTestClientPIDFile); |
FileSystem::removeFile(_stressTestClientPIDFile); |
FileSystem::removeFile(StressTestClientLogFile); |
FileSystem::removeFile(_stressTestClientLogFile); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|
Cleanup function for stressTestController to free allocated | Cleanup function for stressTestController to free allocated |
memory used to execute clients. | memory used to execute clients. |
*/ | */ |
void cleanupProcess(void) |
void cleanupProcess() |
{ | { |
| |
delete [] clientPIDs; | delete [] clientPIDs; |
|
|
/* | /* |
This will generate the current time. | This will generate the current time. |
*/ | */ |
struct tm getCurrentActualTime(void) |
struct tm getCurrentActualTime() |
{ | { |
struct tm tmTime; | struct tm tmTime; |
time_t inTime=time(NULL); | time_t inTime=time(NULL); |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
tmTime=*localtime(&inTime); | tmTime=*localtime(&inTime); |
#else | #else |
localtime_r(&inTime,&tmTime); | localtime_r(&inTime,&tmTime); |
|
|
{ | { |
case SIGINT: | case SIGINT: |
{ | { |
cout <<StressTestControllerCommand::COMMAND_NAME<< "::Recieved interupt signal SIGINT!"<<endl; |
cout<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Recieved interupt signal SIGINT!"<<endl; |
break; | break; |
} | } |
case SIGABRT: | case SIGABRT: |
{ | { |
cout <<StressTestControllerCommand::COMMAND_NAME<< "::Recieved signal SIGABRT!"<<endl; |
cout<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Recieved signal SIGABRT!"<<endl; |
break; | break; |
} | } |
default: | default: |
{ | { |
cout<<StressTestControllerCommand::COMMAND_NAME<<"::Recieved Signal ( "<<signum<<"!" <<endl; |
cout<<StressTestControllerCommand::COMMAND_NAME<< |
|
"::Recieved Signal ( "<<signum<<"!" <<endl; |
break; | break; |
} | } |
} | } |
|
|
char buffer[32]; | char buffer[32]; |
sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", x); | sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", x); |
return(String(buffer)); | return(String(buffer)); |
} |
}/* convertUint64toString(..) */ |