From 8e0e75dd6c68e8781a1424d11c9597c643767b3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Thu, 23 Sep 2004 10:37:48 +0000 Subject: [PATCH] test_query_events with mysteries inside --- org.glite.lb.server/test/oneJob.qry | 14 ++++++ org.glite.lb.server/test/test_query_events.cpp | 65 +++++++++++++++++++++----- 2 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 org.glite.lb.server/test/oneJob.qry diff --git a/org.glite.lb.server/test/oneJob.qry b/org.glite.lb.server/test/oneJob.qry new file mode 100644 index 0000000..8e4b9bd --- /dev/null +++ b/org.glite.lb.server/test/oneJob.qry @@ -0,0 +1,14 @@ +SELECT e.event,j.userid,j.dg_jobid,e.code,e.prog,e.host,u.cert_subj,e.time_stamp,e.usec,e.level,e.arrived FROM events e,users u,jobs j WHERE e.jobid=j.jobid AND e.userid=u.userid AND e.code != 0 AND (j.jobid='WrCEKje9QTXFiSOZuPMLtw') +0 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 17 UserInterface lhun.ics.muni.cz anonymous 2003-08-07 11:08:40 432100 8 2003-08-07 11:08:40 +1 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 2 NetworkServer lhun.ics.muni.cz anonymous 2003-08-07 11:09:05 664600 8 2003-08-07 11:09:05 +2 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 4 NetworkServer lhun.ics.muni.cz anonymous 2003-08-07 11:09:05 913562 8 2003-08-07 11:09:06 +3 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 5 WorkloadManager lhun.ics.muni.cz anonymous 2003-08-07 11:09:06 161989 8 2003-08-07 11:09:06 +4 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 6 WorkloadManager lhun.ics.muni.cz anonymous 2003-08-07 11:09:06 407675 8 2003-08-07 11:09:06 +5 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 15 WorkloadManager lhun.ics.muni.cz anonymous 2003-08-07 11:09:06 655015 8 2003-08-07 11:09:06 +6 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 7 WorkloadManager lhun.ics.muni.cz anonymous 2003-08-07 11:09:06 903089 8 2003-08-07 11:09:07 +7 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 4 WorkloadManager lhun.ics.muni.cz anonymous 2003-08-07 11:09:07 152161 8 2003-08-07 11:09:07 +8 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 5 JobController lhun.ics.muni.cz anonymous 2003-08-07 11:09:07 398869 8 2003-08-07 11:09:07 +9 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 1 JobController lhun.ics.muni.cz anonymous 2003-08-07 11:09:07 677867 8 2003-08-07 11:09:07 +10 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 2 LogMonitor lhun.ics.muni.cz anonymous 2003-08-07 11:09:07 961342 8 2003-08-07 11:09:08 +11 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 1 LogMonitor lhun.ics.muni.cz anonymous 2003-08-07 11:09:08 212690 8 2003-08-07 11:09:08 +12 294de3557d9d00b3d2d8a1e6aab028cf https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw 8 LogMonitor lhun.ics.muni.cz anonymous 2003-08-07 11:09:08 461133 8 2003-08-07 11:09:08 diff --git a/org.glite.lb.server/test/test_query_events.cpp b/org.glite.lb.server/test/test_query_events.cpp index 0a20d86..d2765d8 100644 --- a/org.glite.lb.server/test/test_query_events.cpp +++ b/org.glite.lb.server/test/test_query_events.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -21,8 +21,10 @@ class QueryEventsTest: public CppUnit::TestFixture private: edg_wll_Context ctx; - vector>> expQueries; - int queryIdx; + + ifstream qry_file; + + vector > > queries; public: void oneJob(); @@ -43,20 +45,50 @@ void QueryEventsTest::oneJob() job[0].attr = EDG_WLL_QUERY_ATTR_JOBID; job[0].op = EDG_WLL_QUERY_OP_EQUAL ; - edg_wlc_JobIdParse("https://fake.server/fake_job",&job[0].value.j); + edg_wlc_JobIdParse("https://lhun.ics.muni.cz:4850/WrCEKje9QTXFiSOZuPMLtw", + &job[0].value.j); job[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + qry_file.open("../test/oneJob.qry"); + + while (!qry_file.eof()) { + string query,line; + vector rows; + + getline(qry_file,query); + cout << "read: " << query < >(query,rows)); + } + + qry_file.close(); - expQueries.clear(); - /* - * XXX: ... - */ - expQueries.push_back(); CPPUNIT_ASSERT(!edg_wll_QueryEventsServer(ctx,1,jobs,NULL,&events)); } -int QueryEventsTest::ExecStmt(const char *, edg_wll_Stmt *) +int QueryEventsTest::ExecStmt(const char *qry, edg_wll_Stmt *stmt_out) { - return 0; + vector > >::iterator stmt = queries.begin(); + + for (; stmt != queries.end() && strcmp(stmt->first.c_str(),qry); stmt++) cout << stmt->first << endl; + + if (stmt == queries.end()) { + cerr << "query not found" << endl; + CPPUNIT_ASSERT(0); + } + vector::iterator *rows = new vector::iterator(stmt->second.begin()); + cout << "first: " << stmt->first << endl; + + *stmt_out = (edg_wll_Stmt) rows; + return stmt->second.size()-1; } extern "C" { @@ -71,7 +103,16 @@ int edg_wll_ExecStmt(edg_wll_Context ctx,char *qry,edg_wll_Stmt *stmt) int edg_wll_FetchRow(edg_wll_Stmt stmt, char **cols) { - return 0; + vector::iterator *rows = (vector::iterator *) stmt; + char *row,*p,i=0; + + if (**rows == "END") return 0; + row = strdup((*rows)->c_str()); + for (p = strtok(row,"\t"); p; p = strtok(NULL,"\t")) { + cout << (cols[i++] = strdup(p)) << endl; + } + + return i; } void edg_wll_FreeStmt(edg_wll_Stmt *) {} -- 1.8.2.3