This commit is contained in:
Ren RenJuan 2014-01-29 23:57:01 +00:00
parent c8ada0ffd4
commit 7c140f266b
6 changed files with 147 additions and 150 deletions

View File

@ -255,6 +255,8 @@ namespace AC_OTE {
theseFuncs["case04"] = sunriseCreate; theseFuncs["case04"] = sunriseCreate;
theseFuncs["case06"] = transfer; theseFuncs["case06"] = transfer;
theseLogs->logN(0,"7 test cases bound");
} }
bool setupTestCase(Json::Value where) { // Set recognized variables, silently ignore others bool setupTestCase(Json::Value where) { // Set recognized variables, silently ignore others

View File

@ -13,7 +13,7 @@
typedef struct { typedef struct {
const char *caseName; const char *caseName;
caseBody fBody; caseBody fBody;
const Json::Value *parms; const void *parms; // JSON Value
} testCase; } testCase;
typedef std::map<int,testCase> testCases; typedef std::map<int,testCase> testCases;

View File

@ -259,9 +259,9 @@ void fullProduction() {
int nthDay; int nthDay;
for (nthDay=0;nthDay<30;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(); 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; thisService->artk->daysRunning = nthDay;
} }
@ -292,10 +292,13 @@ void masterDaemon::run() {
theseLogs->logNdebug(MAX_DEBUG,0,"OTE Basic Access Test EOJ."); theseLogs->logNdebug(MAX_DEBUG,0,"OTE Basic Access Test EOJ.");
} }
if (artk->tkScenario == ACTK_OTEC) { if (artk->tkScenario == ACTK_OTEC) {
boost::thread rxPROD(fullProduction);
assert(rxPROD.joinable());
boost::thread prodInOTE(otePROD); boost::thread prodInOTE(otePROD);
assert(prodInOTE.joinable()); assert(prodInOTE.joinable());
prodInOTE.join(); 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) { if (artk->tkScenario == ACTK_PROD) {
boost::thread rxPROD(fullProduction); boost::thread rxPROD(fullProduction);

View File

@ -27,10 +27,17 @@
#include <json/json.h> #include <json/json.h>
#include "mdJSON.hpp" #include "mdJSON.hpp"
typedef std::priority_queue < Transaction* > ACWQ;
ACWQ acq;
using namespace std; using namespace std;
#define PRODINOTESLEEP 1 // seconds
#define EODMARGIN 3 // minutes
#define EVENT_SIZE ( sizeof (struct inotify_event) ) #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 *name1 = "bestever.camera"; //
//char *name3 = "pricey.holdings"; // //char *name3 = "pricey.holdings"; //
//char *name5 = "greedy.ventures"; // //char *name5 = "greedy.ventures"; //
@ -49,7 +56,6 @@ const char *name6 = "mushroomtheory.management";
static std::string TEST_SE = static std::string TEST_SE =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><epp xmlns=\"urn:ietf:params:xml:ns:epp-1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd\"><hello/></epp>"; "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><epp xmlns=\"urn:ietf:params:xml:ns:epp-1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd\"><hello/></epp>";
#include "AC_OTE.h" #include "AC_OTE.h"
// static void testExecuteParallelTransactions() throw (EPPException); // static void testExecuteParallelTransactions() throw (EPPException);
@ -124,23 +130,9 @@ void ausRegEPPTK::registryXOTE() { // PROD in OTE
int fd, wd; int fd, wd;
char buffer[BUF_LEN]; char buffer[BUF_LEN];
string op("newInstance"); theseLogs->logN(0,"Begin RegistryXOTE Session.");
scenario(thisConfig->tkScenario,thisConfig->cfg_path); AC_OTE::setFuncs();
try {
Timer::setTime("20140101.010101");
auto_ptr<SessionManager> manager(SessionManagerFactory::newInstance(&props));
auto_ptr<Session> 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();
fd = inotify_init(); fd = inotify_init();
@ -149,9 +141,6 @@ void ausRegEPPTK::registryXOTE() { // PROD in OTE
return; return;
} }
ac_mgr = manager;
ac_sess = sess;
theseLogs->logN(0,"Monitoring ./json for changes."); theseLogs->logN(0,"Monitoring ./json for changes.");
wd = inotify_add_watch( fd, "./json", IN_MODIFY | IN_CREATE | IN_DELETE ); 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 ) { if ( length < 0 ) {
theseLogs->logN(0,"Fatal error, initial inotify read failed."); theseLogs->logN(0,"Fatal error, initial inotify read failed.");
goto done;
} }
while ( i < length && monitoring)
while ( length >= 0 && monitoring )
{ actionableFileEvent = false; { actionableFileEvent = false;
struct inotify_event *event = ( struct inotify_event * ) &buffer[ i ]; struct inotify_event *event = ( struct inotify_event * ) &buffer[ i ];
if ( event->len ) { if ( event->len ) {
if ( event->mask & IN_CREATE ) { if ( event->mask & IN_CREATE ) {
if ( event->mask & IN_ISDIR ) { 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 { else {
theseLogs->logN(1,"The file %s was created.\n", event->name ); theseLogs->logN(1,"The file %s was created.", event->name );
actionableFileEvent = true; actionableFileEvent = true;
} }
} }
else if ( event->mask & IN_DELETE ) { else if ( event->mask & IN_DELETE ) {
if ( event->mask & IN_ISDIR ) { 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 { 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 ) { else if ( event->mask & IN_MODIFY ) {
if ( event->mask & IN_ISDIR ) { 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 { else {
theseLogs->logN(1, "The file %s was modified.\n", event->name ); theseLogs->logN(1, "The file %s was modified.", event->name );
actionableFileEvent = true; theseLogs->logN(0, "Modifications are ignored." );
}
} }
}
i += EVENT_SIZE + event->len; i += EVENT_SIZE + event->len;
if (actionableFileEvent) { char wxyz[100]; sprintf(wxyz,"./json/%s",event->name);
mdJSON scriptor; if (actionableFileEvent) { char wxyz[100]; sprintf(wxyz,"./json/%s",event->name);
scriptor.setPath(wxyz); mdJSON scriptor;
if (scriptor.parse()) { scriptor.setPath(wxyz);
if (scriptor.run()) { if (!scriptor.parse()) { didDie = false;
if (!scriptor.run()) {
if (didDie) { if (didDie) {
monitoring = false; monitoring = false;
theseLogs->logN(1, "Run of %s fatal error. ./json monitoring stops.\n", event->name ); theseLogs->logN(1, "Run of %s fatal error. ./json monitoring stops.", event->name );
theseLogs->logN(0, "Restart process to resume operations." ); theseLogs->logN(0, "Restart process to resume JSON monitoring operations." );
} else { } 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 } else
theseLogs->logN(1, " %s completed OK. ./json monitoring continues. \n", event->name ); theseLogs->logN(1, " %s completed OK. ./json monitoring continues.", event->name );
}
else {
theseLogs->logN(1, "Parse of %s failed. ,/json monitoring continues.\n", event->name );
} }
else {
theseLogs->logN(1, "Parse of %s failed. ./json monitoring continues.", event->name );
}
}
} }
i=0;
#define PRODINOTESLEEP 2 length = read( fd, buffer, BUF_LEN );
}
if (!(nSleeps % (60/PRODINOTESLEEP))) done:
theseLogs->logN(1,"Approximate AC PROD in OTE Hour %d.",(nSleeps/(60/PRODINOTESLEEP))); ( void ) inotify_rm_watch( fd, wd );
( void ) close( fd );
if (mSleeps == (857/PRODINOTESLEEP)) { theseLogs->logN(0,"End RegistryXOTE Session.");
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());
}
} }
void ausRegEPPTK::doPROD() void ausRegEPPTK::doPROD()
{ {
int hours,hoops; int hours=0,hoops,minutes=0,seconds=0,idleSeconds=0,lastSeconds=0,lastMinutes;
string op("newInstance"); string op("newInstance");
scenario(thisConfig->tkScenario,thisConfig->cfg_path); scenario(thisConfig->tkScenario,thisConfig->cfg_path);
@ -268,19 +230,33 @@ void ausRegEPPTK::doPROD()
op = "run (keep-alive)"; op = "run (keep-alive)";
manager->run(); manager->run();
sess->open(); sess->open();
ac_mgr = manager;
ac_sess = sess;
for (hours=0;hours < 24;hours++) { while ((1440 - minutes) > EODMARGIN) {
// Spawn the keep alive thread.
theseLogs->logN(1,"AC Production Hour %d.",hours);
// if thisEPPServer(mdStdDevIdx).vendor == "Donuts" if (!acq.empty()) { idleSeconds = 0;
for (hoops=0;hoops<7;hoops++) {
sess->writeXML(TEST_SE); }
sess->read();
sleep(857); 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(); sess->close();
manager->shutdown(); manager->shutdown();
@ -295,4 +271,5 @@ void ausRegEPPTK::doPROD()
{ {
theseLogs->logN(2,"General Exception Production (%s).",op.c_str()); theseLogs->logN(2,"General Exception Production (%s).",op.c_str());
} }
} }

View File

@ -39,7 +39,8 @@ readInputTestFile( const char *path )
bool mdJSON::run() 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"]; const Json::Value suite = root["testSuite00"];
@ -48,42 +49,56 @@ bool mdJSON::run()
return true; return true;
} }
for ( i = 0; i < suite.size(); ++i ) { const char *thisItem = suite[i].asString().c_str(); if (!suite.isObject()) {
if (debug) theseLogs->logN(0,"'testSuite00' isn't an object, can't run.");
theseLogs->logN(1,"item %.",thisItem); 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 (strncmp(thisItem,"case",4)) continue;
if (strlen(thisItem) != 6) continue; if (strlen(thisItem) != 6) continue;
if (debug) if (debug > 100)
theseLogs->logN(1,"case %.",thisItem); theseLogs->logN(1,"case %s.",thisItem);
if (!AC_OTE::theseFuncs[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; 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].parms = &suite[i];
AC_OTE::theseCases[nCases].fBody = AC_OTE::theseFuncs[thisItem]; AC_OTE::theseCases[nCases].fBody = AC_OTE::theseFuncs[thisItem];
AC_OTE::theseCases[nCases++].caseName = thisItem; AC_OTE::theseCases[nCases++].caseName = thisItem;
} }
while(!done) { theseLogs->logN(1,"%d cases bound.",nCases);
try {
for (i=0;i<AC_OTE::theseCases.size();i++) {
for (i=0;i<AC_OTE::theseCases.size();i++) {
try{
theseLogs->logN(2,"%d (%s) Begin ",i,AC_OTE::theseCases[i].caseName ); theseLogs->logN(2,"%d (%s) Begin ",i,AC_OTE::theseCases[i].caseName );
AC_OTE::theseCases[i].fBody(); AC_OTE::theseCases[i].fBody();
theseLogs->logN(2,"%d (%s) End ",i,AC_OTE::theseCases[i].caseName ); theseLogs->logN(2,"%d (%s) End ",i,AC_OTE::theseCases[i].caseName );
} }
catch (...)
theseLogs->logN(0,"End OTE Session."); {
theseLogs->logN(0,"Restart with toolkit scenario >= 5 for production ops."); theseLogs->logN(1,"Inner JSON Exception in %s ",AC_OTE::theseCases[i].caseName );
}
} }
catch (...) theseLogs->logN(0,"Suite 'testSuite00' end execution.");
{
theseLogs->logN(0,"Inner JSON Execution in OTE ");
}
}
} }
static bool static bool
@ -93,7 +108,7 @@ parseValueTree( const std::string &input, const std::string &kind, Json::Value
bool parsingSuccessful = reader.parse( input, root ); bool parsingSuccessful = reader.parse( input, root );
if ( !parsingSuccessful ) 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(), kind.c_str(),
reader.getFormattedErrorMessages().c_str() ); reader.getFormattedErrorMessages().c_str() );
return true; return true;
@ -111,7 +126,7 @@ bool mdJSON::parse()
std::string input = readInputTestFile( path.c_str() ); std::string input = readInputTestFile( path.c_str() );
if ( input.empty() ) 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; return 3;
} }
@ -120,7 +135,7 @@ bool mdJSON::parse()
} }
catch ( const std::exception &e ) 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; value = true;
} }

View File

@ -1,19 +1,19 @@
{ {
"_comment" : "mdJSON.cpp will try to bind data and run if it recognizes the leading field name." "_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" : "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()" "testSuites": "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": "Repeat case name casexx as needed, to run needs logic bound in RegistryXOTE.h",
"testSuite-00" : { "testSuite00" : {
"Registry" : "Donuts", "Registry" : "Donuts",
"AccountA" : "secura1-ote", "AccountA" : "secura1-ote",
"AccountB" : "secura2-ote2", "AccountB" : "secura2-ote2",
"case00" : "Create a contact" "case00" : "Create a contact",
"case-00" : { "case-00" : {
"cont_id": "renjuan", "cont_id": "renjuan",
@ -21,43 +21,43 @@
"cont_email": "juan@acm.org", "cont_email": "juan@acm.org",
"cont-name": "Ren Ren-Juan", "cont-name": "Ren Ren-Juan",
"cont-city": "Niagara Falls", "cont-city": "Niagara Falls",
"cont_street1: "2926 2nd Street", "cont_street1": "2926 2nd Street",
"cont-province": NY", "cont-province": "NY",
"cont-postal-code": "14305", "cont-postal-code": "14305",
"cont-guo": "US", "cont-guo": "US",
"cont-org": "American Kybernetik" "cont-org": "American Kybernetik"
} },
"case01" : "Conventional / Standard/ Unextended Check" "case01" : "Conventional / Standard/ Unextended Check",
"case-01" : { "case-01" : {
"name" : "bestever.camera" "name" : "bestever.camera"
} },
"case02" : "Check with Claims Extension" "case02" : "Check with Claims Extension",
"case-02" : { "case-02" : {
"name" : "unicycles.bike" "name" : "unicycles.bike"
} },
"case03" : "Conventional / Standard / Unextended Create" "case03" : "Conventional / Standard / Unextended Create",
"case-03" : { "case-03" : {
"name" : "greedy.ventures" "name" : "greedy.ventures"
} },
"case04" : "DPML Create" "case04" : "DPML Create",
"case-04" : { "case-04" : {
"name" : "face.dpml.zone" "name" : "face.dpml.zone",
"smd-data" : "./smd/face-test.smd" "smd-data" : "./smd/face-test.smd"
} },
"case00" : "Create another contact" "case00" : "Create another contact",
"case-00" : { "case-00" : {
"cont_id": "renjuan2", "cont_id": "renjuan2",
@ -65,28 +65,28 @@
"cont_email": "juan@acm.org", "cont_email": "juan@acm.org",
"cont-name": "Ren Ren-Juan", "cont-name": "Ren Ren-Juan",
"cont-city": "Niagara Falls", "cont-city": "Niagara Falls",
"cont_street1: "2926 2nd Street", "cont_street1": "2926 2nd Street",
"cont-province": NY", "cont-province": "NY",
"cont-postal-code": "14305", "cont-postal-code": "14305",
"cont-guo": "US", "cont-guo": "US",
"cont-org": "American Kybernetik" "cont-org": "American Kybernetik"
} },
"case04" : "DPML Create" "case04" : "DPML Create",
"case-04" : { "case-04" : {
"name" : "secura.dpml.zone" "name" : "secura.dpml.zone",
"smd-data" : "./smd/secura-test.smd" "smd-data" : "./smd/secura-test.smd"
} },
"case05" : "Create with TCN Override" "case05" : "Create with TCN Override",
"case-05" : { "case-05" : {
"name" : "greedy.ventures" "name" : "greedy.ventures",
"noticeID" : "" "noticeID" : "",
"notBefore" : "" "notBefore" : "",
"acceptedDate" : "" "acceptedDate" : ""
} }