test_query_events with mysteries inside
authorAleš Křenek <ljocha@ics.muni.cz>
Thu, 23 Sep 2004 10:37:48 +0000 (10:37 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Thu, 23 Sep 2004 10:37:48 +0000 (10:37 +0000)
org.glite.lb.server/test/oneJob.qry [new file with mode: 0644]
org.glite.lb.server/test/test_query_events.cpp

diff --git a/org.glite.lb.server/test/oneJob.qry b/org.glite.lb.server/test/oneJob.qry
new file mode 100644 (file)
index 0000000..8e4b9bd
--- /dev/null
@@ -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
index 0a20d86..d2765d8 100644 (file)
@@ -1,4 +1,4 @@
-#include <iostream>
+#include <fstream>
 
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/CompilerOutputter.h>
@@ -21,8 +21,10 @@ class QueryEventsTest: public CppUnit::TestFixture
 
 private:
        edg_wll_Context ctx;
-       vector<pair<string,vector<string>>>     expQueries;
-       int                                     queryIdx;
+       
+       ifstream        qry_file;
+
+       vector<pair<string,vector<string> > >   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<string>  rows;
+
+               getline(qry_file,query);
+               cout << "read: " << query <<endl;
+               rows.clear();
+
+               while (!qry_file.eof()) {
+                       getline(qry_file,line);
+                       if (line == "") break;
+       
+                       rows.push_back(line);
+               }
+               rows.push_back("END");
+               queries.push_back(pair<string,vector<string> >(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<pair<string,vector<string> > >::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<string>::iterator        *rows = new vector<string>::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<string>::iterator        *rows = (vector<string>::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 *) {}