291 lines
8.9 KiB
C++
291 lines
8.9 KiB
C++
#define MD_AUSREG
|
|
#include "cliever-md.h"
|
|
#include "session/SessionFactory.hpp"
|
|
#include "session/SessionManagerProperties.hpp"
|
|
#include "session/Transaction.hpp"
|
|
#include "common/SystemProperties.hpp"
|
|
#include "session/Session.hpp"
|
|
#include "session/StatsManager.hpp"
|
|
#include "se/DomainCheckCommand.hpp"
|
|
#include "se/DomainCheckResponse.hpp"
|
|
#include "se/LPE/LPChkCmdExtension.hpp"
|
|
#include "se/LPE/LPChkRespExtension.hpp"
|
|
#include "se/LPE/LPCrtCmdExtension.hpp"
|
|
#include "se/LPE/LPCrtRespExtension.hpp"
|
|
#include "se/TransferOp.hpp"
|
|
#include "se/IntPostalInfo.hpp"
|
|
#include "se/ContactCreateCommand.hpp"
|
|
#include "se/ContactCreateResponse.hpp"
|
|
#include "se/DomainCreateCommand.hpp"
|
|
#include "se/DomainCreateResponse.hpp"
|
|
#include "se/DomainTransferApproveCommand.hpp"
|
|
#include "se/DomainTransferRequestCommand.hpp"
|
|
#include "se/DomainTransferResponse.hpp"
|
|
#include <errno.h>
|
|
#include <sys/types.h>
|
|
#include <sys/inotify.h>
|
|
#include <json/json.h>
|
|
#include "mdJSON.hpp"
|
|
|
|
typedef boost::heap::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 ( 32 * ( EVENT_SIZE + 16 ) )
|
|
//char *name1 = "bestever.camera"; //
|
|
//char *name3 = "pricey.holdings"; //
|
|
//char *name5 = "greedy.ventures"; //
|
|
//char *name6 = "shady.ventures"; //
|
|
//char *name7 = "hemmarhoid.camera"; //
|
|
//char *name3 = "pricey.holdings"; //
|
|
const char *name1 = "yoda.guru";
|
|
const char *name2 = "unicycles.bike";
|
|
const char *name3 = "test-validate.claimsgasix";
|
|
const char *name4 = "horny.singles";
|
|
const char *name5 = "atmospheric.lighting";
|
|
const char *name6 = "mushroomtheory.management";
|
|
|
|
static TestEnvironment props;
|
|
|
|
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>";
|
|
|
|
#include "AC_OTE.h"
|
|
|
|
// static void testExecuteParallelTransactions() throw (EPPException);
|
|
|
|
bool ausRegEPPTK::doNothing(const std::string propertiesFilePath) { // Just verify load
|
|
|
|
bool did=false;
|
|
|
|
try {
|
|
scenario( 0, propertiesFilePath ); // tkScenario 0 assumed
|
|
did = true;
|
|
}
|
|
catch(std::exception &e) {
|
|
theseLogs->logN(2,"Scenario %d TK Exception: %s .",tkScenario,e.what());
|
|
}
|
|
return did;
|
|
|
|
}
|
|
void ausRegEPPTK::doOTEA()
|
|
{
|
|
int hours,hoops;
|
|
string op("newInstance");
|
|
|
|
scenario(tkScenario,thisConfig->cfg_path);
|
|
|
|
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();
|
|
|
|
for (hours=0;hours < 24;hours++) {
|
|
// Spawn the keep alive thread.
|
|
theseLogs->logN(1,"Send Test SEs on or about start OTE Test Hour %d.",hours);
|
|
|
|
for (hoops=0;hoops<7;hoops++) {
|
|
sess->writeXML(TEST_SE);
|
|
sess->read();
|
|
sleep(857);
|
|
}
|
|
|
|
}
|
|
sess->close();
|
|
manager->shutdown();
|
|
|
|
}
|
|
catch (EPPException& e)
|
|
{ const char *eMsg = e.getMessage().c_str();
|
|
const char *opNow = op.c_str();
|
|
theseLogs->logN(2,"EPP Exception during OTE A (%s): %s .",opNow,eMsg);
|
|
throw e;
|
|
}
|
|
catch (...)
|
|
{
|
|
theseLogs->logN(2,"General Exception during OTE A (%s).",op.c_str());
|
|
}
|
|
}
|
|
#include "donutsOTEB.h"
|
|
void ausRegEPPTK::registryXOTE() { // PROD in OTE
|
|
// This scenario generalizes OTEB so that its operations can be performed
|
|
// by json scripting. This is a quick and clean which is meant to allow
|
|
// a Registrar to begin quasi-production ops from the established OTE
|
|
// baseline. It's main use case is scripted OTE ops however, it's not
|
|
// meant to be actual production.
|
|
|
|
bool actionableFileEvent,monitoring=true;
|
|
int length, i = 0, mSleeps=0, nSleeps=0,debug=10000;
|
|
int fd, wd;
|
|
char buffer[BUF_LEN];
|
|
|
|
theseLogs->logN(0,"Begin RegistryXOTE Session.");
|
|
|
|
AC_OTE::setFuncs();
|
|
|
|
fd = inotify_init();
|
|
|
|
if ( fd < 0 ) {
|
|
theseLogs->logN(0,"Fatal error, couldn't init inotify.");
|
|
return;
|
|
}
|
|
|
|
theseLogs->logN(0,"Monitoring ./json for changes.");
|
|
|
|
wd = inotify_add_watch( fd, "./json", IN_MODIFY | IN_CREATE | IN_DELETE );
|
|
length = read( fd, buffer, BUF_LEN );
|
|
|
|
if ( length < 0 ) {
|
|
theseLogs->logN(0,"Fatal error, initial inotify read failed.");
|
|
goto done;
|
|
}
|
|
|
|
|
|
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.", event->name );
|
|
}
|
|
else {
|
|
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.", event->name );
|
|
}
|
|
else {
|
|
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.", event->name );
|
|
}
|
|
else {
|
|
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()) { didDie = false;
|
|
if (!scriptor.run()) {
|
|
if (didDie) {
|
|
monitoring = false;
|
|
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.", 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 );
|
|
}
|
|
}
|
|
}
|
|
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 debug=1000000,hours=0,hoops,minutes=0,seconds=0,idleSeconds=0,lastSeconds=0,lastMinutes;
|
|
string op("newInstance");
|
|
|
|
scenario(thisConfig->tkScenario,thisConfig->cfg_path);
|
|
|
|
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();
|
|
ac_mgr = manager;
|
|
ac_sess = sess;
|
|
|
|
while ((1440 - minutes) > EODMARGIN) {
|
|
|
|
if (!acq.empty()) { idleSeconds = 0;
|
|
|
|
Transaction *tx = acq.top();
|
|
|
|
if (debug > 999)
|
|
theseLogs->logN(3,"Tx dequeued @ minute %d second %d (%d waiting).",minutes,seconds,acq.size()-1);
|
|
|
|
manager->execute(*tx);
|
|
if (debug > 999)
|
|
theseLogs->logN(2,"Tx completed @ minute %d second %d.",minutes,seconds);
|
|
|
|
acq.pop();
|
|
delete tx;
|
|
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
if (debug > 9999 && !(seconds % 10))
|
|
theseLogs->logN(3,"AC Production %d:%d:%d.",hours-1,minutes,seconds);
|
|
}
|
|
|
|
sess->close();
|
|
manager->shutdown();
|
|
|
|
}
|
|
catch (EPPException& e)
|
|
{ const char *eMsg = e.getMessage().c_str();
|
|
const char *opNow = op.c_str();
|
|
theseLogs->logN(2,"EPP Exception in Production (%s): %s .",opNow,eMsg);
|
|
throw e;
|
|
}
|
|
catch (...)
|
|
{
|
|
theseLogs->logN(2,"General Exception Production (%s).",op.c_str());
|
|
}
|
|
|
|
}
|