diff --git a/AusRegCliever/include/AC_OTE.h b/AusRegCliever/include/AC_OTE.h index 7ea7bb9..4b7d8c9 100644 --- a/AusRegCliever/include/AC_OTE.h +++ b/AusRegCliever/include/AC_OTE.h @@ -255,6 +255,8 @@ namespace AC_OTE { theseFuncs["case04"] = sunriseCreate; theseFuncs["case06"] = transfer; + theseLogs->logN(0,"7 test cases bound"); + } bool setupTestCase(Json::Value where) { // Set recognized variables, silently ignore others diff --git a/AusRegCliever/include/mdJSON.hpp b/AusRegCliever/include/mdJSON.hpp index 9a54146..1a3136b 100644 --- a/AusRegCliever/include/mdJSON.hpp +++ b/AusRegCliever/include/mdJSON.hpp @@ -13,7 +13,7 @@ typedef struct { const char *caseName; caseBody fBody; - const Json::Value *parms; + const void *parms; // JSON Value } testCase; typedef std::map testCases; diff --git a/AusRegCliever/server/masterDaemon.cpp b/AusRegCliever/server/masterDaemon.cpp index 8e7bc9c..85e9272 100644 --- a/AusRegCliever/server/masterDaemon.cpp +++ b/AusRegCliever/server/masterDaemon.cpp @@ -259,9 +259,9 @@ void fullProduction() { int nthDay; for (nthDay=0;nthDay<30;nthDay++) { - theseLogs->logNdebug(MAX_DEBUG,1,"AC Production SoD %d",nthDay); + theseLogs->logNdebug(MAX_DEBUG,1,"AC Production SoD %d",nthDay+1); thisService->artk->doPROD(); - theseLogs->logNdebug(MAX_DEBUG,1,"AC Production EoD %d",nthDay); + theseLogs->logNdebug(MAX_DEBUG,1,"AC Production EoD %d",nthDay+1); thisService->artk->daysRunning = nthDay; } @@ -292,10 +292,13 @@ void masterDaemon::run() { theseLogs->logNdebug(MAX_DEBUG,0,"OTE Basic Access Test EOJ."); } if (artk->tkScenario == ACTK_OTEC) { + boost::thread rxPROD(fullProduction); + assert(rxPROD.joinable()); boost::thread prodInOTE(otePROD); assert(prodInOTE.joinable()); prodInOTE.join(); - theseLogs->logNdebug(MAX_DEBUG,0,"OTE Full Access EOJ."); + rxPROD.join(); + theseLogs->logNdebug(MAX_DEBUG,0,"PROD in OTE EOJ."); } if (artk->tkScenario == ACTK_PROD) { boost::thread rxPROD(fullProduction); diff --git a/AusRegCliever/server/mdAusReg.cpp b/AusRegCliever/server/mdAusReg.cpp index 51f80c8..5c64ee2 100644 --- a/AusRegCliever/server/mdAusReg.cpp +++ b/AusRegCliever/server/mdAusReg.cpp @@ -27,10 +27,17 @@ #include #include "mdJSON.hpp" +typedef std::priority_queue < Transaction* > ACWQ; + + ACWQ acq; + using namespace std; +#define PRODINOTESLEEP 1 // seconds +#define EODMARGIN 3 // minutes + #define EVENT_SIZE ( sizeof (struct inotify_event) ) -#define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) +#define BUF_LEN ( 32 * ( EVENT_SIZE + 16 ) ) //char *name1 = "bestever.camera"; // //char *name3 = "pricey.holdings"; // //char *name5 = "greedy.ventures"; // @@ -49,7 +56,6 @@ const char *name6 = "mushroomtheory.management"; static std::string TEST_SE = ""; - #include "AC_OTE.h" // static void testExecuteParallelTransactions() throw (EPPException); @@ -124,23 +130,9 @@ void ausRegEPPTK::registryXOTE() { // PROD in OTE int fd, wd; char buffer[BUF_LEN]; - string op("newInstance"); + theseLogs->logN(0,"Begin RegistryXOTE Session."); - scenario(thisConfig->tkScenario,thisConfig->cfg_path); - - try { - Timer::setTime("20140101.010101"); - auto_ptr manager(SessionManagerFactory::newInstance(&props)); - auto_ptr sess(SessionFactory::newInstance(&props)); - op = "startup"; - manager->startup(); - op = "run (keep-alive)"; - manager->run(); - - sess->open(); - theseLogs->logN(0,"Begin RegistryXOTE Session."); - sess->writeXML(TEST_SE); - sess->read(); + AC_OTE::setFuncs(); fd = inotify_init(); @@ -149,9 +141,6 @@ void ausRegEPPTK::registryXOTE() { // PROD in OTE return; } - ac_mgr = manager; - ac_sess = sess; - theseLogs->logN(0,"Monitoring ./json for changes."); wd = inotify_add_watch( fd, "./json", IN_MODIFY | IN_CREATE | IN_DELETE ); @@ -159,102 +148,75 @@ void ausRegEPPTK::registryXOTE() { // PROD in OTE if ( length < 0 ) { theseLogs->logN(0,"Fatal error, initial inotify read failed."); + goto done; } - while ( i < length && monitoring) + + while ( length >= 0 && monitoring ) { actionableFileEvent = false; struct inotify_event *event = ( struct inotify_event * ) &buffer[ i ]; if ( event->len ) { if ( event->mask & IN_CREATE ) { if ( event->mask & IN_ISDIR ) { - theseLogs->logN(1,"The directory %s was created.\n", event->name ); + theseLogs->logN(1,"The directory %s was created.", event->name ); } else { - theseLogs->logN(1,"The file %s was created.\n", event->name ); + theseLogs->logN(1,"The file %s was created.", event->name ); actionableFileEvent = true; } } else if ( event->mask & IN_DELETE ) { if ( event->mask & IN_ISDIR ) { - theseLogs->logN(1,"The directory %s was deleted.\n", event->name ); + theseLogs->logN(1,"The directory %s was deleted.", event->name ); } else { - printf( "The file %s was deleted.\n", event->name ); + theseLogs->logN(1,"The file %s was deleted.", event->name ); } } else if ( event->mask & IN_MODIFY ) { if ( event->mask & IN_ISDIR ) { - theseLogs->logN(1, "The directory %s was modified.\n", event->name ); + theseLogs->logN(1, "The directory %s was modified.", event->name ); } else { - theseLogs->logN(1, "The file %s was modified.\n", event->name ); - actionableFileEvent = true; + theseLogs->logN(1, "The file %s was modified.", event->name ); + theseLogs->logN(0, "Modifications are ignored." ); + } } - } - i += EVENT_SIZE + event->len; - if (actionableFileEvent) { char wxyz[100]; sprintf(wxyz,"./json/%s",event->name); - mdJSON scriptor; - scriptor.setPath(wxyz); - if (scriptor.parse()) { - if (scriptor.run()) { + i += EVENT_SIZE + event->len; + + if (actionableFileEvent) { char wxyz[100]; sprintf(wxyz,"./json/%s",event->name); + mdJSON scriptor; + scriptor.setPath(wxyz); + if (!scriptor.parse()) { didDie = false; + if (!scriptor.run()) { if (didDie) { monitoring = false; - theseLogs->logN(1, "Run of %s fatal error. ./json monitoring stops.\n", event->name ); - theseLogs->logN(0, "Restart process to resume operations." ); + theseLogs->logN(1, "Run of %s fatal error. ./json monitoring stops.", event->name ); + theseLogs->logN(0, "Restart process to resume JSON monitoring operations." ); } else { - theseLogs->logN(1, "Run of %s has errors ./json monitoring continues.\n", event->name ); + theseLogs->logN(1, "Run of %s has errors ./json monitoring continues.", event->name ); } - } else - theseLogs->logN(1, " %s completed OK. ./json monitoring continues. \n", event->name ); - - } - else { - theseLogs->logN(1, "Parse of %s failed. ,/json monitoring continues.\n", event->name ); + } else + theseLogs->logN(1, " %s completed OK. ./json monitoring continues.", event->name ); } + else { + theseLogs->logN(1, "Parse of %s failed. ./json monitoring continues.", event->name ); + } + } } - -#define PRODINOTESLEEP 2 - - if (!(nSleeps % (60/PRODINOTESLEEP))) - theseLogs->logN(1,"Approximate AC PROD in OTE Hour %d.",(nSleeps/(60/PRODINOTESLEEP))); - - if (mSleeps == (857/PRODINOTESLEEP)) { - sess->writeXML(TEST_SE); - sess->read(); - mSleeps = 0; - } - - sleep(PRODINOTESLEEP); - nSleeps++; mSleeps++; - if (debug > 999) - theseLogs->logN(2,"nSleeps: %d mSleeps %d.",nSleeps,mSleeps); - - } // while monitoring - ( void ) inotify_rm_watch( fd, wd ); - ( void ) close( fd ); - } - theseLogs->logN(0,"End PROD in OTE Session."); - - sess->close(); - manager->shutdown(); - } - catch (EPPException& e) - { const char *eMsg = e.getMessage().c_str(); - const char *opNow = op.c_str(); - theseLogs->logN(2,"Outer EPP Exception during PRODinOTE (%s): %s .",opNow,eMsg); - throw e; - } - catch (...) - { - theseLogs->logN(2,"Outer General Exception in OTE (%s).",op.c_str()); - } - + i=0; + length = read( fd, buffer, BUF_LEN ); + } + done: + ( void ) inotify_rm_watch( fd, wd ); + ( void ) close( fd ); + theseLogs->logN(0,"End RegistryXOTE Session."); } void ausRegEPPTK::doPROD() { - int hours,hoops; + int hours=0,hoops,minutes=0,seconds=0,idleSeconds=0,lastSeconds=0,lastMinutes; string op("newInstance"); scenario(thisConfig->tkScenario,thisConfig->cfg_path); @@ -268,19 +230,33 @@ void ausRegEPPTK::doPROD() op = "run (keep-alive)"; manager->run(); sess->open(); + ac_mgr = manager; + ac_sess = sess; - for (hours=0;hours < 24;hours++) { - // Spawn the keep alive thread. - theseLogs->logN(1,"AC Production Hour %d.",hours); + while ((1440 - minutes) > EODMARGIN) { - // if thisEPPServer(mdStdDevIdx).vendor == "Donuts" - for (hoops=0;hoops<7;hoops++) { - sess->writeXML(TEST_SE); - sess->read(); - sleep(857); - } + if (!acq.empty()) { idleSeconds = 0; + + } + + if (idleSeconds >= (857 - PRODINOTESLEEP)) { idleSeconds = 0; + sess->writeXML(TEST_SE); + sess->read(); + } + + sleep(PRODINOTESLEEP); + seconds += PRODINOTESLEEP; + idleSeconds += PRODINOTESLEEP; + if ((seconds - lastSeconds) == 60) { + minutes++; lastSeconds = seconds; + } + + if (!hours || ((minutes - lastMinutes) >= 59)) { + theseLogs->logN(1,"AC Production Hour %d.",hours++); + lastMinutes = minutes; + } + } - } sess->close(); manager->shutdown(); @@ -295,4 +271,5 @@ void ausRegEPPTK::doPROD() { theseLogs->logN(2,"General Exception Production (%s).",op.c_str()); } + } diff --git a/AusRegCliever/server/mdJSON.cpp b/AusRegCliever/server/mdJSON.cpp index c2f66eb..6d67779 100644 --- a/AusRegCliever/server/mdJSON.cpp +++ b/AusRegCliever/server/mdJSON.cpp @@ -39,7 +39,8 @@ readInputTestFile( const char *path ) bool mdJSON::run() { - bool done=false, debug=true; int i=0, nCases =0; + bool done=false; + int i=0, nCases =0, nThings = 0, debug=1000; const Json::Value suite = root["testSuite00"]; @@ -48,42 +49,56 @@ bool mdJSON::run() return true; } - for ( i = 0; i < suite.size(); ++i ) { const char *thisItem = suite[i].asString().c_str(); - if (debug) - theseLogs->logN(1,"item %.",thisItem); + if (!suite.isObject()) { + theseLogs->logN(0,"'testSuite00' isn't an object, can't run."); + return true; + } + + if (suite.empty()) { + theseLogs->logN(0,"'testSuite00' contains nothing, can't run."); + return true; + } + + theseLogs->logN(1,"'testSuite00' - binding %d fields and case objects.",suite.size()); + Json::Value::Members itemNames = suite.getMemberNames(); + + for ( i = 0; i < itemNames.size(); ++i ) { const char *thisItem; + + thisItem = itemNames[i].c_str(); + if (debug > 100) + theseLogs->logN(1,"item %s.",thisItem); if (strncmp(thisItem,"case",4)) continue; if (strlen(thisItem) != 6) continue; - if (debug) - theseLogs->logN(1,"case %.",thisItem); + if (debug > 100) + theseLogs->logN(1,"case %s.",thisItem); if (!AC_OTE::theseFuncs[thisItem]) { - theseLogs->logN(0,"No logic to bind to '%s', need it."); + theseLogs->logN(1,"No logic to bind to '%s', need it.",thisItem); return false; } + if (!suite[i].isObject()) { + theseLogs->logN(1,"'%s' isn't an object, can't use.",thisItem); + continue; + } AC_OTE::theseCases[nCases].parms = &suite[i]; AC_OTE::theseCases[nCases].fBody = AC_OTE::theseFuncs[thisItem]; AC_OTE::theseCases[nCases++].caseName = thisItem; } - while(!done) { - try { - - for (i=0;ilogN(1,"%d cases bound.",nCases); + for (i=0;ilogN(2,"%d (%s) Begin ",i,AC_OTE::theseCases[i].caseName ); AC_OTE::theseCases[i].fBody(); theseLogs->logN(2,"%d (%s) End ",i,AC_OTE::theseCases[i].caseName ); } - - theseLogs->logN(0,"End OTE Session."); - theseLogs->logN(0,"Restart with toolkit scenario >= 5 for production ops."); - - } - catch (...) - { - theseLogs->logN(0,"Inner JSON Execution in OTE "); - } - } + catch (...) + { + theseLogs->logN(1,"Inner JSON Exception in %s ",AC_OTE::theseCases[i].caseName ); + } + } + theseLogs->logN(0,"Suite 'testSuite00' end execution."); } static bool @@ -93,7 +108,7 @@ parseValueTree( const std::string &input, const std::string &kind, Json::Value bool parsingSuccessful = reader.parse( input, root ); if ( !parsingSuccessful ) { - theseLogs->logN(2, "Failed to parse %s file: \n%s\n", + theseLogs->logN(2, "Failed to parse %s file: %s", kind.c_str(), reader.getFormattedErrorMessages().c_str() ); return true; @@ -111,7 +126,7 @@ bool mdJSON::parse() std::string input = readInputTestFile( path.c_str() ); if ( input.empty() ) { - theseLogs->logN(1, "Failed to read input or empty input: %s\n", path.c_str() ); + theseLogs->logN(1, "Failed to read input or empty input: %s", path.c_str() ); return 3; } @@ -120,7 +135,7 @@ bool mdJSON::parse() } catch ( const std::exception &e ) { - theseLogs->logN(1, "Unhandled exception:\n%s\n", e.what() ); + theseLogs->logN(1, "Unhandled exception: %s", e.what() ); value = true; } diff --git a/json/OTEC.json b/json/OTEC.json index 7b36aa6..e939df4 100644 --- a/json/OTEC.json +++ b/json/OTEC.json @@ -1,19 +1,19 @@ { - "_comment" : "mdJSON.cpp will try to bind data and run if it recognizes the leading field name." - "_comment" : "I'm using convention of inserting a hyphen to disable a test case." + "_comment" : "mdJSON.cpp will try to bind data and run if it recognizes the leading field name.", + "_comment" : "I'm using convention of inserting a hyphen to disable a test case.", - "testSuite00": "Outer block of a set of inputs to mdJSON.cpp to be run by ausRegTK::registryXOTE()" - "testSuite00": "Repeat case name casexx as needed, to run needs logic bound in RegistryXOTE.h" + "testSuites": "Outer block of a set of inputs to mdJSON.cpp to be run by ausRegTK::registryXOTE()", + "testSuites": "Repeat case name casexx as needed, to run needs logic bound in RegistryXOTE.h", - "testSuite-00" : { + "testSuite00" : { "Registry" : "Donuts", "AccountA" : "secura1-ote", "AccountB" : "secura2-ote2", - "case00" : "Create a contact" + "case00" : "Create a contact", "case-00" : { "cont_id": "renjuan", @@ -21,43 +21,43 @@ "cont_email": "juan@acm.org", "cont-name": "Ren Ren-Juan", "cont-city": "Niagara Falls", - "cont_street1: "2926 2nd Street", - "cont-province": NY", + "cont_street1": "2926 2nd Street", + "cont-province": "NY", "cont-postal-code": "14305", "cont-guo": "US", "cont-org": "American Kybernetik" - } + }, - "case01" : "Conventional / Standard/ Unextended Check" + "case01" : "Conventional / Standard/ Unextended Check", "case-01" : { "name" : "bestever.camera" - } + }, - "case02" : "Check with Claims Extension" + "case02" : "Check with Claims Extension", "case-02" : { "name" : "unicycles.bike" - } + }, - "case03" : "Conventional / Standard / Unextended Create" + "case03" : "Conventional / Standard / Unextended Create", "case-03" : { "name" : "greedy.ventures" - } + }, - "case04" : "DPML Create" + "case04" : "DPML Create", "case-04" : { - "name" : "face.dpml.zone" + "name" : "face.dpml.zone", "smd-data" : "./smd/face-test.smd" - } + }, - "case00" : "Create another contact" + "case00" : "Create another contact", "case-00" : { "cont_id": "renjuan2", @@ -65,28 +65,28 @@ "cont_email": "juan@acm.org", "cont-name": "Ren Ren-Juan", "cont-city": "Niagara Falls", - "cont_street1: "2926 2nd Street", - "cont-province": NY", + "cont_street1": "2926 2nd Street", + "cont-province": "NY", "cont-postal-code": "14305", "cont-guo": "US", "cont-org": "American Kybernetik" - } + }, - "case04" : "DPML Create" + "case04" : "DPML Create", "case-04" : { - "name" : "secura.dpml.zone" + "name" : "secura.dpml.zone", "smd-data" : "./smd/secura-test.smd" - } + }, - "case05" : "Create with TCN Override" + "case05" : "Create with TCN Override", "case-05" : { - "name" : "greedy.ventures" - "noticeID" : "" - "notBefore" : "" + "name" : "greedy.ventures", + "noticeID" : "", + "notBefore" : "", "acceptedDate" : "" }