version 1.1.2.1, 2006/04/18 03:37:36
|
version 1.1.2.2, 2006/04/24 19:29:05
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Aruran (aruran.shanmug@in.ibm.com) & Melvin (msolomon@in.ibm.com), IBM |
// Author: Aruran (aruran.shanmug@in.ibm.com) & Melvin (msolomon@in.ibm.com), |
// for PEP# 241 |
// IBM for PEP# 241 |
// Modified By: | // Modified By: |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
|
|
PEGASUS_USING_PEGASUS; | PEGASUS_USING_PEGASUS; |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
///** Constructor - Initializes the time variables and defines the Options Table. */ |
/** Constructor - Initializes the time variables and defines the Options |
|
Table. |
|
*/ |
TestStressTestClient::TestStressTestClient() | TestStressTestClient::TestStressTestClient() |
{ | { |
startMilliseconds = 0; | startMilliseconds = 0; |
|
|
optionCount = sizeof(testOptionsTable) / sizeof(testOptionsTable[0]); | optionCount = sizeof(testOptionsTable) / sizeof(testOptionsTable[0]); |
optionsTable = testOptionsTable; | optionsTable = testOptionsTable; |
} | } |
|
/*/////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////// |
OPTION MANAGEMENT |
// OPTION MANAGEMENT |
///////////////////////////////////////////////////////////////*/ |
/////////////////////////////////////////////////////////////// |
|
| |
/** GetOptions function - This function sets up the options from | /** GetOptions function - This function sets up the options from |
testOptionsTable which is initialized through constructor | testOptionsTable which is initialized through constructor |
|
|
int counter = 0; | int counter = 0; |
String argument = String::EMPTY; | String argument = String::EMPTY; |
| |
//om.registerOptions(newOptionsTable, (const )cOptionCount); |
/** om.registerOptions(newOptionsTable, (const)cOptionCount); */ |
om.registerOptions(newOptionsTable, cOptionCount); | om.registerOptions(newOptionsTable, cOptionCount); |
argvv = argv; | argvv = argv; |
| |
// Following section is introduced to ignore options not |
/** Following section is introduced to ignore options not |
// required by a client. |
required by a client. |
|
*/ |
for (int i = 1; i < argc; i++) | for (int i = 1; i < argc; i++) |
{ | { |
argument = String::EMPTY; | argument = String::EMPTY; |
const char* arg = argv[i]; | const char* arg = argv[i]; |
| |
// Check for -option: |
/** Check for - option. */ |
if (*arg == '-') | if (*arg == '-') |
{ | { |
// Look for the option: |
/** Look for the option. */ |
argument.append(arg + 1); | argument.append(arg + 1); |
const Option* option = om.lookupOption(argument); | const Option* option = om.lookupOption(argument); |
| |
// Get the option argument if any: |
/** Get the option argument if any. */ |
if(option) | if(option) |
{ | { |
argvv[++counter]=argv[i]; | argvv[++counter]=argv[i]; |
|
|
return counter; | return counter; |
} | } |
| |
/** This method is used by clients to register client specific required options |
/** This method is used by clients to register client specific required |
to the option table. All these options are taken as mandatory one. |
options to the option table. All these options are taken as mandatory one. |
*/ | */ |
OptionRow *TestStressTestClient::generateClientOptions( | OptionRow *TestStressTestClient::generateClientOptions( |
OptionRow* clientOptionsTable, | OptionRow* clientOptionsTable, |
|
|
return newOptionsTable; | return newOptionsTable; |
} | } |
| |
/** This method is used by the clients to log information which are required for controller |
/** This method is used by the clients to log information which are required |
reference. It logs the information with Client ID and status of the client |
for controller reference. It logs the information with Client ID and |
in the PID File log file. |
status of the client in the PID File log file. |
*/ | */ |
void TestStressTestClient::logInfo( String clientid, pid_t clientPid, |
void TestStressTestClient::logInfo( |
int clientStatus, String &pidfile) |
String clientId, |
|
pid_t clientPid, |
|
int clientStatus, |
|
String &pidFile) |
{ | { |
String line, searchstring, subline; |
String line, searchString, subLine; |
int indx=0; | int indx=0; |
char pid_str[15]; | char pid_str[15]; |
char status_str[15]; | char status_str[15]; |
char time_str[32]; | char time_str[32]; |
| |
searchstring.append(clientid.getCString()); |
searchString.append(clientId.getCString()); |
| |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
int offset = 2; |
|
#else |
int offset = 1; | int offset = 1; |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
|
offset = 2; |
|
#endif | #endif |
| |
Uint32 whileCount=0; | Uint32 whileCount=0; |
// |
|
// Get current time for time stamp |
/** Get current time for time stamp */ |
// |
|
nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds(); | nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds(); |
| |
sprintf(pid_str, "%d", clientPid); | sprintf(pid_str, "%d", clientPid); |
sprintf(status_str, "%d", clientStatus); | sprintf(status_str, "%d", clientStatus); |
sprintf(time_str, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", nowMilliseconds); |
sprintf(time_str, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", |
|
nowMilliseconds); |
| |
fstream pfile(pidfile.getCString(),ios::in|ios::out); |
fstream pFile(pidFile.getCString(),ios::in|ios::out); |
| |
Boolean addClient= false; | Boolean addClient= false; |
| |
#ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
if (pfile.is_open()) |
if (pFile.is_open()) |
#else | #else |
if (pfile) |
if (pFile) |
#endif | #endif |
{ | { |
while(!pfile.eof()) |
while(!pFile.eof()) |
{ whileCount++; |
{ |
GetLine (pfile,line); |
whileCount++; |
|
GetLine (pFile,line); |
indx=line.find(':'); | indx=line.find(':'); |
if(indx>0) | if(indx>0) |
{ | { |
subline.append(line.subString(0, indx)); |
subLine.append(line.subString(0, indx)); |
} | } |
if(String::compare(subline, searchstring)==0) |
if (String::compare(subLine, searchString) == 0) |
{ | { |
long pos; | long pos; |
addClient = true; | addClient = true; |
pos = pfile.tellp(); |
pos = pFile.tellp(); |
pfile.seekp(pos - line.size()-offset); |
pFile.seekp(pos - line.size()-offset); |
String Newline = String(clientid.getCString()); |
String newLine = String(clientId.getCString()); |
Newline.append("::"); |
newLine.append("::"); |
Newline.append(pid_str); |
newLine.append(pid_str); |
Newline.append("::"); |
newLine.append("::"); |
Newline.append(status_str); |
newLine.append(status_str); |
Newline.append("::"); |
newLine.append("::"); |
Newline.append(time_str); |
newLine.append(time_str); |
if(line.size() > Newline.size()) |
if (line.size() > newLine.size()) |
{ |
{ |
Uint32 jsize = line.size() - Newline.size(); |
Uint32 jSize = line.size() - newLine.size(); |
pfile.write(Newline.getCString(),Newline.size()); |
pFile.write(newLine.getCString(),newLine.size()); |
for(Uint32 i =0;i<jsize;i++) |
for (Uint32 i =0;i<jSize;i++) |
{ | { |
pfile.write(" ",1); |
pFile.write(" ",1); |
} | } |
} | } |
else | else |
{ | { |
pfile.write(Newline.getCString(),Newline.size()); |
pFile.write(newLine.getCString(),newLine.size()); |
} | } |
break; | break; |
} | } |
subline.clear(); |
subLine.clear(); |
line.clear(); | line.clear(); |
} | } |
if(!addClient) | if(!addClient) |
{ | { |
pfile.close(); |
pFile.close(); |
fstream pfile(pidfile.getCString(),ios::out|ios::app); |
fstream pFile(pidFile.getCString(),ios::out|ios::app); |
pfile<<clientid<<"::"<<clientPid<<"::"<<clientStatus<<"::" |
pFile<<clientId<<"::"<<clientPid<<"::"<<clientStatus<<"::" |
<<time_str<<"\n"; | <<time_str<<"\n"; |
} | } |
} | } |
pfile.close(); |
pFile.close(); |
} | } |
| |
/** This method is used to take the client process start time.*/ | /** This method is used to take the client process start time.*/ |
|
|
nowMilliseconds = startMilliseconds; | nowMilliseconds = startMilliseconds; |
} | } |
| |
/** This method is used to check the time stamp for logging information about the |
/** This method is used to check the time stamp for logging information about |
success or failure. |
the success or failure. |
*/ | */ |
Boolean TestStressTestClient::checkTime() | Boolean TestStressTestClient::checkTime() |
{ | { |
|
|
| |
if(nowMilliseconds >= nextCheckupInMillisecs) | if(nowMilliseconds >= nextCheckupInMillisecs) |
{ | { |
nextCheckupInMillisecs = (Uint64)convertmin2millisecs(CHECKUP_INTERVAL) + nowMilliseconds; |
nextCheckupInMillisecs = (Uint64)convertmin2millisecs(CHECKUP_INTERVAL) |
|
+ nowMilliseconds; |
return true; | return true; |
} | } |
return false; | return false; |
} | } |
| |
/** This method is used to log the information about the client's success or failure percentage |
/** This method is used to log the information about the client's success or |
at a specific interval of time. |
failure percentage at a specific interval of time. |
*/ | */ |
void TestStressTestClient::logErrorPercentage( Uint32 successCount, Uint32 totalCount, |
void TestStressTestClient::logErrorPercentage( |
pid_t clientPid, String &clientlog, char client[]) |
Uint32 successCount, |
|
Uint32 totalCount, |
|
pid_t clientPid, |
|
String &clientLog, |
|
char client[]) |
{ | { |
Uint32 successPercentage, errorPercentage; | Uint32 successPercentage, errorPercentage; |
successPercentage = (successCount/totalCount)*100; | successPercentage = (successCount/totalCount)*100; |
errorPercentage = 100 - successPercentage; | errorPercentage = 100 - successPercentage; |
//loging details here ... |
|
ofstream errorlog_file(clientlog.getCString(), ios::app); |
/** loging details here */ |
errorlog_file<<client<<" PID#"<<clientPid<<" ran "<<totalCount<<" times with a " |
ofstream errorLog_File(clientLog.getCString(), ios::app); |
<<errorPercentage<<"% failure"<<"\n"; |
errorLog_File<<client<<" PID#"<<clientPid<<" ran "<<totalCount |
errorlog_file.close(); |
<<" times with a "<<errorPercentage<<"% failure"<<"\n"; |
|
errorLog_File.close(); |
} | } |
| |
/** This method is used to log the informations of client logs to the client log file */ |
/** This method is used to log the informations of client logs to the client |
void TestStressTestClient::errorLog( pid_t clientPid, String &clientlog, String &message) |
log file. |
{ |
*/ |
//loging details here ... |
void TestStressTestClient::errorLog( |
ofstream errorlog_file(clientlog.getCString(), ios::app); |
pid_t clientPid, |
errorlog_file<<" PID#"<<clientPid<<"::"<<message<<"\n"; |
String &clientLog, |
errorlog_file.close(); |
String &message) |
|
{ |
|
/** loging details here .*/ |
|
ofstream errorLog_File(clientLog.getCString(), ios::app); |
|
errorLog_File<<" PID#"<<clientPid<<"::"<<message<<"\n"; |
|
errorLog_File.close(); |
} | } |
| |
/** This method handles the SSLCertificate verification part. */ | /** This method handles the SSLCertificate verification part. */ |
static Boolean verifyCertificate( SSLCertificateInfo &certInfo ) | static Boolean verifyCertificate( SSLCertificateInfo &certInfo ) |
{ | { |
//Add code to handle server certificate verification. |
/** Add code to handle server certificate verification. */ |
return true; | return true; |
} | } |
| |
/** This method is used by the clients to connect to the server. If useSSL is | /** This method is used by the clients to connect to the server. If useSSL is |
true then an SSL connection will be atemped with the userName and passWord that |
true then an SSL connection will be atemped with the userName and passWord |
is passed in. Otherwise connection will be established using localhost. |
that is passed in. Otherwise connection will be established using |
All parameters are required. |
localhost. All parameters are required. |
*/ | */ |
void TestStressTestClient::connectClient( | void TestStressTestClient::connectClient( |
CIMClient *client, | CIMClient *client, |
|
|
{ | { |
if (useSSL) | if (useSSL) |
{ | { |
// |
/** Get environment variables. */ |
// Get environment variables: |
|
// |
|
const char* pegasusHome = getenv("PEGASUS_HOME"); | const char* pegasusHome = getenv("PEGASUS_HOME"); |
| |
String trustpath = FileSystem::getAbsolutePath( | String trustpath = FileSystem::getAbsolutePath( |
pegasusHome, PEGASUS_SSLCLIENT_CERTIFICATEFILE); | pegasusHome, PEGASUS_SSLCLIENT_CERTIFICATEFILE); |
| |
String randFile = String::EMPTY; | String randFile = String::EMPTY; |
|
|
#ifdef PEGASUS_SSL_RANDOMFILE | #ifdef PEGASUS_SSL_RANDOMFILE |
randFile = FileSystem::getAbsolutePath( | randFile = FileSystem::getAbsolutePath( |
pegasusHome, PEGASUS_SSLCLIENT_RANDOMFILE); |
pegasusHome, |
|
PEGASUS_SSLCLIENT_RANDOMFILE); |
#endif | #endif |
SSLContext sslcontext( |
|
|
SSLContext sslContext( |
trustpath, verifyCertificate, randFile); | trustpath, verifyCertificate, randFile); |
if (verboseTest) | if (verboseTest) |
{ | { |
cout << "connecting to " << host << ":" << portNumber |
PEGASUS_STD(cout) << "connecting to " << host << ":" |
<< " using SSL" << endl; |
<< portNumber << " using SSL" |
|
<< PEGASUS_STD(endl); |
} | } |
client->connect (host, portNumber, sslcontext, userName, password); |
client->connect (host, portNumber, sslContext, userName, password); |
} // useSSL |
} /* useSSL. */ |
else | else |
{ | { |
if (verboseTest) | if (verboseTest) |
{ | { |
cout << "Connecting to " << host << ":" << portNumber << endl; |
PEGASUS_STD(cout) << "Connecting to " << host << ":" << portNumber |
|
<< PEGASUS_STD(endl); |
} | } |
client->connect (host, portNumber, userName, password); | client->connect (host, portNumber, userName, password); |
} | } |
if (verboseTest) | if (verboseTest) |
{ | { |
cout << "Client Connected" << endl; |
PEGASUS_STD(cout) << "Client Connected" << PEGASUS_STD(endl); |
} | } |
} | } |