in cppcache/integration-test/CacheHelper.cpp [1013:1150]
void CacheHelper::initServer(int instance, const std::string &xml,
const std::string &locHostport,
const char * /*unused*/, bool ssl,
bool enableDelta, bool, bool testServerGC,
bool untrustedCert, bool useSecurityManager) {
if (!isServerCleanupCallbackRegistered) {
isServerCleanupCallbackRegistered = true;
gClientCleanup.registerCallback(
[]() { CacheHelper::cleanupServerInstances(); });
std::cout << "TimeBomb registered server cleanupcallback \n";
}
std::cout << "Inside initServer added\n";
static const auto gfjavaenv = Utils::getEnv("GFJAVA");
static auto gfLogLevel = Utils::getEnv("GFE_LOGLEVEL");
static auto gfSecLogLevel = Utils::getEnv("GFE_SECLOGLEVEL");
static const auto path = Utils::getEnv("TESTSRC");
static const auto classpath = Utils::getEnv("GF_CLASSPATH");
int portNum = 0;
std::string currDir = boost::filesystem::current_path().string();
ASSERT(!gfjavaenv.empty(),
"Environment variable GFJAVA for java build directory is not set.");
ASSERT(!path.empty(),
"Environment variable TESTSRC for test source directory is not set.");
if (gfLogLevel.empty()) {
gfLogLevel = "config";
}
if (gfSecLogLevel.empty()) {
gfSecLogLevel = "config";
}
if (gfjavaenv.find(PATH_SEP) == std::string::npos) {
return;
}
std::string xmlFile = "";
std::string sname = "GFECS";
currDir += PATH_SEP;
switch (instance) {
case 0:
// note: this need to take for multiple tests run
xmlFile += "cacheserver.xml";
break;
case 1:
xmlFile += "cacheserver.xml";
portNum = CacheHelper::staticHostPort1;
break;
case 2:
xmlFile += "cacheserver2.xml";
portNum = CacheHelper::staticHostPort2;
break;
case 3:
xmlFile += "cacheserver3.xml";
portNum = CacheHelper::staticHostPort3;
break;
case 4:
xmlFile += "cacheserver4.xml";
portNum = CacheHelper::staticHostPort4;
break;
default: /* Support for any number of servers Max 10*/
ASSERT((instance <= 10), " More than 10 servers not supported");
ASSERT(!xml.empty(),
"xml == nullptr : For server instance > 3 xml file is must");
portNum = CacheHelper::staticHostPort4;
break;
}
sname += std::to_string(portNum);
currDir += sname;
if (!xml.empty()) {
xmlFile = xml;
}
std::string xmlFile_new;
std::cout << " xml file name = " << xmlFile << "\n";
xmlFile = CacheHelper::createDuplicateXMLFile(xmlFile);
std::cout << " creating dir = " << sname << "\n";
boost::filesystem::create_directory(sname);
int64_t defaultTombstone_timeout = 600000;
int64_t defaultTombstone_gc_threshold = 100000;
int64_t userTombstone_timeout = 1000;
int64_t userTombstone_gc_threshold = 10;
if (testServerGC) {
boost::filesystem::create_directory("backupDirectory1");
boost::filesystem::create_directory("backupDirectory2");
boost::filesystem::create_directory("backupDirectory3");
boost::filesystem::create_directory("backupDirectory4");
}
GfshExecute gfsh;
auto server =
gfsh.start()
.server()
.withClasspath(classpath)
.withName(sname)
.withCacheXMLFile(xmlFile)
.withDir(currDir)
.withPort(portNum)
.withLogLevel(gfLogLevel)
.withMaxHeap("1g")
.withSystemProperty(
"gemfire.tombstone-timeout",
std::to_string(testServerGC ? userTombstone_timeout
: defaultTombstone_timeout))
.withSystemProperty(
"gemfire.tombstone-gc-threshold",
std::to_string(testServerGC ? userTombstone_gc_threshold
: defaultTombstone_gc_threshold))
.withSystemProperty("gemfire.security-log-level", gfSecLogLevel);
if (useSecurityManager) {
server.withUser("root").withPassword("root-password");
}
if (!locHostport.empty()) {
server.withPropertiesFile(generateGeodeProperties(
currDir, ssl, -1, 0, untrustedCert, useSecurityManager));
}
if (!enableDelta) {
server.withSystemProperty("gemfire.delta-propagation", "false");
}
server.execute();
staticServerInstanceList.push_back(instance);
std::cout << "added server instance " << instance << "\n";
}