Skip to content
Snippets Groups Projects
Commit fff43b6d authored by Andrea Ieri's avatar Andrea Ieri
Browse files

Changes for ns security performance testing.

parent ba0e7380
Branches
Tags
No related merge requests found
......@@ -5,12 +5,9 @@ COMM
COMM Make CASTOR tests for "ns" directory
CPPFLAGS += $(ORACLE_CPPFLAGS)
AddLdFlags(-L$(ORACLE_LIBDIR) -locci -lclntsh)
DependsOnLibrary(common,castorcommon)
DependsOnLibrary(castor,castorclient)
DependsOnLibrary(castor/db/cnv,castorcnvs)
DependsOnLibrary(castor/db/newora,castorcommonora)
NSTESTSRCS = TestThread.cpp \
TestMTServer.cpp
......
......@@ -29,7 +29,7 @@
#include "castor/exception/Exception.hpp"
#include "castor/BaseObject.hpp"
#include "castor/Services.hpp"
#include "castor/db/DbParamsSvc.hpp"
//#include "castor/db/DbParamsSvc.hpp"
#include "castor/dlf/Dlf.hpp"
#include "castor/server/SignalThreadPool.hpp"
......@@ -47,6 +47,7 @@ int main(int argc, char *argv[]) {
// Create a db parameters service and fill with appropriate defaults
// (only needed when direct access to the NS database is required)
/*
castor::IService* s = castor::BaseObject::sharedServices()->service("DbParamsSvc", castor::SVC_DBPARAMSSVC);
castor::db::DbParamsSvc* params = dynamic_cast<castor::db::DbParamsSvc*>(s);
if(params == 0) {
......@@ -56,7 +57,10 @@ int main(int argc, char *argv[]) {
}
params->setSchemaVersion("2_1_9_0");
params->setDbAccessConfFile("/etc/castor/ORANSCONFIG");
*/
//server.addThreadPool(
// new castor::server::SignalThreadPool("Test", new TestCnsStatThread(), 10, 20, 300));
// Create a standard thread pool for the testing code.
// XXX The last argument is a hack to make all threads start immediately as opposed
// to the default behavior of Castor daemons whereby only one thread starts
......@@ -87,7 +91,7 @@ TestMTServer::TestMTServer() :
castor::server::BaseDaemon("MTTest") {
// Initializes the DLF logging
castor::dlf::Message nomsgs[1];
castor::dlf::Message nomsgs[] = {{-1, ""}};
dlfInit(nomsgs);
}
......
......@@ -39,13 +39,16 @@
#include "TestThread.hpp"
#include "castor/server/SignalThreadPool.hpp"
#include <vector>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
TestThread::TestThread() :
m_procTime(0), m_wallTime(0), m_reqCount(0), m_nbThreads(0) {
m_procTime(0), m_wallTime(0), m_reqCount(0), m_timeStdDev(0), m_nbThreads(0) {
m = new castor::server::Mutex(0);
m_timeStart.tv_usec = 0;
srand((unsigned)time(NULL));
}
......@@ -54,21 +57,44 @@ TestThread::TestThread() :
//------------------------------------------------------------------------------
void TestThread::run(void* param) {
//u_signed64 i = 0;
char server[] = "lxc2dev2"; // for nsping
char buf[10];
u_signed64 c = 0;
u_signed64 reqProcTime = 0, timeStdDev = 0;
//struct Cns_filestat cnsFilestat;
castor::server::SignalThreadPool* p = (castor::server::SignalThreadPool*)param;
// For testing Cns_getpath
//char server[] = "lxc2dev2"; // for nsping
//char buf[10000];
//std::vector<u_signed64> validids;
//std::ifstream id_ifs("validids.txt");
//std::string id;
//while(getline(id_ifs, id)){
// validids.push_back(atoi(id.c_str()));
//}
//unsigned validids_len = validids.size();
// For testing Cns_stat
std::vector<std::string> validpaths;
validpaths.reserve(230909);
std::ifstream paths_ifs("validpaths.txt");
std::string path;
Cns_filestat statbuf;
while(getline(paths_ifs, path)){
validpaths.push_back(path);
}
unsigned validpaths_len = validpaths.size();
castor::server::SignalThreadPool* p = (castor::server::SignalThreadPool*)param;
if(!m_timeStart.tv_usec) {
// hopefully only one thread computes it
m_timeStart.tv_usec = 1;
gettimeofday(&m_timeStart, 0);
}
timeval reqStart, reqEnd;
while(!p->stopped()) {
//i = rand() % maxNb;
......@@ -78,10 +104,14 @@ void TestThread::run(void* param) {
gettimeofday(&reqStart, 0);
// *** Do something here ***
Cns_ping(server, buf);
//Cns_ping(server, buf);
//Cns_getpath(server, validids[rand() % validids_len], buf);
Cns_stat(validpaths[rand() % validpaths_len].c_str(), &statbuf);
//Cns_statx(m_files[i].c_str(), &cnsFileid, &cnsFilestat);
// collect statistics
// collect statistics
gettimeofday(&reqEnd, 0);
c++;
u_signed64 t = ((reqEnd.tv_sec * 1000000) + reqEnd.tv_usec) - ((reqStart.tv_sec * 1000000) + reqStart.tv_usec);
......@@ -93,7 +123,7 @@ void TestThread::run(void* param) {
std::cout << "Thread #" << syscall(__NR_gettid) << " : req.count = " << c << " avgProcTime = " << reqProcTime * 0.000001/c
<< " sec +/- " << 0.000001*(c-1)/c*sqrt(timeStdDev*1.0/c - (reqProcTime*1.0/c)*(reqProcTime*1.0/c))
<< " sec" << std::endl;
if(!m_wallTime) {
// hopefully only one thread computes it
m_wallTime = 1;
......@@ -106,6 +136,7 @@ void TestThread::run(void* param) {
m->lock();
m_reqCount += c;
m_nbThreads++;
m_timeStdDev += timeStdDev;
m_procTime += reqProcTime;
m->release();
......@@ -114,6 +145,7 @@ void TestThread::run(void* param) {
std::cout.precision(4);
std::cout << "Total req.count = " << m_reqCount << " wallTime = " << m_wallTime * 0.000001
<< " sec avgProcTime = " << m_procTime * 0.000001/m_reqCount
<< " sec +/- " << 0.000001*m_reqCount/m_reqCount*sqrt(m_timeStdDev*1.0/m_reqCount - pow(m_procTime*1.0/m_reqCount,2))
<< " sec p/wTime = " << m_procTime/m_wallTime << " throughput = " << m_reqCount*1000000.0/m_wallTime
<< " req/sec" << std::endl;
}
......
......@@ -45,7 +45,7 @@ class TestThread : public castor::server::IThread {
~TestThread() throw() {};
private:
u_signed64 m_procTime, m_wallTime, m_reqCount;
u_signed64 m_procTime, m_wallTime, m_reqCount, m_timeStdDev;
timeval m_timeStart;
unsigned m_nbThreads;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment