From 267966811b23ba5f2ee0fa3dfb10994f67b1b372 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Thu, 30 Sep 2004 08:24:10 +0000 Subject: [PATCH] Fix the test build --- org.glite.lb.server/Makefile | 12 +++- org.glite.lb.server/test/oneJob.qry | 24 ++++++++ org.glite.lb.server/test/test_query_events.cpp | 77 +++++++++++++++++++++----- 3 files changed, 97 insertions(+), 16 deletions(-) create mode 100644 org.glite.lb.server/test/oneJob.qry diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index bf01a86..bb2930d 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -20,6 +20,7 @@ ares_prefix=/opt/ares -include Makefile.inc YACC=bison -y +CC=gcc VPATH=${top_srcdir}/src:${top_srcdir}/test AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 @@ -59,7 +60,7 @@ LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} GLOBUS_LIBS:= -L${globus_prefix}/lib \ -lglobus_common_${nothrflavour} \ - -lglobus_gssapi_gsi_${nothrflavour} + -lglobus_gssapi_gsi_${nothrflavour} \ # XXX: our vomsc.la depends on badly installed expat @@ -96,12 +97,17 @@ default all: compile compile: glite_lb_bkserverd glite_lb_bkindex -check: test_xml +check: compile test.xml test.query -echo check.query not complete yet test_xml: test_xml.cpp ${CXX} -c ${CFLAGS} ${TEST_INC} $< - ${LINKXX} -o $@ test_xml.o lb_xml_parse.o ${COMMON_LIB} ${TEST_LIBS} + ${LINKXX} -o $@ test_xml.o lb_xml_parse.o ${COMMON_LIB} ${TEST_LIBS} ${EXT_LIBS} + +test.query: test_query_events + ./test_query_events ${top_srcdir}/test + +test.xml: test_xml ./test_xml lb_xml_parse.c: lb_xml_parse.c.T diff --git a/org.glite.lb.server/test/oneJob.qry b/org.glite.lb.server/test/oneJob.qry new file mode 100644 index 0000000..d419ce8 --- /dev/null +++ b/org.glite.lb.server/test/oneJob.qry @@ -0,0 +1,24 @@ +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 + +select name,value from short_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 0 +JDL x +JOBTYPE SIMPLE +NS NNNSSSS +NSUBJOBS 0 +PARENT https://lhun.ics.muni.cz:4850/Qt7utj80miXexi7bkxyhnA +SEQCODE (nil) +SRC_INSTANCE (nil) + +select name,value from long_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 0 + +select name,value from short_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 1 +FROM UserInterface +FROM_HOST sending component hostname +FROM_INSTANCE sending component instance +LOCAL_JOBID new jobId (Condor Globus ...) +SEQCODE UI=000002:NS=0000000001:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000 +SRC_INSTANCE + +select name,value from long_fields where jobid = 'WrCEKje9QTXFiSOZuPMLtw' and event = 1 diff --git a/org.glite.lb.server/test/test_query_events.cpp b/org.glite.lb.server/test/test_query_events.cpp index 0a20d86..bf356f4 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 @@ -13,6 +13,8 @@ using namespace std; +static const char *test_dir; + class QueryEventsTest: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(QueryEventsTest); @@ -21,8 +23,10 @@ class QueryEventsTest: public CppUnit::TestFixture private: edg_wll_Context ctx; - vector>> expQueries; - int queryIdx; + + ifstream qry_file; + + vector > > queries; public: void oneJob(); @@ -43,27 +47,63 @@ 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; + + string file(test_dir); + file += "/oneJob.qry"; + qry_file.open(file.c_str()); + + 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(); stmt++) { + const char *q = stmt->first.c_str(); + + /* XXX: there some spaces at the end of qry */ + if (!strncmp(q,qry,strlen(q))) break; + } + + if (stmt == queries.end()) { + cerr << "query not found" << endl; + CPPUNIT_ASSERT(0); + } + vector::iterator *rows = new vector::iterator(stmt->second.begin()); + + *stmt_out = (edg_wll_Stmt) rows; + return stmt->second.size()-1; } extern "C" { int edg_wll_ExecStmt(edg_wll_Context ctx,char *qry,edg_wll_Stmt *stmt) { - cout << qry << endl; + cout << "edg_wll_ExecStmt: " << qry << endl; class QueryEventsTest *tst = (class QueryEventsTest *)(ctx->mysql); return tst->ExecStmt(qry, stmt); @@ -71,7 +111,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()); + (*rows)++; + for (p = strtok(row,"\t"); p; p = strtok(NULL,"\t")) + cols[i++] = strdup(p); + + return i; } void edg_wll_FreeStmt(edg_wll_Stmt *) {} @@ -96,6 +145,8 @@ int main (int ac,const char *av[]) CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); CppUnit::TextUi::TestRunner runner; + test_dir = ac >= 2 ? av[1] : "../test"; + runner.addTest(suite); return runner.run() ? 0 : 1; } -- 1.8.2.3